From 34a188b9ea14e62cb48cb4fc533407b29b3124bb Mon Sep 17 00:00:00 2001 From: LFP6 Date: Wed, 5 Jun 2019 11:52:27 -0400 Subject: [PATCH 01/39] Package bump --- package-lock.json | 2013 ++++++++++++++++++++++----------------------- package.json | 38 +- 2 files changed, 1004 insertions(+), 1047 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6356523a6..bd3be9738 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,29 +5,21 @@ "requires": true, "dependencies": { "@babel/cli": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/@babel/cli/-/cli-7.2.3.tgz", - "integrity": "sha512-bfna97nmJV6nDJhXNPeEfxyMjWnt6+IjUAaDPiYRTBlm8L41n8nvw6UAqUCbvpFfU246gHPxW7sfWwqtF4FcYA==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/cli/-/cli-7.4.4.tgz", + "integrity": "sha512-XGr5YjQSjgTa6OzQZY57FAJsdeVSAKR/u/KA5exWIz66IKtv/zXtHy+fIZcMry/EgYegwuHE7vzGnrFhjdIAsQ==", "dev": true, "requires": { - "chokidar": "^2.0.3", + "chokidar": "^2.0.4", "commander": "^2.8.1", "convert-source-map": "^1.1.0", "fs-readdir-recursive": "^1.1.0", "glob": "^7.0.0", - "lodash": "^4.17.10", + "lodash": "^4.17.11", "mkdirp": "^0.5.1", "output-file-sync": "^2.0.0", "slash": "^2.0.0", "source-map": "^0.5.0" - }, - "dependencies": { - "slash": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", - "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==", - "dev": true - } } }, "@babel/code-frame": { @@ -40,18 +32,18 @@ } }, "@babel/core": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.4.0.tgz", - "integrity": "sha512-Dzl7U0/T69DFOTwqz/FJdnOSWS57NpjNfCwMKHABr589Lg8uX1RrlBIJ7L5Dubt/xkLsx0xH5EBFzlBVes1ayA==", + "version": "7.4.5", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.4.5.tgz", + "integrity": "sha512-OvjIh6aqXtlsA8ujtGKfC7LYWksYSX8yQcM8Ay3LuvVeQ63lcOKgoZWVqcpFwkd29aYU9rVx7jxhfhiEDV9MZA==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", - "@babel/generator": "^7.4.0", - "@babel/helpers": "^7.4.0", - "@babel/parser": "^7.4.0", - "@babel/template": "^7.4.0", - "@babel/traverse": "^7.4.0", - "@babel/types": "^7.4.0", + "@babel/generator": "^7.4.4", + "@babel/helpers": "^7.4.4", + "@babel/parser": "^7.4.5", + "@babel/template": "^7.4.4", + "@babel/traverse": "^7.4.5", + "@babel/types": "^7.4.4", "convert-source-map": "^1.1.0", "debug": "^4.1.0", "json5": "^2.1.0", @@ -94,12 +86,12 @@ } }, "@babel/generator": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.4.0.tgz", - "integrity": "sha512-/v5I+a1jhGSKLgZDcmAUZ4K/VePi43eRkUs3yePW1HB1iANOD5tqJXwGSG4BZhSksP8J9ejSlwGeTiiOFZOrXQ==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.4.4.tgz", + "integrity": "sha512-53UOLK6TVNqKxf7RUh8NE851EHRxOOeVXKbK2bivdb+iziMyk03Sr4eaE9OELCbyZAAafAKPDwF2TPUES5QbxQ==", "dev": true, "requires": { - "@babel/types": "^7.4.0", + "@babel/types": "^7.4.4", "jsesc": "^2.5.1", "lodash": "^4.17.11", "source-map": "^0.5.0", @@ -126,38 +118,38 @@ } }, "@babel/helper-call-delegate": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/helper-call-delegate/-/helper-call-delegate-7.4.0.tgz", - "integrity": "sha512-SdqDfbVdNQCBp3WhK2mNdDvHd3BD6qbmIc43CAyjnsfCmgHMeqgDcM3BzY2lchi7HBJGJ2CVdynLWbezaE4mmQ==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/helper-call-delegate/-/helper-call-delegate-7.4.4.tgz", + "integrity": "sha512-l79boDFJ8S1c5hvQvG+rc+wHw6IuH7YldmRKsYtpbawsxURu/paVy57FZMomGK22/JckepaikOkY0MoAmdyOlQ==", "dev": true, "requires": { - "@babel/helper-hoist-variables": "^7.4.0", - "@babel/traverse": "^7.4.0", - "@babel/types": "^7.4.0" + "@babel/helper-hoist-variables": "^7.4.4", + "@babel/traverse": "^7.4.4", + "@babel/types": "^7.4.4" } }, "@babel/helper-create-class-features-plugin": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.4.0.tgz", - "integrity": "sha512-2K8NohdOT7P6Vyp23QH4w2IleP8yG3UJsbRKwA4YP6H8fErcLkFuuEEqbF2/BYBKSNci/FWJiqm6R3VhM/QHgw==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.4.4.tgz", + "integrity": "sha512-UbBHIa2qeAGgyiNR9RszVF7bUHEdgS4JAUNT8SiqrAN6YJVxlOxeLr5pBzb5kan302dejJ9nla4RyKcR1XT6XA==", "dev": true, "requires": { "@babel/helper-function-name": "^7.1.0", "@babel/helper-member-expression-to-functions": "^7.0.0", "@babel/helper-optimise-call-expression": "^7.0.0", "@babel/helper-plugin-utils": "^7.0.0", - "@babel/helper-replace-supers": "^7.4.0", - "@babel/helper-split-export-declaration": "^7.4.0" + "@babel/helper-replace-supers": "^7.4.4", + "@babel/helper-split-export-declaration": "^7.4.4" } }, "@babel/helper-define-map": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/helper-define-map/-/helper-define-map-7.4.0.tgz", - "integrity": "sha512-wAhQ9HdnLIywERVcSvX40CEJwKdAa1ID4neI9NXQPDOHwwA+57DqwLiPEVy2AIyWzAk0CQ8qx4awO0VUURwLtA==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/helper-define-map/-/helper-define-map-7.4.4.tgz", + "integrity": "sha512-IX3Ln8gLhZpSuqHJSnTNBWGDE9kdkTEWl21A/K7PQ00tseBwbqCHTvNLHSBd9M0R5rER4h5Rsvj9vw0R5SieBg==", "dev": true, "requires": { "@babel/helper-function-name": "^7.1.0", - "@babel/types": "^7.4.0", + "@babel/types": "^7.4.4", "lodash": "^4.17.11" } }, @@ -192,12 +184,12 @@ } }, "@babel/helper-hoist-variables": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.4.0.tgz", - "integrity": "sha512-/NErCuoe/et17IlAQFKWM24qtyYYie7sFIrW/tIQXpck6vAu2hhtYYsKLBWQV+BQZMbcIYPU/QMYuTufrY4aQw==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.4.4.tgz", + "integrity": "sha512-VYk2/H/BnYbZDDg39hr3t2kKyifAm1W6zHRfhx8jGjIHpQEBv9dry7oQ2f3+J703TLu69nYdxsovl0XYfcnK4w==", "dev": true, "requires": { - "@babel/types": "^7.4.0" + "@babel/types": "^7.4.4" } }, "@babel/helper-member-expression-to-functions": { @@ -219,17 +211,17 @@ } }, "@babel/helper-module-transforms": { - "version": "7.2.2", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.2.2.tgz", - "integrity": "sha512-YRD7I6Wsv+IHuTPkAmAS4HhY0dkPobgLftHp0cRGZSdrRvmZY8rFvae/GVu3bD00qscuvK3WPHB3YdNpBXUqrA==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.4.4.tgz", + "integrity": "sha512-3Z1yp8TVQf+B4ynN7WoHPKS8EkdTbgAEy0nU0rs/1Kw4pDgmvYH3rz3aI11KgxKCba2cn7N+tqzV1mY2HMN96w==", "dev": true, "requires": { "@babel/helper-module-imports": "^7.0.0", "@babel/helper-simple-access": "^7.1.0", - "@babel/helper-split-export-declaration": "^7.0.0", - "@babel/template": "^7.2.2", - "@babel/types": "^7.2.2", - "lodash": "^4.17.10" + "@babel/helper-split-export-declaration": "^7.4.4", + "@babel/template": "^7.4.4", + "@babel/types": "^7.4.4", + "lodash": "^4.17.11" } }, "@babel/helper-optimise-call-expression": { @@ -248,12 +240,12 @@ "dev": true }, "@babel/helper-regex": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/@babel/helper-regex/-/helper-regex-7.0.0.tgz", - "integrity": "sha512-TR0/N0NDCcUIUEbqV6dCO+LptmmSQFQ7q70lfcEB4URsjD0E1HzicrwUH+ap6BAQ2jhCX9Q4UqZy4wilujWlkg==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/helper-regex/-/helper-regex-7.4.4.tgz", + "integrity": "sha512-Y5nuB/kESmR3tKjU8Nkn1wMGEx1tjJX076HBMeL3XLQCu6vA/YRzuTW0bbb+qRnXvQGn+d6Rx953yffl8vEy7Q==", "dev": true, "requires": { - "lodash": "^4.17.10" + "lodash": "^4.17.11" } }, "@babel/helper-remap-async-to-generator": { @@ -270,15 +262,15 @@ } }, "@babel/helper-replace-supers": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.4.0.tgz", - "integrity": "sha512-PVwCVnWWAgnal+kJ+ZSAphzyl58XrFeSKSAJRiqg5QToTsjL+Xu1f9+RJ+d+Q0aPhPfBGaYfkox66k86thxNSg==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.4.4.tgz", + "integrity": "sha512-04xGEnd+s01nY1l15EuMS1rfKktNF+1CkKmHoErDppjAAZL+IUBZpzT748x262HF7fibaQPhbvWUl5HeSt1EXg==", "dev": true, "requires": { "@babel/helper-member-expression-to-functions": "^7.0.0", "@babel/helper-optimise-call-expression": "^7.0.0", - "@babel/traverse": "^7.4.0", - "@babel/types": "^7.4.0" + "@babel/traverse": "^7.4.4", + "@babel/types": "^7.4.4" } }, "@babel/helper-simple-access": { @@ -292,12 +284,12 @@ } }, "@babel/helper-split-export-declaration": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.4.0.tgz", - "integrity": "sha512-7Cuc6JZiYShaZnybDmfwhY4UYHzI6rlqhWjaIqbsJGsIqPimEYy5uh3akSRLMg65LSdSEnJ8a8/bWQN6u2oMGw==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.4.4.tgz", + "integrity": "sha512-Ro/XkzLf3JFITkW6b+hNxzZ1n5OQ80NvIUdmHspih1XAhtN3vPTuUFT4eQnela+2MaZ5ulH+iyP513KJrxbN7Q==", "dev": true, "requires": { - "@babel/types": "^7.4.0" + "@babel/types": "^7.4.4" } }, "@babel/helper-wrap-function": { @@ -313,14 +305,14 @@ } }, "@babel/helpers": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.4.0.tgz", - "integrity": "sha512-2Lfcn74A2WSFUbYJ76ilYE1GnegCKUHTfXxp25EL2zPZHjV7OcDncqNjl295mUH0VnB65mNriXW4J5ROvxsgGg==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.4.4.tgz", + "integrity": "sha512-igczbR/0SeuPR8RFfC7tGrbdTbFL3QTvH6D+Z6zNxnTe//GyqmtHmDkzrqDmyZ3eSwPqB/LhyKoU5DXsp+Vp2A==", "dev": true, "requires": { - "@babel/template": "^7.4.0", - "@babel/traverse": "^7.4.0", - "@babel/types": "^7.4.0" + "@babel/template": "^7.4.4", + "@babel/traverse": "^7.4.4", + "@babel/types": "^7.4.4" } }, "@babel/highlight": { @@ -335,9 +327,9 @@ } }, "@babel/parser": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.4.0.tgz", - "integrity": "sha512-ZmMhJfU/+SXXvy9ALjDZopa3T3EixQtQai89JRC48eM9OUwrxJjYjuM/0wmdl2AekytlzMVhPY8cYdLb13kpKQ==", + "version": "7.4.5", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.4.5.tgz", + "integrity": "sha512-9mUqkL1FF5T7f0WDFfAoDdiMVPWsdD1gZYzSnaXsxUCUqzuch/8of9G3VUSNiZmMBoRxT3neyVsqeiL/ZPcjew==", "dev": true }, "@babel/plugin-proposal-async-generator-functions": { @@ -352,12 +344,12 @@ } }, "@babel/plugin-proposal-class-properties": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.4.0.tgz", - "integrity": "sha512-t2ECPNOXsIeK1JxJNKmgbzQtoG27KIlVE61vTqX0DKR9E9sZlVVxWUtEW9D5FlZ8b8j7SBNCHY47GgPKCKlpPg==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.4.4.tgz", + "integrity": "sha512-WjKTI8g8d5w1Bc9zgwSz2nfrsNQsXcCf9J9cdCvrJV6RF56yztwm4TmJC0MgJ9tvwO9gUA/mcYe89bLdGfiXFg==", "dev": true, "requires": { - "@babel/helper-create-class-features-plugin": "^7.4.0", + "@babel/helper-create-class-features-plugin": "^7.4.4", "@babel/helper-plugin-utils": "^7.0.0" } }, @@ -372,9 +364,9 @@ } }, "@babel/plugin-proposal-object-rest-spread": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.4.0.tgz", - "integrity": "sha512-uTNi8pPYyUH2eWHyYWWSYJKwKg34hhgl4/dbejEjL+64OhbHjTX7wEVWMQl82tEmdDsGeu77+s8HHLS627h6OQ==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.4.4.tgz", + "integrity": "sha512-dMBG6cSPBbHeEBdFXeQ2QLc5gUpg4Vkaz8octD4aoW/ISO+jBOcsuxYL7bsb5WSu8RLP6boxrBIALEHgoHtO9g==", "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.0.0", @@ -392,13 +384,13 @@ } }, "@babel/plugin-proposal-unicode-property-regex": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.4.0.tgz", - "integrity": "sha512-h/KjEZ3nK9wv1P1FSNb9G079jXrNYR0Ko+7XkOx85+gM24iZbPn0rh4vCftk+5QKY7y1uByFataBTmX7irEF1w==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.4.4.tgz", + "integrity": "sha512-j1NwnOqMG9mFUOH58JTFsA/+ZYzQLUZ/drqWUqxCYLGeu2JFZL8YrNC9hBxKmWtAuOCHPcRpgv7fhap09Fb4kA==", "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.0.0", - "@babel/helper-regex": "^7.0.0", + "@babel/helper-regex": "^7.4.4", "regexpu-core": "^4.5.4" } }, @@ -466,9 +458,9 @@ } }, "@babel/plugin-transform-async-to-generator": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.4.0.tgz", - "integrity": "sha512-EeaFdCeUULM+GPFEsf7pFcNSxM7hYjoj5fiYbyuiXobW4JhFnjAv9OWzNwHyHcKoPNpAfeRDuW6VyaXEDUBa7g==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.4.4.tgz", + "integrity": "sha512-YiqW2Li8TXmzgbXw+STsSqPBPFnGviiaSp6CYOq55X8GQ2SGVLrXB6pNid8HkqkZAzOH6knbai3snhP7v0fNwA==", "dev": true, "requires": { "@babel/helper-module-imports": "^7.0.0", @@ -486,9 +478,9 @@ } }, "@babel/plugin-transform-block-scoping": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.4.0.tgz", - "integrity": "sha512-AWyt3k+fBXQqt2qb9r97tn3iBwFpiv9xdAiG+Gr2HpAZpuayvbL55yWrsV3MyHvXk/4vmSiedhDRl1YI2Iy5nQ==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.4.4.tgz", + "integrity": "sha512-jkTUyWZcTrwxu5DD4rWz6rDB5Cjdmgz6z7M7RLXOJyCUkFBawssDGcGh8M/0FTSB87avyJI1HsTwUXp9nKA1PA==", "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.0.0", @@ -496,18 +488,18 @@ } }, "@babel/plugin-transform-classes": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.4.0.tgz", - "integrity": "sha512-XGg1Mhbw4LDmrO9rSTNe+uI79tQPdGs0YASlxgweYRLZqo/EQktjaOV4tchL/UZbM0F+/94uOipmdNGoaGOEYg==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.4.4.tgz", + "integrity": "sha512-/e44eFLImEGIpL9qPxSRat13I5QNRgBLu2hOQJCF7VLy/otSM/sypV1+XaIw5+502RX/+6YaSAPmldk+nhHDPw==", "dev": true, "requires": { "@babel/helper-annotate-as-pure": "^7.0.0", - "@babel/helper-define-map": "^7.4.0", + "@babel/helper-define-map": "^7.4.4", "@babel/helper-function-name": "^7.1.0", "@babel/helper-optimise-call-expression": "^7.0.0", "@babel/helper-plugin-utils": "^7.0.0", - "@babel/helper-replace-supers": "^7.4.0", - "@babel/helper-split-export-declaration": "^7.4.0", + "@babel/helper-replace-supers": "^7.4.4", + "@babel/helper-split-export-declaration": "^7.4.4", "globals": "^11.1.0" } }, @@ -521,23 +513,23 @@ } }, "@babel/plugin-transform-destructuring": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.4.0.tgz", - "integrity": "sha512-HySkoatyYTY3ZwLI8GGvkRWCFrjAGXUHur5sMecmCIdIharnlcWWivOqDJI76vvmVZfzwb6G08NREsrY96RhGQ==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.4.4.tgz", + "integrity": "sha512-/aOx+nW0w8eHiEHm+BTERB2oJn5D127iye/SUQl7NjHy0lf+j7h4MKMMSOwdazGq9OxgiNADncE+SRJkCxjZpQ==", "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.0.0" } }, "@babel/plugin-transform-dotall-regex": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.2.0.tgz", - "integrity": "sha512-sKxnyHfizweTgKZf7XsXu/CNupKhzijptfTM+bozonIuyVrLWVUvYjE2bhuSBML8VQeMxq4Mm63Q9qvcvUcciQ==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.4.4.tgz", + "integrity": "sha512-P05YEhRc2h53lZDjRPk/OektxCVevFzZs2Gfjd545Wde3k+yFDbXORgl2e0xpbq8mLcKJ7Idss4fAg0zORN/zg==", "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.0.0", - "@babel/helper-regex": "^7.0.0", - "regexpu-core": "^4.1.3" + "@babel/helper-regex": "^7.4.4", + "regexpu-core": "^4.5.4" } }, "@babel/plugin-transform-duplicate-keys": { @@ -560,18 +552,18 @@ } }, "@babel/plugin-transform-for-of": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.4.0.tgz", - "integrity": "sha512-vWdfCEYLlYSxbsKj5lGtzA49K3KANtb8qCPQ1em07txJzsBwY+cKJzBHizj5fl3CCx7vt+WPdgDLTHmydkbQSQ==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.4.4.tgz", + "integrity": "sha512-9T/5Dlr14Z9TIEXLXkt8T1DU7F24cbhwhMNUziN3hB1AXoZcdzPcTiKGRn/6iOymDqtTKWnr/BtRKN9JwbKtdQ==", "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.0.0" } }, "@babel/plugin-transform-function-name": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.2.0.tgz", - "integrity": "sha512-kWgksow9lHdvBC2Z4mxTsvc7YdY7w/V6B2vy9cTIPtLEE9NhwoWivaxdNM/S37elu5bqlLP/qOY906LukO9lkQ==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.4.4.tgz", + "integrity": "sha512-iU9pv7U+2jC9ANQkKeNF6DrPy4GBa4NWQtl6dHB4Pb3izX2JOEvDTFarlNsBj/63ZEzNNIAMs3Qw4fNCcSOXJA==", "dev": true, "requires": { "@babel/helper-function-name": "^7.1.0", @@ -587,6 +579,15 @@ "@babel/helper-plugin-utils": "^7.0.0" } }, + "@babel/plugin-transform-member-expression-literals": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.2.0.tgz", + "integrity": "sha512-HiU3zKkSU6scTidmnFJ0bMX8hz5ixC93b4MHMiYebmk2lUVNGOboPsqQvx5LzooihijUoLR/v7Nc1rbBtnc7FA==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, "@babel/plugin-transform-modules-amd": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.2.0.tgz", @@ -598,23 +599,23 @@ } }, "@babel/plugin-transform-modules-commonjs": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.4.0.tgz", - "integrity": "sha512-iWKAooAkipG7g1IY0eah7SumzfnIT3WNhT4uYB2kIsvHnNSB6MDYVa5qyICSwaTBDBY2c4SnJ3JtEa6ltJd6Jw==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.4.4.tgz", + "integrity": "sha512-4sfBOJt58sEo9a2BQXnZq+Q3ZTSAUXyK3E30o36BOGnJ+tvJ6YSxF0PG6kERvbeISgProodWuI9UVG3/FMY6iw==", "dev": true, "requires": { - "@babel/helper-module-transforms": "^7.1.0", + "@babel/helper-module-transforms": "^7.4.4", "@babel/helper-plugin-utils": "^7.0.0", "@babel/helper-simple-access": "^7.1.0" } }, "@babel/plugin-transform-modules-systemjs": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.4.0.tgz", - "integrity": "sha512-gjPdHmqiNhVoBqus5qK60mWPp1CmYWp/tkh11mvb0rrys01HycEGD7NvvSoKXlWEfSM9TcL36CpsK8ElsADptQ==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.4.4.tgz", + "integrity": "sha512-MSiModfILQc3/oqnG7NrP1jHaSPryO6tA2kOMmAQApz5dayPxWiHqmq4sWH2xF5LcQK56LlbKByCd8Aah/OIkQ==", "dev": true, "requires": { - "@babel/helper-hoist-variables": "^7.4.0", + "@babel/helper-hoist-variables": "^7.4.4", "@babel/helper-plugin-utils": "^7.0.0" } }, @@ -629,18 +630,18 @@ } }, "@babel/plugin-transform-named-capturing-groups-regex": { - "version": "7.3.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.3.0.tgz", - "integrity": "sha512-NxIoNVhk9ZxS+9lSoAQ/LM0V2UEvARLttEHUrRDGKFaAxOYQcrkN/nLRE+BbbicCAvZPl7wMP0X60HsHE5DtQw==", + "version": "7.4.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.4.5.tgz", + "integrity": "sha512-z7+2IsWafTBbjNsOxU/Iv5CvTJlr5w4+HGu1HovKYTtgJ362f7kBcQglkfmlspKKZ3bgrbSGvLfNx++ZJgCWsg==", "dev": true, "requires": { - "regexp-tree": "^0.1.0" + "regexp-tree": "^0.1.6" } }, "@babel/plugin-transform-new-target": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.4.0.tgz", - "integrity": "sha512-6ZKNgMQmQmrEX/ncuCwnnw1yVGoaOW5KpxNhoWI7pCQdA0uZ0HqHGqenCUIENAnxRjy2WwNQ30gfGdIgqJXXqw==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.4.4.tgz", + "integrity": "sha512-r1z3T2DNGQwwe2vPGZMBNjioT2scgWzK9BCnDEh+46z8EEwXBq24uRzd65I7pjtugzPSj921aM15RpESgzsSuA==", "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.0.0" @@ -657,23 +658,41 @@ } }, "@babel/plugin-transform-parameters": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.4.0.tgz", - "integrity": "sha512-Xqv6d1X+doyiuCGDoVJFtlZx0onAX0tnc3dY8w71pv/O0dODAbusVv2Ale3cGOwfiyi895ivOBhYa9DhAM8dUA==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.4.4.tgz", + "integrity": "sha512-oMh5DUO1V63nZcu/ZVLQFqiihBGo4OpxJxR1otF50GMeCLiRx5nUdtokd+u9SuVJrvvuIh9OosRFPP4pIPnwmw==", "dev": true, "requires": { - "@babel/helper-call-delegate": "^7.4.0", + "@babel/helper-call-delegate": "^7.4.4", "@babel/helper-get-function-arity": "^7.0.0", "@babel/helper-plugin-utils": "^7.0.0" } }, + "@babel/plugin-transform-property-literals": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.2.0.tgz", + "integrity": "sha512-9q7Dbk4RhgcLp8ebduOpCbtjh7C0itoLYHXd9ueASKAG/is5PQtMR5VJGka9NKqGhYEGn5ITahd4h9QeBMylWQ==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, "@babel/plugin-transform-regenerator": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.4.0.tgz", - "integrity": "sha512-SZ+CgL4F0wm4npojPU6swo/cK4FcbLgxLd4cWpHaNXY/NJ2dpahODCqBbAwb2rDmVszVb3SSjnk9/vik3AYdBw==", + "version": "7.4.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.4.5.tgz", + "integrity": "sha512-gBKRh5qAaCWntnd09S8QC7r3auLCqq5DI6O0DlfoyDjslSBVqBibrMdsqO+Uhmx3+BlOmE/Kw1HFxmGbv0N9dA==", + "dev": true, + "requires": { + "regenerator-transform": "^0.14.0" + } + }, + "@babel/plugin-transform-reserved-words": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.2.0.tgz", + "integrity": "sha512-fz43fqW8E1tAB3DKF19/vxbpib1fuyCwSPE418ge5ZxILnBhWyhtPgz8eh1RCGGJlwvksHkyxMxh0eenFi+kFw==", "dev": true, "requires": { - "regenerator-transform": "^0.13.4" + "@babel/helper-plugin-utils": "^7.0.0" } }, "@babel/plugin-transform-shorthand-properties": { @@ -705,9 +724,9 @@ } }, "@babel/plugin-transform-template-literals": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.2.0.tgz", - "integrity": "sha512-FkPix00J9A/XWXv4VoKJBMeSkyY9x/TqIh76wzcdfl57RJJcf8CehQ08uwfhCDNtRQYtHQKBTwKZDEyjE13Lwg==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.4.4.tgz", + "integrity": "sha512-mQrEC4TWkhLN0z8ygIvEL9ZEToPhG5K7KDW3pzGqOfIGZ28Jb0POUkeWcoz8HnHvhFy6dwAT1j8OzqN8s804+g==", "dev": true, "requires": { "@babel/helper-annotate-as-pure": "^7.0.0", @@ -734,67 +753,70 @@ } }, "@babel/plugin-transform-unicode-regex": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.2.0.tgz", - "integrity": "sha512-m48Y0lMhrbXEJnVUaYly29jRXbQ3ksxPrS1Tg8t+MHqzXhtBYAvI51euOBaoAlZLPHsieY9XPVMf80a5x0cPcA==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.4.4.tgz", + "integrity": "sha512-il+/XdNw01i93+M9J9u4T7/e/Ue/vWfNZE4IRUQjplu2Mqb/AFTDimkw2tdEdSH50wuQXZAbXSql0UphQke+vA==", "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.0.0", - "@babel/helper-regex": "^7.0.0", - "regexpu-core": "^4.1.3" + "@babel/helper-regex": "^7.4.4", + "regexpu-core": "^4.5.4" } }, "@babel/preset-env": { - "version": "7.4.1", - "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.4.1.tgz", - "integrity": "sha512-uC2DeVb6ljdjBGhJCyHxNZfSJEVgPdUm2R5cX85GCl1Qreo5sMM5g85ntqtzRF7XRYGgnRmV5we9cdlvo1wJvg==", + "version": "7.4.5", + "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.4.5.tgz", + "integrity": "sha512-f2yNVXM+FsR5V8UwcFeIHzHWgnhXg3NpRmy0ADvALpnhB0SLbCvrCRr4BLOUYbQNLS+Z0Yer46x9dJXpXewI7w==", "dev": true, "requires": { "@babel/helper-module-imports": "^7.0.0", "@babel/helper-plugin-utils": "^7.0.0", "@babel/plugin-proposal-async-generator-functions": "^7.2.0", "@babel/plugin-proposal-json-strings": "^7.2.0", - "@babel/plugin-proposal-object-rest-spread": "^7.4.0", + "@babel/plugin-proposal-object-rest-spread": "^7.4.4", "@babel/plugin-proposal-optional-catch-binding": "^7.2.0", - "@babel/plugin-proposal-unicode-property-regex": "^7.4.0", + "@babel/plugin-proposal-unicode-property-regex": "^7.4.4", "@babel/plugin-syntax-async-generators": "^7.2.0", "@babel/plugin-syntax-json-strings": "^7.2.0", "@babel/plugin-syntax-object-rest-spread": "^7.2.0", "@babel/plugin-syntax-optional-catch-binding": "^7.2.0", "@babel/plugin-transform-arrow-functions": "^7.2.0", - "@babel/plugin-transform-async-to-generator": "^7.4.0", + "@babel/plugin-transform-async-to-generator": "^7.4.4", "@babel/plugin-transform-block-scoped-functions": "^7.2.0", - "@babel/plugin-transform-block-scoping": "^7.4.0", - "@babel/plugin-transform-classes": "^7.4.0", + "@babel/plugin-transform-block-scoping": "^7.4.4", + "@babel/plugin-transform-classes": "^7.4.4", "@babel/plugin-transform-computed-properties": "^7.2.0", - "@babel/plugin-transform-destructuring": "^7.4.0", - "@babel/plugin-transform-dotall-regex": "^7.2.0", + "@babel/plugin-transform-destructuring": "^7.4.4", + "@babel/plugin-transform-dotall-regex": "^7.4.4", "@babel/plugin-transform-duplicate-keys": "^7.2.0", "@babel/plugin-transform-exponentiation-operator": "^7.2.0", - "@babel/plugin-transform-for-of": "^7.4.0", - "@babel/plugin-transform-function-name": "^7.2.0", + "@babel/plugin-transform-for-of": "^7.4.4", + "@babel/plugin-transform-function-name": "^7.4.4", "@babel/plugin-transform-literals": "^7.2.0", + "@babel/plugin-transform-member-expression-literals": "^7.2.0", "@babel/plugin-transform-modules-amd": "^7.2.0", - "@babel/plugin-transform-modules-commonjs": "^7.4.0", - "@babel/plugin-transform-modules-systemjs": "^7.4.0", + "@babel/plugin-transform-modules-commonjs": "^7.4.4", + "@babel/plugin-transform-modules-systemjs": "^7.4.4", "@babel/plugin-transform-modules-umd": "^7.2.0", - "@babel/plugin-transform-named-capturing-groups-regex": "^7.3.0", - "@babel/plugin-transform-new-target": "^7.4.0", + "@babel/plugin-transform-named-capturing-groups-regex": "^7.4.5", + "@babel/plugin-transform-new-target": "^7.4.4", "@babel/plugin-transform-object-super": "^7.2.0", - "@babel/plugin-transform-parameters": "^7.4.0", - "@babel/plugin-transform-regenerator": "^7.4.0", + "@babel/plugin-transform-parameters": "^7.4.4", + "@babel/plugin-transform-property-literals": "^7.2.0", + "@babel/plugin-transform-regenerator": "^7.4.5", + "@babel/plugin-transform-reserved-words": "^7.2.0", "@babel/plugin-transform-shorthand-properties": "^7.2.0", "@babel/plugin-transform-spread": "^7.2.0", "@babel/plugin-transform-sticky-regex": "^7.2.0", - "@babel/plugin-transform-template-literals": "^7.2.0", + "@babel/plugin-transform-template-literals": "^7.4.4", "@babel/plugin-transform-typeof-symbol": "^7.2.0", - "@babel/plugin-transform-unicode-regex": "^7.2.0", - "@babel/types": "^7.4.0", - "browserslist": "^4.4.2", - "core-js-compat": "^3.0.0", + "@babel/plugin-transform-unicode-regex": "^7.4.4", + "@babel/types": "^7.4.4", + "browserslist": "^4.6.0", + "core-js-compat": "^3.1.1", "invariant": "^2.2.2", "js-levenshtein": "^1.1.3", - "semver": "^5.3.0" + "semver": "^5.5.0" } }, "@babel/preset-typescript": { @@ -808,28 +830,28 @@ } }, "@babel/template": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.4.0.tgz", - "integrity": "sha512-SOWwxxClTTh5NdbbYZ0BmaBVzxzTh2tO/TeLTbF6MO6EzVhHTnff8CdBXx3mEtazFBoysmEM6GU/wF+SuSx4Fw==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.4.4.tgz", + "integrity": "sha512-CiGzLN9KgAvgZsnivND7rkA+AeJ9JB0ciPOD4U59GKbQP2iQl+olF1l76kJOupqidozfZ32ghwBEJDhnk9MEcw==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", - "@babel/parser": "^7.4.0", - "@babel/types": "^7.4.0" + "@babel/parser": "^7.4.4", + "@babel/types": "^7.4.4" } }, "@babel/traverse": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.4.0.tgz", - "integrity": "sha512-/DtIHKfyg2bBKnIN+BItaIlEg5pjAnzHOIQe5w+rHAw/rg9g0V7T4rqPX8BJPfW11kt3koyjAnTNwCzb28Y1PA==", + "version": "7.4.5", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.4.5.tgz", + "integrity": "sha512-Vc+qjynwkjRmIFGxy0KYoPj4FdVDxLej89kMHFsWScq999uX+pwcX4v9mWRjW0KcAYTPAuVQl2LKP1wEVLsp+A==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", - "@babel/generator": "^7.4.0", + "@babel/generator": "^7.4.4", "@babel/helper-function-name": "^7.1.0", - "@babel/helper-split-export-declaration": "^7.4.0", - "@babel/parser": "^7.4.0", - "@babel/types": "^7.4.0", + "@babel/helper-split-export-declaration": "^7.4.4", + "@babel/parser": "^7.4.5", + "@babel/types": "^7.4.4", "debug": "^4.1.0", "globals": "^11.1.0", "lodash": "^4.17.11" @@ -853,9 +875,9 @@ } }, "@babel/types": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.4.0.tgz", - "integrity": "sha512-aPvkXyU2SPOnztlgo8n9cEiXW755mgyvueUPcpStqdzoSPm0fjO0vQBjLkt3JKJW7ufikfcnMTTPsN1xaTsBPA==", + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.4.4.tgz", + "integrity": "sha512-dOllgYdnEFOebhkKCjzSVFqw/PmmB8pH6RGOWkY4GsboQNd47b1fBThBSwlHAq9alF9vc1M3+6oqR47R50L0tQ==", "dev": true, "requires": { "esutils": "^2.0.2", @@ -882,44 +904,43 @@ } }, "@jest/console": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/@jest/console/-/console-24.3.0.tgz", - "integrity": "sha512-NaCty/OOei6rSDcbPdMiCbYCI0KGFGPgGO6B09lwWt5QTxnkuhKYET9El5u5z1GAcSxkQmSMtM63e24YabCWqA==", + "version": "24.7.1", + "resolved": "https://registry.npmjs.org/@jest/console/-/console-24.7.1.tgz", + "integrity": "sha512-iNhtIy2M8bXlAOULWVTUxmnelTLFneTNEkHCgPmgd+zNwy9zVddJ6oS5rZ9iwoscNdT5mMwUd0C51v/fSlzItg==", "dev": true, "requires": { "@jest/source-map": "^24.3.0", - "@types/node": "*", "chalk": "^2.0.1", "slash": "^2.0.0" } }, "@jest/core": { - "version": "24.5.0", - "resolved": "https://registry.npmjs.org/@jest/core/-/core-24.5.0.tgz", - "integrity": "sha512-RDZArRzAs51YS7dXG1pbXbWGxK53rvUu8mCDYsgqqqQ6uSOaTjcVyBl2Jce0exT2rSLk38ca7az7t2f3b0/oYQ==", + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/@jest/core/-/core-24.8.0.tgz", + "integrity": "sha512-R9rhAJwCBQzaRnrRgAdVfnglUuATXdwTRsYqs6NMdVcAl5euG8LtWDe+fVkN27YfKVBW61IojVsXKaOmSnqd/A==", "dev": true, "requires": { - "@jest/console": "^24.3.0", - "@jest/reporters": "^24.5.0", - "@jest/test-result": "^24.5.0", - "@jest/transform": "^24.5.0", - "@jest/types": "^24.5.0", + "@jest/console": "^24.7.1", + "@jest/reporters": "^24.8.0", + "@jest/test-result": "^24.8.0", + "@jest/transform": "^24.8.0", + "@jest/types": "^24.8.0", "ansi-escapes": "^3.0.0", "chalk": "^2.0.1", "exit": "^0.1.2", "graceful-fs": "^4.1.15", - "jest-changed-files": "^24.5.0", - "jest-config": "^24.5.0", - "jest-haste-map": "^24.5.0", - "jest-message-util": "^24.5.0", + "jest-changed-files": "^24.8.0", + "jest-config": "^24.8.0", + "jest-haste-map": "^24.8.0", + "jest-message-util": "^24.8.0", "jest-regex-util": "^24.3.0", - "jest-resolve-dependencies": "^24.5.0", - "jest-runner": "^24.5.0", - "jest-runtime": "^24.5.0", - "jest-snapshot": "^24.5.0", - "jest-util": "^24.5.0", - "jest-validate": "^24.5.0", - "jest-watcher": "^24.5.0", + "jest-resolve-dependencies": "^24.8.0", + "jest-runner": "^24.8.0", + "jest-runtime": "^24.8.0", + "jest-snapshot": "^24.8.0", + "jest-util": "^24.8.0", + "jest-validate": "^24.8.0", + "jest-watcher": "^24.8.0", "micromatch": "^3.1.10", "p-each-series": "^1.0.0", "pirates": "^4.0.1", @@ -952,52 +973,51 @@ } }, "@jest/environment": { - "version": "24.5.0", - "resolved": "https://registry.npmjs.org/@jest/environment/-/environment-24.5.0.tgz", - "integrity": "sha512-tzUHR9SHjMXwM8QmfHb/EJNbF0fjbH4ieefJBvtwO8YErLTrecc1ROj0uo2VnIT6SlpEGZnvdCK6VgKYBo8LsA==", + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/@jest/environment/-/environment-24.8.0.tgz", + "integrity": "sha512-vlGt2HLg7qM+vtBrSkjDxk9K0YtRBi7HfRFaDxoRtyi+DyVChzhF20duvpdAnKVBV6W5tym8jm0U9EfXbDk1tw==", "dev": true, "requires": { - "@jest/fake-timers": "^24.5.0", - "@jest/transform": "^24.5.0", - "@jest/types": "^24.5.0", - "@types/node": "*", - "jest-mock": "^24.5.0" + "@jest/fake-timers": "^24.8.0", + "@jest/transform": "^24.8.0", + "@jest/types": "^24.8.0", + "jest-mock": "^24.8.0" } }, "@jest/fake-timers": { - "version": "24.5.0", - "resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-24.5.0.tgz", - "integrity": "sha512-i59KVt3QBz9d+4Qr4QxsKgsIg+NjfuCjSOWj3RQhjF5JNy+eVJDhANQ4WzulzNCHd72srMAykwtRn5NYDGVraw==", + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-24.8.0.tgz", + "integrity": "sha512-2M4d5MufVXwi6VzZhJ9f5S/wU4ud2ck0kxPof1Iz3zWx6Y+V2eJrES9jEktB6O3o/oEyk+il/uNu9PvASjWXQw==", "dev": true, "requires": { - "@jest/types": "^24.5.0", - "@types/node": "*", - "jest-message-util": "^24.5.0", - "jest-mock": "^24.5.0" + "@jest/types": "^24.8.0", + "jest-message-util": "^24.8.0", + "jest-mock": "^24.8.0" } }, "@jest/reporters": { - "version": "24.5.0", - "resolved": "https://registry.npmjs.org/@jest/reporters/-/reporters-24.5.0.tgz", - "integrity": "sha512-vfpceiaKtGgnuC3ss5czWOihKOUSyjJA4M4udm6nH8xgqsuQYcyDCi4nMMcBKsHXWgz9/V5G7iisnZGfOh1w6Q==", + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/@jest/reporters/-/reporters-24.8.0.tgz", + "integrity": "sha512-eZ9TyUYpyIIXfYCrw0UHUWUvE35vx5I92HGMgS93Pv7du+GHIzl+/vh8Qj9MCWFK/4TqyttVBPakWMOfZRIfxw==", "dev": true, "requires": { - "@jest/environment": "^24.5.0", - "@jest/test-result": "^24.5.0", - "@jest/transform": "^24.5.0", - "@jest/types": "^24.5.0", + "@jest/environment": "^24.8.0", + "@jest/test-result": "^24.8.0", + "@jest/transform": "^24.8.0", + "@jest/types": "^24.8.0", "chalk": "^2.0.1", "exit": "^0.1.2", "glob": "^7.1.2", - "istanbul-api": "^2.1.1", "istanbul-lib-coverage": "^2.0.2", "istanbul-lib-instrument": "^3.0.1", + "istanbul-lib-report": "^2.0.4", "istanbul-lib-source-maps": "^3.0.1", - "jest-haste-map": "^24.5.0", - "jest-resolve": "^24.5.0", - "jest-runtime": "^24.5.0", - "jest-util": "^24.5.0", - "jest-worker": "^24.4.0", + "istanbul-reports": "^2.1.1", + "jest-haste-map": "^24.8.0", + "jest-resolve": "^24.8.0", + "jest-runtime": "^24.8.0", + "jest-util": "^24.8.0", + "jest-worker": "^24.6.0", "node-notifier": "^5.2.1", "slash": "^2.0.0", "source-map": "^0.6.0", @@ -1038,32 +1058,44 @@ } }, "@jest/test-result": { - "version": "24.5.0", - "resolved": "https://registry.npmjs.org/@jest/test-result/-/test-result-24.5.0.tgz", - "integrity": "sha512-u66j2vBfa8Bli1+o3rCaVnVYa9O8CAFZeqiqLVhnarXtreSXG33YQ6vNYBogT7+nYiFNOohTU21BKiHlgmxD5A==", + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/@jest/test-result/-/test-result-24.8.0.tgz", + "integrity": "sha512-+YdLlxwizlfqkFDh7Mc7ONPQAhA4YylU1s529vVM1rsf67vGZH/2GGm5uO8QzPeVyaVMobCQ7FTxl38QrKRlng==", + "dev": true, + "requires": { + "@jest/console": "^24.7.1", + "@jest/types": "^24.8.0", + "@types/istanbul-lib-coverage": "^2.0.0" + } + }, + "@jest/test-sequencer": { + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/@jest/test-sequencer/-/test-sequencer-24.8.0.tgz", + "integrity": "sha512-OzL/2yHyPdCHXEzhoBuq37CE99nkme15eHkAzXRVqthreWZamEMA0WoetwstsQBCXABhczpK03JNbc4L01vvLg==", "dev": true, "requires": { - "@jest/console": "^24.3.0", - "@jest/types": "^24.5.0", - "@types/istanbul-lib-coverage": "^1.1.0" + "@jest/test-result": "^24.8.0", + "jest-haste-map": "^24.8.0", + "jest-runner": "^24.8.0", + "jest-runtime": "^24.8.0" } }, "@jest/transform": { - "version": "24.5.0", - "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-24.5.0.tgz", - "integrity": "sha512-XSsDz1gdR/QMmB8UCKlweAReQsZrD/DK7FuDlNo/pE8EcKMrfi2kqLRk8h8Gy/PDzgqJj64jNEzOce9pR8oj1w==", + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-24.8.0.tgz", + "integrity": "sha512-xBMfFUP7TortCs0O+Xtez2W7Zu1PLH9bvJgtraN1CDST6LBM/eTOZ9SfwS/lvV8yOfcDpFmwf9bq5cYbXvqsvA==", "dev": true, "requires": { "@babel/core": "^7.1.0", - "@jest/types": "^24.5.0", + "@jest/types": "^24.8.0", "babel-plugin-istanbul": "^5.1.0", "chalk": "^2.0.1", "convert-source-map": "^1.4.0", "fast-json-stable-stringify": "^2.0.0", "graceful-fs": "^4.1.15", - "jest-haste-map": "^24.5.0", + "jest-haste-map": "^24.8.0", "jest-regex-util": "^24.3.0", - "jest-util": "^24.5.0", + "jest-util": "^24.8.0", "micromatch": "^3.1.10", "realpath-native": "^1.1.0", "slash": "^2.0.0", @@ -1097,12 +1129,13 @@ } }, "@jest/types": { - "version": "24.5.0", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-24.5.0.tgz", - "integrity": "sha512-kN7RFzNMf2R8UDadPOl6ReyI+MT8xfqRuAnuVL+i4gwjv/zubdDK+EDeLHYwq1j0CSSR2W/MmgaRlMZJzXdmVA==", + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-24.8.0.tgz", + "integrity": "sha512-g17UxVr2YfBtaMUxn9u/4+siG1ptg9IGYAYwvpwn61nBg779RXnjE/m7CxYcIzEt0AbHZZAHSEZNhkE2WxURVg==", "dev": true, "requires": { - "@types/istanbul-lib-coverage": "^1.1.0", + "@types/istanbul-lib-coverage": "^2.0.0", + "@types/istanbul-reports": "^1.1.1", "@types/yargs": "^12.0.9" } }, @@ -1277,9 +1310,9 @@ "integrity": "sha512-m64jGei+C+Ndbi+B9twwWg3yk98x0gPBTqcFmagiJsAIf/LQYK5tP2l8ROJu/5OXlPE6WcVIKaf3VByaZ6kiWQ==" }, "@types/babel__core": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.0.tgz", - "integrity": "sha512-wJTeJRt7BToFx3USrCDs2BhEi4ijBInTQjOIukj6a/5tEkwpFMVZ+1ppgmE+Q/FQyc5P/VWUbx7I9NELrKruHA==", + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.2.tgz", + "integrity": "sha512-cfCCrFmiGY/yq0NuKNxIQvZFy9kY/1immpSpTngOnyIbD4+eJOG5mxphhHDv3CHL9GltO4GcKr54kGBg3RNdbg==", "dev": true, "requires": { "@babel/parser": "^7.1.0", @@ -1324,27 +1357,55 @@ "dev": true }, "@types/istanbul-lib-coverage": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-1.1.0.tgz", - "integrity": "sha512-ohkhb9LehJy+PA40rDtGAji61NCgdtKLAlFoYp4cnuuQEswwdK3vz9SOIkkyc3wrk8dzjphQApNs56yyXLStaQ==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.1.tgz", + "integrity": "sha512-hRJD2ahnnpLgsj6KWMYSrmXkM3rm2Dl1qkx6IOFD5FnuNPXJIG5L0dhgKXCYTRMGzU4n0wImQ/xfmRc4POUFlg==", "dev": true }, + "@types/istanbul-lib-report": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-1.1.1.tgz", + "integrity": "sha512-3BUTyMzbZa2DtDI2BkERNC6jJw2Mr2Y0oGI7mRxYNBPxppbtEK1F66u3bKwU2g+wxwWI7PAoRpJnOY1grJqzHg==", + "dev": true, + "requires": { + "@types/istanbul-lib-coverage": "*" + } + }, + "@types/istanbul-reports": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-1.1.1.tgz", + "integrity": "sha512-UpYjBi8xefVChsCoBpKShdxTllC9pwISirfoZsUa2AAdQg/Jd2KQGtSbw+ya7GPo7x/wAPlH6JBhKhAsXUEZNA==", + "dev": true, + "requires": { + "@types/istanbul-lib-coverage": "*", + "@types/istanbul-lib-report": "*" + } + }, "@types/jest": { - "version": "23.3.12", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-23.3.12.tgz", - "integrity": "sha512-/kQvbVzdEpOq4tEWT79yAHSM4nH4xMlhJv2GrLVQt4Qmo8yYsPdioBM1QpN/2GX1wkfMnyXvdoftvLUr0LBj7Q==", + "version": "24.0.13", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-24.0.13.tgz", + "integrity": "sha512-3m6RPnO35r7Dg+uMLj1+xfZaOgIHHHut61djNjzwExXN4/Pm9has9C6I1KMYSfz7mahDhWUOVg4HW/nZdv5Pww==", + "dev": true, + "requires": { + "@types/jest-diff": "*" + } + }, + "@types/jest-diff": { + "version": "20.0.1", + "resolved": "https://registry.npmjs.org/@types/jest-diff/-/jest-diff-20.0.1.tgz", + "integrity": "sha512-yALhelO3i0hqZwhjtcr6dYyaLoCHbAMshwtj6cGxTvHZAKXHsYGdff6E8EPw3xLKY0ELUTQ69Q1rQiJENnccMA==", "dev": true }, "@types/loglevel": { - "version": "1.5.3", - "resolved": "https://registry.npmjs.org/@types/loglevel/-/loglevel-1.5.3.tgz", - "integrity": "sha512-TzzIZihV+y9kxSg5xJMkyIkaoGkXi50isZTtGHObNHRqAAwjGNjSCNPI7AUAv0tZUKTq9f2cdkCUd/2JVZUTrA==", + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/@types/loglevel/-/loglevel-1.5.4.tgz", + "integrity": "sha512-8dx4ckP0vndJeN+iKZwdGiapLqFjVQ3JLOt92uqK0C63acs5NcPLbUOpfXCJkKVRjZLBQjw8NIGNBSsnatFnFQ==", "dev": true }, "@types/node": { - "version": "10.12.18", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.18.tgz", - "integrity": "sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==", + "version": "12.0.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.0.4.tgz", + "integrity": "sha512-j8YL2C0fXq7IONwl/Ud5Kt0PeXw22zGERt+HSSnwbKOJVsAGkEz3sFCYwaF9IOuoG1HOtE0vKCj6sXF7Q0+Vaw==", "dev": true }, "@types/pixi.js": { @@ -1372,9 +1433,9 @@ "dev": true }, "@types/yargs": { - "version": "12.0.10", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-12.0.10.tgz", - "integrity": "sha512-WsVzTPshvCSbHThUduGGxbmnwcpkgSctHGHTqzWyFg4lYAuV5qXlyFPOsP3OWqCINfmg/8VXP+zJaa4OxEsBQQ==", + "version": "12.0.12", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-12.0.12.tgz", + "integrity": "sha512-SOhuU4wNBxhhTHxYaiG5NY4HBhDIDnJF60GU+2LqHAdKKer86//e4yg69aENCtQ04n0ovz+tq2YPME5t5yp4pw==", "dev": true }, "@typescript-eslint/eslint-plugin": { @@ -1667,9 +1728,9 @@ "dev": true }, "acorn-globals": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-4.3.0.tgz", - "integrity": "sha512-hMtHj3s5RnuhvHPowpBYvJVj3rAar82JiDQHvGs1zO0l10ocX/xEdBShNHTJaboucJUsScghp74pH3s7EnHHQw==", + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-4.3.2.tgz", + "integrity": "sha512-BbzvZhVtZP+Bs1J1HcwrQe8ycfO0wStkSGxuul3He3GkHOIZ6eTqOkPuw9IP1X3+IkOo4wiJmwkobzXYz4wewQ==", "dev": true, "requires": { "acorn": "^6.0.1", @@ -1756,15 +1817,17 @@ "requires": { "micromatch": "^3.1.4", "normalize-path": "^2.1.1" - } - }, - "append-transform": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/append-transform/-/append-transform-1.0.0.tgz", - "integrity": "sha512-P009oYkeHyU742iSZJzZZywj4QRJdnTWffaKuJQLablCZ1uz6/cW4yaRgcDaoQ+uwOxxnt0gRUcwfsNP2ri0gw==", - "dev": true, - "requires": { - "default-require-extensions": "^2.0.0" + }, + "dependencies": { + "normalize-path": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", + "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "dev": true, + "requires": { + "remove-trailing-separator": "^1.0.1" + } + } } }, "aproba": { @@ -1818,18 +1881,22 @@ "integrity": "sha1-bI4obRHtdoMn+OYuzuhzU8o+eLg=", "dev": true }, + "array-includes": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.0.3.tgz", + "integrity": "sha1-GEtI9i2S10UrsxsyMWXH+L0CJm0=", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "es-abstract": "^1.7.0" + } + }, "array-unique": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", "dev": true }, - "arrify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", - "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", - "dev": true - }, "asn1": { "version": "0.2.4", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", @@ -1851,11 +1918,12 @@ } }, "assert": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/assert/-/assert-1.4.1.tgz", - "integrity": "sha1-mZEtWRg2tab1s0XA8H7vwI/GXZE=", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/assert/-/assert-1.5.0.tgz", + "integrity": "sha512-EDsgawzwoun2CZkCgtxJbv392v4nbk9XDD06zI+kQYoBM/3RBWLlEyJARDOmhAAosBjWACEkKL6S+lIZtcAubA==", "dev": true, "requires": { + "object-assign": "^4.1.1", "util": "0.10.3" }, "dependencies": { @@ -1904,9 +1972,9 @@ } }, "async-each": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.1.tgz", - "integrity": "sha1-GdOGodntxufByF04iu28xW0zYC0=", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.3.tgz", + "integrity": "sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ==", "dev": true }, "async-limiter": { @@ -1922,9 +1990,9 @@ "dev": true }, "atob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.1.tgz", - "integrity": "sha1-ri1acpR38onWDdf5amMUoi3Wwio=", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", + "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", "dev": true }, "aws-sign2": { @@ -1982,16 +2050,16 @@ "dev": true }, "babel-jest": { - "version": "24.5.0", - "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-24.5.0.tgz", - "integrity": "sha512-0fKCXyRwxFTJL0UXDJiT2xYxO9Lu2vBd9n+cC+eDjESzcVG3s2DRGAxbzJX21fceB1WYoBjAh8pQ83dKcl003g==", + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-24.8.0.tgz", + "integrity": "sha512-+5/kaZt4I9efoXzPlZASyK/lN9qdRKmmUav9smVc0ruPQD7IsfucQ87gpOE8mn2jbDuS6M/YOW6n3v9ZoIfgnw==", "dev": true, "requires": { - "@jest/transform": "^24.5.0", - "@jest/types": "^24.5.0", + "@jest/transform": "^24.8.0", + "@jest/types": "^24.8.0", "@types/babel__core": "^7.1.0", "babel-plugin-istanbul": "^5.1.0", - "babel-preset-jest": "^24.3.0", + "babel-preset-jest": "^24.6.0", "chalk": "^2.4.2", "slash": "^2.0.0" }, @@ -2010,26 +2078,34 @@ } }, "babel-loader": { - "version": "8.0.5", - "resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-8.0.5.tgz", - "integrity": "sha512-NTnHnVRd2JnRqPC0vW+iOQWU5pchDbYXsG2E6DMXEpMfUcQKclF9gmf3G3ZMhzG7IG9ji4coL0cm+FxeWxDpnw==", + "version": "8.0.6", + "resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-8.0.6.tgz", + "integrity": "sha512-4BmWKtBOBm13uoUwd08UwjZlaw3O9GWf456R9j+5YykFZ6LUIjIKLc0zEZf+hauxPOJs96C8k6FvYD09vWzhYw==", "dev": true, "requires": { "find-cache-dir": "^2.0.0", "loader-utils": "^1.0.2", "mkdirp": "^0.5.1", - "util.promisify": "^1.0.0" + "pify": "^4.0.1" + }, + "dependencies": { + "pify": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", + "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", + "dev": true + } } }, "babel-plugin-istanbul": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-5.1.1.tgz", - "integrity": "sha512-RNNVv2lsHAXJQsEJ5jonQwrJVWK8AcZpG1oxhnjCUaAjL7xahYLANhPUZbzEQHjKy1NMYUwn+0NPKQc8iSY4xQ==", + "version": "5.1.4", + "resolved": "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-5.1.4.tgz", + "integrity": "sha512-dySz4VJMH+dpndj0wjJ8JPs/7i1TdSPb1nRrn56/92pKOF9VKC1FMFJmMXjzlGGusnCAqujP6PBCiKq0sVA+YQ==", "dev": true, "requires": { "find-up": "^3.0.0", - "istanbul-lib-instrument": "^3.0.0", - "test-exclude": "^5.0.0" + "istanbul-lib-instrument": "^3.3.0", + "test-exclude": "^5.2.3" }, "dependencies": { "find-up": { @@ -2070,17 +2146,17 @@ } }, "p-try": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.1.0.tgz", - "integrity": "sha512-H2RyIJ7+A3rjkwKC2l5GGtU4H1vkxKCAGsWasNVd0Set+6i4znxbWy6/j16YDPJDWxhsgZiKAstMEP8wCdSpjA==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "dev": true } } }, "babel-plugin-jest-hoist": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-24.3.0.tgz", - "integrity": "sha512-nWh4N1mVH55Tzhx2isvUN5ebM5CDUvIpXPZYMRazQughie/EqGnbR+czzoQlhUmJG9pPJmYDRhvocotb2THl1w==", + "version": "24.6.0", + "resolved": "https://registry.npmjs.org/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-24.6.0.tgz", + "integrity": "sha512-3pKNH6hMt9SbOv0F3WVmy5CWQ4uogS3k0GY5XLyQHJ9EGpAT9XWkFd2ZiXXtkwFHdAHa5j7w7kfxSP5lAIwu7w==", "dev": true, "requires": { "@types/babel__traverse": "^7.0.6" @@ -2262,13 +2338,13 @@ } }, "babel-preset-jest": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/babel-preset-jest/-/babel-preset-jest-24.3.0.tgz", - "integrity": "sha512-VGTV2QYBa/Kn3WCOKdfS31j9qomaXSgJqi65B6o05/1GsJyj9LVhSljM9ro4S+IBGj/ENhNBuH9bpqzztKAQSw==", + "version": "24.6.0", + "resolved": "https://registry.npmjs.org/babel-preset-jest/-/babel-preset-jest-24.6.0.tgz", + "integrity": "sha512-pdZqLEdmy1ZK5kyRUfvBb2IfTPb2BUvIJczlPspS8fWmBQslNNDBqVfh7BW5leOVJMDZKzjD8XEyABTk6gQ5yw==", "dev": true, "requires": { "@babel/plugin-syntax-object-rest-spread": "^7.0.0", - "babel-plugin-jest-hoist": "^24.3.0" + "babel-plugin-jest-hoist": "^24.6.0" } }, "babel-preset-minify": { @@ -2414,9 +2490,9 @@ "dev": true }, "binary-extensions": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.12.0.tgz", - "integrity": "sha512-DYWGk01lDcxeS/K9IHPGWfT8PsJmbXRtRd2Sx72Tnb8pcYZQFF1oSDb8hJtS1vhp212q1Rzi5dUf9+nq0o9UIg==", + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz", + "integrity": "sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==", "dev": true }, "bit-twiddle": { @@ -2425,9 +2501,9 @@ "integrity": "sha1-DGwfq+KyPRcXPZpht7cJPrnhdp4=" }, "bluebird": { - "version": "3.5.3", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.3.tgz", - "integrity": "sha512-/qKPUQlaW1OyR51WeCPBvRnAlnZFUJkCSG5HzGnuIqhgyJtF+T94lFnn33eiazjRm2LAHVy2guNnaq48X9SJuw==", + "version": "3.5.5", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.5.tgz", + "integrity": "sha512-5am6HnnfN+urzt4yfg7IgTbotDjIT/u8AJpEt0sIU9FtXfVeezXAPKswrG+xKUCOYAINpSdgZVDU6QFh+cuH3w==", "dev": true }, "bn.js": { @@ -2582,14 +2658,14 @@ } }, "browserslist": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.5.2.tgz", - "integrity": "sha512-zmJVLiKLrzko0iszd/V4SsjTaomFeoVzQGYYOYgRgsbh7WNh95RgDB0CmBdFWYs/3MyFSt69NypjL/h3iaddKQ==", + "version": "4.6.1", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.6.1.tgz", + "integrity": "sha512-1MC18ooMPRG2UuVFJTHFIAkk6mpByJfxCrnUyvSlu/hyQSFHMrlhM02SzNuCV+quTP4CKmqtOMAIjrifrpBJXQ==", "dev": true, "requires": { - "caniuse-lite": "^1.0.30000951", - "electron-to-chromium": "^1.3.116", - "node-releases": "^1.1.11" + "caniuse-lite": "^1.0.30000971", + "electron-to-chromium": "^1.3.137", + "node-releases": "^1.1.21" } }, "bs-logger": { @@ -2680,9 +2756,9 @@ }, "dependencies": { "glob": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", - "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", "dev": true, "requires": { "fs.realpath": "^1.0.0", @@ -2729,9 +2805,9 @@ } }, "callsites": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.0.0.tgz", - "integrity": "sha512-tWnkwu9YEq2uzlBDI4RcLn8jrFvF9AOi8PxDNU3hZZjJcjkcRAq3vCI+vZcg1SuxISDYe86k9VZFwAxDiJGoAw==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", "dev": true }, "camel-case": { @@ -2751,9 +2827,9 @@ "dev": true }, "caniuse-lite": { - "version": "1.0.30000951", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000951.tgz", - "integrity": "sha512-eRhP+nQ6YUkIcNQ6hnvdhMkdc7n3zadog0KXNRxAZTT2kHjUb1yGn71OrPhSn8MOvlX97g5CR97kGVj8fMsXWg==", + "version": "1.0.30000973", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000973.tgz", + "integrity": "sha512-/F3t/Yo8LEdRSEPCmI15fLu5vepVh9UCg/9inJXF5AAfW7xRRJkbaM2ut52iRMQMnGCLQouLbFdbOA+VEFOIsg==", "dev": true }, "capture-exit": { @@ -2789,24 +2865,23 @@ "dev": true }, "chokidar": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.0.4.tgz", - "integrity": "sha512-z9n7yt9rOvIJrMhvDtDictKrkFHeihkNl6uWMmZlmL6tJtX9Cs+87oK+teBx+JIgzvbX3yZHT3eF8vpbDxHJXQ==", + "version": "2.1.6", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.6.tgz", + "integrity": "sha512-V2jUo67OKkc6ySiRpJrjlpJKl9kDuG+Xb8VgsGzb+aEouhgS1D0weyPU4lEzdAcsCAvrih2J2BqyXqHWvVLw5g==", "dev": true, "requires": { "anymatch": "^2.0.0", - "async-each": "^1.0.0", - "braces": "^2.3.0", - "fsevents": "^1.2.2", + "async-each": "^1.0.1", + "braces": "^2.3.2", + "fsevents": "^1.2.7", "glob-parent": "^3.1.0", - "inherits": "^2.0.1", + "inherits": "^2.0.3", "is-binary-path": "^1.0.0", "is-glob": "^4.0.0", - "lodash.debounce": "^4.0.8", - "normalize-path": "^2.1.1", + "normalize-path": "^3.0.0", "path-is-absolute": "^1.0.0", - "readdirp": "^2.0.0", - "upath": "^1.0.5" + "readdirp": "^2.2.1", + "upath": "^1.1.1" } }, "chownr": { @@ -2816,9 +2891,9 @@ "dev": true }, "chrome-trace-event": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.0.tgz", - "integrity": "sha512-xDbVgyfDTT2piup/h8dK/y4QZfJRSa73bw1WZ8b4XM1o7fsFubUVGYcE+1ANtOzJJELGpYoG2961z0Z6OAld9A==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.2.tgz", + "integrity": "sha512-9e/zx1jw7B4CO+c/RXoCsfg/x1AfUBioy4owYH0bJprEYAx5hRFLRhWBqHAG57D0ZM4H7vxbP7bPe0VwhQRYDQ==", "dev": true, "requires": { "tslib": "^1.9.0" @@ -2989,9 +3064,9 @@ "dev": true }, "combined-stream": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz", - "integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==", + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", "dev": true, "requires": { "delayed-stream": "~1.0.0" @@ -3090,16 +3165,10 @@ "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=", "dev": true }, - "compare-versions": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-3.4.0.tgz", - "integrity": "sha512-tK69D7oNXXqUW3ZNo/z7NXTEz22TCF0pTE+YF9cxvaAM9XnkLo1fV621xCLrRR6aevJlKxExkss0vWqUCUpqdg==", - "dev": true - }, "component-emitter": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", - "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", + "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==", "dev": true }, "compressible": { @@ -3382,10 +3451,13 @@ "dev": true }, "convert-source-map": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.5.1.tgz", - "integrity": "sha1-uCeAl7m8IpNl3lxiz1/K7YtVmeU=", - "dev": true + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.6.0.tgz", + "integrity": "sha512-eFu7XigvxdZ1ETfbgPBohgyQ/Z++C0eEhTor0qRwBw9unw+L0/6V8wkSuGgzdThkiS5lSpdptOQPD8Ak40a+7A==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.1" + } }, "cookies": { "version": "0.7.3", @@ -3430,35 +3502,28 @@ "dev": true }, "core-js-compat": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.0.0.tgz", - "integrity": "sha512-W/Ppz34uUme3LmXWjMgFlYyGnbo1hd9JvA0LNQ4EmieqVjg2GPYbj3H6tcdP2QGPGWdRKUqZVbVKLNIFVs/HiA==", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.1.3.tgz", + "integrity": "sha512-EP018pVhgwsKHz3YoN1hTq49aRe+h017Kjz0NQz3nXV0cCRMvH3fLQl+vEPGr4r4J5sk4sU3tUC7U1aqTCeJeA==", "dev": true, "requires": { - "browserslist": "^4.5.1", - "core-js": "3.0.0", - "core-js-pure": "3.0.0", - "semver": "^5.6.0" + "browserslist": "^4.6.0", + "core-js-pure": "3.1.3", + "semver": "^6.1.0" }, "dependencies": { - "core-js": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.0.0.tgz", - "integrity": "sha512-WBmxlgH2122EzEJ6GH8o9L/FeoUKxxxZ6q6VUxoTlsE4EvbTWKJb447eyVxTEuq0LpXjlq/kCB2qgBvsYRkLvQ==", - "dev": true - }, "semver": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", - "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.1.1.tgz", + "integrity": "sha512-rWYq2e5iYW+fFe/oPPtYJxYgjBm8sC4rmoGdUOgBB7VnwKt6HrL793l2voH1UlsyYZpJ4g0wfjnTEO1s1NP2eQ==", "dev": true } } }, "core-js-pure": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.0.0.tgz", - "integrity": "sha512-yPiS3fQd842RZDgo/TAKGgS0f3p2nxssF1H65DIZvZv0Od5CygP8puHXn3IQiM/39VAvgCbdaMQpresrbGgt9g==", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.1.3.tgz", + "integrity": "sha512-k3JWTrcQBKqjkjI0bkfXS0lbpWPxYuHWfMMjC1VDmzU4Q58IwSbuXSo99YO/hUHlw/EB4AlfA2PVxOGkrIq6dA==", "dev": true }, "core-util-is": { @@ -3626,9 +3691,9 @@ "dev": true }, "cssstyle": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-1.2.1.tgz", - "integrity": "sha512-7DYm8qe+gPx/h77QlCyFmX80+fGaE/6A/Ekl0zaszYOubvySO2saYFdQ78P29D0UsULxFKCetDGNaNRUdSF+2A==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-1.2.2.tgz", + "integrity": "sha512-43wY3kl1CVQSvL7wUY1qXkxVGkStjpkDmVjiIKX8R97uhajy8Bybay78uOtqvh7Q5GK75dNPfW0geWjE6qQQow==", "dev": true, "requires": { "cssom": "0.3.x" @@ -3724,15 +3789,6 @@ "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", "dev": true }, - "default-require-extensions": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/default-require-extensions/-/default-require-extensions-2.0.0.tgz", - "integrity": "sha1-9fj7sYp9bVCyH2QfZJ67Uiz+JPc=", - "dev": true, - "requires": { - "strip-bom": "^3.0.0" - } - }, "defer-promise": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/defer-promise/-/defer-promise-1.0.2.tgz", @@ -4001,9 +4057,9 @@ "dev": true }, "electron-to-chromium": { - "version": "1.3.118", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.118.tgz", - "integrity": "sha512-/1FpHvmKmKo2Z6CCza2HfkrKvKhU7Rq4nvyX1FOherdTrdTufhVrJbCrcrIqgqUCI+BG6JC2rlY4z5QA1G0NOw==", + "version": "1.3.146", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.146.tgz", + "integrity": "sha512-BrUq08sx7eR4PCwLbjFxXmjcbDro6DSoc1pN8VCxq76U+o9JQzJlWH/NVtcpAqcktwpE5CVvMyqHqTQfCETNoQ==", "dev": true }, "elliptic": { @@ -4148,9 +4204,9 @@ } }, "eslint": { - "version": "5.15.3", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.15.3.tgz", - "integrity": "sha512-vMGi0PjCHSokZxE0NLp2VneGw5sio7SSiDNgIUn2tC0XkWJRNOIoHIg3CliLVfXnJsiHxGAYrkw0PieAu8+KYQ==", + "version": "5.16.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.16.0.tgz", + "integrity": "sha512-S3Rz11i7c8AA5JPv7xAH+dOyq/Cu/VXHiHXBPOU1k/JAM5dXqQPt3qcrhpHSorXmrpu2g0gkIBVXAqCpzfoZIg==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", @@ -4173,7 +4229,7 @@ "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", "inquirer": "^6.2.2", - "js-yaml": "^3.12.0", + "js-yaml": "^3.13.0", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.3.0", "lodash": "^4.17.11", @@ -4213,9 +4269,9 @@ "dev": true }, "semver": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", - "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", + "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==", "dev": true }, "strip-ansi": { @@ -4251,9 +4307,9 @@ } }, "eslint-import-resolver-webpack": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/eslint-import-resolver-webpack/-/eslint-import-resolver-webpack-0.11.0.tgz", - "integrity": "sha512-vX8rYSPdKtTLkK2FoU1ZRyEsl6wP1FB40ytjrEgMhzUkEkBLuZAkv1KNR+2Ml7lzMOObXI3yaEDiaQ/Yvoczhw==", + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-webpack/-/eslint-import-resolver-webpack-0.11.1.tgz", + "integrity": "sha512-eK3zR7xVQR/MaoBWwGuD+CULYVuqe5QFlDukman71aI6IboCGzggDUohHNfu1ZeBnbHcUHJc0ywWoXUBNB6qdg==", "dev": true, "requires": { "array-find": "^1.0.0", @@ -4264,14 +4320,14 @@ "interpret": "^1.0.0", "lodash": "^4.17.4", "node-libs-browser": "^1.0.0 || ^2.0.0", - "resolve": "^1.4.0", + "resolve": "^1.10.0", "semver": "^5.3.0" } }, "eslint-module-utils": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.3.0.tgz", - "integrity": "sha512-lmDJgeOOjk8hObTysjqH7wyMi+nsHwwvfBykwfhjR1LNdd7C2uFJBvx4OpWYpXOw4df1yE1cDEVd1yLHitk34w==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.4.0.tgz", + "integrity": "sha512-14tltLm38Eu3zS+mt0KvILC3q8jyIAH518MlG+HO0p+yK885Lb1UHTY/UgR91eOyGdmxAPb+OLoW4znqIT6Ndw==", "dev": true, "requires": { "debug": "^2.6.8", @@ -4279,21 +4335,22 @@ } }, "eslint-plugin-import": { - "version": "2.16.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.16.0.tgz", - "integrity": "sha512-z6oqWlf1x5GkHIFgrSvtmudnqM6Q60KM4KvpWi5ubonMjycLjndvd5+8VAZIsTlHC03djdgJuyKG6XO577px6A==", + "version": "2.17.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.17.3.tgz", + "integrity": "sha512-qeVf/UwXFJbeyLbxuY8RgqDyEKCkqV7YC+E5S5uOjAp4tOc8zj01JP3ucoBM8JcEqd1qRasJSg6LLlisirfy0Q==", "dev": true, "requires": { + "array-includes": "^3.0.3", "contains-path": "^0.1.0", "debug": "^2.6.9", "doctrine": "1.5.0", "eslint-import-resolver-node": "^0.3.2", - "eslint-module-utils": "^2.3.0", + "eslint-module-utils": "^2.4.0", "has": "^1.0.3", "lodash": "^4.17.11", "minimatch": "^3.0.4", "read-pkg-up": "^2.0.0", - "resolve": "^1.9.0" + "resolve": "^1.11.0" }, "dependencies": { "doctrine": { @@ -4482,16 +4539,16 @@ } }, "expect": { - "version": "24.5.0", - "resolved": "https://registry.npmjs.org/expect/-/expect-24.5.0.tgz", - "integrity": "sha512-p2Gmc0CLxOgkyA93ySWmHFYHUPFIHG6XZ06l7WArWAsrqYVaVEkOU5NtT5i68KUyGKbkQgDCkiT65bWmdoL6Bw==", + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/expect/-/expect-24.8.0.tgz", + "integrity": "sha512-/zYvP8iMDrzaaxHVa724eJBCKqSHmO0FA7EDkBiRHxg6OipmMn1fN+C8T9L9K8yr7UONkOifu6+LLH+z76CnaA==", "dev": true, "requires": { - "@jest/types": "^24.5.0", + "@jest/types": "^24.8.0", "ansi-styles": "^3.2.0", - "jest-get-type": "^24.3.0", - "jest-matcher-utils": "^24.5.0", - "jest-message-util": "^24.5.0", + "jest-get-type": "^24.8.0", + "jest-matcher-utils": "^24.8.0", + "jest-message-util": "^24.8.0", "jest-regex-util": "^24.3.0" } }, @@ -4656,23 +4713,47 @@ } }, "file-loader": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/file-loader/-/file-loader-3.0.1.tgz", - "integrity": "sha512-4sNIOXgtH/9WZq4NvlfU3Opn5ynUsqBwSLyM+I7UOwdGigTBYfVVQEwe/msZNX/j4pCJTIM14Fsw66Svo1oVrw==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/file-loader/-/file-loader-4.0.0.tgz", + "integrity": "sha512-roAbL6IdSGczwfXxhMi6Zq+jD4IfUpL0jWHD7fvmjdOVb7xBfdRUHe4LpBgO23VtVK5AW1OlWZo0p34Jvx3iWg==", "dev": true, "requires": { - "loader-utils": "^1.0.2", + "loader-utils": "^1.2.2", "schema-utils": "^1.0.0" - } - }, - "fileset": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/fileset/-/fileset-2.0.3.tgz", - "integrity": "sha1-jnVIqW08wjJ+5eZ0FocjozO7oqA=", - "dev": true, - "requires": { - "glob": "^7.0.3", - "minimatch": "^3.0.3" + }, + "dependencies": { + "big.js": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", + "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==", + "dev": true + }, + "json5": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", + "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "dev": true, + "requires": { + "minimist": "^1.2.0" + } + }, + "loader-utils": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.2.3.tgz", + "integrity": "sha512-fkpz8ejdnEMG3s37wGL07iSBDg99O9D5yflE9RGNH3hRdx9SOwYfnGYdZOUIZitN8E+E2vkq3MUMYMvPYl5ZZA==", + "dev": true, + "requires": { + "big.js": "^5.2.2", + "emojis-list": "^2.0.0", + "json5": "^1.0.1" + } + }, + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true + } } }, "fill-range": { @@ -4822,9 +4903,9 @@ }, "dependencies": { "glob": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", - "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", "dev": true, "requires": { "fs.realpath": "^1.0.0", @@ -4960,7 +5041,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -5375,7 +5457,8 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -5431,6 +5514,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -5474,12 +5558,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, @@ -5585,9 +5671,9 @@ } }, "globals": { - "version": "11.11.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.11.0.tgz", - "integrity": "sha512-WHq43gS+6ufNOEqlrDBxVEbb8ntfXrfAUU2ZOpCxrBdGKW3gyv8mCxAfIBD0DroPKGrJ2eSsXsLtY9MPntsyTw==", + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", "dev": true }, "graceful-fs": { @@ -6029,9 +6115,9 @@ } }, "ieee754": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.12.tgz", - "integrity": "sha512-GguP+DRY+pJ3soyIiGPTvdiVXjZ+DbXOxGpXn3eMvNW4x4irjqXm4wHKscC+TfxSJ0yw/S1F24tqdMNsMZTiLA==", + "version": "1.1.13", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", + "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==", "dev": true }, "iferr": { @@ -6109,9 +6195,9 @@ } }, "p-try": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.1.0.tgz", - "integrity": "sha512-H2RyIJ7+A3rjkwKC2l5GGtU4H1vkxKCAGsWasNVd0Set+6i4znxbWy6/j16YDPJDWxhsgZiKAstMEP8wCdSpjA==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "dev": true }, "pkg-dir": { @@ -6172,9 +6258,9 @@ "dev": true }, "inquirer": { - "version": "6.2.2", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.2.2.tgz", - "integrity": "sha512-Z2rREiXA6cHRR9KBOarR3WuLlFzlIfAEIiB45ll5SSadMg7WqOh1MKEjjndfuH5ewXdixWCxqnVfGOQzPeiztA==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.3.1.tgz", + "integrity": "sha512-MmL624rfkFt4TG9y/Jvmt8vdmOo836U7Y0Hxr2aFk3RelZEGX4Igk0KabWrcaaZaTv9uzglOqWh1Vly+FAWAXA==", "dev": true, "requires": { "ansi-escapes": "^3.2.0", @@ -6188,7 +6274,7 @@ "run-async": "^2.2.0", "rxjs": "^6.4.0", "string-width": "^2.1.0", - "strip-ansi": "^5.0.0", + "strip-ansi": "^5.1.0", "through": "^2.3.6" }, "dependencies": { @@ -6210,9 +6296,9 @@ } }, "rxjs": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.4.0.tgz", - "integrity": "sha512-Z9Yfa11F6B9Sg/BK9MnqnQ+aQYicPLtilXBp2yUtDt2JRCE0h26d33EnfO3ZxoNxG0T92OUucP3Ct7cpfkdFfw==", + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.2.tgz", + "integrity": "sha512-HUb7j3kvb7p7eCUHE3FqjoDsC1xfZQ4AHFWfTKSpZ+sAhhz5X1WX0ZuUqWbzB2QhSLp3DoLUG+hMdEDKqWo2Zg==", "dev": true, "requires": { "tslib": "^1.9.0" @@ -6379,9 +6465,9 @@ "dev": true }, "is-generator-fn": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-generator-fn/-/is-generator-fn-2.0.0.tgz", - "integrity": "sha512-elzyIdM7iKoFHzcrndIqjYomImhxrFRnGP3galODoII4TB9gI7mZ+FnlLQmmjf27SxHS2gKEeyhX5/+YRS6H9g==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-generator-fn/-/is-generator-fn-2.1.0.tgz", + "integrity": "sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==", "dev": true }, "is-generator-function": { @@ -6391,9 +6477,9 @@ "dev": true }, "is-glob": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.0.tgz", - "integrity": "sha1-lSHHaEXMJhCoUgPd8ICpWML/q8A=", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", "dev": true, "requires": { "is-extglob": "^2.1.1" @@ -6508,249 +6594,35 @@ "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", "dev": true }, - "istanbul-api": { - "version": "2.1.7", - "resolved": "https://registry.npmjs.org/istanbul-api/-/istanbul-api-2.1.7.tgz", - "integrity": "sha512-LYTOa2UrYFyJ/aSczZi/6lBykVMjCCvUmT64gOe+jPZFy4w6FYfPGqFT2IiQ2BxVHHDOvCD7qrIXb0EOh4uGWw==", + "istanbul-lib-coverage": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.5.tgz", + "integrity": "sha512-8aXznuEPCJvGnMSRft4udDRDtb1V3pkQkMMI5LI+6HuQz5oQ4J2UFn1H82raA3qJtyOLkkwVqICBQkjnGtn5mA==", + "dev": true + }, + "istanbul-lib-instrument": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-3.3.0.tgz", + "integrity": "sha512-5nnIN4vo5xQZHdXno/YDXJ0G+I3dAm4XgzfSVTPLQpj/zAV2dV6Juy0yaf10/zrJOJeHoN3fraFe+XRq2bFVZA==", "dev": true, "requires": { - "async": "^2.6.2", - "compare-versions": "^3.4.0", - "fileset": "^2.0.3", + "@babel/generator": "^7.4.0", + "@babel/parser": "^7.4.3", + "@babel/template": "^7.4.0", + "@babel/traverse": "^7.4.3", + "@babel/types": "^7.4.0", "istanbul-lib-coverage": "^2.0.5", - "istanbul-lib-hook": "^2.0.7", - "istanbul-lib-instrument": "^3.3.0", - "istanbul-lib-report": "^2.0.8", - "istanbul-lib-source-maps": "^3.0.6", - "istanbul-reports": "^2.2.5", - "js-yaml": "^3.13.1", - "make-dir": "^2.1.0", - "minimatch": "^3.0.4", - "once": "^1.4.0" + "semver": "^6.0.0" }, "dependencies": { - "@babel/helper-split-export-declaration": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.4.4.tgz", - "integrity": "sha512-Ro/XkzLf3JFITkW6b+hNxzZ1n5OQ80NvIUdmHspih1XAhtN3vPTuUFT4eQnela+2MaZ5ulH+iyP513KJrxbN7Q==", - "dev": true, - "requires": { - "@babel/types": "^7.4.4" - }, - "dependencies": { - "@babel/types": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.4.4.tgz", - "integrity": "sha512-dOllgYdnEFOebhkKCjzSVFqw/PmmB8pH6RGOWkY4GsboQNd47b1fBThBSwlHAq9alF9vc1M3+6oqR47R50L0tQ==", - "dev": true, - "requires": { - "esutils": "^2.0.2", - "lodash": "^4.17.11", - "to-fast-properties": "^2.0.0" - } - } - } - }, - "@babel/parser": { - "version": "7.4.5", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.4.5.tgz", - "integrity": "sha512-9mUqkL1FF5T7f0WDFfAoDdiMVPWsdD1gZYzSnaXsxUCUqzuch/8of9G3VUSNiZmMBoRxT3neyVsqeiL/ZPcjew==", - "dev": true - }, - "@babel/traverse": { - "version": "7.4.5", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.4.5.tgz", - "integrity": "sha512-Vc+qjynwkjRmIFGxy0KYoPj4FdVDxLej89kMHFsWScq999uX+pwcX4v9mWRjW0KcAYTPAuVQl2LKP1wEVLsp+A==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "@babel/generator": "^7.4.4", - "@babel/helper-function-name": "^7.1.0", - "@babel/helper-split-export-declaration": "^7.4.4", - "@babel/parser": "^7.4.5", - "@babel/types": "^7.4.4", - "debug": "^4.1.0", - "globals": "^11.1.0", - "lodash": "^4.17.11" - }, - "dependencies": { - "@babel/generator": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.4.4.tgz", - "integrity": "sha512-53UOLK6TVNqKxf7RUh8NE851EHRxOOeVXKbK2bivdb+iziMyk03Sr4eaE9OELCbyZAAafAKPDwF2TPUES5QbxQ==", - "dev": true, - "requires": { - "@babel/types": "^7.4.4", - "jsesc": "^2.5.1", - "lodash": "^4.17.11", - "source-map": "^0.5.0", - "trim-right": "^1.0.1" - } - }, - "@babel/types": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.4.4.tgz", - "integrity": "sha512-dOllgYdnEFOebhkKCjzSVFqw/PmmB8pH6RGOWkY4GsboQNd47b1fBThBSwlHAq9alF9vc1M3+6oqR47R50L0tQ==", - "dev": true, - "requires": { - "esutils": "^2.0.2", - "lodash": "^4.17.11", - "to-fast-properties": "^2.0.0" - } - } - } - }, - "async": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.2.tgz", - "integrity": "sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg==", - "dev": true, - "requires": { - "lodash": "^4.17.11" - } - }, - "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - }, - "glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "istanbul-lib-coverage": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.5.tgz", - "integrity": "sha512-8aXznuEPCJvGnMSRft4udDRDtb1V3pkQkMMI5LI+6HuQz5oQ4J2UFn1H82raA3qJtyOLkkwVqICBQkjnGtn5mA==", - "dev": true - }, - "istanbul-lib-instrument": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-3.3.0.tgz", - "integrity": "sha512-5nnIN4vo5xQZHdXno/YDXJ0G+I3dAm4XgzfSVTPLQpj/zAV2dV6Juy0yaf10/zrJOJeHoN3fraFe+XRq2bFVZA==", - "dev": true, - "requires": { - "@babel/generator": "^7.4.0", - "@babel/parser": "^7.4.3", - "@babel/template": "^7.4.0", - "@babel/traverse": "^7.4.3", - "@babel/types": "^7.4.0", - "istanbul-lib-coverage": "^2.0.5", - "semver": "^6.0.0" - } - }, - "istanbul-lib-source-maps": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-3.0.6.tgz", - "integrity": "sha512-R47KzMtDJH6X4/YW9XTx+jrLnZnscW4VpNN+1PViSYTejLVPWv7oov+Duf8YQSPyVRUvueQqz1TcsC6mooZTXw==", - "dev": true, - "requires": { - "debug": "^4.1.1", - "istanbul-lib-coverage": "^2.0.5", - "make-dir": "^2.1.0", - "rimraf": "^2.6.3", - "source-map": "^0.6.1" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - } - } - }, - "make-dir": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz", - "integrity": "sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==", - "dev": true, - "requires": { - "pify": "^4.0.1", - "semver": "^5.6.0" - }, - "dependencies": { - "semver": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", - "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==", - "dev": true - } - } - }, - "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", - "dev": true - }, - "pify": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", - "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", - "dev": true - }, - "rimraf": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", - "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", - "dev": true, - "requires": { - "glob": "^7.1.3" - } - }, "semver": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.1.0.tgz", - "integrity": "sha512-kCqEOOHoBcFs/2Ccuk4Xarm/KiWRSLEX9CAZF8xkJ6ZPlIoTZ8V5f7J16vYLJqDbR7KrxTJpR2lqjIEm2Qx9cQ==", + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.1.1.tgz", + "integrity": "sha512-rWYq2e5iYW+fFe/oPPtYJxYgjBm8sC4rmoGdUOgBB7VnwKt6HrL793l2voH1UlsyYZpJ4g0wfjnTEO1s1NP2eQ==", "dev": true } } }, - "istanbul-lib-coverage": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.3.tgz", - "integrity": "sha512-dKWuzRGCs4G+67VfW9pBFFz2Jpi4vSp/k7zBcJ888ofV5Mi1g5CUML5GvMvV6u9Cjybftu+E8Cgp+k0dI1E5lw==", - "dev": true - }, - "istanbul-lib-hook": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/istanbul-lib-hook/-/istanbul-lib-hook-2.0.7.tgz", - "integrity": "sha512-vrRztU9VRRFDyC+aklfLoeXyNdTfga2EI3udDGn4cZ6fpSXpHLV9X6CHvfoMCPtggg8zvDDmC4b9xfu0z6/llA==", - "dev": true, - "requires": { - "append-transform": "^1.0.0" - } - }, - "istanbul-lib-instrument": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-3.1.0.tgz", - "integrity": "sha512-ooVllVGT38HIk8MxDj/OIHXSYvH+1tq/Vb38s8ixt9GoJadXska4WkGY+0wkmtYCZNYtaARniH/DixUGGLZ0uA==", - "dev": true, - "requires": { - "@babel/generator": "^7.0.0", - "@babel/parser": "^7.0.0", - "@babel/template": "^7.0.0", - "@babel/traverse": "^7.0.0", - "@babel/types": "^7.0.0", - "istanbul-lib-coverage": "^2.0.3", - "semver": "^5.5.0" - } - }, "istanbul-lib-report": { "version": "2.0.8", "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-2.0.8.tgz", @@ -6762,12 +6634,6 @@ "supports-color": "^6.1.0" }, "dependencies": { - "istanbul-lib-coverage": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.5.tgz", - "integrity": "sha512-8aXznuEPCJvGnMSRft4udDRDtb1V3pkQkMMI5LI+6HuQz5oQ4J2UFn1H82raA3qJtyOLkkwVqICBQkjnGtn5mA==", - "dev": true - }, "make-dir": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz", @@ -6802,15 +6668,15 @@ } }, "istanbul-lib-source-maps": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-3.0.2.tgz", - "integrity": "sha512-JX4v0CiKTGp9fZPmoxpu9YEkPbEqCqBbO3403VabKjH+NRXo72HafD5UgnjTEqHL2SAjaZK1XDuDOkn6I5QVfQ==", + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-3.0.6.tgz", + "integrity": "sha512-R47KzMtDJH6X4/YW9XTx+jrLnZnscW4VpNN+1PViSYTejLVPWv7oov+Duf8YQSPyVRUvueQqz1TcsC6mooZTXw==", "dev": true, "requires": { "debug": "^4.1.1", - "istanbul-lib-coverage": "^2.0.3", - "make-dir": "^1.3.0", - "rimraf": "^2.6.2", + "istanbul-lib-coverage": "^2.0.5", + "make-dir": "^2.1.0", + "rimraf": "^2.6.3", "source-map": "^0.6.1" }, "dependencies": { @@ -6823,12 +6689,57 @@ "ms": "^2.1.1" } }, + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "make-dir": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz", + "integrity": "sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==", + "dev": true, + "requires": { + "pify": "^4.0.1", + "semver": "^5.6.0" + } + }, "ms": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", "dev": true }, + "pify": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", + "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", + "dev": true + }, + "rimraf": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", + "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, + "semver": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", + "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==", + "dev": true + }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -6847,31 +6758,31 @@ } }, "jest": { - "version": "24.5.0", - "resolved": "https://registry.npmjs.org/jest/-/jest-24.5.0.tgz", - "integrity": "sha512-lxL+Fq5/RH7inxxmfS2aZLCf8MsS+YCUBfeiNO6BWz/MmjhDGaIEA/2bzEf9q4Q0X+mtFHiinHFvQ0u+RvW/qQ==", + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/jest/-/jest-24.8.0.tgz", + "integrity": "sha512-o0HM90RKFRNWmAWvlyV8i5jGZ97pFwkeVoGvPW1EtLTgJc2+jcuqcbbqcSZLE/3f2S5pt0y2ZBETuhpWNl1Reg==", "dev": true, "requires": { "import-local": "^2.0.0", - "jest-cli": "^24.5.0" + "jest-cli": "^24.8.0" }, "dependencies": { "jest-cli": { - "version": "24.5.0", - "resolved": "https://registry.npmjs.org/jest-cli/-/jest-cli-24.5.0.tgz", - "integrity": "sha512-P+Jp0SLO4KWN0cGlNtC7JV0dW1eSFR7eRpoOucP2UM0sqlzp/bVHeo71Omonvigrj9AvCKy7NtQANtqJ7FXz8g==", + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/jest-cli/-/jest-cli-24.8.0.tgz", + "integrity": "sha512-+p6J00jSMPQ116ZLlHJJvdf8wbjNbZdeSX9ptfHX06/MSNaXmKihQzx5vQcw0q2G6JsdVkUIdWbOWtSnaYs3yA==", "dev": true, "requires": { - "@jest/core": "^24.5.0", - "@jest/test-result": "^24.5.0", - "@jest/types": "^24.5.0", + "@jest/core": "^24.8.0", + "@jest/test-result": "^24.8.0", + "@jest/types": "^24.8.0", "chalk": "^2.0.1", "exit": "^0.1.2", "import-local": "^2.0.0", "is-ci": "^2.0.0", - "jest-config": "^24.5.0", - "jest-util": "^24.5.0", - "jest-validate": "^24.5.0", + "jest-config": "^24.8.0", + "jest-util": "^24.8.0", + "jest-validate": "^24.8.0", "prompts": "^2.0.1", "realpath-native": "^1.1.0", "yargs": "^12.0.2" @@ -6880,50 +6791,51 @@ } }, "jest-changed-files": { - "version": "24.5.0", - "resolved": "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-24.5.0.tgz", - "integrity": "sha512-Ikl29dosYnTsH9pYa1Tv9POkILBhN/TLZ37xbzgNsZ1D2+2n+8oEZS2yP1BrHn/T4Rs4Ggwwbp/x8CKOS5YJOg==", + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-24.8.0.tgz", + "integrity": "sha512-qgANC1Yrivsq+UrLXsvJefBKVoCsKB0Hv+mBb6NMjjZ90wwxCDmU3hsCXBya30cH+LnPYjwgcU65i6yJ5Nfuug==", "dev": true, "requires": { - "@jest/types": "^24.5.0", + "@jest/types": "^24.8.0", "execa": "^1.0.0", "throat": "^4.0.0" } }, "jest-config": { - "version": "24.5.0", - "resolved": "https://registry.npmjs.org/jest-config/-/jest-config-24.5.0.tgz", - "integrity": "sha512-t2UTh0Z2uZhGBNVseF8wA2DS2SuBiLOL6qpLq18+OZGfFUxTM7BzUVKyHFN/vuN+s/aslY1COW95j1Rw81huOQ==", + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/jest-config/-/jest-config-24.8.0.tgz", + "integrity": "sha512-Czl3Nn2uEzVGsOeaewGWoDPD8GStxCpAe0zOYs2x2l0fZAgPbCr3uwUkgNKV3LwE13VXythM946cd5rdGkkBZw==", "dev": true, "requires": { "@babel/core": "^7.1.0", - "@jest/types": "^24.5.0", - "babel-jest": "^24.5.0", + "@jest/test-sequencer": "^24.8.0", + "@jest/types": "^24.8.0", + "babel-jest": "^24.8.0", "chalk": "^2.0.1", "glob": "^7.1.1", - "jest-environment-jsdom": "^24.5.0", - "jest-environment-node": "^24.5.0", - "jest-get-type": "^24.3.0", - "jest-jasmine2": "^24.5.0", + "jest-environment-jsdom": "^24.8.0", + "jest-environment-node": "^24.8.0", + "jest-get-type": "^24.8.0", + "jest-jasmine2": "^24.8.0", "jest-regex-util": "^24.3.0", - "jest-resolve": "^24.5.0", - "jest-util": "^24.5.0", - "jest-validate": "^24.5.0", + "jest-resolve": "^24.8.0", + "jest-util": "^24.8.0", + "jest-validate": "^24.8.0", "micromatch": "^3.1.10", - "pretty-format": "^24.5.0", + "pretty-format": "^24.8.0", "realpath-native": "^1.1.0" } }, "jest-diff": { - "version": "24.5.0", - "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-24.5.0.tgz", - "integrity": "sha512-mCILZd9r7zqL9Uh6yNoXjwGQx0/J43OD2vvWVKwOEOLZliQOsojXwqboubAQ+Tszrb6DHGmNU7m4whGeB9YOqw==", + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-24.8.0.tgz", + "integrity": "sha512-wxetCEl49zUpJ/bvUmIFjd/o52J+yWcoc5ZyPq4/W1LUKGEhRYDIbP1KcF6t+PvqNrGAFk4/JhtxDq/Nnzs66g==", "dev": true, "requires": { "chalk": "^2.0.1", "diff-sequences": "^24.3.0", - "jest-get-type": "^24.3.0", - "pretty-format": "^24.5.0" + "jest-get-type": "^24.8.0", + "pretty-format": "^24.8.0" } }, "jest-docblock": { @@ -6936,66 +6848,69 @@ } }, "jest-each": { - "version": "24.5.0", - "resolved": "https://registry.npmjs.org/jest-each/-/jest-each-24.5.0.tgz", - "integrity": "sha512-6gy3Kh37PwIT5sNvNY2VchtIFOOBh8UCYnBlxXMb5sr5wpJUDPTUATX2Axq1Vfk+HWTMpsYPeVYp4TXx5uqUBw==", + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/jest-each/-/jest-each-24.8.0.tgz", + "integrity": "sha512-NrwK9gaL5+XgrgoCsd9svsoWdVkK4gnvyhcpzd6m487tXHqIdYeykgq3MKI1u4I+5Zf0tofr70at9dWJDeb+BA==", "dev": true, "requires": { - "@jest/types": "^24.5.0", + "@jest/types": "^24.8.0", "chalk": "^2.0.1", - "jest-get-type": "^24.3.0", - "jest-util": "^24.5.0", - "pretty-format": "^24.5.0" + "jest-get-type": "^24.8.0", + "jest-util": "^24.8.0", + "pretty-format": "^24.8.0" } }, "jest-environment-jsdom": { - "version": "24.5.0", - "resolved": "https://registry.npmjs.org/jest-environment-jsdom/-/jest-environment-jsdom-24.5.0.tgz", - "integrity": "sha512-62Ih5HbdAWcsqBx2ktUnor/mABBo1U111AvZWcLKeWN/n/gc5ZvDBKe4Og44fQdHKiXClrNGC6G0mBo6wrPeGQ==", + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/jest-environment-jsdom/-/jest-environment-jsdom-24.8.0.tgz", + "integrity": "sha512-qbvgLmR7PpwjoFjM/sbuqHJt/NCkviuq9vus9NBn/76hhSidO+Z6Bn9tU8friecegbJL8gzZQEMZBQlFWDCwAQ==", "dev": true, "requires": { - "@jest/environment": "^24.5.0", - "@jest/fake-timers": "^24.5.0", - "@jest/types": "^24.5.0", - "jest-mock": "^24.5.0", - "jest-util": "^24.5.0", + "@jest/environment": "^24.8.0", + "@jest/fake-timers": "^24.8.0", + "@jest/types": "^24.8.0", + "jest-mock": "^24.8.0", + "jest-util": "^24.8.0", "jsdom": "^11.5.1" } }, "jest-environment-node": { - "version": "24.5.0", - "resolved": "https://registry.npmjs.org/jest-environment-node/-/jest-environment-node-24.5.0.tgz", - "integrity": "sha512-du6FuyWr/GbKLsmAbzNF9mpr2Iu2zWSaq/BNHzX+vgOcts9f2ayXBweS7RAhr+6bLp6qRpMB6utAMF5Ygktxnw==", + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/jest-environment-node/-/jest-environment-node-24.8.0.tgz", + "integrity": "sha512-vIGUEScd1cdDgR6sqn2M08sJTRLQp6Dk/eIkCeO4PFHxZMOgy+uYLPMC4ix3PEfM5Au/x3uQ/5Tl0DpXXZsJ/Q==", "dev": true, "requires": { - "@jest/environment": "^24.5.0", - "@jest/fake-timers": "^24.5.0", - "@jest/types": "^24.5.0", - "jest-mock": "^24.5.0", - "jest-util": "^24.5.0" + "@jest/environment": "^24.8.0", + "@jest/fake-timers": "^24.8.0", + "@jest/types": "^24.8.0", + "jest-mock": "^24.8.0", + "jest-util": "^24.8.0" } }, "jest-get-type": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-24.3.0.tgz", - "integrity": "sha512-HYF6pry72YUlVcvUx3sEpMRwXEWGEPlJ0bSPVnB3b3n++j4phUEoSPcS6GC0pPJ9rpyPSe4cb5muFo6D39cXow==", + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-24.8.0.tgz", + "integrity": "sha512-RR4fo8jEmMD9zSz2nLbs2j0zvPpk/KCEz3a62jJWbd2ayNo0cb+KFRxPHVhE4ZmgGJEQp0fosmNz84IfqM8cMQ==", "dev": true }, "jest-haste-map": { - "version": "24.5.0", - "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-24.5.0.tgz", - "integrity": "sha512-mb4Yrcjw9vBgSvobDwH8QUovxApdimGcOkp+V1ucGGw4Uvr3VzZQBJhNm1UY3dXYm4XXyTW2G7IBEZ9pM2ggRQ==", + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-24.8.0.tgz", + "integrity": "sha512-ZBPRGHdPt1rHajWelXdqygIDpJx8u3xOoLyUBWRW28r3tagrgoepPrzAozW7kW9HrQfhvmiv1tncsxqHJO1onQ==", "dev": true, "requires": { - "@jest/types": "^24.5.0", + "@jest/types": "^24.8.0", + "anymatch": "^2.0.0", "fb-watchman": "^2.0.0", + "fsevents": "^1.2.7", "graceful-fs": "^4.1.15", "invariant": "^2.2.4", "jest-serializer": "^24.4.0", - "jest-util": "^24.5.0", - "jest-worker": "^24.4.0", + "jest-util": "^24.8.0", + "jest-worker": "^24.6.0", "micromatch": "^3.1.10", - "sane": "^4.0.3" + "sane": "^4.0.3", + "walker": "^1.0.7" }, "dependencies": { "graceful-fs": { @@ -7007,59 +6922,59 @@ } }, "jest-jasmine2": { - "version": "24.5.0", - "resolved": "https://registry.npmjs.org/jest-jasmine2/-/jest-jasmine2-24.5.0.tgz", - "integrity": "sha512-sfVrxVcx1rNUbBeyIyhkqZ4q+seNKyAG6iM0S2TYBdQsXjoFDdqWFfsUxb6uXSsbimbXX/NMkJIwUZ1uT9+/Aw==", + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/jest-jasmine2/-/jest-jasmine2-24.8.0.tgz", + "integrity": "sha512-cEky88npEE5LKd5jPpTdDCLvKkdyklnaRycBXL6GNmpxe41F0WN44+i7lpQKa/hcbXaQ+rc9RMaM4dsebrYong==", "dev": true, "requires": { "@babel/traverse": "^7.1.0", - "@jest/environment": "^24.5.0", - "@jest/test-result": "^24.5.0", - "@jest/types": "^24.5.0", + "@jest/environment": "^24.8.0", + "@jest/test-result": "^24.8.0", + "@jest/types": "^24.8.0", "chalk": "^2.0.1", "co": "^4.6.0", - "expect": "^24.5.0", + "expect": "^24.8.0", "is-generator-fn": "^2.0.0", - "jest-each": "^24.5.0", - "jest-matcher-utils": "^24.5.0", - "jest-message-util": "^24.5.0", - "jest-runtime": "^24.5.0", - "jest-snapshot": "^24.5.0", - "jest-util": "^24.5.0", - "pretty-format": "^24.5.0", + "jest-each": "^24.8.0", + "jest-matcher-utils": "^24.8.0", + "jest-message-util": "^24.8.0", + "jest-runtime": "^24.8.0", + "jest-snapshot": "^24.8.0", + "jest-util": "^24.8.0", + "pretty-format": "^24.8.0", "throat": "^4.0.0" } }, "jest-leak-detector": { - "version": "24.5.0", - "resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-24.5.0.tgz", - "integrity": "sha512-LZKBjGovFRx3cRBkqmIg+BZnxbrLqhQl09IziMk3oeh1OV81Hg30RUIx885mq8qBv1PA0comB9bjKcuyNO1bCQ==", + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-24.8.0.tgz", + "integrity": "sha512-cG0yRSK8A831LN8lIHxI3AblB40uhv0z+SsQdW3GoMMVcK+sJwrIIyax5tu3eHHNJ8Fu6IMDpnLda2jhn2pD/g==", "dev": true, "requires": { - "pretty-format": "^24.5.0" + "pretty-format": "^24.8.0" } }, "jest-matcher-utils": { - "version": "24.5.0", - "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-24.5.0.tgz", - "integrity": "sha512-QM1nmLROjLj8GMGzg5VBra3I9hLpjMPtF1YqzQS3rvWn2ltGZLrGAO1KQ9zUCVi5aCvrkbS5Ndm2evIP9yZg1Q==", + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-24.8.0.tgz", + "integrity": "sha512-lex1yASY51FvUuHgm0GOVj7DCYEouWSlIYmCW7APSqB9v8mXmKSn5+sWVF0MhuASG0bnYY106/49JU1FZNl5hw==", "dev": true, "requires": { "chalk": "^2.0.1", - "jest-diff": "^24.5.0", - "jest-get-type": "^24.3.0", - "pretty-format": "^24.5.0" + "jest-diff": "^24.8.0", + "jest-get-type": "^24.8.0", + "pretty-format": "^24.8.0" } }, "jest-message-util": { - "version": "24.5.0", - "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-24.5.0.tgz", - "integrity": "sha512-6ZYgdOojowCGiV0D8WdgctZEAe+EcFU+KrVds+0ZjvpZurUW2/oKJGltJ6FWY2joZwYXN5VL36GPV6pNVRqRnQ==", + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-24.8.0.tgz", + "integrity": "sha512-p2k71rf/b6ns8btdB0uVdljWo9h0ovpnEe05ZKWceQGfXYr4KkzgKo3PBi8wdnd9OtNh46VpNIJynUn/3MKm1g==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", - "@jest/test-result": "^24.5.0", - "@jest/types": "^24.5.0", + "@jest/test-result": "^24.8.0", + "@jest/types": "^24.8.0", "@types/stack-utils": "^1.0.1", "chalk": "^2.0.1", "micromatch": "^3.1.10", @@ -7068,12 +6983,12 @@ } }, "jest-mock": { - "version": "24.5.0", - "resolved": "https://registry.npmjs.org/jest-mock/-/jest-mock-24.5.0.tgz", - "integrity": "sha512-ZnAtkWrKf48eERgAOiUxVoFavVBziO2pAi2MfZ1+bGXVkDfxWLxU0//oJBkgwbsv6OAmuLBz4XFFqvCFMqnGUw==", + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/jest-mock/-/jest-mock-24.8.0.tgz", + "integrity": "sha512-6kWugwjGjJw+ZkK4mDa0Df3sDlUTsV47MSrT0nGQ0RBWJbpODDQ8MHDVtGtUYBne3IwZUhtB7elxHspU79WH3A==", "dev": true, "requires": { - "@jest/types": "^24.5.0" + "@jest/types": "^24.8.0" } }, "jest-pnp-resolver": { @@ -7089,12 +7004,12 @@ "dev": true }, "jest-resolve": { - "version": "24.5.0", - "resolved": "https://registry.npmjs.org/jest-resolve/-/jest-resolve-24.5.0.tgz", - "integrity": "sha512-ZIfGqLX1Rg8xJpQqNjdoO8MuxHV1q/i2OO1hLXjgCWFWs5bsedS8UrOdgjUqqNae6DXA+pCyRmdcB7lQEEbXew==", + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/jest-resolve/-/jest-resolve-24.8.0.tgz", + "integrity": "sha512-+hjSzi1PoRvnuOICoYd5V/KpIQmkAsfjFO71458hQ2Whi/yf1GDeBOFj8Gxw4LrApHsVJvn5fmjcPdmoUHaVKw==", "dev": true, "requires": { - "@jest/types": "^24.5.0", + "@jest/types": "^24.8.0", "browser-resolve": "^1.11.3", "chalk": "^2.0.1", "jest-pnp-resolver": "^1.2.1", @@ -7102,39 +7017,39 @@ } }, "jest-resolve-dependencies": { - "version": "24.5.0", - "resolved": "https://registry.npmjs.org/jest-resolve-dependencies/-/jest-resolve-dependencies-24.5.0.tgz", - "integrity": "sha512-dRVM1D+gWrFfrq2vlL5P9P/i8kB4BOYqYf3S7xczZ+A6PC3SgXYSErX/ScW/469pWMboM1uAhgLF+39nXlirCQ==", + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/jest-resolve-dependencies/-/jest-resolve-dependencies-24.8.0.tgz", + "integrity": "sha512-hyK1qfIf/krV+fSNyhyJeq3elVMhK9Eijlwy+j5jqmZ9QsxwKBiP6qukQxaHtK8k6zql/KYWwCTQ+fDGTIJauw==", "dev": true, "requires": { - "@jest/types": "^24.5.0", + "@jest/types": "^24.8.0", "jest-regex-util": "^24.3.0", - "jest-snapshot": "^24.5.0" + "jest-snapshot": "^24.8.0" } }, "jest-runner": { - "version": "24.5.0", - "resolved": "https://registry.npmjs.org/jest-runner/-/jest-runner-24.5.0.tgz", - "integrity": "sha512-oqsiS9TkIZV5dVkD+GmbNfWBRPIvxqmlTQ+AQUJUQ07n+4xTSDc40r+aKBynHw9/tLzafC00DIbJjB2cOZdvMA==", + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/jest-runner/-/jest-runner-24.8.0.tgz", + "integrity": "sha512-utFqC5BaA3JmznbissSs95X1ZF+d+4WuOWwpM9+Ak356YtMhHE/GXUondZdcyAAOTBEsRGAgH/0TwLzfI9h7ow==", "dev": true, "requires": { - "@jest/console": "^24.3.0", - "@jest/environment": "^24.5.0", - "@jest/test-result": "^24.5.0", - "@jest/types": "^24.5.0", + "@jest/console": "^24.7.1", + "@jest/environment": "^24.8.0", + "@jest/test-result": "^24.8.0", + "@jest/types": "^24.8.0", "chalk": "^2.4.2", "exit": "^0.1.2", "graceful-fs": "^4.1.15", - "jest-config": "^24.5.0", + "jest-config": "^24.8.0", "jest-docblock": "^24.3.0", - "jest-haste-map": "^24.5.0", - "jest-jasmine2": "^24.5.0", - "jest-leak-detector": "^24.5.0", - "jest-message-util": "^24.5.0", - "jest-resolve": "^24.5.0", - "jest-runtime": "^24.5.0", - "jest-util": "^24.5.0", - "jest-worker": "^24.4.0", + "jest-haste-map": "^24.8.0", + "jest-jasmine2": "^24.8.0", + "jest-leak-detector": "^24.8.0", + "jest-message-util": "^24.8.0", + "jest-resolve": "^24.8.0", + "jest-runtime": "^24.8.0", + "jest-util": "^24.8.0", + "jest-worker": "^24.6.0", "source-map-support": "^0.5.6", "throat": "^4.0.0" }, @@ -7159,30 +7074,30 @@ } }, "jest-runtime": { - "version": "24.5.0", - "resolved": "https://registry.npmjs.org/jest-runtime/-/jest-runtime-24.5.0.tgz", - "integrity": "sha512-GTFHzfLdwpaeoDPilNpBrorlPoNZuZrwKKzKJs09vWwHo+9TOsIIuszK8cWOuKC7ss07aN1922Ge8fsGdsqCuw==", + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/jest-runtime/-/jest-runtime-24.8.0.tgz", + "integrity": "sha512-Mq0aIXhvO/3bX44ccT+czU1/57IgOMyy80oM0XR/nyD5zgBcesF84BPabZi39pJVA6UXw+fY2Q1N+4BiVUBWOA==", "dev": true, "requires": { - "@jest/console": "^24.3.0", - "@jest/environment": "^24.5.0", + "@jest/console": "^24.7.1", + "@jest/environment": "^24.8.0", "@jest/source-map": "^24.3.0", - "@jest/transform": "^24.5.0", - "@jest/types": "^24.5.0", + "@jest/transform": "^24.8.0", + "@jest/types": "^24.8.0", "@types/yargs": "^12.0.2", "chalk": "^2.0.1", "exit": "^0.1.2", "glob": "^7.1.3", "graceful-fs": "^4.1.15", - "jest-config": "^24.5.0", - "jest-haste-map": "^24.5.0", - "jest-message-util": "^24.5.0", - "jest-mock": "^24.5.0", + "jest-config": "^24.8.0", + "jest-haste-map": "^24.8.0", + "jest-message-util": "^24.8.0", + "jest-mock": "^24.8.0", "jest-regex-util": "^24.3.0", - "jest-resolve": "^24.5.0", - "jest-snapshot": "^24.5.0", - "jest-util": "^24.5.0", - "jest-validate": "^24.5.0", + "jest-resolve": "^24.8.0", + "jest-snapshot": "^24.8.0", + "jest-util": "^24.8.0", + "jest-validate": "^24.8.0", "realpath-native": "^1.1.0", "slash": "^2.0.0", "strip-bom": "^3.0.0", @@ -7190,9 +7105,9 @@ }, "dependencies": { "glob": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", - "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", "dev": true, "requires": { "fs.realpath": "^1.0.0", @@ -7218,37 +7133,36 @@ "dev": true }, "jest-snapshot": { - "version": "24.5.0", - "resolved": "https://registry.npmjs.org/jest-snapshot/-/jest-snapshot-24.5.0.tgz", - "integrity": "sha512-eBEeJb5ROk0NcpodmSKnCVgMOo+Qsu5z9EDl3tGffwPzK1yV37mjGWF2YeIz1NkntgTzP+fUL4s09a0+0dpVWA==", + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/jest-snapshot/-/jest-snapshot-24.8.0.tgz", + "integrity": "sha512-5ehtWoc8oU9/cAPe6fez6QofVJLBKyqkY2+TlKTOf0VllBB/mqUNdARdcjlZrs9F1Cv+/HKoCS/BknT0+tmfPg==", "dev": true, "requires": { "@babel/types": "^7.0.0", - "@jest/types": "^24.5.0", + "@jest/types": "^24.8.0", "chalk": "^2.0.1", - "expect": "^24.5.0", - "jest-diff": "^24.5.0", - "jest-matcher-utils": "^24.5.0", - "jest-message-util": "^24.5.0", - "jest-resolve": "^24.5.0", + "expect": "^24.8.0", + "jest-diff": "^24.8.0", + "jest-matcher-utils": "^24.8.0", + "jest-message-util": "^24.8.0", + "jest-resolve": "^24.8.0", "mkdirp": "^0.5.1", "natural-compare": "^1.4.0", - "pretty-format": "^24.5.0", + "pretty-format": "^24.8.0", "semver": "^5.5.0" } }, "jest-util": { - "version": "24.5.0", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-24.5.0.tgz", - "integrity": "sha512-Xy8JsD0jvBz85K7VsTIQDuY44s+hYJyppAhcsHsOsGisVtdhar6fajf2UOf2mEVEgh15ZSdA0zkCuheN8cbr1Q==", + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-24.8.0.tgz", + "integrity": "sha512-DYZeE+XyAnbNt0BG1OQqKy/4GVLPtzwGx5tsnDrFcax36rVE3lTA5fbvgmbVPUZf9w77AJ8otqR4VBbfFJkUZA==", "dev": true, "requires": { - "@jest/console": "^24.3.0", - "@jest/fake-timers": "^24.5.0", + "@jest/console": "^24.7.1", + "@jest/fake-timers": "^24.8.0", "@jest/source-map": "^24.3.0", - "@jest/test-result": "^24.5.0", - "@jest/types": "^24.5.0", - "@types/node": "*", + "@jest/test-result": "^24.8.0", + "@jest/types": "^24.8.0", "callsites": "^3.0.0", "chalk": "^2.0.1", "graceful-fs": "^4.1.15", @@ -7273,42 +7187,40 @@ } }, "jest-validate": { - "version": "24.5.0", - "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-24.5.0.tgz", - "integrity": "sha512-gg0dYszxjgK2o11unSIJhkOFZqNRQbWOAB2/LOUdsd2LfD9oXiMeuee8XsT0iRy5EvSccBgB4h/9HRbIo3MHgQ==", + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-24.8.0.tgz", + "integrity": "sha512-+/N7VOEMW1Vzsrk3UWBDYTExTPwf68tavEPKDnJzrC6UlHtUDU/fuEdXqFoHzv9XnQ+zW6X3qMZhJ3YexfeLDA==", "dev": true, "requires": { - "@jest/types": "^24.5.0", + "@jest/types": "^24.8.0", "camelcase": "^5.0.0", "chalk": "^2.0.1", - "jest-get-type": "^24.3.0", + "jest-get-type": "^24.8.0", "leven": "^2.1.0", - "pretty-format": "^24.5.0" + "pretty-format": "^24.8.0" } }, "jest-watcher": { - "version": "24.5.0", - "resolved": "https://registry.npmjs.org/jest-watcher/-/jest-watcher-24.5.0.tgz", - "integrity": "sha512-/hCpgR6bg0nKvD3nv4KasdTxuhwfViVMHUATJlnGCD0r1QrmIssimPbmc5KfAQblAVxkD8xrzuij9vfPUk1/rA==", + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/jest-watcher/-/jest-watcher-24.8.0.tgz", + "integrity": "sha512-SBjwHt5NedQoVu54M5GEx7cl7IGEFFznvd/HNT8ier7cCAx/Qgu9ZMlaTQkvK22G1YOpcWBLQPFSImmxdn3DAw==", "dev": true, "requires": { - "@jest/test-result": "^24.5.0", - "@jest/types": "^24.5.0", - "@types/node": "*", + "@jest/test-result": "^24.8.0", + "@jest/types": "^24.8.0", "@types/yargs": "^12.0.9", "ansi-escapes": "^3.0.0", "chalk": "^2.0.1", - "jest-util": "^24.5.0", + "jest-util": "^24.8.0", "string-length": "^2.0.0" } }, "jest-worker": { - "version": "24.4.0", - "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-24.4.0.tgz", - "integrity": "sha512-BH9X/klG9vxwoO99ZBUbZFfV8qO0XNZ5SIiCyYK2zOuJBl6YJVAeNIQjcoOVNu4HGEHeYEKsUWws8kSlSbZ9YQ==", + "version": "24.6.0", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-24.6.0.tgz", + "integrity": "sha512-jDwgW5W9qGNvpI1tNnvajh0a5IE/PuGLFmHk6aR/BZFz8tSgGw17GsDPXAJ6p91IvYDjOw8GpFbvvZGAK+DPQQ==", "dev": true, "requires": { - "@types/node": "*", "merge-stream": "^1.0.1", "supports-color": "^6.1.0" }, @@ -7481,9 +7393,9 @@ "dev": true }, "kleur": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.2.tgz", - "integrity": "sha512-3h7B2WRT5LNXOtQiAaWonilegHcPSf9nLVXlSTci8lu1dZUuui61+EsPEZqSVxY7rXYmB2DVKMQILxaO5WL61Q==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", + "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", "dev": true }, "koa": { @@ -7936,12 +7848,6 @@ "integrity": "sha1-soqmKIorn8ZRA1x3EfZathkDMaY=", "dev": true }, - "lodash.debounce": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", - "integrity": "sha1-gteb/zCmfEAF/9XiUVMArZyk168=", - "dev": true - }, "lodash.isplainobject": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", @@ -7985,9 +7891,9 @@ "dev": true }, "loglevel": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.6.1.tgz", - "integrity": "sha1-4PyVEztu8nbNyIh82vJKpvFW+Po=" + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.6.2.tgz", + "integrity": "sha512-Jt2MHrCNdtIe1W6co3tF5KXGRkzF+TYffiQstfXa04mrss9IKXzAAXYWak8LbZseAQY03sH2GzMCMU0ZOUc9bg==" }, "loose-envify": { "version": "1.4.0", @@ -8336,9 +8242,9 @@ "dev": true }, "mem": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/mem/-/mem-4.2.0.tgz", - "integrity": "sha512-5fJxa68urlY0Ir8ijatKa3eRz5lwXnRCTvo9+TbTGAuTFJOwpGcY0X05moBd0nW45965Njt4CDI2GFQoG8DvqA==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/mem/-/mem-4.3.0.tgz", + "integrity": "sha512-qX2bG48pTqYRVmDB37rn/6PT7LcR8T7oAX3bf99u1Tt1nzxYfxkgqDwUwolPlXweM0XzBOBFzSx4kfp7KP1s/w==", "dev": true, "requires": { "map-age-cleaner": "^0.1.1", @@ -8347,15 +8253,15 @@ }, "dependencies": { "mimic-fn": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.0.0.tgz", - "integrity": "sha512-jbex9Yd/3lmICXwYT6gA/j2mNQGU48wCh/VzRd+/Y/PjYQtlg1gLMdZqvu9s/xH7qKvngxRObl56XZR609IMbA==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", "dev": true }, "p-is-promise": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-2.0.0.tgz", - "integrity": "sha512-pzQPhYMCAgLAKPWD2jC3Se9fEfrD9npNos0y150EeqZll7akhEgGhTW/slB6lHku8AvYGiJ+YJ5hfHKePPgFWg==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-2.1.0.tgz", + "integrity": "sha512-Y3W0wlRPK8ZMRbNq97l4M5otioeA5lm1z7bkNkxCka8HSPjR0xRWmpCmc9utiaLP9Jb1eD8BgeIxTW4AIF45Pg==", "dev": true } } @@ -8613,9 +8519,9 @@ "dev": true }, "neo-async": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.0.tgz", - "integrity": "sha512-MFh0d/Wa7vkKO3Y3LlacqAEeHK0mckVqzDieUKTT+KGxi+zIpeVsFxymkIiRpbpDziHc290Xr9A1O4Om7otoRA==", + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.1.tgz", + "integrity": "sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==", "dev": true }, "nice-try": { @@ -8696,9 +8602,9 @@ "dev": true }, "node-releases": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.11.tgz", - "integrity": "sha512-8v1j5KfP+s5WOTa1spNUAOfreajQPN12JXbRR0oDE+YrJBQCXBnNqUDj27EKpPLOoSiU3tKi3xGPB+JaOdUEQQ==", + "version": "1.1.23", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.23.tgz", + "integrity": "sha512-uq1iL79YjfYC0WXoHbC/z28q/9pOl8kSHaXdWmAAc8No+bDwqkZbzIJz55g/MUsPgSGm9LZ7QSUbzTcH5tz47w==", "dev": true, "requires": { "semver": "^5.3.0" @@ -8734,13 +8640,10 @@ } }, "normalize-path": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", - "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", - "dev": true, - "requires": { - "remove-trailing-separator": "^1.0.1" - } + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true }, "npm-run-path": { "version": "2.0.2", @@ -8767,9 +8670,9 @@ "dev": true }, "nwsapi": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.1.1.tgz", - "integrity": "sha512-T5GaA1J/d34AC8mkrFD2O0DR17kwJ702ZOtJOsS8RpbsQZVOC2/xYFb1i/cw+xdM54JIlMuojjDOYct8GIWtwg==", + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.1.4.tgz", + "integrity": "sha512-iGfd9Y6SFdTNldEy2L0GUhcarIutFmk+MPWIn9dmj8NMIup03G08uUF2KGbbmv/Ux4RT0VZJoP/sVbWA6d/VIw==", "dev": true }, "oauth-sign": { @@ -9069,9 +8972,9 @@ } }, "parent-module": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.0.tgz", - "integrity": "sha512-8Mf5juOMmiE4FcmzYc4IaiS9L3+9paz2KOiXzkRviCP6aDmN49Hz6EMWz0lGNp9pX80GvvAuLADtyGfW/Em3TA==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", "dev": true, "requires": { "callsites": "^3.0.0" @@ -9441,12 +9344,12 @@ } }, "pretty-format": { - "version": "24.5.0", - "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-24.5.0.tgz", - "integrity": "sha512-/3RuSghukCf8Riu5Ncve0iI+BzVkbRU5EeUoArKARZobREycuH5O4waxvaNIloEXdb0qwgmEAed5vTpX1HNROQ==", + "version": "24.8.0", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-24.8.0.tgz", + "integrity": "sha512-P952T7dkrDEplsR+TuY7q3VXDae5Sr7zmQb12JU/NDQa/3CH7/QW0yvqLcGN6jL+zQFKaoJcPc+yJxMTGmosqw==", "dev": true, "requires": { - "@jest/types": "^24.5.0", + "@jest/types": "^24.8.0", "ansi-regex": "^4.0.0", "ansi-styles": "^3.2.0", "react-is": "^16.8.4" @@ -9491,9 +9394,9 @@ "dev": true }, "prompts": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.0.4.tgz", - "integrity": "sha512-HTzM3UWp/99A0gk51gAegwo1QRYA7xjcZufMNe33rCclFszUYAuHe1fIN/3ZmiHeGPkUsNaRyQm1hHOfM0PKxA==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.1.0.tgz", + "integrity": "sha512-+x5TozgqYdOwWsQFZizE/Tra3fKvAoy037kOyU6cgz84n8f6zxngLOV4O32kTwt9FcLCxAqw0P/c8rOr9y+Gfg==", "dev": true, "requires": { "kleur": "^3.0.2", @@ -9507,9 +9410,9 @@ "dev": true }, "psl": { - "version": "1.1.31", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.31.tgz", - "integrity": "sha512-/6pt4+C+T+wZUieKR620OpzN/LlnNKuWjy1iFLQ/UG35JqHlR/89MP1d96dUfkf6Dne3TuLQzOYEYshJ+Hx8mw==", + "version": "1.1.32", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.32.tgz", + "integrity": "sha512-MHACAkHpihU/REGGPLj4sEfc/XKW2bheigvHO1dUqjaKigMp1C8+WLQYRGgeKFMsw5PMfegZcaN8IDXK/cD0+g==", "dev": true }, "public-encrypt": { @@ -9615,9 +9518,9 @@ } }, "react-is": { - "version": "16.8.4", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.8.4.tgz", - "integrity": "sha512-PVadd+WaUDOAciICm/J1waJaSvgq+4rHE/K70j0PFqKhkTBsPv/82UGQJNXAngz1fOQLLxI6z1sEDmJDQhCTAA==", + "version": "16.8.6", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.8.6.tgz", + "integrity": "sha512-aUk3bHfZ2bRSVFFbbeVS4i+lNPZr3/WM5jT2J5omUVV1zzcs1nAaf3l51ctA5FFvCRbhrH0bdAsRRQddFJZPtA==", "dev": true }, "read-pkg": { @@ -9689,9 +9592,9 @@ "dev": true }, "regenerate-unicode-properties": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/regenerate-unicode-properties/-/regenerate-unicode-properties-8.0.2.tgz", - "integrity": "sha512-SbA/iNrBUf6Pv2zU8Ekv1Qbhv92yxL4hiDa2siuxs4KKn4oOoMDHXjAf7+Nz9qinUQ46B1LcWEi/PhJfPWpZWQ==", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/regenerate-unicode-properties/-/regenerate-unicode-properties-8.1.0.tgz", + "integrity": "sha512-LGZzkgtLY79GeXLm8Dp0BVLdQlWICzBnJz/ipWUgo59qBaZ+BHtq51P2q1uVZlppMuUAT37SDk39qUbjTWB7bA==", "dev": true, "requires": { "regenerate": "^1.4.0" @@ -9704,9 +9607,9 @@ "dev": true }, "regenerator-transform": { - "version": "0.13.4", - "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.13.4.tgz", - "integrity": "sha512-T0QMBjK3J0MtxjPmdIMXm72Wvj2Abb0Bd4HADdfijwMdoIsyQZ6fWC7kDFhk2YinBBEMZDL7Y7wh0J1sGx3S4A==", + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.14.0.tgz", + "integrity": "sha512-rtOelq4Cawlbmq9xuMR5gdFmv7ku/sFoB7sRiywx7aq53bc52b4j6zvH7Te1Vt/X2YveDKnCGUbioieU7FEL3w==", "dev": true, "requires": { "private": "^0.1.6" @@ -9723,9 +9626,9 @@ } }, "regexp-tree": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/regexp-tree/-/regexp-tree-0.1.5.tgz", - "integrity": "sha512-nUmxvfJyAODw+0B13hj8CFVAxhe7fDEAgJgaotBu3nnR+IgGgZq59YedJP5VYTlkEfqjuK6TuRpnymKdatLZfQ==", + "version": "0.1.10", + "resolved": "https://registry.npmjs.org/regexp-tree/-/regexp-tree-0.1.10.tgz", + "integrity": "sha512-K1qVSbcedffwuIslMwpe6vGlj+ZXRnGkvjAtFHfDZZZuEdA/h0dxljAPu9vhUo6Rrx2U2AwJ+nSQ6hK+lrP5MQ==", "dev": true }, "regexpp": { @@ -9810,9 +9713,9 @@ } }, "repeat-element": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz", - "integrity": "sha1-7wiaF40Ug7quTZPrmLT55OEdmQo=", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.3.tgz", + "integrity": "sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g==", "dev": true }, "repeat-string": { @@ -9930,9 +9833,9 @@ "dev": true }, "resolve": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.10.0.tgz", - "integrity": "sha512-3sUr9aq5OfSg2S9pNtPA9hL1FVEAjvfOC4leW0SNf/mpnaakz2a9femSd6LqAww2RaFctwyf1lCqnTHuF1rxDg==", + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.11.1.tgz", + "integrity": "sha512-vIpgF6wfuJOZI7KKKSP+HmiKggadPQAdsp5HiC1mvqnfp0gF1vdwgBWZIdrVft9pgqoMFQN+R7BSWZiBxx+BBw==", "dev": true, "requires": { "path-parse": "^1.0.6" @@ -10180,9 +10083,9 @@ "dev": true }, "serialize-javascript": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-1.6.1.tgz", - "integrity": "sha512-A5MOagrPFga4YaKQSWHryl7AXvbQkEqpw4NNYMTNYUNV51bA8ABHgYFpqKx+YFFrw59xMV1qGH1R4AgoNIVgCw==", + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-1.7.0.tgz", + "integrity": "sha512-ke8UG8ulpFOxO8f8gRYabHQe/ZntKlcig2Mp+8+URDP1D8vJZ0KUt7LYo07q25Z/+JVSgpr/cui9PIp5H6/+nA==", "dev": true }, "serve-index-75lb": { @@ -10473,9 +10376,9 @@ } }, "source-map-support": { - "version": "0.5.11", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.11.tgz", - "integrity": "sha512-//sajEx/fGL3iw6fltKMdPvy8kL3kJ2O3iuYlRoT3k9Kb4BjOoZ+BZzaNHeuaruSt+Kf3Zk9tnfAQg9/AJqUVQ==", + "version": "0.5.12", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.12.tgz", + "integrity": "sha512-4h2Pbvyy15EE02G+JOZpUCmqWJuqrs+sEkzewTm++BPi7Hvn/HwcqLAcNxYAyI0x13CpPPn+kMjl+hplXMHITQ==", "dev": true, "requires": { "buffer-from": "^1.0.0", @@ -10892,9 +10795,9 @@ "dev": true }, "table": { - "version": "5.2.3", - "resolved": "https://registry.npmjs.org/table/-/table-5.2.3.tgz", - "integrity": "sha512-N2RsDAMvDLvYwFcwbPyF3VmVSSkuF+G1e+8inhBLtHpvwXGw4QRPEZhihQNeEN0i1up6/f6ObCJXNdlRG3YVyQ==", + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/table/-/table-5.4.0.tgz", + "integrity": "sha512-nHFDrxmbrkU7JAFKqKbDJXfzrX2UBsWmrieXFTGxiI5e4ncg3VqsZeI4EzNmX0ncp4XNGVeoxIWJXfCIXwrsvw==", "dev": true, "requires": { "ajv": "^6.9.1", @@ -10968,9 +10871,9 @@ "dev": true }, "terser": { - "version": "3.17.0", - "resolved": "https://registry.npmjs.org/terser/-/terser-3.17.0.tgz", - "integrity": "sha512-/FQzzPJmCpjAH9Xvk2paiWrFq+5M6aVOf+2KRbwhByISDX/EujxsK+BAvrhb6H+2rtrLCHK9N01wO014vrIwVQ==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/terser/-/terser-4.0.0.tgz", + "integrity": "sha512-dOapGTU0hETFl1tCo4t56FN+2jffoKyER9qBGoUFyZ6y7WLoKT0bF+lAYi6B6YsILcGF3q1C2FBh8QcKSCgkgA==", "dev": true, "requires": { "commander": "^2.19.0", @@ -10979,9 +10882,9 @@ }, "dependencies": { "commander": { - "version": "2.19.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz", - "integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==", + "version": "2.20.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", + "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==", "dev": true }, "source-map": { @@ -10993,21 +10896,55 @@ } }, "terser-webpack-plugin": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-1.2.3.tgz", - "integrity": "sha512-GOK7q85oAb/5kE12fMuLdn2btOS9OBZn4VsecpHDywoUC/jLhSAKOiYo0ezx7ss2EXPMzyEWFoE0s1WLE+4+oA==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-1.3.0.tgz", + "integrity": "sha512-W2YWmxPjjkUcOWa4pBEv4OP4er1aeQJlSo2UhtCFQCuRXEHjOFscO8VyWHj9JLlA0RzQb8Y2/Ta78XZvT54uGg==", "dev": true, "requires": { - "cacache": "^11.0.2", + "cacache": "^11.3.2", "find-cache-dir": "^2.0.0", + "is-wsl": "^1.1.0", + "loader-utils": "^1.2.3", "schema-utils": "^1.0.0", - "serialize-javascript": "^1.4.0", + "serialize-javascript": "^1.7.0", "source-map": "^0.6.1", - "terser": "^3.16.1", - "webpack-sources": "^1.1.0", - "worker-farm": "^1.5.2" + "terser": "^4.0.0", + "webpack-sources": "^1.3.0", + "worker-farm": "^1.7.0" }, "dependencies": { + "big.js": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", + "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==", + "dev": true + }, + "json5": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", + "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "dev": true, + "requires": { + "minimist": "^1.2.0" + } + }, + "loader-utils": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.2.3.tgz", + "integrity": "sha512-fkpz8ejdnEMG3s37wGL07iSBDg99O9D5yflE9RGNH3hRdx9SOwYfnGYdZOUIZitN8E+E2vkq3MUMYMvPYl5ZZA==", + "dev": true, + "requires": { + "big.js": "^5.2.2", + "emojis-list": "^2.0.0", + "json5": "^1.0.1" + } + }, + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true + }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -11017,15 +10954,15 @@ } }, "test-exclude": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-5.1.0.tgz", - "integrity": "sha512-gwf0S2fFsANC55fSeSqpb8BYk6w3FDvwZxfNjeF6FRgvFa43r+7wRiA/Q0IxoRU37wB/LE8IQ4221BsNucTaCA==", + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-5.2.3.tgz", + "integrity": "sha512-M+oxtseCFO3EDtAaGH7iiej3CBkzXqFMbzqYAACdzKui4eZA+pq3tZEwChvOdNfa7xxy8BfbmgJSIr43cC/+2g==", "dev": true, "requires": { - "arrify": "^1.0.1", + "glob": "^7.1.3", "minimatch": "^3.0.4", "read-pkg-up": "^4.0.0", - "require-main-filename": "^1.0.1" + "require-main-filename": "^2.0.0" }, "dependencies": { "find-up": { @@ -11037,6 +10974,20 @@ "locate-path": "^3.0.0" } }, + "glob": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, "load-json-file": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", @@ -11078,9 +11029,9 @@ } }, "p-try": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.1.0.tgz", - "integrity": "sha512-H2RyIJ7+A3rjkwKC2l5GGtU4H1vkxKCAGsWasNVd0Set+6i4znxbWy6/j16YDPJDWxhsgZiKAstMEP8wCdSpjA==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "dev": true }, "parse-json": { @@ -11122,6 +11073,12 @@ "find-up": "^3.0.0", "read-pkg": "^3.0.0" } + }, + "require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", + "dev": true } } }, @@ -11309,9 +11266,9 @@ "dev": true }, "ts-jest": { - "version": "24.0.0", - "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-24.0.0.tgz", - "integrity": "sha512-o8BO3TkMREpAATaFTrXkovMsCpBl2z4NDBoLJuWZcJJj1ijI49UnvDMfVpj+iogn/Jl8Pbhuei5nc/Ti+frEHw==", + "version": "24.0.2", + "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-24.0.2.tgz", + "integrity": "sha512-h6ZCZiA1EQgjczxq+uGLXQlNgeg02WWJBbeT8j6nyIBRQdglqbvzDoHahTEIiS6Eor6x8mK6PfZ7brQ9Q6tzHw==", "dev": true, "requires": { "bs-logger": "0.x", @@ -11436,9 +11393,9 @@ "dev": true }, "typescript": { - "version": "3.3.4000", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.3.4000.tgz", - "integrity": "sha512-jjOcCZvpkl2+z7JFn0yBOoLQyLoIkNZAs/fYJkUG6VKy6zLPHJGfQJYFHzibB6GJaF/8QrcECtlQ5cpvRHSMEA==", + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.1.tgz", + "integrity": "sha512-64HkdiRv1yYZsSe4xC1WVgamNigVYjlssIoaH2HcZF0+ijsk5YK2g0G34w9wJkze8+5ow4STd22AynfO6ZYYLw==", "dev": true }, "typical": { @@ -11448,9 +11405,9 @@ "dev": true }, "uglify-js": { - "version": "3.5.15", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.5.15.tgz", - "integrity": "sha512-fe7aYFotptIddkwcm6YuA0HmknBZ52ZzOsUxZEdhhkSsz7RfjHDX2QDxwKTiv4JQ5t5NhfmpgAK+J7LiDhKSqg==", + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.0.tgz", + "integrity": "sha512-W+jrUHJr3DXKhrsS7NUVxn3zqMOFn0hL/Ei6v0anCIMoKC93TjcflTagwIHLW7SfMFfiQuktQyFVCFHGUE0+yg==", "dev": true, "optional": true, "requires": { @@ -11614,9 +11571,9 @@ } }, "upath": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/upath/-/upath-1.1.0.tgz", - "integrity": "sha512-bzpH/oBhoS/QI/YtbkqCg6VEiPYjSZtrHQM6/QnJS6OL9pKUFLqb3aFh4Scvwm45+7iAgiMkLhSbaZxUqmrprw==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/upath/-/upath-1.1.2.tgz", + "integrity": "sha512-kXpym8nmDmlCBr7nKdIx8P2jNBa+pBpIUFRnKJ4dr8htyYGJFokkr2ZvERRtUN+9SY+JqXouNgUPtv6JQva/2Q==", "dev": true }, "upng-js": { @@ -11718,9 +11675,9 @@ "dev": true }, "v8-compile-cache": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.0.2.tgz", - "integrity": "sha512-1wFuMUIM16MDJRCrpbpuEPTUGmM5QMUg0cr3KFwra2XgOgFcPGDQHDh3CszSCD2Zewc/dh/pamNEW8CbfDebUw==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.0.3.tgz", + "integrity": "sha512-CNmdbwQMBjwr9Gsmohvm0pbL954tJrNzf6gWL3K+QMQf00PF7ERGrEiLgjuU3mKreLC2MeGhUsNV9ybTbLgd3w==", "dev": true }, "validate-npm-package-license": { @@ -11806,9 +11763,9 @@ "dev": true }, "webpack": { - "version": "4.29.6", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.29.6.tgz", - "integrity": "sha512-MwBwpiE1BQpMDkbnUUaW6K8RFZjljJHArC6tWQJoFm0oQtfoSebtg4Y7/QHnJ/SddtjYLHaKGX64CFjG5rehJw==", + "version": "4.33.0", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.33.0.tgz", + "integrity": "sha512-ggWMb0B2QUuYso6FPZKUohOgfm+Z0sVFs8WwWuSH1IAvkWs428VDNmOlAxvHGTB9Dm/qOB/qtE5cRx5y01clxw==", "dev": true, "requires": { "@webassemblyjs/ast": "1.8.5", @@ -11859,17 +11816,17 @@ } }, "tapable": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/tapable/-/tapable-1.1.1.tgz", - "integrity": "sha512-9I2ydhj8Z9veORCw5PRm4u9uebCn0mcCa6scWoNcbZ6dAtoo2618u9UUzxgmsCOreJpqDDuv61LvwofW7hLcBA==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-1.1.3.tgz", + "integrity": "sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA==", "dev": true } } }, "webpack-cli": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-3.3.0.tgz", - "integrity": "sha512-t1M7G4z5FhHKJ92WRKwZ1rtvi7rHc0NZoZRbSkol0YKl4HvcC8+DsmGDmK7MmZxHSAetHagiOsjOB6MmzC2TUw==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-3.3.2.tgz", + "integrity": "sha512-FLkobnaJJ+03j5eplxlI0TUxhGCOdfewspIGuvDVtpOlrAuKMFC57K42Ukxqs1tn8947/PM6tP95gQc0DCzRYA==", "dev": true, "requires": { "chalk": "^2.4.1", @@ -11916,9 +11873,9 @@ } }, "tapable": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/tapable/-/tapable-1.1.1.tgz", - "integrity": "sha512-9I2ydhj8Z9veORCw5PRm4u9uebCn0mcCa6scWoNcbZ6dAtoo2618u9UUzxgmsCOreJpqDDuv61LvwofW7hLcBA==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-1.1.3.tgz", + "integrity": "sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA==", "dev": true } } @@ -12052,9 +12009,9 @@ } }, "worker-farm": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/worker-farm/-/worker-farm-1.6.0.tgz", - "integrity": "sha512-6w+3tHbM87WnSWnENBUvA2pxJPLhQUg5LKwUQHq3r+XPhIM+Gh2R5ycbwPCyuGbNg+lPgdcnQUhuC02kJCvffQ==", + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/worker-farm/-/worker-farm-1.7.0.tgz", + "integrity": "sha512-rvw3QTZc8lAxyVrqcSGVm5yP/IJ2UcB3U0graE3LCFoZ0Yn2x4EoVSqJKdB/T5M+FLcRPjz4TDacRf3OCfNUzw==", "dev": true, "requires": { "errno": "~0.1.7" @@ -12223,9 +12180,9 @@ } }, "p-try": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.1.0.tgz", - "integrity": "sha512-H2RyIJ7+A3rjkwKC2l5GGtU4H1vkxKCAGsWasNVd0Set+6i4znxbWy6/j16YDPJDWxhsgZiKAstMEP8wCdSpjA==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "dev": true } } diff --git a/package.json b/package.json index 1b095817f..91ef63c93 100644 --- a/package.json +++ b/package.json @@ -40,44 +40,44 @@ "author": "Tim Conkling", "license": "ISC", "devDependencies": { - "@babel/cli": "^7.2.3", - "@babel/core": "^7.4.0", - "@babel/plugin-proposal-class-properties": "^7.4.0", - "@babel/plugin-proposal-object-rest-spread": "^7.4.0", + "@babel/cli": "^7.4.4", + "@babel/core": "^7.4.5", + "@babel/plugin-proposal-class-properties": "^7.4.4", + "@babel/plugin-proposal-object-rest-spread": "^7.4.4", "@babel/plugin-syntax-dynamic-import": "^7.2.0", - "@babel/preset-env": "^7.4.1", + "@babel/preset-env": "^7.4.5", "@babel/preset-typescript": "^7.3.3", "@types/base64-js": "^1.2.5", - "@types/jest": "^23.3.12", - "@types/loglevel": "^1.5.3", - "@types/node": "^10.12.18", + "@types/jest": "^24.0.13", + "@types/loglevel": "^1.5.4", + "@types/node": "^12.0.4", "@types/pixi.js": "^4.8.6", "@types/storejs": "^2.0.3", "@types/webfontloader": "^1.6.29", "@typescript-eslint/eslint-plugin": "^1.9.0", "@typescript-eslint/parser": "^1.9.0", - "babel-loader": "^8.0.5", + "babel-loader": "^8.0.6", "babel-polyfill": "^6.26.0", "babel-preset-minify": "^0.5.0", "coffeescript": "^1.12.7", "concurrently": "^4.1.0", "css-loader": "^2.1.1", "dotenv-webpack": "^1.7.0", - "eslint": "^5.15.3", + "eslint": "^5.16.0", "eslint-config-airbnb-base": "^13.1.0", - "eslint-import-resolver-webpack": "^0.11.0", - "eslint-plugin-import": "^2.16.0", - "file-loader": "^3.0.1", + "eslint-import-resolver-webpack": "^0.11.1", + "eslint-plugin-import": "^2.17.3", + "file-loader": "^4.0.0", "hard-source-webpack-plugin": "0.13.1", "html-webpack-plugin": "^3.2.0", - "jest": "^24.5.0", + "jest": "^24.8.0", "local-web-server": "^2.6.1", "source-map-loader": "^0.2.4", "style-loader": "^0.23.1", - "ts-jest": "^24.0.0", - "typescript": "^3.3.4000", - "webpack": "^4.29.6", - "webpack-cli": "^3.3.0", + "ts-jest": "^24.0.2", + "typescript": "^3.5.1", + "webpack": "^4.33.0", + "webpack-cli": "^3.3.2", "webpack-manifest-plugin": "^2.0.4", "webpack-merge": "^4.2.1" }, @@ -85,7 +85,7 @@ "base64-js": "^1.3.0", "js-polyfills": "^0.1.42", "localforage": "^1.7.3", - "loglevel": "^1.6.1", + "loglevel": "^1.6.2", "pixi-filters": "^2.7.1", "pixi-multistyle-text": "^0.7.0", "pixi-sound": "^2.1.0", From 10c524c721cbde1d6461d52a6cce43ff066a2e81 Mon Sep 17 00:00:00 2001 From: LFP6 Date: Wed, 5 Jun 2019 12:04:11 -0400 Subject: [PATCH 02/39] Default exports, index files, and general import cleanup --- src/eterna/ChatManager.ts | 4 +- src/eterna/Constants.ts | 2 +- src/eterna/EPars.ts | 6 +- src/eterna/Eterna.ts | 20 ++--- src/eterna/EternaApp.ts | 48 ++++------ src/eterna/ExpPainter.ts | 7 +- src/eterna/Feedback.ts | 2 +- src/eterna/IntLoopPars.ts | 2 +- src/eterna/Plot.ts | 6 +- src/eterna/UndoBlock.ts | 12 +-- src/eterna/achievements/AchievementBox.ts | 23 ++--- src/eterna/achievements/AchievementManager.ts | 16 ++-- src/eterna/achievements/index.ts | 2 + src/eterna/debug/TestMode.ts | 11 +-- src/eterna/debug/index.ts | 1 + src/eterna/emscripten/EmscriptenUtil.ts | 2 +- src/eterna/emscripten/index.ts | 1 + src/eterna/folding/FoldUtil.ts | 2 +- src/eterna/folding/Folder.ts | 4 +- src/eterna/folding/FolderManager.ts | 9 +- src/eterna/folding/LinearFoldBase.ts | 9 +- src/eterna/folding/LinearFoldC.ts | 6 +- src/eterna/folding/LinearFoldV.ts | 6 +- src/eterna/folding/NuPACK.ts | 13 ++- src/eterna/folding/RNAFoldBasic.ts | 6 +- src/eterna/folding/Vienna.ts | 13 ++- src/eterna/folding/Vienna2.ts | 13 ++- src/eterna/folding/index.ts | 10 +++ src/eterna/index.ts | 2 +- src/eterna/mode/CopyTextDialogMode.ts | 9 +- .../CustomizeColumnOrderDialog.ts | 26 +++--- src/eterna/mode/DesignBrowser/DataCol.ts | 32 +++---- .../mode/DesignBrowser/DesignBrowserMode.ts | 61 ++++--------- src/eterna/mode/DesignBrowser/DotLine.ts | 2 +- src/eterna/mode/DesignBrowser/GridLines.ts | 2 +- src/eterna/mode/DesignBrowser/LabComments.ts | 6 +- .../mode/DesignBrowser/MarkerBoxView.ts | 4 +- src/eterna/mode/DesignBrowser/SelectionBox.ts | 2 +- .../DesignBrowser/SequenceStringListView.ts | 21 ++--- .../mode/DesignBrowser/SolutionDescBox.ts | 38 +++----- src/eterna/mode/DesignBrowser/SortOptions.ts | 10 +-- .../mode/DesignBrowser/SortOptionsDialog.ts | 29 +++---- .../mode/DesignBrowser/ViewSolutionDialog.ts | 38 ++++---- .../mode/DesignBrowser/VoteProcessor.ts | 8 +- src/eterna/mode/DesignBrowser/index.ts | 16 ++++ src/eterna/mode/ErrorDialogMode.ts | 15 ++-- .../mode/FeedbackView/FeedbackViewMode.ts | 44 ++++------ .../mode/FeedbackView/FeedbackViewToolbar.ts | 24 +++-- src/eterna/mode/FeedbackView/index.ts | 2 + src/eterna/mode/GameMode.ts | 35 +++----- src/eterna/mode/LoadingMode.ts | 21 ++--- src/eterna/mode/PoseEdit/Booster.ts | 18 ++-- .../mode/PoseEdit/MissionClearedPanel.ts | 30 +++---- src/eterna/mode/PoseEdit/MissionIntroMode.ts | 33 +++---- src/eterna/mode/PoseEdit/PoseEditMode.ts | 87 ++++++------------- src/eterna/mode/PoseEdit/PoseEditToolbar.ts | 40 ++++----- src/eterna/mode/PoseEdit/SubmitPoseDetails.ts | 2 +- src/eterna/mode/PoseEdit/SubmitPoseDialog.ts | 11 ++- src/eterna/mode/PoseEdit/SubmittingDialog.ts | 14 ++- src/eterna/mode/PoseEdit/index.ts | 8 ++ src/eterna/mode/PuzzleEdit/PuzzleEditMode.ts | 59 +++++-------- .../mode/PuzzleEdit/PuzzleEditToolbar.ts | 23 +++-- src/eterna/mode/PuzzleEdit/StructureInput.ts | 23 +++-- .../mode/PuzzleEdit/SubmitPuzzleDialog.ts | 15 ++-- src/eterna/mode/PuzzleEdit/index.ts | 4 + src/eterna/mode/index.ts | 8 ++ src/eterna/net/EternaURL.ts | 6 +- src/eterna/net/GameClient.ts | 4 +- src/eterna/net/index.ts | 2 + src/eterna/pose2D/Base.ts | 18 ++-- src/eterna/pose2D/BaseAssets.ts | 19 ++-- src/eterna/pose2D/BaseDrawFlags.ts | 2 +- src/eterna/pose2D/BaseTextures.ts | 14 ++- src/eterna/pose2D/EnergyScoreDisplay.ts | 8 +- src/eterna/pose2D/ExplosionFactorPanel.ts | 14 ++- src/eterna/pose2D/HighlightBox.ts | 14 ++- src/eterna/pose2D/Molecule.ts | 8 +- src/eterna/pose2D/PaintCursor.ts | 8 +- src/eterna/pose2D/Pose2D.ts | 74 ++++++---------- src/eterna/pose2D/PoseField.ts | 23 ++--- src/eterna/pose2D/PoseOp.ts | 2 +- src/eterna/pose2D/PoseUtil.ts | 6 +- src/eterna/pose2D/PuzzleEditOp.ts | 4 +- src/eterna/pose2D/RNAAnchorObject.ts | 6 +- src/eterna/pose2D/RNALayout.ts | 6 +- src/eterna/pose2D/ScoreDisplayNode.ts | 5 +- src/eterna/pose2D/index.ts | 17 ++++ src/eterna/puzzle/Constraints.ts | 2 +- src/eterna/puzzle/Puzzle.ts | 16 ++-- src/eterna/puzzle/PuzzleManager.ts | 14 ++- src/eterna/puzzle/Solution.ts | 6 +- src/eterna/puzzle/SolutionManager.ts | 12 +-- src/eterna/puzzle/index.ts | 5 ++ src/eterna/rank/PlayerRank.ts | 2 +- src/eterna/rank/RankBoard.ts | 9 +- src/eterna/rank/RankRowLayout.ts | 10 +-- src/eterna/rank/RankScroll.ts | 30 +++---- src/eterna/rank/index.ts | 4 + src/eterna/resources/BitmapManager.ts | 10 +-- src/eterna/resources/Bitmaps.ts | 2 +- src/eterna/resources/PlaySoundTask.ts | 6 +- src/eterna/resources/SoundManager.ts | 8 +- src/eterna/resources/Sounds.ts | 2 +- src/eterna/resources/index.ts | 5 ++ src/eterna/rscript/NovaPaintHint.ts | 16 ++-- src/eterna/rscript/RNAScript.ts | 22 ++--- src/eterna/rscript/ROPHighlight.ts | 22 ++--- src/eterna/rscript/ROPHint.ts | 6 +- src/eterna/rscript/ROPPre.ts | 7 +- src/eterna/rscript/ROPRNA.ts | 10 +-- src/eterna/rscript/ROPTextbox.ts | 22 ++--- src/eterna/rscript/ROPUI.ts | 5 +- src/eterna/rscript/ROPWait.ts | 7 +- src/eterna/rscript/RScriptArrow.ts | 8 +- src/eterna/rscript/RScriptEnv.ts | 21 ++--- src/eterna/rscript/RScriptOp.ts | 4 +- src/eterna/rscript/RScriptOpTree.ts | 5 +- src/eterna/rscript/RScriptUIElement.ts | 4 +- src/eterna/rscript/index.ts | 14 +++ src/eterna/settings/EternaSettings.ts | 9 +- src/eterna/settings/index.ts | 1 + src/eterna/ui/ActionBar.ts | 7 +- src/eterna/ui/AsyncProcessDialog.ts | 14 ++- src/eterna/ui/Band.ts | 19 ++-- src/eterna/ui/BaseGamePanel.ts | 4 +- src/eterna/ui/ConfirmDialog.ts | 17 ++-- src/eterna/ui/ConstraintBox.ts | 40 +++------ src/eterna/ui/ContextMenu.ts | 15 ++-- src/eterna/ui/Dialog.ts | 13 ++- src/eterna/ui/EternaMenu.ts | 11 ++- src/eterna/ui/EternaViewOptionsDialog.ts | 20 ++--- src/eterna/ui/FancyGamePanel.ts | 6 +- src/eterna/ui/FancyTextBalloon.ts | 19 ++-- src/eterna/ui/FixedWidthTextField.ts | 8 +- src/eterna/ui/GameButton.ts | 29 +++---- src/eterna/ui/GameCheckbox.ts | 11 ++- src/eterna/ui/GamePanel.ts | 10 +-- src/eterna/ui/HTMLTextObject.ts | 6 +- src/eterna/ui/NotificationDialog.ts | 10 +-- src/eterna/ui/NucleotidePalette.ts | 32 +++---- src/eterna/ui/PasteSequenceDialog.ts | 11 ++- src/eterna/ui/PoseThumbnail.ts | 19 ++-- src/eterna/ui/ScrollContainer.ts | 4 +- src/eterna/ui/SliderBar.ts | 15 ++-- src/eterna/ui/SpecBox.ts | 40 ++++----- src/eterna/ui/SpecBoxDialog.ts | 15 ++-- src/eterna/ui/TextBalloon.ts | 15 ++-- src/eterna/ui/TextInputObject.ts | 15 ++-- src/eterna/ui/TextInputPanel.ts | 14 ++- src/eterna/ui/ToggleBar.ts | 24 +++-- src/eterna/ui/Tooltips.ts | 24 ++--- src/eterna/ui/UILockDialog.ts | 6 +- src/eterna/ui/URLButton.ts | 4 +- src/eterna/ui/VScrollBox.ts | 9 +- src/eterna/ui/index.ts | 35 ++++++++ src/eterna/util/CSVParser.ts | 2 +- src/eterna/util/EternaTextureUtil.ts | 6 +- src/eterna/util/ExternalInterface.ts | 8 +- src/eterna/util/Fonts.ts | 6 +- src/eterna/util/GraphicsUtil.ts | 4 +- src/eterna/util/Utility.ts | 2 +- src/eterna/util/index.ts | 7 ++ src/eterna/util/int.ts | 2 +- src/eterna/vfx/Background.ts | 8 +- src/eterna/vfx/BaseGlow.ts | 7 +- src/eterna/vfx/Bubble.ts | 18 ++-- src/eterna/vfx/BubbleSweep.ts | 6 +- src/eterna/vfx/LightRay.ts | 13 ++- src/eterna/vfx/VibrateTask.ts | 6 +- src/eterna/vfx/index.ts | 6 ++ src/flashbang/core/AppMode.ts | 21 ++--- src/flashbang/core/Flashbang.ts | 7 +- src/flashbang/core/FlashbangApp.ts | 13 +-- src/flashbang/core/GameObject.ts | 8 +- src/flashbang/core/GameObjectBase.ts | 12 +-- src/flashbang/core/GameObjectRef.ts | 5 +- src/flashbang/core/LateUpdatable.ts | 2 +- src/flashbang/core/ModeStack.ts | 9 +- src/flashbang/core/ObjectTask.ts | 4 +- src/flashbang/core/Updatable.ts | 2 +- src/flashbang/core/index.ts | 11 +++ src/flashbang/geom/Vector2.ts | 2 +- src/flashbang/geom/index.ts | 1 + .../input/DisplayObjectPointerTarget.ts | 8 +- src/flashbang/input/InputUtil.ts | 5 +- src/flashbang/input/KeyCode.ts | 4 +- src/flashbang/input/KeyboardEventType.ts | 4 +- src/flashbang/input/KeyboardInput.ts | 6 +- src/flashbang/input/MouseWheelInput.ts | 6 +- src/flashbang/input/PointerCapture.ts | 4 +- src/flashbang/input/PointerTarget.ts | 4 +- src/flashbang/input/index.ts | 8 ++ src/flashbang/layout/HLayoutContainer.ts | 8 +- src/flashbang/layout/LayoutContainer.ts | 2 +- src/flashbang/layout/VLayoutContainer.ts | 8 +- src/flashbang/layout/index.ts | 3 + src/flashbang/objects/Button.ts | 26 +++--- src/flashbang/objects/ContainerObject.ts | 4 +- src/flashbang/objects/DOMObject.ts | 7 +- src/flashbang/objects/Enableable.ts | 2 +- src/flashbang/objects/ImageButton.ts | 4 +- src/flashbang/objects/SceneObject.ts | 9 +- src/flashbang/objects/SimpleTextButton.ts | 6 +- src/flashbang/objects/SpriteObject.ts | 4 +- src/flashbang/objects/ToggleButton.ts | 6 +- src/flashbang/objects/index.ts | 9 ++ src/flashbang/resources/FontLoader.ts | 2 +- src/flashbang/resources/index.ts | 1 + src/flashbang/settings/SaveGameManager.ts | 2 +- src/flashbang/settings/Setting.ts | 6 +- src/flashbang/settings/Settings.ts | 4 +- src/flashbang/settings/index.ts | 3 + src/flashbang/tasks/AlphaTask.ts | 6 +- src/flashbang/tasks/CallbackTask.ts | 4 +- src/flashbang/tasks/DelayTask.ts | 5 +- src/flashbang/tasks/DisplayObjectTask.ts | 7 +- src/flashbang/tasks/FrameDelayTask.ts | 5 +- src/flashbang/tasks/FunctionTask.ts | 5 +- src/flashbang/tasks/InterpolatingTask.ts | 7 +- src/flashbang/tasks/LocationTask.ts | 6 +- src/flashbang/tasks/ParallelTask.ts | 6 +- src/flashbang/tasks/RepeatingTask.ts | 4 +- src/flashbang/tasks/RotationTask.ts | 6 +- src/flashbang/tasks/ScaleTask.ts | 6 +- src/flashbang/tasks/SelfDestructTask.ts | 4 +- src/flashbang/tasks/SerialTask.ts | 6 +- src/flashbang/tasks/VisibleTask.ts | 6 +- src/flashbang/tasks/index.ts | 15 ++++ src/flashbang/util/Arrays.ts | 2 +- src/flashbang/util/Assert.ts | 2 +- src/flashbang/util/Base64.ts | 4 +- src/flashbang/util/ColorUtil.ts | 5 +- src/flashbang/util/Deferred.ts | 2 +- src/flashbang/util/DisplayUtil.ts | 11 +-- src/flashbang/util/Dragger.ts | 9 +- src/flashbang/util/Easing.ts | 4 +- src/flashbang/util/ErrorUtil.ts | 2 +- src/flashbang/util/EventSignal.ts | 7 +- src/flashbang/util/JSONUtil.ts | 2 +- src/flashbang/util/LinkedList.ts | 4 +- src/flashbang/util/MathUtil.ts | 2 +- src/flashbang/util/MatrixUtil.ts | 2 +- src/flashbang/util/PowerEaser.ts | 2 +- src/flashbang/util/RectangleUtil.ts | 4 +- src/flashbang/util/StringUtil.ts | 2 +- src/flashbang/util/StyledTextBuilder.ts | 4 +- src/flashbang/util/TextBuilder.ts | 2 +- src/flashbang/util/TextUtil.ts | 2 +- src/flashbang/util/TextureUtil.ts | 10 +-- src/flashbang/util/index.ts | 21 +++++ src/signals/AbstractSignal.ts | 9 +- src/signals/AbstractValue.ts | 11 +-- src/signals/Connection.ts | 5 +- src/signals/Cons.ts | 8 +- src/signals/FilteredSignal.ts | 9 +- src/signals/MappedSignal.ts | 11 +-- src/signals/MappedValue.ts | 9 +- src/signals/MultiFailureError.ts | 2 +- src/signals/Reactor.ts | 5 +- src/signals/Registration.ts | 2 +- src/signals/RegistrationGroup.ts | 7 +- src/signals/Registrations.ts | 5 +- src/signals/Signal.ts | 11 +-- src/signals/SignalView.ts | 5 +- src/signals/UnitSignal.ts | 11 +-- src/signals/Value.ts | 9 +- src/signals/ValueView.ts | 5 +- src/signals/index.ts | 17 ++++ tsconfig.json | 3 +- webpack.common.js | 3 + 270 files changed, 1363 insertions(+), 1555 deletions(-) create mode 100644 src/eterna/achievements/index.ts create mode 100644 src/eterna/debug/index.ts create mode 100644 src/eterna/emscripten/index.ts create mode 100644 src/eterna/folding/index.ts create mode 100644 src/eterna/mode/DesignBrowser/index.ts create mode 100644 src/eterna/mode/FeedbackView/index.ts create mode 100644 src/eterna/mode/PoseEdit/index.ts create mode 100644 src/eterna/mode/PuzzleEdit/index.ts create mode 100644 src/eterna/mode/index.ts create mode 100644 src/eterna/net/index.ts create mode 100644 src/eterna/pose2D/index.ts create mode 100644 src/eterna/puzzle/index.ts create mode 100644 src/eterna/rank/index.ts create mode 100644 src/eterna/resources/index.ts create mode 100644 src/eterna/rscript/index.ts create mode 100644 src/eterna/settings/index.ts create mode 100644 src/eterna/ui/index.ts create mode 100644 src/eterna/util/index.ts create mode 100644 src/eterna/vfx/index.ts create mode 100644 src/flashbang/core/index.ts create mode 100644 src/flashbang/geom/index.ts create mode 100644 src/flashbang/input/index.ts create mode 100644 src/flashbang/layout/index.ts create mode 100644 src/flashbang/objects/index.ts create mode 100644 src/flashbang/resources/index.ts create mode 100644 src/flashbang/settings/index.ts create mode 100644 src/flashbang/tasks/index.ts create mode 100644 src/flashbang/util/index.ts create mode 100644 src/signals/index.ts diff --git a/src/eterna/ChatManager.ts b/src/eterna/ChatManager.ts index 813dc28c4..09e5467b1 100644 --- a/src/eterna/ChatManager.ts +++ b/src/eterna/ChatManager.ts @@ -1,7 +1,7 @@ -import {EternaSettings} from "./settings/EternaSettings"; +import {EternaSettings} from "eterna/settings"; import * as log from "loglevel"; -export class ChatManager { +export default class ChatManager { public constructor(chatboxID: string, settings: EternaSettings) { this._chatbox = document.getElementById(chatboxID); if (this._chatbox == null) { diff --git a/src/eterna/Constants.ts b/src/eterna/Constants.ts index b1a2438e7..017a6dd00 100644 --- a/src/eterna/Constants.ts +++ b/src/eterna/Constants.ts @@ -1,4 +1,4 @@ -export class Constants { +export default class Constants { public static EPSILON: number = 0.00001; public static BOLTZMANN: number = 0.0019872041; // kcal/mol/K diff --git a/src/eterna/EPars.ts b/src/eterna/EPars.ts index c32f5a20a..285d77314 100644 --- a/src/eterna/EPars.ts +++ b/src/eterna/EPars.ts @@ -1,7 +1,7 @@ -import {StyledTextBuilder} from "../flashbang/util/StyledTextBuilder"; -import {IntLoopPars} from "./IntLoopPars"; +import {StyledTextBuilder} from "flashbang/util"; +import IntLoopPars from "eterna/IntLoopPars"; -export class EPars { +export default class EPars { public static readonly INF: number = 1000000; public static readonly NST: number = 0; public static readonly MAXLOOP: number = 30; diff --git a/src/eterna/Eterna.ts b/src/eterna/Eterna.ts index 040dd07d7..5401ee8fd 100644 --- a/src/eterna/Eterna.ts +++ b/src/eterna/Eterna.ts @@ -1,16 +1,16 @@ import * as log from "loglevel"; -import {Flashbang} from "../flashbang/core/Flashbang"; -import {ErrorUtil} from "../flashbang/util/ErrorUtil"; -import {ChatManager} from "./ChatManager"; -import {EternaApp} from "./EternaApp"; -import {ErrorDialogMode} from "./mode/ErrorDialogMode"; -import {GameClient} from "./net/GameClient"; -import {EternaSettings} from "./settings/EternaSettings"; -import {SoundManager} from "./resources/SoundManager"; -import {SaveGameManager} from "../flashbang/settings/SaveGameManager"; +import {Flashbang} from "flashbang/core"; +import {SaveGameManager} from "../flashbang/settings"; +import {ErrorUtil} from "flashbang/util"; +import ChatManager from "eterna/ChatManager"; +import EternaApp from "eterna/EternaApp"; +import {ErrorDialogMode} from "eterna/mode"; +import {GameClient} from "eterna/net"; +import {EternaSettings} from "eterna/settings"; +import {SoundManager} from "eterna/resources"; /** Constants and global managers */ -export class Eterna { +export default class Eterna { public static readonly OVERLAY_DIV_ID = "overlay"; public static readonly PIXI_CONTAINER_ID = "pixi-container"; public static readonly MAX_PUZZLE_EDIT_LENGTH = 400; // max length of PuzzleEditMode input diff --git a/src/eterna/EternaApp.ts b/src/eterna/EternaApp.ts index 6f018d39f..3094e7a4f 100644 --- a/src/eterna/EternaApp.ts +++ b/src/eterna/EternaApp.ts @@ -1,35 +1,21 @@ import "assets/styles.css"; // css-loader will pick up on this and embed our stylesheet import * as log from "loglevel"; -import {FlashbangApp} from "../flashbang/core/FlashbangApp"; -import {ErrorUtil} from "../flashbang/util/ErrorUtil"; -import {TextureUtil} from "../flashbang/util/TextureUtil"; -import {ChatManager} from "./ChatManager"; -import {TestMode} from "./debug/TestMode"; -import {Eterna} from "./Eterna"; -import {Folder} from "./folding/Folder"; -import {FolderManager} from "./folding/FolderManager"; -import {LinearFoldC} from "./folding/LinearFoldC"; -import {LinearFoldV} from "./folding/LinearFoldV"; -import {NuPACK} from "./folding/NuPACK"; -import {RNAFoldBasic} from "./folding/RNAFoldBasic"; -import {Vienna} from "./folding/Vienna"; -import {Vienna2} from "./folding/Vienna2"; -import {DesignBrowserFilter, DesignBrowserMode} from "./mode/DesignBrowser/DesignBrowserMode"; -import {FeedbackViewMode} from "./mode/FeedbackView/FeedbackViewMode"; -import {LoadingMode} from "./mode/LoadingMode"; -import {PoseEditMode, PoseEditParams} from "./mode/PoseEdit/PoseEditMode"; -import {PuzzleEditMode, PuzzleEditPoseData} from "./mode/PuzzleEdit/PuzzleEditMode"; -import {GameClient} from "./net/GameClient"; -import {Puzzle} from "./puzzle/Puzzle"; -import {PuzzleManager} from "./puzzle/PuzzleManager"; -import {Solution} from "./puzzle/Solution"; -import {SolutionManager} from "./puzzle/SolutionManager"; -import {Bitmaps} from "./resources/Bitmaps"; -import {SoundManager} from "./resources/SoundManager"; -import {EternaSettings} from "./settings/EternaSettings"; -import {ExternalInterface, ExternalInterfaceCtx} from "./util/ExternalInterface"; -import {Fonts} from "./util/Fonts"; -import {SaveGameManager} from "../flashbang/settings/SaveGameManager"; +import {FlashbangApp} from "flashbang/core"; +import {SaveGameManager} from "flashbang/settings"; +import {ErrorUtil, TextureUtil} from "flashbang/util"; +import ChatManager from "eterna/ChatManager"; +import {TestMode} from "eterna/debug"; +import Eterna from "eterna/Eterna"; +import {Folder, FolderManager, LinearFoldC, LinearFoldV, NuPACK, RNAFoldBasic, Vienna, Vienna2} from "eterna/folding"; +import { + LoadingMode, FeedbackViewMode, DesignBrowserFilter, DesignBrowserMode, + PoseEditMode, PoseEditParams, PuzzleEditMode, PuzzleEditPoseData +} from "eterna/mode"; +import {GameClient} from "eterna/net"; +import {Puzzle, PuzzleManager, Solution, SolutionManager} from "eterna/puzzle"; +import {Bitmaps, SoundManager} from "eterna/resources"; +import {EternaSettings} from "eterna/settings"; +import {ExternalInterface, ExternalInterfaceCtx, Fonts} from "eterna/util"; enum PuzzleID { FunAndEasy = 4350940, @@ -89,7 +75,7 @@ export interface EternaAppParams { } /** Entry point for the game */ -export class EternaApp extends FlashbangApp { +export default class EternaApp extends FlashbangApp { public constructor(params: EternaAppParams) { super(); diff --git a/src/eterna/ExpPainter.ts b/src/eterna/ExpPainter.ts index 1a48b786b..9fe68b814 100644 --- a/src/eterna/ExpPainter.ts +++ b/src/eterna/ExpPainter.ts @@ -1,8 +1,7 @@ -import {Constants} from "./Constants"; -import {ColorUtil} from "../flashbang/util/ColorUtil"; -import {MathUtil} from "../flashbang/util/MathUtil"; +import Constants from "eterna/Constants"; +import {ColorUtil, MathUtil} from "flashbang/util"; -export class ExpPainter { +export default class ExpPainter { public static readonly NUM_COLORS = 5; public static transformData(data: number[], data_max: number, data_min: number): number[] { diff --git a/src/eterna/Feedback.ts b/src/eterna/Feedback.ts index e2368c5f8..ebd750048 100644 --- a/src/eterna/Feedback.ts +++ b/src/eterna/Feedback.ts @@ -1,4 +1,4 @@ -export class Feedback { +export default class Feedback { public static readonly EXPCODES: number[] = [1, -100, -200]; public static readonly EXPSTRINGS: string[] = ["NOT SYNTHESIZED", "FAILED", "NOT INTERPRETABLE"]; public static readonly EXPDISPLAYS: string[] = ["-", "Failed", "Unreadable"]; diff --git a/src/eterna/IntLoopPars.ts b/src/eterna/IntLoopPars.ts index 9c947fef8..8b4a9f148 100644 --- a/src/eterna/IntLoopPars.ts +++ b/src/eterna/IntLoopPars.ts @@ -1,6 +1,6 @@ /* eslint-disable max-len */ -export class IntLoopPars { +export default class IntLoopPars { public static readonly int11_37: number[] = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, diff --git a/src/eterna/Plot.ts b/src/eterna/Plot.ts index e1b5ae997..07d14115e 100644 --- a/src/eterna/Plot.ts +++ b/src/eterna/Plot.ts @@ -1,12 +1,12 @@ import {Graphics, Text, Container} from "pixi.js"; -import {ColorUtil} from "../flashbang/util/ColorUtil"; -import {Fonts} from "./util/Fonts"; +import {ColorUtil} from "flashbang/util"; +import {Fonts} from "eterna/util"; export enum PlotType { LINE, BAR, SCATTER } -export class Plot extends Container { +export default class Plot extends Container { public type: PlotType = PlotType.BAR; public constructor(type: PlotType = PlotType.BAR) { diff --git a/src/eterna/UndoBlock.ts b/src/eterna/UndoBlock.ts index 6906c9df7..52fdbf5de 100644 --- a/src/eterna/UndoBlock.ts +++ b/src/eterna/UndoBlock.ts @@ -1,8 +1,8 @@ -import {JSONUtil} from "../flashbang/util/JSONUtil"; -import {EPars} from "./EPars"; -import {Folder} from "./folding/Folder"; -import {Plot, PlotType} from "./Plot"; -import {Oligo, Pose2D} from "./pose2D/Pose2D"; +import {JSONUtil} from "flashbang/util"; +import EPars from "eterna/EPars"; +import {Folder} from "eterna/folding"; +import {default as Plot, PlotType} from "eterna/Plot"; +import {Oligo, Pose2D} from "eterna/pose2D"; export enum UndoBlockParam { GU = 0, @@ -22,7 +22,7 @@ export enum UndoBlockParam { MAX = 14, } -export class UndoBlock { +export default class UndoBlock { public constructor(seq: number[]) { this._sequence = seq.slice(); } diff --git a/src/eterna/achievements/AchievementBox.ts b/src/eterna/achievements/AchievementBox.ts index 0873b52d7..5cc12ac51 100644 --- a/src/eterna/achievements/AchievementBox.ts +++ b/src/eterna/achievements/AchievementBox.ts @@ -1,21 +1,14 @@ import * as log from "loglevel"; import {Point, Sprite, Text} from "pixi.js"; -import {ContainerObject} from "../../flashbang/objects/ContainerObject"; -import {AlphaTask} from "../../flashbang/tasks/AlphaTask"; -import {DelayTask} from "../../flashbang/tasks/DelayTask"; -import {ParallelTask} from "../../flashbang/tasks/ParallelTask"; -import {ScaleTask} from "../../flashbang/tasks/ScaleTask"; -import {SerialTask} from "../../flashbang/tasks/SerialTask"; -import {Easing} from "../../flashbang/util/Easing"; -import {TextureUtil} from "../../flashbang/util/TextureUtil"; -import {PlaySoundTask} from "../resources/PlaySoundTask"; -import {Sounds} from "../resources/Sounds"; -import {GameButton} from "../ui/GameButton"; -import {GamePanel, GamePanelType} from "../ui/GamePanel"; -import {Fonts} from "../util/Fonts"; -import {VibrateTask} from "../vfx/VibrateTask"; +import {ContainerObject} from "flashbang/objects"; +import {AlphaTask, DelayTask, ParallelTask, ScaleTask, SerialTask} from "flashbang/tasks"; +import {Easing, TextureUtil} from "flashbang/util"; +import {PlaySoundTask, Sounds} from "eterna/resources"; +import {GameButton, GamePanel, GamePanelType} from "eterna/ui"; +import {Fonts} from "eterna/util"; +import {VibrateTask} from "eterna/vfx"; -export class AchievementBox extends ContainerObject { +export default class AchievementBox extends ContainerObject { constructor(imageURL: string, text: string) { super(); this._imageURL = imageURL; diff --git a/src/eterna/achievements/AchievementManager.ts b/src/eterna/achievements/AchievementManager.ts index b16cdd066..8d9fd0ffc 100644 --- a/src/eterna/achievements/AchievementManager.ts +++ b/src/eterna/achievements/AchievementManager.ts @@ -1,14 +1,10 @@ -import {HAlign, VAlign} from "../../flashbang/core/Align"; -import {GameObject} from "../../flashbang/core/GameObject"; -import {GameObjectRef} from "../../flashbang/core/GameObjectRef"; -import {CallbackTask} from "../../flashbang/tasks/CallbackTask"; -import {FunctionTask} from "../../flashbang/tasks/FunctionTask"; -import {SerialTask} from "../../flashbang/tasks/SerialTask"; -import {DisplayUtil} from "../../flashbang/util/DisplayUtil"; -import {GameMode} from "../mode/GameMode"; -import {AchievementBox} from "./AchievementBox"; +import {HAlign, VAlign, GameObject, GameObjectRef} from "flashbang/core"; +import {CallbackTask, FunctionTask, SerialTask} from "flashbang/tasks"; +import {DisplayUtil} from "flashbang/util"; +import {GameMode} from "eterna/mode"; +import {AchievementBox} from "."; -export class AchievementManager extends GameObject { +export default class AchievementManager extends GameObject { /** True if there's an achievement animation playing, or about to play */ public get hasPendingAchievements(): boolean { return this._cur.isLive || this._pending.length > 0; diff --git a/src/eterna/achievements/index.ts b/src/eterna/achievements/index.ts new file mode 100644 index 000000000..a7cd6ffc3 --- /dev/null +++ b/src/eterna/achievements/index.ts @@ -0,0 +1,2 @@ +export {default as AchievementBox} from "./AchievementBox"; +export {default as AchievementManager} from "./AchievementManager"; \ No newline at end of file diff --git a/src/eterna/debug/TestMode.ts b/src/eterna/debug/TestMode.ts index 1cdd93d25..46ee3d2ab 100644 --- a/src/eterna/debug/TestMode.ts +++ b/src/eterna/debug/TestMode.ts @@ -1,11 +1,8 @@ -import {ViewSolutionDialog} from "../mode/DesignBrowser/ViewSolutionDialog"; -import {GameMode} from "../mode/GameMode"; -import {Puzzle} from "../puzzle/Puzzle"; -import {PuzzleManager} from "../puzzle/PuzzleManager"; -import {Solution} from "../puzzle/Solution"; -import {SolutionManager} from "../puzzle/SolutionManager"; +import {GameMode} from "../mode"; +import {ViewSolutionDialog} from "../mode/DesignBrowser"; +import {Puzzle, PuzzleManager, Solution, SolutionManager} from "../puzzle"; -export class TestMode extends GameMode { +export default class TestMode extends GameMode { protected setup(): void { super.setup(); diff --git a/src/eterna/debug/index.ts b/src/eterna/debug/index.ts new file mode 100644 index 000000000..80fb07b2e --- /dev/null +++ b/src/eterna/debug/index.ts @@ -0,0 +1 @@ +export {default as TestMode} from "./TestMode"; \ No newline at end of file diff --git a/src/eterna/emscripten/EmscriptenUtil.ts b/src/eterna/emscripten/EmscriptenUtil.ts index 74151cd73..93bed1b78 100644 --- a/src/eterna/emscripten/EmscriptenUtil.ts +++ b/src/eterna/emscripten/EmscriptenUtil.ts @@ -1,6 +1,6 @@ import * as stdcpp from "./stdcpp"; -export class EmscriptenUtil { +export default class EmscriptenUtil { /** * Instantiates a program from an Emscripten module and calls its main() function if it has one. * @returns {Promise} a promise that will resolve with the instantiated module. diff --git a/src/eterna/emscripten/index.ts b/src/eterna/emscripten/index.ts new file mode 100644 index 000000000..c4ed37bc6 --- /dev/null +++ b/src/eterna/emscripten/index.ts @@ -0,0 +1 @@ +export {default as EmscriptenUtil} from "./EmscriptenUtil"; \ No newline at end of file diff --git a/src/eterna/folding/FoldUtil.ts b/src/eterna/folding/FoldUtil.ts index 39c9d2bea..db9d0c161 100644 --- a/src/eterna/folding/FoldUtil.ts +++ b/src/eterna/folding/FoldUtil.ts @@ -1,4 +1,4 @@ -export class FoldUtil { +export default class FoldUtil { public static nextPerm(v: number[]): boolean { let more = false; let ii: number = v.length; diff --git a/src/eterna/folding/Folder.ts b/src/eterna/folding/Folder.ts index 50d348de7..2bef17281 100644 --- a/src/eterna/folding/Folder.ts +++ b/src/eterna/folding/Folder.ts @@ -1,6 +1,6 @@ -import {PoseOp} from "../pose2D/PoseOp"; +import {PoseOp} from "eterna/pose2D"; -export abstract class Folder { +export default abstract class Folder { protected constructor() { } diff --git a/src/eterna/folding/FolderManager.ts b/src/eterna/folding/FolderManager.ts index 323ad1981..6456aa0be 100644 --- a/src/eterna/folding/FolderManager.ts +++ b/src/eterna/folding/FolderManager.ts @@ -1,10 +1,7 @@ -import {Eterna} from "../Eterna"; -import {Folder} from "./Folder"; -import {RNAFoldBasic} from "./RNAFoldBasic"; -import {LinearFoldC} from "./LinearFoldC"; -import {Vienna} from "./Vienna"; +import Eterna from "eterna/Eterna"; +import {Folder, LinearFoldC, RNAFoldBasic, Vienna} from "."; -export class FolderManager { +export default class FolderManager { public static get instance(): FolderManager { if (FolderManager._instance == null) { FolderManager._instance = new FolderManager(); diff --git a/src/eterna/folding/LinearFoldBase.ts b/src/eterna/folding/LinearFoldBase.ts index 4672230bc..203976e72 100644 --- a/src/eterna/folding/LinearFoldBase.ts +++ b/src/eterna/folding/LinearFoldBase.ts @@ -1,13 +1,12 @@ import * as log from "loglevel"; -import {EmscriptenUtil} from "../emscripten/EmscriptenUtil"; -import {EPars} from "../EPars"; +import {EmscriptenUtil} from "eterna/emscripten"; +import EPars from "eterna/EPars"; import {FullFoldResult} from "./engines/LinearFold_lib"; import * as LinearFold_lib from "./engines/LinearFold_lib/index"; -import {Folder} from "./Folder"; -import {FoldUtil} from "./FoldUtil"; import {FullEvalResult} from "./engines/vienna_lib"; +import {Folder, FoldUtil} from "."; -export abstract class LinearFoldBase extends Folder { +export default abstract class LinearFoldBase extends Folder { protected constructor(lib: LinearFold_lib) { super(); this._lib = lib; diff --git a/src/eterna/folding/LinearFoldC.ts b/src/eterna/folding/LinearFoldC.ts index bc6348d12..421edea82 100644 --- a/src/eterna/folding/LinearFoldC.ts +++ b/src/eterna/folding/LinearFoldC.ts @@ -1,7 +1,7 @@ -import {EmscriptenUtil} from "../emscripten/EmscriptenUtil"; -import {LinearFoldBase} from "./LinearFoldBase"; +import {EmscriptenUtil} from "eterna/emscripten"; +import {LinearFoldBase} from "."; -export class LinearFoldC extends LinearFoldBase { +export default class LinearFoldC extends LinearFoldBase { public static readonly NAME = "LinearFoldC"; /** diff --git a/src/eterna/folding/LinearFoldV.ts b/src/eterna/folding/LinearFoldV.ts index 4fe4cbd08..fc9244bc0 100644 --- a/src/eterna/folding/LinearFoldV.ts +++ b/src/eterna/folding/LinearFoldV.ts @@ -1,7 +1,7 @@ -import {EmscriptenUtil} from "../emscripten/EmscriptenUtil"; -import {LinearFoldBase} from "./LinearFoldBase"; +import {EmscriptenUtil} from "eterna/emscripten"; +import {LinearFoldBase} from "."; -export class LinearFoldV extends LinearFoldBase { +export default class LinearFoldV extends LinearFoldBase { public static readonly NAME = "LinearFoldV"; /** diff --git a/src/eterna/folding/NuPACK.ts b/src/eterna/folding/NuPACK.ts index 0d7eb9b3a..b8146cf5b 100644 --- a/src/eterna/folding/NuPACK.ts +++ b/src/eterna/folding/NuPACK.ts @@ -1,14 +1,13 @@ import * as log from "loglevel"; -import {EmscriptenUtil} from "../emscripten/EmscriptenUtil"; -import {EPars} from "../EPars"; -import {PoseOp} from "../pose2D/PoseOp"; -import {int} from "../util/int"; +import {EmscriptenUtil} from "eterna/emscripten"; +import EPars from "eterna/EPars"; +import {PoseOp} from "eterna/pose2D"; +import {int} from "eterna/util"; import * as nupack_lib from "./engines/nupack_lib/index"; import {DotPlotResult, FullEvalResult, FullFoldResult} from "./engines/nupack_lib/index"; -import {Folder} from "./Folder"; -import {FoldUtil} from "./FoldUtil"; +import {Folder, FoldUtil} from "."; -export class NuPACK extends Folder { +export default class NuPACK extends Folder { public static NAME = "NuPACK"; /** diff --git a/src/eterna/folding/RNAFoldBasic.ts b/src/eterna/folding/RNAFoldBasic.ts index 4f11c1e3f..d936a8faa 100644 --- a/src/eterna/folding/RNAFoldBasic.ts +++ b/src/eterna/folding/RNAFoldBasic.ts @@ -1,7 +1,7 @@ -import {EPars} from "../EPars"; -import {Folder} from "./Folder"; +import EPars from "eterna/EPars"; +import {Folder} from "."; -export class RNAFoldBasic extends Folder { +export default class RNAFoldBasic extends Folder { public static readonly NAME = "Basic"; /** Asynchronously creates a new instance of the RNAFoldBasic folder. */ diff --git a/src/eterna/folding/Vienna.ts b/src/eterna/folding/Vienna.ts index 87aaed411..1bae88c94 100644 --- a/src/eterna/folding/Vienna.ts +++ b/src/eterna/folding/Vienna.ts @@ -1,14 +1,13 @@ import * as log from "loglevel"; -import {EmscriptenUtil} from "../emscripten/EmscriptenUtil"; -import {EPars} from "../EPars"; -import {RNALayout} from "../pose2D/RNALayout"; -import {CSVParser} from "../util/CSVParser"; +import {EmscriptenUtil} from "eterna/emscripten"; +import EPars from "eterna/EPars"; +import {RNALayout} from "eterna/pose2D"; +import {CSVParser} from "eterna/util"; import * as vienna_lib from "./engines/vienna_lib/index"; import {DotPlotResult, FullEvalResult, FullFoldResult} from "./engines/vienna_lib/index"; -import {Folder} from "./Folder"; -import {FoldUtil} from "./FoldUtil"; +import {Folder, FoldUtil} from "."; -export class Vienna extends Folder { +export default class Vienna extends Folder { public static readonly NAME: string = "Vienna"; /** diff --git a/src/eterna/folding/Vienna2.ts b/src/eterna/folding/Vienna2.ts index 99c300f4e..4f6e4eaba 100644 --- a/src/eterna/folding/Vienna2.ts +++ b/src/eterna/folding/Vienna2.ts @@ -1,14 +1,13 @@ import * as log from "loglevel"; -import {EmscriptenUtil} from "../emscripten/EmscriptenUtil"; -import {EPars} from "../EPars"; -import {RNALayout} from "../pose2D/RNALayout"; -import {CSVParser} from "../util/CSVParser"; +import {EmscriptenUtil} from "eterna/emscripten"; +import EPars from "eterna/EPars"; +import {RNALayout} from "eterna/pose2D"; +import {CSVParser} from "eterna/util"; import * as vrna2_lib from "./engines/vrna2_lib/index"; import {DotPlotResult, FullEvalResult, FullFoldResult} from "./engines/vrna2_lib/index"; -import {Folder} from "./Folder"; -import {FoldUtil} from "./FoldUtil"; +import {Folder, FoldUtil} from "."; -export class Vienna2 extends Folder { +export default class Vienna2 extends Folder { public static NAME = "Vienna2"; /** diff --git a/src/eterna/folding/index.ts b/src/eterna/folding/index.ts new file mode 100644 index 000000000..5a9509da1 --- /dev/null +++ b/src/eterna/folding/index.ts @@ -0,0 +1,10 @@ +export {default as Folder} from "./Folder"; +export {default as FolderManager} from "./FolderManager"; +export {default as FoldUtil} from "./FoldUtil"; +export {default as LinearFoldBase} from "./LinearFoldBase"; +export {default as LinearFoldC} from "./LinearFoldC"; +export {default as LinearFoldV} from "./LinearFoldV"; +export {default as NuPACK} from "./NuPACK"; +export {default as RNAFoldBasic} from "./RNAFoldBasic"; +export {default as Vienna} from "./Vienna"; +export {default as Vienna2} from "./Vienna2"; \ No newline at end of file diff --git a/src/eterna/index.ts b/src/eterna/index.ts index 96595b8ba..7a868fa6b 100644 --- a/src/eterna/index.ts +++ b/src/eterna/index.ts @@ -1,5 +1,5 @@ import * as log from "loglevel"; -import {EternaApp} from "./EternaApp"; +import EternaApp from "eterna/EternaApp"; const isProduction = process.env.NODE_ENV === "production"; log.setLevel(isProduction ? "info" : "trace"); diff --git a/src/eterna/mode/CopyTextDialogMode.ts b/src/eterna/mode/CopyTextDialogMode.ts index 9cc7562e4..b8893cbb2 100644 --- a/src/eterna/mode/CopyTextDialogMode.ts +++ b/src/eterna/mode/CopyTextDialogMode.ts @@ -1,11 +1,10 @@ import {Graphics} from "pixi.js"; -import {AppMode} from "../../flashbang/core/AppMode"; -import {Flashbang} from "../../flashbang/core/Flashbang"; -import {KeyCode} from "../../flashbang/input/KeyCode"; -import {TextInputPanel} from "../ui/TextInputPanel"; +import {Flashbang, AppMode} from "flashbang/core"; +import {KeyCode} from "flashbang/input"; +import {TextInputPanel} from "eterna/ui"; /** Show a dialog with text that the user can copy */ -export class CopyTextDialogMode extends AppMode { +export default class CopyTextDialogMode extends AppMode { public constructor(text: string, dialogTitle?: string) { super(); this._text = text; diff --git a/src/eterna/mode/DesignBrowser/CustomizeColumnOrderDialog.ts b/src/eterna/mode/DesignBrowser/CustomizeColumnOrderDialog.ts index 051d4d7e1..47987ceef 100644 --- a/src/eterna/mode/DesignBrowser/CustomizeColumnOrderDialog.ts +++ b/src/eterna/mode/DesignBrowser/CustomizeColumnOrderDialog.ts @@ -1,20 +1,14 @@ import {Container, Point, Text} from "pixi.js"; -import {HAlign, VAlign} from "../../../flashbang/core/Align"; -import {HLayoutContainer} from "../../../flashbang/layout/HLayoutContainer"; -import {VLayoutContainer} from "../../../flashbang/layout/VLayoutContainer"; -import {Arrays} from "../../../flashbang/util/Arrays"; -import {DisplayUtil} from "../../../flashbang/util/DisplayUtil"; -import {Signal} from "../../../signals/Signal"; -import {Bitmaps} from "../../resources/Bitmaps"; -import {Dialog} from "../../ui/Dialog"; -import {FixedWidthTextField} from "../../ui/FixedWidthTextField"; -import {GameButton} from "../../ui/GameButton"; -import {GamePanel, GamePanelType} from "../../ui/GamePanel"; -import {Fonts} from "../../util/Fonts"; -import {GraphicsUtil} from "../../util/GraphicsUtil"; -import {DesignCategory} from "./DesignBrowserMode"; - -export class CustomizeColumnOrderDialog extends Dialog { +import {HAlign, VAlign} from "flashbang/core"; +import {HLayoutContainer, VLayoutContainer} from "flashbang/layout"; +import {Arrays, DisplayUtil} from "flashbang/util"; +import {Signal} from "signals"; +import {Bitmaps} from "eterna/resources"; +import {Dialog, FixedWidthTextField, GameButton, GamePanel, GamePanelType} from "eterna/ui"; +import {Fonts, GraphicsUtil} from "eterna/util"; +import {DesignCategory} from "."; + +export default class CustomizeColumnOrderDialog extends Dialog { public readonly columnsReorganized = new Signal(); public constructor(allCategories: DesignCategory[], curColumns: DesignCategory[], disabled: Set = null) { diff --git a/src/eterna/mode/DesignBrowser/DataCol.ts b/src/eterna/mode/DesignBrowser/DataCol.ts index 021e77e6f..0fe3a64d2 100644 --- a/src/eterna/mode/DesignBrowser/DataCol.ts +++ b/src/eterna/mode/DesignBrowser/DataCol.ts @@ -1,23 +1,15 @@ -import { - Container, Graphics, Point, Text -} from "pixi.js"; -import {Flashbang} from "../../../flashbang/core/Flashbang"; -import {ContainerObject} from "../../../flashbang/objects/ContainerObject"; -import {TextBuilder} from "../../../flashbang/util/TextBuilder"; -import {Signal} from "../../../signals/Signal"; -import {UnitSignal} from "../../../signals/UnitSignal"; -import {Feedback} from "../../Feedback"; -import {Solution} from "../../puzzle/Solution"; -import {GameButton} from "../../ui/GameButton"; -import {TextInputObject} from "../../ui/TextInputObject"; -import {Fonts} from "../../util/Fonts"; -import {int} from "../../util/int"; -import {Utility} from "../../util/Utility"; -import {DesignBrowserDataType, DesignCategory} from "./DesignBrowserMode"; -import {SequenceStringListView} from "./SequenceStringListView"; -import {SortOrder} from "./SortOptions"; - -export class DataCol extends ContainerObject { +import {Container, Graphics, Point, Text} from "pixi.js"; +import {Flashbang} from "flashbang/core"; +import {ContainerObject} from "flashbang/objects"; +import {TextBuilder} from "flashbang/util"; +import {Signal, UnitSignal} from "signals"; +import Feedback from "eterna/Feedback"; +import {Solution} from "eterna/puzzle"; +import {GameButton, TextInputObject} from "eterna/ui"; +import {Fonts, int, Utility} from "eterna/util"; +import {DesignBrowserDataType, DesignCategory, SequenceStringListView, SortOrder} from "."; + +export default class DataCol extends ContainerObject { public readonly sortOrderChanged = new Signal(); public readonly filtersChanged = new UnitSignal(); public readonly category: DesignCategory; diff --git a/src/eterna/mode/DesignBrowser/DesignBrowserMode.ts b/src/eterna/mode/DesignBrowser/DesignBrowserMode.ts index e6319fa59..572ee375b 100644 --- a/src/eterna/mode/DesignBrowser/DesignBrowserMode.ts +++ b/src/eterna/mode/DesignBrowser/DesignBrowserMode.ts @@ -1,48 +1,23 @@ import * as log from "loglevel"; import MultiStyleText from "pixi-multistyle-text"; +import {Container, Graphics, Point, Sprite, Text} from "pixi.js"; +import {Flashbang, HAlign, VAlign} from "flashbang/core"; +import {HLayoutContainer} from "flashbang/layout"; +import {ContainerObject, SceneObject} from "flashbang/objects"; +import {AlphaTask, CallbackTask, DelayTask, LocationTask, RepeatingTask, SerialTask} from "flashbang/tasks"; +import {DisplayUtil, Easing, MathUtil} from "flashbang/util"; +import EPars from "eterna/EPars"; +import Eterna from "eterna/Eterna"; +import Feedback from "eterna/Feedback"; +import {Puzzle, Solution, SolutionManager} from "eterna/puzzle"; +import {BitmapManager, Bitmaps} from "eterna/resources"; +import {GameButton, GamePanel, HTMLTextObject, SliderBar, URLButton} from "eterna/ui"; +import {Fonts, int} from "eterna/util"; +import {GameMode} from "eterna/mode"; import { - Container, Graphics, Point, Sprite, Text -} from "pixi.js"; -import {HAlign, VAlign} from "../../../flashbang/core/Align"; -import {Flashbang} from "../../../flashbang/core/Flashbang"; -import {HLayoutContainer} from "../../../flashbang/layout/HLayoutContainer"; -import {ContainerObject} from "../../../flashbang/objects/ContainerObject"; -import {SceneObject} from "../../../flashbang/objects/SceneObject"; -import {AlphaTask} from "../../../flashbang/tasks/AlphaTask"; -import {CallbackTask} from "../../../flashbang/tasks/CallbackTask"; -import {DelayTask} from "../../../flashbang/tasks/DelayTask"; -import {LocationTask} from "../../../flashbang/tasks/LocationTask"; -import {RepeatingTask} from "../../../flashbang/tasks/RepeatingTask"; -import {SerialTask} from "../../../flashbang/tasks/SerialTask"; -import {DisplayUtil} from "../../../flashbang/util/DisplayUtil"; -import {Easing} from "../../../flashbang/util/Easing"; -import {MathUtil} from "../../../flashbang/util/MathUtil"; -import {EPars} from "../../EPars"; -import {Eterna} from "../../Eterna"; -import {Feedback} from "../../Feedback"; -import {Puzzle} from "../../puzzle/Puzzle"; -import {Solution} from "../../puzzle/Solution"; -import {SolutionManager} from "../../puzzle/SolutionManager"; -import {BitmapManager} from "../../resources/BitmapManager"; -import {Bitmaps} from "../../resources/Bitmaps"; -import {GameButton} from "../../ui/GameButton"; -import {GamePanel} from "../../ui/GamePanel"; -import {HTMLTextObject} from "../../ui/HTMLTextObject"; -import {SliderBar} from "../../ui/SliderBar"; -import {URLButton} from "../../ui/URLButton"; -import {Fonts} from "../../util/Fonts"; -import {int} from "../../util/int"; -import {GameMode} from "../GameMode"; -import {CustomizeColumnOrderDialog} from "./CustomizeColumnOrderDialog"; -import {DataCol} from "./DataCol"; -import {DotLine} from "./DotLine"; -import {GridLines} from "./GridLines"; -import {MarkerBoxView} from "./MarkerBoxView"; -import {SelectionBox} from "./SelectionBox"; -import {SortOptions, SortOrder} from "./SortOptions"; -import {SortOptionsDialog} from "./SortOptionsDialog"; -import {ViewSolutionDialog} from "./ViewSolutionDialog"; -import {VoteProcessor} from "./VoteProcessor"; + CustomizeColumnOrderDialog, DataCol, DotLine, GridLines, MarkerBoxView, + SelectionBox, SortOptions, SortOrder, SortOptionsDialog, ViewSolutionDialog, VoteProcessor +} from "."; export enum DesignBrowserDataType { INT = 0, @@ -78,7 +53,7 @@ export interface DesignBrowserFilter { arg2?: string; } -export class DesignBrowserMode extends GameMode { +export default class DesignBrowserMode extends GameMode { constructor(puzzle: Puzzle, novote: boolean = false, initialFilters: DesignBrowserFilter[] = null) { super(); diff --git a/src/eterna/mode/DesignBrowser/DotLine.ts b/src/eterna/mode/DesignBrowser/DotLine.ts index b9a088c3b..6d7a729f0 100644 --- a/src/eterna/mode/DesignBrowser/DotLine.ts +++ b/src/eterna/mode/DesignBrowser/DotLine.ts @@ -1,6 +1,6 @@ import {Graphics} from "pixi.js"; -export class DotLine extends Graphics { +export default class DotLine extends Graphics { public constructor(thickness: number, color: number) { super(); this._thickness = thickness; diff --git a/src/eterna/mode/DesignBrowser/GridLines.ts b/src/eterna/mode/DesignBrowser/GridLines.ts index f050d38a7..acc3b0a04 100644 --- a/src/eterna/mode/DesignBrowser/GridLines.ts +++ b/src/eterna/mode/DesignBrowser/GridLines.ts @@ -3,7 +3,7 @@ import {Graphics} from "pixi.js"; // GridLines class written by Jerry Fu // Draws any number of lines covering the entire width of the design browser at a specified interval, // starting from the top heading down -export class GridLines extends Graphics { +export default class GridLines extends Graphics { constructor(thickness: number, color: number, intervalSpacing: number) { super(); this._thickness = thickness; diff --git a/src/eterna/mode/DesignBrowser/LabComments.ts b/src/eterna/mode/DesignBrowser/LabComments.ts index 311797a0f..a15693996 100644 --- a/src/eterna/mode/DesignBrowser/LabComments.ts +++ b/src/eterna/mode/DesignBrowser/LabComments.ts @@ -1,7 +1,7 @@ -import {Eterna} from "../../Eterna"; -import {Utility} from "../../util/Utility"; +import Eterna from "eterna/Eterna"; +import {Utility} from "eterna/util"; -export class LabComments { +export default class LabComments { constructor(nid: number) { this._solution_nid = nid; this._comments_data = []; diff --git a/src/eterna/mode/DesignBrowser/MarkerBoxView.ts b/src/eterna/mode/DesignBrowser/MarkerBoxView.ts index f8c36c3b8..886e5fe22 100644 --- a/src/eterna/mode/DesignBrowser/MarkerBoxView.ts +++ b/src/eterna/mode/DesignBrowser/MarkerBoxView.ts @@ -1,7 +1,7 @@ import {Container, Point} from "pixi.js"; -import {SelectionBox} from "./SelectionBox"; +import {SelectionBox} from "."; -export class MarkerBoxView extends Container { +export default class MarkerBoxView extends Container { constructor(color: number, markerHeight: number) { super(); diff --git a/src/eterna/mode/DesignBrowser/SelectionBox.ts b/src/eterna/mode/DesignBrowser/SelectionBox.ts index 242d5398a..8529492aa 100644 --- a/src/eterna/mode/DesignBrowser/SelectionBox.ts +++ b/src/eterna/mode/DesignBrowser/SelectionBox.ts @@ -1,6 +1,6 @@ import {Graphics} from "pixi.js"; -export class SelectionBox extends Graphics { +export default class SelectionBox extends Graphics { public constructor(color: number) { super(); this._color = color; diff --git a/src/eterna/mode/DesignBrowser/SequenceStringListView.ts b/src/eterna/mode/DesignBrowser/SequenceStringListView.ts index 582adb480..302294d3d 100644 --- a/src/eterna/mode/DesignBrowser/SequenceStringListView.ts +++ b/src/eterna/mode/DesignBrowser/SequenceStringListView.ts @@ -1,15 +1,12 @@ -import { - Container, Graphics, Sprite, Texture -} from "pixi.js"; -import {TextBuilder} from "../../../flashbang/util/TextBuilder"; -import {TextureUtil} from "../../../flashbang/util/TextureUtil"; -import {EPars} from "../../EPars"; -import {Eterna} from "../../Eterna"; -import {ExpPainter} from "../../ExpPainter"; -import {Feedback} from "../../Feedback"; -import {EternaTextureUtil} from "../../util/EternaTextureUtil"; - -export class SequenceStringListView extends Container { +import {Container, Graphics, Sprite, Texture} from "pixi.js"; +import {TextBuilder, TextureUtil} from "flashbang/util"; +import EPars from "eterna/EPars"; +import Eterna from "eterna/Eterna"; +import ExpPainter from "eterna/ExpPainter"; +import Feedback from "eterna/Feedback"; +import {EternaTextureUtil} from "eterna/util"; + +export default class SequenceStringListView extends Container { public constructor(fontname: string, fontsize: number, fontbold: boolean, letterWidth: number, letterHeight: number) { super(); diff --git a/src/eterna/mode/DesignBrowser/SolutionDescBox.ts b/src/eterna/mode/DesignBrowser/SolutionDescBox.ts index 102477649..0bfaecdbf 100644 --- a/src/eterna/mode/DesignBrowser/SolutionDescBox.ts +++ b/src/eterna/mode/DesignBrowser/SolutionDescBox.ts @@ -1,29 +1,19 @@ import MultiStyleText from "pixi-multistyle-text"; import {Point, Text} from "pixi.js"; -import {HAlign} from "../../../flashbang/core/Align"; -import {HLayoutContainer} from "../../../flashbang/layout/HLayoutContainer"; -import {VLayoutContainer} from "../../../flashbang/layout/VLayoutContainer"; -import {SceneObject} from "../../../flashbang/objects/SceneObject"; -import {AlphaTask} from "../../../flashbang/tasks/AlphaTask"; -import {RepeatingTask} from "../../../flashbang/tasks/RepeatingTask"; -import {SerialTask} from "../../../flashbang/tasks/SerialTask"; -import {Eterna} from "../../Eterna"; -import {Feedback} from "../../Feedback"; -import {EternaURL} from "../../net/EternaURL"; -import {Puzzle} from "../../puzzle/Puzzle"; -import {Solution} from "../../puzzle/Solution"; -import {GameButton} from "../../ui/GameButton"; -import {GamePanel, GamePanelType} from "../../ui/GamePanel"; -import {HTMLTextObject} from "../../ui/HTMLTextObject"; -import {TextInputObject} from "../../ui/TextInputObject"; -import {VScrollBox} from "../../ui/VScrollBox"; -import {Fonts} from "../../util/Fonts"; -import {Utility} from "../../util/Utility"; -import {CopyTextDialogMode} from "../CopyTextDialogMode"; -import {GameMode} from "../GameMode"; -import {LabComments} from "./LabComments"; - -export class SolutionDescBox extends GamePanel { +import {HAlign} from "flashbang/core"; +import {HLayoutContainer, VLayoutContainer} from "flashbang/layout"; +import {SceneObject} from "flashbang/objects"; +import {AlphaTask, RepeatingTask, SerialTask} from "flashbang/tasks"; +import Eterna from "eterna/Eterna"; +import Feedback from "eterna/Feedback"; +import {EternaURL} from "eterna/net"; +import {Puzzle, Solution} from "eterna/puzzle"; +import {GameButton, GamePanel, GamePanelType, HTMLTextObject, TextInputObject, VScrollBox} from "eterna/ui"; +import {Fonts, Utility} from "eterna/util"; +import {CopyTextDialogMode, GameMode} from "eterna/mode"; +import {LabComments} from "."; + +export default class SolutionDescBox extends GamePanel { constructor(solution: Solution, puzzle: Puzzle) { super(GamePanelType.INVISIBLE, 1.0, 0x152843, 0.27, 0xC0DCE7); this._solution = solution; diff --git a/src/eterna/mode/DesignBrowser/SortOptions.ts b/src/eterna/mode/DesignBrowser/SortOptions.ts index 29506e567..13752a860 100644 --- a/src/eterna/mode/DesignBrowser/SortOptions.ts +++ b/src/eterna/mode/DesignBrowser/SortOptions.ts @@ -1,7 +1,7 @@ -import {Arrays} from "../../../flashbang/util/Arrays"; -import {UnitSignal} from "../../../signals/UnitSignal"; -import {Solution} from "../../puzzle/Solution"; -import {DesignCategory} from "./DesignBrowserMode"; +import {Arrays} from "flashbang/util"; +import {UnitSignal} from "signals"; +import {Solution} from "eterna/puzzle"; +import {DesignCategory} from "."; export enum SortOrder { INCREASING = 1, @@ -21,7 +21,7 @@ export class SortCriterion { } } -export class SortOptions { +export default class SortOptions { /** Emitted when any of our sort options have changed */ public readonly sortChanged = new UnitSignal(); diff --git a/src/eterna/mode/DesignBrowser/SortOptionsDialog.ts b/src/eterna/mode/DesignBrowser/SortOptionsDialog.ts index b0cadd8db..e04b4bb59 100644 --- a/src/eterna/mode/DesignBrowser/SortOptionsDialog.ts +++ b/src/eterna/mode/DesignBrowser/SortOptionsDialog.ts @@ -1,22 +1,13 @@ -import { - Container, Graphics, Point, Text -} from "pixi.js"; -import {HAlign, VAlign} from "../../../flashbang/core/Align"; -import {HLayoutContainer} from "../../../flashbang/layout/HLayoutContainer"; -import {VLayoutContainer} from "../../../flashbang/layout/VLayoutContainer"; -import {Arrays} from "../../../flashbang/util/Arrays"; -import {DisplayUtil} from "../../../flashbang/util/DisplayUtil"; -import {Bitmaps} from "../../resources/Bitmaps"; -import {Dialog} from "../../ui/Dialog"; -import {FixedWidthTextField} from "../../ui/FixedWidthTextField"; -import {GameButton} from "../../ui/GameButton"; -import {GamePanel, GamePanelType} from "../../ui/GamePanel"; -import {Fonts} from "../../util/Fonts"; -import {GraphicsUtil} from "../../util/GraphicsUtil"; -import {DesignCategory} from "./DesignBrowserMode"; -import {SortOptions, SortOrder} from "./SortOptions"; - -export class SortOptionsDialog extends Dialog { +import {Container, Graphics, Point, Text} from "pixi.js"; +import {HAlign, VAlign} from "flashbang/core"; +import {HLayoutContainer, VLayoutContainer} from "flashbang/layout"; +import {Arrays, DisplayUtil} from "flashbang/util"; +import {Bitmaps} from "eterna/resources"; +import {Dialog, FixedWidthTextField, GameButton, GamePanel, GamePanelType} from "eterna/ui"; +import {Fonts, GraphicsUtil} from "eterna/util"; +import {DesignCategory, SortOptions, SortOrder} from "."; + +export default class SortOptionsDialog extends Dialog { public readonly options: SortOptions; constructor(options: SortOptions) { diff --git a/src/eterna/mode/DesignBrowser/ViewSolutionDialog.ts b/src/eterna/mode/DesignBrowser/ViewSolutionDialog.ts index c13be1741..d828b098e 100644 --- a/src/eterna/mode/DesignBrowser/ViewSolutionDialog.ts +++ b/src/eterna/mode/DesignBrowser/ViewSolutionDialog.ts @@ -1,26 +1,18 @@ -import { - Container, Graphics, Point, Sprite, Text -} from "pixi.js"; -import {HAlign, VAlign} from "../../../flashbang/core/Align"; -import {Flashbang} from "../../../flashbang/core/Flashbang"; -import {HLayoutContainer} from "../../../flashbang/layout/HLayoutContainer"; -import {DisplayUtil} from "../../../flashbang/util/DisplayUtil"; -import {MathUtil} from "../../../flashbang/util/MathUtil"; -import {UnitSignal} from "../../../signals/UnitSignal"; -import {EPars} from "../../EPars"; -import {Eterna} from "../../Eterna"; -import {ExpPainter} from "../../ExpPainter"; -import {Puzzle} from "../../puzzle/Puzzle"; -import {Solution} from "../../puzzle/Solution"; -import {Bitmaps} from "../../resources/Bitmaps"; -import {Dialog} from "../../ui/Dialog"; -import {GameButton} from "../../ui/GameButton"; -import {GamePanel} from "../../ui/GamePanel"; -import {PoseThumbnail, PoseThumbnailType} from "../../ui/PoseThumbnail"; -import {Fonts} from "../../util/Fonts"; -import {SolutionDescBox} from "./SolutionDescBox"; - -export class ViewSolutionDialog extends Dialog { +import {Container, Graphics, Point, Sprite, Text} from "pixi.js"; +import {Flashbang, HAlign, VAlign} from "flashbang/core"; +import {HLayoutContainer} from "flashbang/layout"; +import {DisplayUtil, MathUtil} from "flashbang/util"; +import {UnitSignal} from "signals"; +import EPars from "eterna/EPars"; +import Eterna from "eterna/Eterna"; +import ExpPainter from "eterna/ExpPainter"; +import {Puzzle, Solution} from "eterna/puzzle"; +import {Bitmaps} from "eterna/resources"; +import {Dialog, GameButton, GamePanel, PoseThumbnail, PoseThumbnailType} from "eterna/ui"; +import {Fonts} from "eterna/util"; +import {SolutionDescBox} from "."; + +export default class ViewSolutionDialog extends Dialog { public readonly playClicked = new UnitSignal(); public readonly seeResultClicked = new UnitSignal(); public readonly sortClicked = new UnitSignal(); diff --git a/src/eterna/mode/DesignBrowser/VoteProcessor.ts b/src/eterna/mode/DesignBrowser/VoteProcessor.ts index 7d57be7a9..9702af15c 100644 --- a/src/eterna/mode/DesignBrowser/VoteProcessor.ts +++ b/src/eterna/mode/DesignBrowser/VoteProcessor.ts @@ -1,8 +1,8 @@ -import {Eterna} from "../../Eterna"; -import {SolutionManager} from "../../puzzle/SolutionManager"; -import {int} from "../../util/int"; +import Eterna from "eterna/Eterna"; +import {SolutionManager} from "eterna/puzzle"; +import {int} from "eterna/util"; -export class VoteProcessor { +export default class VoteProcessor { public process_data(data: any[]): void { let solutionIDs: number[] = []; let voteCounts: number[] = []; diff --git a/src/eterna/mode/DesignBrowser/index.ts b/src/eterna/mode/DesignBrowser/index.ts new file mode 100644 index 000000000..be87452ff --- /dev/null +++ b/src/eterna/mode/DesignBrowser/index.ts @@ -0,0 +1,16 @@ +export {default as CustomizeColumnOrderDialog} from "./CustomizeColumnOrderDialog"; +export {default as DataCol} from "./DataCol"; +export { + default as DesignBrowserMode, DesignBrowserDataType, DesignCategory, DesignBrowserFilter +} from "./DesignBrowserMode"; +export {default as DotLine} from "./DotLine"; +export {default as GridLines} from "./GridLines"; +export {default as LabComments} from "./LabComments"; +export {default as MarkerBoxView} from "./MarkerBoxView"; +export {default as SelectionBox} from "./SelectionBox"; +export {default as SequenceStringListView} from "./SequenceStringListView"; +export {default as SolutionDescBox} from "./SolutionDescBox"; +export {default as SortOptions, SortOrder, SortCriterion} from "./SortOptions"; +export {default as SortOptionsDialog} from "./SortOptionsDialog"; +export {default as ViewSolutionDialog} from "./ViewSolutionDialog"; +export {default as VoteProcessor} from "./VoteProcessor"; \ No newline at end of file diff --git a/src/eterna/mode/ErrorDialogMode.ts b/src/eterna/mode/ErrorDialogMode.ts index 411a6d0d5..f3f83bd67 100644 --- a/src/eterna/mode/ErrorDialogMode.ts +++ b/src/eterna/mode/ErrorDialogMode.ts @@ -1,14 +1,11 @@ import {Graphics, Point} from "pixi.js"; -import {HAlign} from "../../flashbang/core/Align"; -import {AppMode} from "../../flashbang/core/AppMode"; -import {Flashbang} from "../../flashbang/core/Flashbang"; -import {VLayoutContainer} from "../../flashbang/layout/VLayoutContainer"; -import {ErrorUtil} from "../../flashbang/util/ErrorUtil"; -import {GameButton} from "../ui/GameButton"; -import {GamePanel, GamePanelType} from "../ui/GamePanel"; -import {Fonts} from "../util/Fonts"; +import {Flashbang, HAlign, AppMode} from "flashbang/core"; +import {VLayoutContainer} from "flashbang/layout"; +import {ErrorUtil} from "flashbang/util"; +import {GameButton, GamePanel, GamePanelType} from "eterna/ui"; +import {Fonts} from "eterna/util"; -export class ErrorDialogMode extends AppMode { +export default class ErrorDialogMode extends AppMode { public readonly error: any; public constructor(error: any) { diff --git a/src/eterna/mode/FeedbackView/FeedbackViewMode.ts b/src/eterna/mode/FeedbackView/FeedbackViewMode.ts index fe74fc5e9..e0ff240a7 100644 --- a/src/eterna/mode/FeedbackView/FeedbackViewMode.ts +++ b/src/eterna/mode/FeedbackView/FeedbackViewMode.ts @@ -1,30 +1,24 @@ import * as log from "loglevel"; import {DisplayObject, Point, Text} from "pixi.js"; -import {HAlign, VAlign} from "../../../flashbang/core/Align"; -import {KeyboardEventType} from "../../../flashbang/input/KeyboardEventType"; -import {KeyCode} from "../../../flashbang/input/KeyCode"; -import {DisplayUtil} from "../../../flashbang/util/DisplayUtil"; -import {Constants} from "../../Constants"; -import {EPars} from "../../EPars"; -import {Eterna} from "../../Eterna"; -import {Feedback} from "../../Feedback"; -import {Folder} from "../../folding/Folder"; -import {FolderManager} from "../../folding/FolderManager"; -import {Vienna} from "../../folding/Vienna"; -import {PoseField} from "../../pose2D/PoseField"; -import {Puzzle} from "../../puzzle/Puzzle"; -import {Solution} from "../../puzzle/Solution"; -import {EternaViewOptionsDialog, EternaViewOptionsMode} from "../../ui/EternaViewOptionsDialog"; -import {SpecBoxDialog} from "../../ui/SpecBoxDialog"; -import {URLButton} from "../../ui/URLButton"; -import {UndoBlock} from "../../UndoBlock"; -import {Fonts} from "../../util/Fonts"; -import {Utility} from "../../util/Utility"; -import {Background} from "../../vfx/Background"; -import {GameMode} from "../GameMode"; -import {FeedbackViewToolbar} from "./FeedbackViewToolbar"; - -export class FeedbackViewMode extends GameMode { +import {HAlign, VAlign} from "flashbang/core"; +import {KeyboardEventType, KeyCode} from "flashbang/input"; +import {DisplayUtil} from "flashbang/util"; +import Constants from "eterna/Constants"; +import EPars from "eterna/EPars"; +import Eterna from "eterna/Eterna"; +import Feedback from "eterna/Feedback"; +import UndoBlock from "eterna/UndoBlock"; +import {Folder, FolderManager, Vienna} from "eterna/folding"; +import {PoseField} from "eterna/pose2D"; +import {Puzzle, Solution} from "eterna/puzzle"; +import {EternaViewOptionsDialog, EternaViewOptionsMode, SpecBoxDialog, URLButton} from "eterna/ui"; +import {Fonts} from "eterna/util"; +import {Utility} from "eterna/util"; +import {Background} from "eterna/vfx"; +import {GameMode} from "eterna/mode"; +import {FeedbackViewToolbar} from "."; + +export default class FeedbackViewMode extends GameMode { public constructor(solution: Solution, puzzle: Puzzle) { super(); this._solution = solution; diff --git a/src/eterna/mode/FeedbackView/FeedbackViewToolbar.ts b/src/eterna/mode/FeedbackView/FeedbackViewToolbar.ts index eebdae48a..f0a4942e0 100644 --- a/src/eterna/mode/FeedbackView/FeedbackViewToolbar.ts +++ b/src/eterna/mode/FeedbackView/FeedbackViewToolbar.ts @@ -1,17 +1,15 @@ import {Container, Graphics} from "pixi.js"; -import {HAlign, VAlign} from "../../../flashbang/core/Align"; -import {Flashbang} from "../../../flashbang/core/Flashbang"; -import {KeyCode} from "../../../flashbang/input/KeyCode"; -import {HLayoutContainer} from "../../../flashbang/layout/HLayoutContainer"; -import {ContainerObject} from "../../../flashbang/objects/ContainerObject"; -import {DisplayUtil} from "../../../flashbang/util/DisplayUtil"; -import {Puzzle} from "../../puzzle/Puzzle"; -import {Bitmaps} from "../../resources/Bitmaps"; -import {RScriptUIElementID} from "../../rscript/RScriptUIElement"; -import {GameButton} from "../../ui/GameButton"; -import {ToggleBar} from "../../ui/ToggleBar"; - -export class FeedbackViewToolbar extends ContainerObject { +import {Flashbang, HAlign, VAlign} from "flashbang/core"; +import {KeyCode} from "flashbang/input"; +import {HLayoutContainer} from "flashbang/layout"; +import {ContainerObject} from "flashbang/objects"; +import {DisplayUtil} from "flashbang/util"; +import {Puzzle} from "eterna/puzzle"; +import {Bitmaps} from "eterna/resources"; +import {RScriptUIElementID} from "eterna/rscript"; +import {GameButton, ToggleBar} from "eterna/ui"; + +export default class FeedbackViewToolbar extends ContainerObject { public screenshotButton: GameButton; public zoomOutButton: GameButton; diff --git a/src/eterna/mode/FeedbackView/index.ts b/src/eterna/mode/FeedbackView/index.ts new file mode 100644 index 000000000..4d582c378 --- /dev/null +++ b/src/eterna/mode/FeedbackView/index.ts @@ -0,0 +1,2 @@ +export {default as FeedbackViewMode} from "./FeedbackViewMode"; +export {default as FeedbackViewToolbar} from "./FeedbackViewToolbar";`` \ No newline at end of file diff --git a/src/eterna/mode/GameMode.ts b/src/eterna/mode/GameMode.ts index 9105c3dac..ed1f227f0 100644 --- a/src/eterna/mode/GameMode.ts +++ b/src/eterna/mode/GameMode.ts @@ -1,27 +1,18 @@ import * as log from "loglevel"; import {Container, Point} from "pixi.js"; -import {AppMode} from "../../flashbang/core/AppMode"; -import {Flashbang} from "../../flashbang/core/Flashbang"; -import {GameObjectRef} from "../../flashbang/core/GameObjectRef"; -import {SceneObject} from "../../flashbang/objects/SceneObject"; -import {AchievementManager} from "../achievements/AchievementManager"; -import {Eterna} from "../Eterna"; -import {EternaURL} from "../net/EternaURL"; -import {Pose2D} from "../pose2D/Pose2D"; -import {PoseField} from "../pose2D/PoseField"; -import {ConfirmDialog} from "../ui/ConfirmDialog"; -import {ContextMenu} from "../ui/ContextMenu"; -import {Dialog} from "../ui/Dialog"; -import {NotificationDialog} from "../ui/NotificationDialog"; -import {Tooltips} from "../ui/Tooltips"; -import {UILockDialog} from "../ui/UILockDialog"; -import {URLButton} from "../ui/URLButton"; -import {ExternalInterface, ExternalInterfaceCtx} from "../util/ExternalInterface"; -import {Folder} from "../folding/Folder"; -import {UndoBlock} from "../UndoBlock"; -import {EPars} from "../EPars"; - -export abstract class GameMode extends AppMode { +import {Flashbang, AppMode, GameObjectRef} from "flashbang/core"; +import {SceneObject} from "flashbang/objects"; +import {AchievementManager} from "eterna/achievements"; +import Eterna from "eterna/Eterna"; +import {EternaURL} from "eterna/net"; +import {Pose2D, PoseField} from "eterna/pose2D"; +import {ConfirmDialog, ContextMenu, Dialog, NotificationDialog, Tooltips, UILockDialog, URLButton} from "eterna/ui"; +import {ExternalInterface, ExternalInterfaceCtx} from "eterna/util"; +import {Folder} from "eterna/folding"; +import UndoBlock from "eterna/UndoBlock"; +import EPars from "eterna/EPars"; + +export default abstract class GameMode extends AppMode { public readonly bgLayer = new Container(); public readonly poseLayer = new Container(); public readonly uiLayer = new Container(); diff --git a/src/eterna/mode/LoadingMode.ts b/src/eterna/mode/LoadingMode.ts index d6f97e23e..e396d9e5a 100644 --- a/src/eterna/mode/LoadingMode.ts +++ b/src/eterna/mode/LoadingMode.ts @@ -1,19 +1,14 @@ import {Text} from "pixi.js"; -import {AppMode} from "../../flashbang/core/AppMode"; -import {Flashbang} from "../../flashbang/core/Flashbang"; -import {ObjectTask} from "../../flashbang/core/ObjectTask"; -import {ContainerObject} from "../../flashbang/objects/ContainerObject"; -import {DelayTask} from "../../flashbang/tasks/DelayTask"; -import {RepeatingTask} from "../../flashbang/tasks/RepeatingTask"; -import {ScaleTask} from "../../flashbang/tasks/ScaleTask"; -import {SerialTask} from "../../flashbang/tasks/SerialTask"; -import {Easing} from "../../flashbang/util/Easing"; -import {Eterna} from "../Eterna"; -import {Fonts} from "../util/Fonts"; -import {Background} from "../vfx/Background"; +import {Flashbang, AppMode, ObjectTask} from "flashbang/core"; +import {ContainerObject} from "flashbang/objects"; +import {DelayTask, RepeatingTask, ScaleTask, SerialTask} from "flashbang/tasks"; +import {Easing} from "flashbang/util"; +import Eterna from "eterna/Eterna"; +import {Fonts} from "eterna/util"; +import {Background} from "eterna/vfx"; /** Displays a simple animation while we're loading assets */ -export class LoadingMode extends AppMode { +export default class LoadingMode extends AppMode { public constructor(text: string) { super(); this._text = text; diff --git a/src/eterna/mode/PoseEdit/Booster.ts b/src/eterna/mode/PoseEdit/Booster.ts index a72a629e8..b8d8683be 100644 --- a/src/eterna/mode/PoseEdit/Booster.ts +++ b/src/eterna/mode/PoseEdit/Booster.ts @@ -1,20 +1,20 @@ import * as log from "loglevel"; import {Texture} from "pixi.js"; -import {TextureUtil} from "../../../flashbang/util/TextureUtil"; -import {EPars} from "../../EPars"; -import {Eterna} from "../../Eterna"; -import {Pose2D} from "../../pose2D/Pose2D"; -import {Sounds} from "../../resources/Sounds"; -import {GameButton} from "../../ui/GameButton"; -import {ExternalInterface, ExternalInterfaceCtx} from "../../util/ExternalInterface"; -import {GameMode} from "../GameMode"; +import {TextureUtil} from "flashbang/util"; +import EPars from "eterna/EPars"; +import Eterna from "eterna/Eterna"; +import {Pose2D} from "eterna/pose2D"; +import {Sounds} from "eterna/resources"; +import {GameButton} from "eterna/ui"; +import {ExternalInterface, ExternalInterfaceCtx} from "eterna/util"; +import {GameMode} from "eterna/mode"; export enum BoosterType { PAINTER = 1, ACTION = 2, } -export class Booster { +export default class Booster { public static create(mode: GameMode, data: any): Promise { if (!data["type"]) { return Promise.reject("Invalid booster definition (missing 'type')"); diff --git a/src/eterna/mode/PoseEdit/MissionClearedPanel.ts b/src/eterna/mode/PoseEdit/MissionClearedPanel.ts index 7ad78472a..7110dd8c9 100644 --- a/src/eterna/mode/PoseEdit/MissionClearedPanel.ts +++ b/src/eterna/mode/PoseEdit/MissionClearedPanel.ts @@ -1,21 +1,15 @@ -import { - Container, Graphics, Point, Text -} from "pixi.js"; -import {HAlign, VAlign} from "../../../flashbang/core/Align"; -import {Flashbang} from "../../../flashbang/core/Flashbang"; -import {VLayoutContainer} from "../../../flashbang/layout/VLayoutContainer"; -import {ContainerObject} from "../../../flashbang/objects/ContainerObject"; -import {DOMObject} from "../../../flashbang/objects/DOMObject"; -import {AlphaTask} from "../../../flashbang/tasks/AlphaTask"; -import {DisplayUtil} from "../../../flashbang/util/DisplayUtil"; -import {RankScroll} from "../../rank/RankScroll"; -import {Bitmaps} from "../../resources/Bitmaps"; -import {GameButton} from "../../ui/GameButton"; -import {GamePanel, GamePanelType} from "../../ui/GamePanel"; -import {HTMLTextObject} from "../../ui/HTMLTextObject"; -import {Fonts} from "../../util/Fonts"; - -export class MissionClearedPanel extends ContainerObject { +import {Container, Graphics, Point, Text} from "pixi.js"; +import {Flashbang, HAlign, VAlign} from "flashbang/core"; +import {VLayoutContainer} from "flashbang/layout"; +import {ContainerObject, DOMObject} from "flashbang/objects"; +import {AlphaTask} from "flashbang/tasks"; +import {DisplayUtil} from "flashbang/util"; +import {RankScroll} from "eterna/rank"; +import {Bitmaps} from "eterna/resources"; +import {GameButton, GamePanel, GamePanelType, HTMLTextObject} from "eterna/ui"; +import {Fonts} from "eterna/util"; + +export default class MissionClearedPanel extends ContainerObject { public nextButton: GameButton; public closeButton: GameButton; diff --git a/src/eterna/mode/PoseEdit/MissionIntroMode.ts b/src/eterna/mode/PoseEdit/MissionIntroMode.ts index ad3328d48..af1be5e15 100644 --- a/src/eterna/mode/PoseEdit/MissionIntroMode.ts +++ b/src/eterna/mode/PoseEdit/MissionIntroMode.ts @@ -1,23 +1,14 @@ -import { - Container, Graphics, Point, Sprite -} from "pixi.js"; -import {AppMode} from "../../../flashbang/core/AppMode"; -import {Flashbang} from "../../../flashbang/core/Flashbang"; -import {DisplayObjectPointerTarget} from "../../../flashbang/input/DisplayObjectPointerTarget"; -import {IsLeftMouse} from "../../../flashbang/input/InputUtil"; -import {KeyCode} from "../../../flashbang/input/KeyCode"; -import {DisplayUtil} from "../../../flashbang/util/DisplayUtil"; -import {StyledTextBuilder} from "../../../flashbang/util/StyledTextBuilder"; -import {EPars} from "../../EPars"; -import {Eterna} from "../../Eterna"; -import {Bitmaps} from "../../resources/Bitmaps"; -import {ConstraintBox} from "../../ui/ConstraintBox"; -import {GameButton} from "../../ui/GameButton"; -import {HTMLTextObject} from "../../ui/HTMLTextObject"; -import {PoseThumbnail, PoseThumbnailType} from "../../ui/PoseThumbnail"; -import {Fonts} from "../../util/Fonts"; - -export class MissionIntroMode extends AppMode { +import {Container, Graphics, Point, Sprite} from "pixi.js"; +import {Flashbang, AppMode} from "flashbang/core"; +import {DisplayObjectPointerTarget, InputUtil, KeyCode} from "flashbang/input"; +import {DisplayUtil, StyledTextBuilder} from "flashbang/util"; +import EPars from "eterna/EPars"; +import Eterna from "eterna/Eterna"; +import {Bitmaps} from "eterna/resources"; +import {ConstraintBox, GameButton, HTMLTextObject, PoseThumbnail, PoseThumbnailType} from "eterna/ui"; +import {Fonts} from "eterna/util"; + +export default class MissionIntroMode extends AppMode { public constructor(puzzleName: string, puzzleDescription: string, puzzleThumbnails: number[][], constraintBoxes: ConstraintBox[]) { super(); this._puzzleName = puzzleName; @@ -32,7 +23,7 @@ export class MissionIntroMode extends AppMode { let background = new Graphics(); this.container.addChild(background); - new DisplayObjectPointerTarget(background).pointerDown.filter(IsLeftMouse).connect(() => this.play()); + new DisplayObjectPointerTarget(background).pointerDown.filter(InputUtil.IsLeftMouse).connect(() => this.play()); let moleculeImg = Sprite.fromImage(Bitmaps.MissionBackgroundImage); this.container.addChild(moleculeImg); diff --git a/src/eterna/mode/PoseEdit/PoseEditMode.ts b/src/eterna/mode/PoseEdit/PoseEditMode.ts index 982a4d89d..b9096cb5c 100644 --- a/src/eterna/mode/PoseEdit/PoseEditMode.ts +++ b/src/eterna/mode/PoseEdit/PoseEditMode.ts @@ -1,63 +1,32 @@ import * as log from "loglevel"; import {Container, DisplayObject, Point, Sprite, Text} from "pixi.js"; -import {HAlign, VAlign} from "../../../flashbang/core/Align"; -import {Flashbang} from "../../../flashbang/core/Flashbang"; -import {GameObjectRef} from "../../../flashbang/core/GameObjectRef"; -import {KeyboardEventType} from "../../../flashbang/input/KeyboardEventType"; -import {KeyCode} from "../../../flashbang/input/KeyCode"; -import {SpriteObject} from "../../../flashbang/objects/SpriteObject"; -import {AlphaTask} from "../../../flashbang/tasks/AlphaTask"; -import {SelfDestructTask} from "../../../flashbang/tasks/SelfDestructTask"; -import {SerialTask} from "../../../flashbang/tasks/SerialTask"; -import {Assert} from "../../../flashbang/util/Assert"; -import {DisplayUtil} from "../../../flashbang/util/DisplayUtil"; -import {Easing} from "../../../flashbang/util/Easing"; -import {EPars} from "../../EPars"; -import {Eterna} from "../../Eterna"; -import {Folder} from "../../folding/Folder"; -import {FolderManager} from "../../folding/FolderManager"; -import {FoldUtil} from "../../folding/FoldUtil"; -import {EternaURL} from "../../net/EternaURL"; -import {Oligo, Pose2D} from "../../pose2D/Pose2D"; -import {PoseField} from "../../pose2D/PoseField"; -import {PoseOp} from "../../pose2D/PoseOp"; -import {PuzzleEditOp} from "../../pose2D/PuzzleEditOp"; -import {Constraints, ConstraintType} from "../../puzzle/Constraints"; -import {BoostersData, PoseState, Puzzle, PuzzleType} from "../../puzzle/Puzzle"; -import {PuzzleManager} from "../../puzzle/PuzzleManager"; -import {Solution} from "../../puzzle/Solution"; -import {SolutionManager} from "../../puzzle/SolutionManager"; -import {BitmapManager} from "../../resources/BitmapManager"; -import {Bitmaps} from "../../resources/Bitmaps"; -import {Sounds} from "../../resources/Sounds"; -import {RNAScript} from "../../rscript/RNAScript"; -import {ActionBar} from "../../ui/ActionBar"; -import {ConstraintBox, ConstraintBoxType} from "../../ui/ConstraintBox"; -import {ContextMenu} from "../../ui/ContextMenu"; -import {EternaViewOptionsDialog, EternaViewOptionsMode} from "../../ui/EternaViewOptionsDialog"; -import {GameButton} from "../../ui/GameButton"; -import {GamePanel} from "../../ui/GamePanel"; -import {HTMLTextObject} from "../../ui/HTMLTextObject"; -import {GetPaletteTargetBaseType, PaletteTargetType} from "../../ui/NucleotidePalette"; -import {PasteSequenceDialog} from "../../ui/PasteSequenceDialog"; -import {SpecBox} from "../../ui/SpecBox"; -import {SpecBoxDialog} from "../../ui/SpecBoxDialog"; -import {URLButton} from "../../ui/URLButton"; -import {UndoBlock, UndoBlockParam} from "../../UndoBlock"; -import {ExternalInterface, ExternalInterfaceCtx} from "../../util/ExternalInterface"; -import {Fonts} from "../../util/Fonts"; -import {int} from "../../util/int"; -import {Background} from "../../vfx/Background"; -import {BubbleSweep} from "../../vfx/BubbleSweep"; -import {CopyTextDialogMode} from "../CopyTextDialogMode"; -import {GameMode} from "../GameMode"; -import {PuzzleEditPoseData} from "../PuzzleEdit/PuzzleEditMode"; -import {MissionClearedPanel} from "./MissionClearedPanel"; -import {MissionIntroMode} from "./MissionIntroMode"; -import {PoseEditToolbar} from "./PoseEditToolbar"; -import {SubmitPoseDetails} from "./SubmitPoseDetails"; -import {SubmitPoseDialog} from "./SubmitPoseDialog"; -import {SubmittingDialog} from "./SubmittingDialog"; +import {Flashbang, HAlign, VAlign, GameObjectRef} from "flashbang/core"; +import {KeyboardEventType, KeyCode} from "flashbang/input"; +import {SpriteObject} from "flashbang/objects"; +import {AlphaTask, SelfDestructTask, SerialTask} from "flashbang/tasks"; +import {Assert, DisplayUtil, Easing} from "flashbang/util"; +import EPars from "eterna/EPars"; +import Eterna from "eterna/Eterna"; +import {Folder, FolderManager, FoldUtil} from "eterna/folding"; +import {EternaURL} from "eterna/net"; +import {Oligo, Pose2D, PoseField, PoseOp, PuzzleEditOp} from "eterna/pose2D"; +import { + Constraints, ConstraintType, BoostersData, PoseState, + Puzzle, PuzzleType, PuzzleManager, Solution, SolutionManager +} from "eterna/puzzle"; +import {BitmapManager, Bitmaps, Sounds} from "eterna/resources"; +import {RNAScript} from "eterna/rscript"; +import { + ActionBar, ConstraintBox, ConstraintBoxType, ContextMenu, EternaViewOptionsDialog, EternaViewOptionsMode, + GameButton, GamePanel, HTMLTextObject, GetPaletteTargetBaseType, PaletteTargetType, + PasteSequenceDialog, SpecBox, SpecBoxDialog, URLButton +} from "eterna/ui"; +import {default as UndoBlock, UndoBlockParam} from "eterna/UndoBlock"; +import {ExternalInterface, ExternalInterfaceCtx} from "eterna/util"; +import {Fonts, int} from "eterna/util"; +import {Background, BubbleSweep} from "eterna/vfx"; +import {CopyTextDialogMode, GameMode, PuzzleEditPoseData} from "eterna/mode"; +import {MissionClearedPanel, MissionIntroMode, PoseEditToolbar, SubmitPoseDetails, SubmitPoseDialog, SubmittingDialog} from "."; type InteractionEvent = PIXI.interaction.InteractionEvent; @@ -82,7 +51,7 @@ export interface PoseEditParams { solutions?: Solution[]; } -export class PoseEditMode extends GameMode { +export default class PoseEditMode extends GameMode { public constructor(puzzle: Puzzle, params: PoseEditParams, autosaveData: any[] = null) { super(); this._puzzle = puzzle; diff --git a/src/eterna/mode/PoseEdit/PoseEditToolbar.ts b/src/eterna/mode/PoseEdit/PoseEditToolbar.ts index 582a9db52..4732e8ee3 100644 --- a/src/eterna/mode/PoseEdit/PoseEditToolbar.ts +++ b/src/eterna/mode/PoseEdit/PoseEditToolbar.ts @@ -1,27 +1,21 @@ import {Container, Graphics, Point} from "pixi.js"; -import {HAlign, VAlign} from "../../../flashbang/core/Align"; -import {Flashbang} from "../../../flashbang/core/Flashbang"; -import {KeyCode} from "../../../flashbang/input/KeyCode"; -import {HLayoutContainer} from "../../../flashbang/layout/HLayoutContainer"; -import {ContainerObject} from "../../../flashbang/objects/ContainerObject"; -import {LocationTask} from "../../../flashbang/tasks/LocationTask"; -import {DisplayUtil} from "../../../flashbang/util/DisplayUtil"; -import {Easing} from "../../../flashbang/util/Easing"; -import {RegistrationGroup} from "../../../signals/RegistrationGroup"; -import {Eterna} from "../../Eterna"; -import {BoostersData, Puzzle, PuzzleType} from "../../puzzle/Puzzle"; -import {Bitmaps} from "../../resources/Bitmaps"; -import {RScriptUIElementID} from "../../rscript/RScriptUIElement"; -import {EternaMenu, EternaMenuStyle} from "../../ui/EternaMenu"; -import {GameButton} from "../../ui/GameButton"; -import {NucleotidePalette} from "../../ui/NucleotidePalette"; -import {ToggleBar} from "../../ui/ToggleBar"; -import {ExternalInterfaceCtx} from "../../util/ExternalInterface"; -import {GameMode} from "../GameMode"; -import {Booster} from "./Booster"; -import {PoseEditMode} from "./PoseEditMode"; - -export class PoseEditToolbar extends ContainerObject { +import {Flashbang, HAlign, VAlign} from "flashbang/core"; +import {KeyCode} from "flashbang/input"; +import {HLayoutContainer} from "flashbang/layout"; +import {ContainerObject} from "flashbang/objects"; +import {LocationTask} from "flashbang/tasks"; +import {DisplayUtil, Easing} from "flashbang/util"; +import {RegistrationGroup} from "signals"; +import Eterna from "eterna/Eterna"; +import {BoostersData, Puzzle, PuzzleType} from "eterna/puzzle"; +import {Bitmaps} from "eterna/resources"; +import {RScriptUIElementID} from "eterna/rscript"; +import {EternaMenu, EternaMenuStyle, GameButton, NucleotidePalette, ToggleBar} from "eterna/ui"; +import {ExternalInterfaceCtx} from "eterna/util"; +import {GameMode} from "eterna/mode"; +import {Booster, PoseEditMode} from "."; + +export default class PoseEditToolbar extends ContainerObject { public palette: NucleotidePalette; public nativeButton: GameButton; diff --git a/src/eterna/mode/PoseEdit/SubmitPoseDetails.ts b/src/eterna/mode/PoseEdit/SubmitPoseDetails.ts index 2259dcd27..87501df1c 100644 --- a/src/eterna/mode/PoseEdit/SubmitPoseDetails.ts +++ b/src/eterna/mode/PoseEdit/SubmitPoseDetails.ts @@ -1,4 +1,4 @@ -export interface SubmitPoseDetails { +export default interface SubmitPoseDetails { title: string; comment: string; } diff --git a/src/eterna/mode/PoseEdit/SubmitPoseDialog.ts b/src/eterna/mode/PoseEdit/SubmitPoseDialog.ts index 29bbd8ace..c2509d615 100644 --- a/src/eterna/mode/PoseEdit/SubmitPoseDialog.ts +++ b/src/eterna/mode/PoseEdit/SubmitPoseDialog.ts @@ -1,11 +1,10 @@ -import {Flashbang} from "../../../flashbang/core/Flashbang"; -import {KeyCode} from "../../../flashbang/input/KeyCode"; -import {Dialog} from "../../ui/Dialog"; -import {TextInputPanel} from "../../ui/TextInputPanel"; -import {SubmitPoseDetails} from "./SubmitPoseDetails"; +import {Flashbang} from "flashbang/core"; +import {KeyCode} from "flashbang/input"; +import {Dialog, TextInputPanel} from "eterna/ui"; +import {SubmitPoseDetails} from "."; /** Prompts the player for a title and comment */ -export class SubmitPoseDialog extends Dialog { +export default class SubmitPoseDialog extends Dialog { protected added(): void { super.added(); diff --git a/src/eterna/mode/PoseEdit/SubmittingDialog.ts b/src/eterna/mode/PoseEdit/SubmittingDialog.ts index 10122bdef..9752b809d 100644 --- a/src/eterna/mode/PoseEdit/SubmittingDialog.ts +++ b/src/eterna/mode/PoseEdit/SubmittingDialog.ts @@ -1,13 +1,11 @@ import {Point} from "pixi.js"; -import {Flashbang} from "../../../flashbang/core/Flashbang"; -import {AlphaTask} from "../../../flashbang/tasks/AlphaTask"; -import {RepeatingTask} from "../../../flashbang/tasks/RepeatingTask"; -import {SerialTask} from "../../../flashbang/tasks/SerialTask"; -import {Easing} from "../../../flashbang/util/Easing"; -import {Dialog} from "../../ui/Dialog"; -import {Fonts} from "../../util/Fonts"; +import {Flashbang} from "flashbang/core"; +import {AlphaTask, RepeatingTask, SerialTask} from "flashbang/tasks"; +import {Easing} from "flashbang/util"; +import {Dialog} from "eterna/ui"; +import {Fonts} from "eterna/util"; -export class SubmittingDialog extends Dialog { +export default class SubmittingDialog extends Dialog { protected added(): void { super.added(); diff --git a/src/eterna/mode/PoseEdit/index.ts b/src/eterna/mode/PoseEdit/index.ts new file mode 100644 index 000000000..45c26afc0 --- /dev/null +++ b/src/eterna/mode/PoseEdit/index.ts @@ -0,0 +1,8 @@ +export {default as Booster, BoosterType} from "./Booster"; +export {default as MissionClearedPanel} from "./MissionClearedPanel"; +export {default as MissionIntroMode} from "./MissionIntroMode"; +export {default as PoseEditMode, PuzzleState, PoseEditParams} from "./PoseEditMode"; +export {default as PoseEditToolbar} from "./PoseEditToolbar"; +export {default as SubmitPoseDetails} from "./SubmitPoseDetails"; +export {default as SubmitPoseDialog} from "./SubmitPoseDialog"; +export {default as SubmittingDialog} from "./SubmittingDialog"; \ No newline at end of file diff --git a/src/eterna/mode/PuzzleEdit/PuzzleEditMode.ts b/src/eterna/mode/PuzzleEdit/PuzzleEditMode.ts index 0ad06dc8c..cf64d3073 100644 --- a/src/eterna/mode/PuzzleEdit/PuzzleEditMode.ts +++ b/src/eterna/mode/PuzzleEdit/PuzzleEditMode.ts @@ -1,42 +1,23 @@ import {DisplayObject, Point} from "pixi.js"; -import {HAlign, VAlign} from "../../../flashbang/core/Align"; -import {KeyCode} from "../../../flashbang/input/KeyCode"; -import {Base64} from "../../../flashbang/util/Base64"; -import {DisplayUtil} from "../../../flashbang/util/DisplayUtil"; -import {EPars} from "../../EPars"; -import {Eterna} from "../../Eterna"; -import {Folder} from "../../folding/Folder"; -import {FolderManager} from "../../folding/FolderManager"; -import {NuPACK} from "../../folding/NuPACK"; -import {Vienna} from "../../folding/Vienna"; -import {Vienna2} from "../../folding/Vienna2"; -import {Molecule} from "../../pose2D/Molecule"; -import {Pose2D} from "../../pose2D/Pose2D"; -import {PoseField} from "../../pose2D/PoseField"; -import {PuzzleEditOp} from "../../pose2D/PuzzleEditOp"; -import {ConstraintType} from "../../puzzle/Constraints"; -import {Bitmaps} from "../../resources/Bitmaps"; -import {AsyncProcessDialog} from "../../ui/AsyncProcessDialog"; -import {ConstraintBox} from "../../ui/ConstraintBox"; -import {DialogCanceledError} from "../../ui/Dialog"; -import {EternaViewOptionsDialog, EternaViewOptionsMode} from "../../ui/EternaViewOptionsDialog"; -import {GameButton} from "../../ui/GameButton"; -import {GetPaletteTargetBaseType, PaletteTargetType} from "../../ui/NucleotidePalette"; -import {PasteSequenceDialog} from "../../ui/PasteSequenceDialog"; -import {PoseThumbnail, PoseThumbnailType} from "../../ui/PoseThumbnail"; -import {URLButton} from "../../ui/URLButton"; -import {UndoBlock, UndoBlockParam} from "../../UndoBlock"; -import {ExternalInterfaceCtx} from "../../util/ExternalInterface"; -import {Fonts} from "../../util/Fonts"; -import {Background} from "../../vfx/Background"; -import {BaseGlow} from "../../vfx/BaseGlow"; -import {CopyTextDialogMode} from "../CopyTextDialogMode"; -import {GameMode} from "../GameMode"; -import {PuzzleEditToolbar} from "./PuzzleEditToolbar"; -import {StructureInput} from "./StructureInput"; -import {SubmitPuzzleDetails, SubmitPuzzleDialog} from "./SubmitPuzzleDialog"; -import {LinearFoldC} from "../../folding/LinearFoldC"; -import {LinearFoldV} from "../../folding/LinearFoldV"; +import {HAlign, VAlign} from "flashbang/core"; +import {KeyCode} from "flashbang/input"; +import {Base64, DisplayUtil} from "flashbang/util"; +import EPars from "eterna/EPars"; +import Eterna from "eterna/Eterna"; +import {Folder, FolderManager, LinearFoldC, LinearFoldV, NuPACK, Vienna, Vienna2} from "eterna/folding"; +import {Molecule, Pose2D, PoseField, PuzzleEditOp} from "eterna/pose2D"; +import {ConstraintType} from "eterna/puzzle"; +import {Bitmaps} from "eterna/resources"; +import { + AsyncProcessDialog, ConstraintBox, DialogCanceledError, EternaViewOptionsDialog, EternaViewOptionsMode, + GameButton, GetPaletteTargetBaseType, PaletteTargetType, PasteSequenceDialog, PoseThumbnail, PoseThumbnailType, + URLButton +} from "eterna/ui"; +import {default as UndoBlock, UndoBlockParam} from "eterna/UndoBlock"; +import {ExternalInterfaceCtx, Fonts} from "eterna/util"; +import {Background, BaseGlow} from "eterna/vfx"; +import {CopyTextDialogMode, GameMode} from "eterna/mode"; +import {PuzzleEditToolbar, StructureInput, SubmitPuzzleDialog, SubmitPuzzleDetails} from "."; type InteractionEvent = PIXI.interaction.InteractionEvent; @@ -45,7 +26,7 @@ export interface PuzzleEditPoseData { structure: string; } -export class PuzzleEditMode extends GameMode { +export default class PuzzleEditMode extends GameMode { constructor(embedded: boolean, numTargets?: number, poses?: PuzzleEditPoseData[]) { super(); this._embedded = embedded; diff --git a/src/eterna/mode/PuzzleEdit/PuzzleEditToolbar.ts b/src/eterna/mode/PuzzleEdit/PuzzleEditToolbar.ts index aca9a7610..f7fadfea7 100644 --- a/src/eterna/mode/PuzzleEdit/PuzzleEditToolbar.ts +++ b/src/eterna/mode/PuzzleEdit/PuzzleEditToolbar.ts @@ -1,17 +1,14 @@ import {Graphics} from "pixi.js"; -import {HAlign, VAlign} from "../../../flashbang/core/Align"; -import {Flashbang} from "../../../flashbang/core/Flashbang"; -import {KeyCode} from "../../../flashbang/input/KeyCode"; -import {HLayoutContainer} from "../../../flashbang/layout/HLayoutContainer"; -import {VLayoutContainer} from "../../../flashbang/layout/VLayoutContainer"; -import {ContainerObject} from "../../../flashbang/objects/ContainerObject"; -import {DisplayUtil} from "../../../flashbang/util/DisplayUtil"; -import {Bitmaps} from "../../resources/Bitmaps"; -import {RScriptUIElementID} from "../../rscript/RScriptUIElement"; -import {GameButton} from "../../ui/GameButton"; -import {NucleotidePalette} from "../../ui/NucleotidePalette"; - -export class PuzzleEditToolbar extends ContainerObject { +import {Flashbang, HAlign, VAlign} from "flashbang/core"; +import {KeyCode} from "flashbang/input"; +import {HLayoutContainer, VLayoutContainer} from "flashbang/layout"; +import {ContainerObject} from "flashbang/objects"; +import {DisplayUtil} from "flashbang/util"; +import {Bitmaps} from "eterna/resources"; +import {RScriptUIElementID} from "eterna/rscript"; +import {GameButton, NucleotidePalette} from "eterna/ui"; + +export default class PuzzleEditToolbar extends ContainerObject { public palette: NucleotidePalette; public addbaseButton: GameButton; diff --git a/src/eterna/mode/PuzzleEdit/StructureInput.ts b/src/eterna/mode/PuzzleEdit/StructureInput.ts index 4fc0f09e2..4825bf33a 100644 --- a/src/eterna/mode/PuzzleEdit/StructureInput.ts +++ b/src/eterna/mode/PuzzleEdit/StructureInput.ts @@ -1,16 +1,13 @@ -import {HAlign, VAlign} from "../../../flashbang/core/Align"; -import {Updatable} from "../../../flashbang/core/Updatable"; -import {KeyCode} from "../../../flashbang/input/KeyCode"; -import {DisplayUtil} from "../../../flashbang/util/DisplayUtil"; -import {EPars} from "../../EPars"; -import {Eterna} from "../../Eterna"; -import {Pose2D} from "../../pose2D/Pose2D"; -import {PuzzleEditOp} from "../../pose2D/PuzzleEditOp"; -import {GamePanel} from "../../ui/GamePanel"; -import {TextInputObject} from "../../ui/TextInputObject"; -import {Fonts} from "../../util/Fonts"; -import {TextBalloon} from "../../ui/TextBalloon"; import {Rectangle} from "pixi.js"; +import {HAlign, VAlign, Updatable} from "flashbang/core"; +import {KeyCode} from "flashbang/input"; +import {DisplayUtil} from "flashbang/util"; +import EPars from "eterna/EPars"; +import Eterna from "eterna/Eterna"; +import {Pose2D, PuzzleEditOp} from "eterna/pose2D"; +import {GamePanel, TextInputObject} from "eterna/ui"; +import {Fonts} from "eterna/util"; +import {TextBalloon} from "eterna/ui"; function IsArrowKey(keyCode: string): boolean { return keyCode === KeyCode.ArrowRight @@ -19,7 +16,7 @@ function IsArrowKey(keyCode: string): boolean { || keyCode === KeyCode.ArrowDown; } -export class StructureInput extends GamePanel implements Updatable { +export default class StructureInput extends GamePanel implements Updatable { public constructor(pose: Pose2D) { super(); this._pose = pose; diff --git a/src/eterna/mode/PuzzleEdit/SubmitPuzzleDialog.ts b/src/eterna/mode/PuzzleEdit/SubmitPuzzleDialog.ts index d2734288c..008c76a08 100644 --- a/src/eterna/mode/PuzzleEdit/SubmitPuzzleDialog.ts +++ b/src/eterna/mode/PuzzleEdit/SubmitPuzzleDialog.ts @@ -1,10 +1,9 @@ -import {Flashbang} from "../../../flashbang/core/Flashbang"; -import {KeyCode} from "../../../flashbang/input/KeyCode"; -import {EPars} from "../../EPars"; -import {Dialog, DialogCanceledError} from "../../ui/Dialog"; -import {TextInputPanel} from "../../ui/TextInputPanel"; -import {UndoBlock, UndoBlockParam} from "../../UndoBlock"; -import {GameMode} from "../GameMode"; +import {Flashbang} from "flashbang/core"; +import {KeyCode} from "flashbang/input"; +import EPars from "eterna/EPars"; +import {Dialog, DialogCanceledError, TextInputPanel} from "eterna/ui"; +import {default as UndoBlock, UndoBlockParam} from "eterna/UndoBlock"; +import {GameMode} from "eterna/mode"; export interface SubmitPuzzleDetails { title: string; @@ -15,7 +14,7 @@ export interface SubmitPuzzleDetails { minAU?: number; } -export class SubmitPuzzleDialog extends Dialog { +export default class SubmitPuzzleDialog extends Dialog { public constructor(numPoses: number, puzzleState: UndoBlock) { super(); this._numPoses = numPoses; diff --git a/src/eterna/mode/PuzzleEdit/index.ts b/src/eterna/mode/PuzzleEdit/index.ts new file mode 100644 index 000000000..2a6b6f9f3 --- /dev/null +++ b/src/eterna/mode/PuzzleEdit/index.ts @@ -0,0 +1,4 @@ +export {default as PuzzleEditMode, PuzzleEditPoseData} from "./PuzzleEditMode"; +export {default as PuzzleEditToolbar} from "./PuzzleEditToolbar"; +export {default as StructureInput} from "./StructureInput"; +export {default as SubmitPuzzleDialog, SubmitPuzzleDetails} from "./SubmitPuzzleDialog"; \ No newline at end of file diff --git a/src/eterna/mode/index.ts b/src/eterna/mode/index.ts new file mode 100644 index 000000000..915c445fa --- /dev/null +++ b/src/eterna/mode/index.ts @@ -0,0 +1,8 @@ +export {default as CopyTextDialogMode} from "./CopyTextDialogMode"; +export {default as ErrorDialogMode} from "./ErrorDialogMode"; +export {default as GameMode} from "./GameMode"; +export {default as LoadingMode} from "./LoadingMode"; +export {DesignBrowserMode, DesignBrowserFilter} from "./DesignBrowser"; +export {FeedbackViewMode} from "./FeedbackView"; +export {PoseEditMode, PoseEditParams} from "./PoseEdit"; +export {PuzzleEditMode, PuzzleEditPoseData} from "./PuzzleEdit"; \ No newline at end of file diff --git a/src/eterna/net/EternaURL.ts b/src/eterna/net/EternaURL.ts index 50c75c117..97688d5a5 100644 --- a/src/eterna/net/EternaURL.ts +++ b/src/eterna/net/EternaURL.ts @@ -1,7 +1,7 @@ -import {Eterna} from "../Eterna"; -import {Utility} from "../util/Utility"; +import Eterna from "eterna/Eterna"; +import {Utility} from "eterna/util"; -export class EternaURL { +export default class EternaURL { public static readonly BARCODE_HELP: string = "/web/lab/manual/#barcode"; public static readonly STRATEGY_GUIDE: string = "http://getsatisfaction.com/eternagame/topics/the_strategy_guide_to_solve_eterna_puzzles"; diff --git a/src/eterna/net/GameClient.ts b/src/eterna/net/GameClient.ts index fc9efc330..7f7da04f4 100644 --- a/src/eterna/net/GameClient.ts +++ b/src/eterna/net/GameClient.ts @@ -1,9 +1,9 @@ import * as log from "loglevel"; -import {Base64} from "../../flashbang/util/Base64"; +import {Base64} from "flashbang/util"; type JSONData = any; -export class GameClient { +export default class GameClient { public readonly baseURL: string; public constructor(baseURL: string) { diff --git a/src/eterna/net/index.ts b/src/eterna/net/index.ts new file mode 100644 index 000000000..00ad0da0c --- /dev/null +++ b/src/eterna/net/index.ts @@ -0,0 +1,2 @@ +export {default as EternaURL} from "./EternaURL"; +export {default as GameClient} from "./GameClient"; \ No newline at end of file diff --git a/src/eterna/pose2D/Base.ts b/src/eterna/pose2D/Base.ts index 8a2a37fbb..07c38fa76 100644 --- a/src/eterna/pose2D/Base.ts +++ b/src/eterna/pose2D/Base.ts @@ -1,18 +1,16 @@ import * as log from "loglevel"; import {Point, Sprite, Texture} from "pixi.js"; -import {LateUpdatable} from "../../flashbang/core/LateUpdatable"; -import {ContainerObject} from "../../flashbang/objects/ContainerObject"; -import {Constants} from "../Constants"; -import {EPars} from "../EPars"; -import {Eterna} from "../Eterna"; -import {ROPWait} from "../rscript/ROPWait"; -import {BaseAssets} from "./BaseAssets"; -import {BaseDrawFlags} from "./BaseDrawFlags"; -import {Pose2D, RNAHighlightState} from "./Pose2D"; +import {LateUpdatable} from "flashbang/core"; +import {ContainerObject} from "flashbang/objects"; +import Constants from "eterna/Constants"; +import EPars from "eterna/EPars"; +import Eterna from "eterna/Eterna"; +import {ROPWait} from "eterna/rscript"; +import {BaseAssets, BaseDrawFlags, Pose2D, RNAHighlightState} from "."; type ColorMatrixFilter = PIXI.filters.ColorMatrixFilter; -export class Base extends ContainerObject implements LateUpdatable { +export default class Base extends ContainerObject implements LateUpdatable { public static NUM_ZOOM_LEVELS = 2; public static ZOOM_SCALE_FACTOR = 0.75; diff --git a/src/eterna/pose2D/BaseAssets.ts b/src/eterna/pose2D/BaseAssets.ts index fa2ed9f35..d8a5afaa1 100644 --- a/src/eterna/pose2D/BaseAssets.ts +++ b/src/eterna/pose2D/BaseAssets.ts @@ -1,18 +1,13 @@ import {Container, Graphics, Sprite, Texture} from "pixi.js"; -import {ColorUtil} from "../../flashbang/util/ColorUtil"; -import {TextureUtil} from "../../flashbang/util/TextureUtil"; -import {EPars} from "../EPars"; -import {ExpPainter} from "../ExpPainter"; -import {BitmapManager} from "../resources/BitmapManager"; -import {Bitmaps} from "../resources/Bitmaps"; -import {Sounds} from "../resources/Sounds"; -import {EternaTextureUtil} from "../util/EternaTextureUtil"; -import {Base} from "./Base"; -import {BaseDrawFlags} from "./BaseDrawFlags"; -import {BaseTextures} from "./BaseTextures"; +import {ColorUtil, TextureUtil} from "flashbang/util"; +import EPars from "eterna/EPars"; +import ExpPainter from "eterna/ExpPainter"; +import {BitmapManager, Bitmaps, Sounds} from "eterna/resources"; +import {EternaTextureUtil} from "eterna/util"; +import {Base, BaseDrawFlags, BaseTextures} from "."; /** Handles initialization and management of Base-related assets */ -export class BaseAssets { +export default class BaseAssets { public static getHitTestDistanceThreshold(zoomLevel: number): number { let bitmapWidth: number; diff --git a/src/eterna/pose2D/BaseDrawFlags.ts b/src/eterna/pose2D/BaseDrawFlags.ts index 0646e1e12..8743b35c2 100644 --- a/src/eterna/pose2D/BaseDrawFlags.ts +++ b/src/eterna/pose2D/BaseDrawFlags.ts @@ -1,5 +1,5 @@ /** View state flags for Base.as rendering */ -export class BaseDrawFlags { +export default class BaseDrawFlags { /** If set, the base will have a lock icon on it */ public static LOCKED: number = 1 << 0; diff --git a/src/eterna/pose2D/BaseTextures.ts b/src/eterna/pose2D/BaseTextures.ts index b73d40f89..4244fb504 100644 --- a/src/eterna/pose2D/BaseTextures.ts +++ b/src/eterna/pose2D/BaseTextures.ts @@ -1,14 +1,12 @@ import {Text, Texture} from "pixi.js"; -import {TextureUtil} from "../../flashbang/util/TextureUtil"; -import {EPars} from "../EPars"; -import {BitmapManager} from "../resources/BitmapManager"; -import {EternaTextureUtil} from "../util/EternaTextureUtil"; -import {Fonts} from "../util/Fonts"; -import {Base} from "./Base"; -import {BaseDrawFlags} from "./BaseDrawFlags"; +import {TextureUtil} from "flashbang/util"; +import EPars from "eterna/EPars"; +import {BitmapManager} from "eterna/resources"; +import {EternaTextureUtil, Fonts} from "eterna/util"; +import {Base, BaseDrawFlags} from "."; /** Encapsulates textures for a Base type */ -export class BaseTextures { +export default class BaseTextures { public baseType: number; public letterData: Texture[]; // letters diff --git a/src/eterna/pose2D/EnergyScoreDisplay.ts b/src/eterna/pose2D/EnergyScoreDisplay.ts index df64ea64e..833822976 100644 --- a/src/eterna/pose2D/EnergyScoreDisplay.ts +++ b/src/eterna/pose2D/EnergyScoreDisplay.ts @@ -1,10 +1,10 @@ import MultiStyleText from "pixi-multistyle-text"; import {Container, Graphics, Point} from "pixi.js"; -import {HAlign} from "../../flashbang/core/Align"; -import {VLayoutContainer} from "../../flashbang/layout/VLayoutContainer"; -import {Fonts} from "../util/Fonts"; +import {HAlign} from "flashbang/core"; +import {VLayoutContainer} from "flashbang/layout"; +import {Fonts} from "eterna/util"; -export class EnergyScoreDisplay extends Container { +export default class EnergyScoreDisplay extends Container { public static grey(text: string): string { return `${text}`; } diff --git a/src/eterna/pose2D/ExplosionFactorPanel.ts b/src/eterna/pose2D/ExplosionFactorPanel.ts index e86abf585..4cb38e71e 100644 --- a/src/eterna/pose2D/ExplosionFactorPanel.ts +++ b/src/eterna/pose2D/ExplosionFactorPanel.ts @@ -1,12 +1,10 @@ import {Point, Text} from "pixi.js"; -import {GamePanel} from "../ui/GamePanel"; -import {Signal} from "../../signals/Signal"; -import {GameButton} from "../ui/GameButton"; -import {TextInputObject} from "../ui/TextInputObject"; -import {Fonts} from "../util/Fonts"; -import {KeyCode} from "../../flashbang/input/KeyCode"; - -export class ExplosionFactorPanel extends GamePanel { +import {Signal} from "signals"; +import {KeyCode} from "flashbang/input"; +import {GamePanel, GameButton, TextInputObject} from "eterna/ui"; +import {Fonts} from "eterna/util"; + +export default class ExplosionFactorPanel extends GamePanel { public readonly factorUpdated: Signal = new Signal(); public constructor() { diff --git a/src/eterna/pose2D/HighlightBox.ts b/src/eterna/pose2D/HighlightBox.ts index 801250bc9..2f906e63b 100644 --- a/src/eterna/pose2D/HighlightBox.ts +++ b/src/eterna/pose2D/HighlightBox.ts @@ -1,12 +1,8 @@ import {DisplayObject, Graphics, Point} from "pixi.js"; -import {GameObject} from "../../flashbang/core/GameObject"; -import {LateUpdatable} from "../../flashbang/core/LateUpdatable"; -import {ObjectTask} from "../../flashbang/core/ObjectTask"; -import {Vector2} from "../../flashbang/geom/Vector2"; -import {AlphaTask} from "../../flashbang/tasks/AlphaTask"; -import {RepeatingTask} from "../../flashbang/tasks/RepeatingTask"; -import {SerialTask} from "../../flashbang/tasks/SerialTask"; -import {Pose2D} from "./Pose2D"; +import {GameObject, LateUpdatable, ObjectTask} from "flashbang/core"; +import {Vector2} from "flashbang/geom"; +import {AlphaTask, RepeatingTask, SerialTask} from "flashbang/tasks"; +import {Pose2D} from "."; export enum HighlightType { STACK = 0, @@ -21,7 +17,7 @@ export enum HighlightType { /** A class for highlighting groups of bases in a Pose2D */ -export class HighlightBox extends GameObject implements LateUpdatable { +export default class HighlightBox extends GameObject implements LateUpdatable { public constructor(pose: Pose2D) { super(); this._pose = pose; diff --git a/src/eterna/pose2D/Molecule.ts b/src/eterna/pose2D/Molecule.ts index b2203f77b..5e0fbfaea 100644 --- a/src/eterna/pose2D/Molecule.ts +++ b/src/eterna/pose2D/Molecule.ts @@ -1,10 +1,8 @@ import {Container, Point, Sprite, Texture} from "pixi.js"; -import {BitmapManager} from "../resources/BitmapManager"; -import {Bitmaps} from "../resources/Bitmaps"; -import {EternaTextureUtil} from "../util/EternaTextureUtil"; -import {int} from "../util/int"; +import {BitmapManager, Bitmaps} from "eterna/resources"; +import {EternaTextureUtil, int} from "eterna/util"; -export class Molecule extends Container { +export default class Molecule extends Container { public constructor() { super(); Molecule.initTextures(); diff --git a/src/eterna/pose2D/PaintCursor.ts b/src/eterna/pose2D/PaintCursor.ts index 054bc385f..5f45cce12 100644 --- a/src/eterna/pose2D/PaintCursor.ts +++ b/src/eterna/pose2D/PaintCursor.ts @@ -1,10 +1,8 @@ import {Graphics, DisplayObject} from "pixi.js"; -import {Flashbang} from "../../flashbang/core/Flashbang"; -import {GameObject} from "../../flashbang/core/GameObject"; -import {Updatable} from "../../flashbang/core/Updatable"; -import {EPars} from "../EPars"; +import {Flashbang, GameObject, Updatable} from "flashbang/core"; +import EPars from "eterna/EPars"; -export class PaintCursor extends GameObject implements Updatable { +export default class PaintCursor extends GameObject implements Updatable { public constructor() { super(); this._graphics = new Graphics(); diff --git a/src/eterna/pose2D/Pose2D.ts b/src/eterna/pose2D/Pose2D.ts index 51c2e45cb..5bd75a137 100644 --- a/src/eterna/pose2D/Pose2D.ts +++ b/src/eterna/pose2D/Pose2D.ts @@ -1,56 +1,36 @@ import * as log from "loglevel"; import {Container, Graphics, Point, Sprite, Texture, Rectangle} from "pixi.js"; -import {Flashbang} from "../../flashbang/core/Flashbang"; -import {Updatable} from "../../flashbang/core/Updatable"; -import {Vector2} from "../../flashbang/geom/Vector2"; -import {IsLeftMouse} from "../../flashbang/input/InputUtil"; -import {ContainerObject} from "../../flashbang/objects/ContainerObject"; -import {SceneObject} from "../../flashbang/objects/SceneObject"; -import {AlphaTask} from "../../flashbang/tasks/AlphaTask"; -import {DelayTask} from "../../flashbang/tasks/DelayTask"; -import {LocationTask} from "../../flashbang/tasks/LocationTask"; -import {ParallelTask} from "../../flashbang/tasks/ParallelTask"; -import {RepeatingTask} from "../../flashbang/tasks/RepeatingTask"; -import {SelfDestructTask} from "../../flashbang/tasks/SelfDestructTask"; -import {SerialTask} from "../../flashbang/tasks/SerialTask"; -import {Arrays} from "../../flashbang/util/Arrays"; -import {DisplayUtil} from "../../flashbang/util/DisplayUtil"; -import {Dragger} from "../../flashbang/util/Dragger"; -import {Easing} from "../../flashbang/util/Easing"; -import {Registration} from "../../signals/Registration"; -import {EPars} from "../EPars"; -import {Eterna} from "../Eterna"; -import {ExpPainter} from "../ExpPainter"; -import {Folder} from "../folding/Folder"; -import {GameMode} from "../mode/GameMode"; -import {Booster} from "../mode/PoseEdit/Booster"; -import {BitmapManager} from "../resources/BitmapManager"; -import {Sounds} from "../resources/Sounds"; -import {ROPWait} from "../rscript/ROPWait"; -import {TextBalloon} from "../ui/TextBalloon"; -import {Fonts} from "../util/Fonts"; -import {Utility} from "../util/Utility"; -import {BaseGlow} from "../vfx/BaseGlow"; -import {LightRay} from "../vfx/LightRay"; -import {Base} from "./Base"; -import {BaseDrawFlags} from "./BaseDrawFlags"; -import {EnergyScoreDisplay} from "./EnergyScoreDisplay"; -import {HighlightBox, HighlightType} from "./HighlightBox"; -import {Molecule} from "./Molecule"; -import {PaintCursor} from "./PaintCursor" -import {PoseField} from "./PoseField"; -import {PoseUtil} from "./PoseUtil"; -import {PuzzleEditOp} from "./PuzzleEditOp"; -import {RNAAnchorObject} from "./RNAAnchorObject"; -import {RNALayout, RNATreeNode} from "./RNALayout"; -import {ScoreDisplayNode, ScoreDisplayNodeType} from "./ScoreDisplayNode"; -import {ExplosionFactorPanel} from "./ExplosionFactorPanel"; +import {Flashbang, Updatable} from "flashbang/core"; +import {Vector2} from "flashbang/geom"; +import {InputUtil} from "flashbang/input"; +import {ContainerObject, SceneObject} from "flashbang/objects"; +import { + AlphaTask, DelayTask, LocationTask, ParallelTask, RepeatingTask, SelfDestructTask, SerialTask +} from "flashbang/tasks"; +import {Arrays, DisplayUtil, Dragger, Easing} from "flashbang/util"; +import {Registration} from "signals"; +import EPars from "eterna/EPars"; +import Eterna from "eterna/Eterna"; +import ExpPainter from "eterna/ExpPainter"; +import {Folder} from "eterna/folding"; +import {GameMode} from "eterna/mode"; +import {Booster} from "eterna/mode/PoseEdit"; +import {BitmapManager, Sounds} from "eterna/resources"; +import {ROPWait} from "eterna/rscript"; +import {TextBalloon} from "eterna/ui"; +import {Fonts, Utility} from "eterna/util"; +import {BaseGlow, LightRay} from "eterna/vfx"; +import { + Base, BaseDrawFlags, EnergyScoreDisplay, HighlightBox, HighlightType, Molecule, PaintCursor, + PoseField, PoseUtil, PuzzleEditOp, RNAAnchorObject, RNALayout, RNATreeNode, + ScoreDisplayNode, ScoreDisplayNodeType, ExplosionFactorPanel +} from "."; type InteractionEvent = PIXI.interaction.InteractionEvent; export type PoseMouseDownCallback = (e: InteractionEvent, closest_dist: number, closest_index: number) => void; -export class Pose2D extends ContainerObject implements Updatable { +export default class Pose2D extends ContainerObject implements Updatable { public static readonly COLOR_CURSOR: number = 0xFFC0CB; public static readonly ZOOM_SPACINGS: number[] = [45, 30, 20, 14, 7]; public static readonly BASE_TRACK_THICKNESS: number[] = [5, 4, 3, 2, 2]; @@ -148,7 +128,7 @@ export class Pose2D extends ContainerObject implements Updatable { this.addObject(this._strandLabel, this.container); this.pointerMove.connect(() => this.onMouseMoved()); - this.pointerDown.filter(IsLeftMouse).connect(e => this.callStartMousedownCallback(e)); + this.pointerDown.filter(InputUtil.IsLeftMouse).connect(e => this.callStartMousedownCallback(e)); this.pointerOut.connect(() => this.onMouseOut()); // handle view settings diff --git a/src/eterna/pose2D/PoseField.ts b/src/eterna/pose2D/PoseField.ts index 63d2515d4..71f8ff283 100644 --- a/src/eterna/pose2D/PoseField.ts +++ b/src/eterna/pose2D/PoseField.ts @@ -1,20 +1,15 @@ import {Graphics, Point} from "pixi.js"; -import {Flashbang} from "../../flashbang/core/Flashbang"; -import {GameObjectRef} from "../../flashbang/core/GameObjectRef"; -import {IsLeftMouse} from "../../flashbang/input/InputUtil"; -import {KeyboardEventType} from "../../flashbang/input/KeyboardEventType"; -import {KeyboardListener} from "../../flashbang/input/KeyboardInput"; -import {KeyCode} from "../../flashbang/input/KeyCode"; -import {MouseWheelListener} from "../../flashbang/input/MouseWheelInput"; -import {ContainerObject} from "../../flashbang/objects/ContainerObject"; -import {Dragger} from "../../flashbang/util/Dragger"; -import {ROPWait} from "../rscript/ROPWait"; -import {Pose2D} from "./Pose2D"; +import {Flashbang, GameObjectRef} from "flashbang/core"; +import {InputUtil, KeyboardEventType, KeyboardListener, KeyCode, MouseWheelListener} from "flashbang/input"; +import {ContainerObject} from "flashbang/objects"; +import {Dragger} from "flashbang/util"; +import {ROPWait} from "eterna/rscript"; +import {Pose2D} from "."; type InteractionEvent = PIXI.interaction.InteractionEvent; /** Wraps a Pose2D and handles resizing, masking, and input events */ -export class PoseField extends ContainerObject implements KeyboardListener, MouseWheelListener { +export default class PoseField extends ContainerObject implements KeyboardListener, MouseWheelListener { constructor(edit: boolean) { super(); this._pose = new Pose2D(this, edit); @@ -29,8 +24,8 @@ export class PoseField extends ContainerObject implements KeyboardListener, Mous this.addObject(this._pose, this.container); - this.pointerDown.filter(IsLeftMouse).connect((e) => this.onMouseDown(e)); - this.pointerUp.filter(IsLeftMouse).connect(() => this.onMouseUp()); + this.pointerDown.filter(InputUtil.IsLeftMouse).connect((e) => this.onMouseDown(e)); + this.pointerUp.filter(InputUtil.IsLeftMouse).connect(() => this.onMouseUp()); this.regs.add(this.mode.keyboardInput.pushListener(this)); this.regs.add(this.mode.mouseWheelInput.pushListener(this)); diff --git a/src/eterna/pose2D/PoseOp.ts b/src/eterna/pose2D/PoseOp.ts index dedbedbf4..68a6f5afc 100644 --- a/src/eterna/pose2D/PoseOp.ts +++ b/src/eterna/pose2D/PoseOp.ts @@ -1,4 +1,4 @@ -export class PoseOp { +export default class PoseOp { public sn?: number; public fn: () => void; diff --git a/src/eterna/pose2D/PoseUtil.ts b/src/eterna/pose2D/PoseUtil.ts index 90f779770..d2a5de853 100644 --- a/src/eterna/pose2D/PoseUtil.ts +++ b/src/eterna/pose2D/PoseUtil.ts @@ -1,8 +1,8 @@ -import {EPars} from "../EPars"; -import {PuzzleEditOp} from "./PuzzleEditOp"; +import EPars from "eterna/EPars"; +import {PuzzleEditOp} from "."; /** Utility functions for pose data */ -export class PoseUtil { +export default class PoseUtil { public static getPairStrength(s1: number, s2: number): number { if (PoseUtil.isPair(s1, s2, EPars.RNABASE_ADENINE, EPars.RNABASE_URACIL)) { return 2; diff --git a/src/eterna/pose2D/PuzzleEditOp.ts b/src/eterna/pose2D/PuzzleEditOp.ts index 4e8921d0f..a2ee5ad0d 100644 --- a/src/eterna/pose2D/PuzzleEditOp.ts +++ b/src/eterna/pose2D/PuzzleEditOp.ts @@ -1,7 +1,9 @@ -export enum PuzzleEditOp { +enum PuzzleEditOp { ADD_BASE = "AddBase", ADD_PAIR = "AddPair", ADD_CYCLE = "AddCycle", DELETE_PAIR = "DeletePair", DELETE_BASE = "DeleteBase", } + +export default PuzzleEditOp; diff --git a/src/eterna/pose2D/RNAAnchorObject.ts b/src/eterna/pose2D/RNAAnchorObject.ts index 6b3970b27..8e0353b64 100644 --- a/src/eterna/pose2D/RNAAnchorObject.ts +++ b/src/eterna/pose2D/RNAAnchorObject.ts @@ -1,8 +1,8 @@ import {Point} from "pixi.js" -import {GameObjectRef} from "../../flashbang/core/GameObjectRef"; -import {SceneObject} from "../../flashbang/objects/SceneObject"; +import {GameObjectRef} from "flashbang/core"; +import {SceneObject} from "flashbang/objects"; -export class RNAAnchorObject { +export default class RNAAnchorObject { public ref: GameObjectRef; public base: number; public offset: Point; diff --git a/src/eterna/pose2D/RNALayout.ts b/src/eterna/pose2D/RNALayout.ts index 0bd538c0e..6daaf5258 100644 --- a/src/eterna/pose2D/RNALayout.ts +++ b/src/eterna/pose2D/RNALayout.ts @@ -1,5 +1,5 @@ -import {EPars} from "../EPars"; -import {Folder} from "../folding/Folder"; +import EPars from "eterna/EPars"; +import {Folder} from "eterna/folding"; export class RNATreeNode { public isPair: boolean = false; @@ -17,7 +17,7 @@ export class RNATreeNode { public goY: number = 0; } -export class RNALayout { +export default class RNALayout { public constructor(primSpace: number = 45, pairSpace: number = 45, exceptionIndices: number[] = null) { this._primarySpace = primSpace; this._pairSpace = pairSpace; diff --git a/src/eterna/pose2D/ScoreDisplayNode.ts b/src/eterna/pose2D/ScoreDisplayNode.ts index e4acc5f6b..3c81e6146 100644 --- a/src/eterna/pose2D/ScoreDisplayNode.ts +++ b/src/eterna/pose2D/ScoreDisplayNode.ts @@ -1,11 +1,10 @@ -import {MathUtil} from "../../flashbang/util/MathUtil"; -import {ColorUtil} from "../../flashbang/util/ColorUtil"; +import {MathUtil, ColorUtil} from "flashbang/util"; export enum ScoreDisplayNodeType { STACK = 0, LOOP } -export class ScoreDisplayNode { +export default class ScoreDisplayNode { public get baseIndices(): number[] { return this._baseIndices; } diff --git a/src/eterna/pose2D/index.ts b/src/eterna/pose2D/index.ts new file mode 100644 index 000000000..79994e957 --- /dev/null +++ b/src/eterna/pose2D/index.ts @@ -0,0 +1,17 @@ +export {default as Base} from "./Base"; +export {default as BaseAssets} from "./BaseAssets"; +export {default as BaseDrawFlags} from "./BaseDrawFlags"; +export {default as BaseTextures} from "./BaseTextures"; +export {default as EnergyScoreDisplay} from "./EnergyScoreDisplay"; +export {default as ExplosionFactorPanel} from "./ExplosionFactorPanel"; +export {default as HighlightBox, HighlightType} from "./HighlightBox"; +export {default as Molecule} from "./Molecule"; +export {default as PaintCursor} from "./PaintCursor"; +export {default as Pose2D, PoseMouseDownCallback, Oligo, RNAHighlightState} from "./Pose2D"; +export {default as PoseField} from "./PoseField"; +export {default as PoseOp} from "./PoseOp"; +export {default as PoseUtil} from "./PoseUtil"; +export {default as PuzzleEditOp} from "./PuzzleEditOp"; +export {default as RNAAnchorObject} from "./RNAAnchorObject"; +export {default as RNALayout, RNATreeNode} from "./RNALayout"; +export {default as ScoreDisplayNode, ScoreDisplayNodeType} from "./ScoreDisplayNode"; \ No newline at end of file diff --git a/src/eterna/puzzle/Constraints.ts b/src/eterna/puzzle/Constraints.ts index 3b7db3ab0..16188a486 100644 --- a/src/eterna/puzzle/Constraints.ts +++ b/src/eterna/puzzle/Constraints.ts @@ -39,7 +39,7 @@ export enum ConstraintType { SCRIPT = "SCRIPT", } -export class Constraints { +export default class Constraints { public static count(sequence: number[], type: number): number { let total = 0; for (let value of sequence) { diff --git a/src/eterna/puzzle/Puzzle.ts b/src/eterna/puzzle/Puzzle.ts index 4967ed003..18cd49e0b 100644 --- a/src/eterna/puzzle/Puzzle.ts +++ b/src/eterna/puzzle/Puzzle.ts @@ -1,11 +1,9 @@ -import {Constants} from "../Constants"; -import {EPars} from "../EPars"; -import {FolderManager} from "../folding/FolderManager"; -import {Vienna} from "../folding/Vienna"; -import {EternaURL} from "../net/EternaURL"; -import {Pose2D} from "../pose2D/Pose2D"; -import {ConstraintType} from "./Constraints"; -import {Folder} from "../folding/Folder"; +import Constants from "eterna/Constants"; +import EPars from "eterna/EPars"; +import {Folder, FolderManager, Vienna} from "eterna/folding"; +import {EternaURL} from "eterna/net"; +import {Pose2D} from "eterna/pose2D"; +import {ConstraintType} from "."; export interface BoostersData { mission?: any; @@ -33,7 +31,7 @@ export enum PoseState { SECOND = "SECOND", } -export class Puzzle { +export default class Puzzle { public static isAptamerType(tc_type: string): boolean { return (Puzzle.T_APTAMER.indexOf(tc_type) >= 0); } diff --git a/src/eterna/puzzle/PuzzleManager.ts b/src/eterna/puzzle/PuzzleManager.ts index d43994bfc..05edfe21b 100644 --- a/src/eterna/puzzle/PuzzleManager.ts +++ b/src/eterna/puzzle/PuzzleManager.ts @@ -1,12 +1,10 @@ import * as log from "loglevel"; -import {Eterna} from "../Eterna"; -import {CSVParser} from "../util/CSVParser"; -import {Puzzle} from "./Puzzle"; -import {SolutionManager} from "./SolutionManager"; -import {FolderManager} from "../folding/FolderManager"; -import {Folder} from "../folding/Folder"; - -export class PuzzleManager { +import Eterna from "eterna/Eterna"; +import {CSVParser} from "eterna/util"; +import {Folder, FolderManager} from "../folding"; +import {Puzzle, SolutionManager} from "."; + +export default class PuzzleManager { public static get instance(): PuzzleManager { if (PuzzleManager._instance == null) { PuzzleManager._instance = new PuzzleManager(); diff --git a/src/eterna/puzzle/Solution.ts b/src/eterna/puzzle/Solution.ts index 0bcf89974..8e409014b 100644 --- a/src/eterna/puzzle/Solution.ts +++ b/src/eterna/puzzle/Solution.ts @@ -1,7 +1,7 @@ -import {Eterna} from "../Eterna"; -import {Feedback} from "../Feedback"; +import Eterna from "eterna/Eterna"; +import Feedback from "eterna/Feedback"; -export class Solution { +export default class Solution { public constructor(nid: number, puzzle_nid: number) { this._nid = nid; this._puzzleNid = puzzle_nid; diff --git a/src/eterna/puzzle/SolutionManager.ts b/src/eterna/puzzle/SolutionManager.ts index 8b980304c..c7f28b9c1 100644 --- a/src/eterna/puzzle/SolutionManager.ts +++ b/src/eterna/puzzle/SolutionManager.ts @@ -1,11 +1,11 @@ import * as log from "loglevel"; -import {EPars} from "../EPars"; -import {Eterna} from "../Eterna"; -import {Feedback} from "../Feedback"; -import {CSVParser} from "../util/CSVParser"; -import {Solution} from "./Solution"; +import EPars from "eterna/EPars"; +import Eterna from "eterna/Eterna"; +import Feedback from "eterna/Feedback"; +import {CSVParser} from "eterna/util"; +import {Solution} from "."; -export class SolutionManager { +export default class SolutionManager { public static get instance(): SolutionManager { if (SolutionManager._instance == null) { SolutionManager._instance = new SolutionManager(); diff --git a/src/eterna/puzzle/index.ts b/src/eterna/puzzle/index.ts new file mode 100644 index 000000000..8e7a5d4cc --- /dev/null +++ b/src/eterna/puzzle/index.ts @@ -0,0 +1,5 @@ +export {default as Constraints, ConstraintType} from "./Constraints"; +export {default as Puzzle, BoostersData, PuzzleType, PoseState} from "./Puzzle"; +export {default as PuzzleManager} from "./PuzzleManager"; +export {default as Solution} from "./Solution"; +export {default as SolutionManager} from "./SolutionManager"; \ No newline at end of file diff --git a/src/eterna/rank/PlayerRank.ts b/src/eterna/rank/PlayerRank.ts index 35a0ab429..8f20098de 100644 --- a/src/eterna/rank/PlayerRank.ts +++ b/src/eterna/rank/PlayerRank.ts @@ -1,4 +1,4 @@ -export class PlayerRank { +export default class PlayerRank { public name: string; public score: number; public rank: number; diff --git a/src/eterna/rank/RankBoard.ts b/src/eterna/rank/RankBoard.ts index c26b9fb2f..646704837 100644 --- a/src/eterna/rank/RankBoard.ts +++ b/src/eterna/rank/RankBoard.ts @@ -1,10 +1,9 @@ import {Point} from "pixi.js"; -import {Updatable} from "../../flashbang/core/Updatable"; -import {ContainerObject} from "../../flashbang/objects/ContainerObject"; -import {PlayerRank} from "./PlayerRank"; -import {RankRowLayout} from "./RankRowLayout"; +import {Updatable} from "flashbang/core"; +import {ContainerObject} from "flashbang/objects"; +import {PlayerRank, RankRowLayout} from "."; -export class RankBoard extends ContainerObject implements Updatable { +export default class RankBoard extends ContainerObject implements Updatable { public static readonly ROW_WIDTH = 400; public static readonly ROW_HEIGHT = 20; public static readonly PLAYER_ROW_HEIGHT = 32; diff --git a/src/eterna/rank/RankRowLayout.ts b/src/eterna/rank/RankRowLayout.ts index 8952678cf..a908cd0d6 100644 --- a/src/eterna/rank/RankRowLayout.ts +++ b/src/eterna/rank/RankRowLayout.ts @@ -1,10 +1,10 @@ import {Point, Text} from "pixi.js"; -import {ContainerObject} from "../../flashbang/objects/ContainerObject"; -import {TextUtil} from "../../flashbang/util/TextUtil"; -import {Fonts} from "../util/Fonts"; -import {PlayerRank} from "./PlayerRank"; +import {ContainerObject} from "flashbang/objects"; +import {TextUtil} from "flashbang/util"; +import {Fonts} from "eterna/util"; +import {PlayerRank} from "."; -export class RankRowLayout extends ContainerObject { +export default class RankRowLayout extends ContainerObject { public constructor(rank: number, data: PlayerRank, rankScoreOffset: number, fontSize: number = 18, maxNameWidth: number = -1, textColor: number = 0xFFFFFF) { super(); diff --git a/src/eterna/rank/RankScroll.ts b/src/eterna/rank/RankScroll.ts index 5bd6faa57..9d93fd0a7 100644 --- a/src/eterna/rank/RankScroll.ts +++ b/src/eterna/rank/RankScroll.ts @@ -1,22 +1,16 @@ import {Graphics, Point, Text} from "pixi.js"; -import {ContainerObject} from "../../flashbang/objects/ContainerObject"; -import {AlphaTask} from "../../flashbang/tasks/AlphaTask"; -import {DelayTask} from "../../flashbang/tasks/DelayTask"; -import {InterpolatingTask} from "../../flashbang/tasks/InterpolatingTask"; -import {LocationTask} from "../../flashbang/tasks/LocationTask"; -import {ParallelTask} from "../../flashbang/tasks/ParallelTask"; -import {SerialTask} from "../../flashbang/tasks/SerialTask"; -import {VisibleTask} from "../../flashbang/tasks/VisibleTask"; -import {Easing, EasingFunc} from "../../flashbang/util/Easing"; -import {Eterna} from "../Eterna"; -import {GamePanel} from "../ui/GamePanel"; -import {Fonts} from "../util/Fonts"; -import {VibrateTask} from "../vfx/VibrateTask"; -import {PlayerRank} from "./PlayerRank"; -import {RankBoard} from "./RankBoard"; -import {RankRowLayout} from "./RankRowLayout"; - -export class RankScroll extends ContainerObject { +import {ContainerObject} from "flashbang/objects"; +import { + AlphaTask, DelayTask, InterpolatingTask, LocationTask, ParallelTask, SerialTask, VisibleTask +} from "flashbang/tasks"; +import {Easing, EasingFunc} from "flashbang/util"; +import Eterna from "eterna/Eterna"; +import {GamePanel} from "eterna/ui"; +import {Fonts} from "eterna/util"; +import {VibrateTask} from "eterna/vfx"; +import {PlayerRank, RankBoard, RankRowLayout} from "."; + +export default class RankScroll extends ContainerObject { public static hasRankScrollData(submissionRsp: any): boolean { return (submissionRsp["pointsrank-before"] != null && submissionRsp["pointsrank-after"] != null); } diff --git a/src/eterna/rank/index.ts b/src/eterna/rank/index.ts new file mode 100644 index 000000000..2623ae8b3 --- /dev/null +++ b/src/eterna/rank/index.ts @@ -0,0 +1,4 @@ +export {default as PlayerRank} from "./PlayerRank"; +export {default as RankBoard} from "./RankBoard"; +export {default as RankRowLayout} from "./RankRowLayout"; +export {default as RankScroll} from "./RankScroll"; \ No newline at end of file diff --git a/src/eterna/resources/BitmapManager.ts b/src/eterna/resources/BitmapManager.ts index 997d43aa4..672d9a3e4 100644 --- a/src/eterna/resources/BitmapManager.ts +++ b/src/eterna/resources/BitmapManager.ts @@ -1,11 +1,9 @@ import {Texture} from "pixi.js"; -import {Assert} from "../../flashbang/util/Assert"; -import {TextBuilder} from "../../flashbang/util/TextBuilder"; -import {TextureUtil} from "../../flashbang/util/TextureUtil"; -import {Fonts} from "../util/Fonts"; -import {Bitmaps} from "./Bitmaps"; +import {Assert, TextBuilder, TextureUtil} from "flashbang/util"; +import {Fonts} from "eterna/util"; +import {Bitmaps} from "."; -export class BitmapManager { +export default class BitmapManager { public static getBitmap(url: string): Texture { return Texture.fromImage(url); } diff --git a/src/eterna/resources/Bitmaps.ts b/src/eterna/resources/Bitmaps.ts index 8f07d1aab..d7e9d2d0f 100644 --- a/src/eterna/resources/Bitmaps.ts +++ b/src/eterna/resources/Bitmaps.ts @@ -1,6 +1,6 @@ /* eslint-disable max-len, global-require */ -export class Bitmaps { +export default class Bitmaps { public static readonly NovaAMissionReq: string = require("assets/NOVA/Mission/a-box.png"); public static readonly NovaAReq: string = require("assets/NOVA/Constraints/a-requirement-box.png"); public static readonly NovaARowMissionReq: string = require("assets/NOVA/Mission/a-row-box.png"); diff --git a/src/eterna/resources/PlaySoundTask.ts b/src/eterna/resources/PlaySoundTask.ts index 8bd4735c0..af8455aa6 100644 --- a/src/eterna/resources/PlaySoundTask.ts +++ b/src/eterna/resources/PlaySoundTask.ts @@ -1,7 +1,7 @@ -import {ObjectTask} from "../../flashbang/core/ObjectTask"; -import {Eterna} from "../Eterna"; +import {ObjectTask} from "flashbang/core"; +import Eterna from "eterna/Eterna"; -export class PlaySoundTask extends ObjectTask { +export default class PlaySoundTask extends ObjectTask { public constructor(name: string) { super(); this._soundName = name; diff --git a/src/eterna/resources/SoundManager.ts b/src/eterna/resources/SoundManager.ts index d8289e4a5..b3822e81e 100644 --- a/src/eterna/resources/SoundManager.ts +++ b/src/eterna/resources/SoundManager.ts @@ -1,10 +1,10 @@ import * as log from "loglevel"; import "pixi-sound"; -import {RegistrationGroup} from "../../signals/RegistrationGroup"; -import {Eterna} from "../Eterna"; -import {EternaSettings} from "../settings/EternaSettings"; +import {RegistrationGroup} from "signals"; +import Eterna from "eterna/Eterna"; +import {EternaSettings} from "eterna/settings"; -export class SoundManager { +export default class SoundManager { public constructor(settings: EternaSettings) { this._settings = settings; diff --git a/src/eterna/resources/Sounds.ts b/src/eterna/resources/Sounds.ts index c3d26e0f6..7dd5aa9d0 100644 --- a/src/eterna/resources/Sounds.ts +++ b/src/eterna/resources/Sounds.ts @@ -1,6 +1,6 @@ /* eslint-disable max-len, global-require */ -export class Sounds { +export default class Sounds { public static readonly SoundSwitch: string = require("assets/Sounds/1-TextBubble-Click-A.mp3"); public static readonly SoundButtonClick: string = require("assets/Sounds/1-TextBubble-Click-C.mp3"); public static readonly SoundAllConditions: string = require("assets/Sounds/11-Flag.mp3"); diff --git a/src/eterna/resources/index.ts b/src/eterna/resources/index.ts new file mode 100644 index 000000000..6444fd4b8 --- /dev/null +++ b/src/eterna/resources/index.ts @@ -0,0 +1,5 @@ +export {default as BitmapManager} from "./BitmapManager"; +export {default as Bitmaps} from "./Bitmaps"; +export {default as PlaySoundTask} from "./PlaySoundTask"; +export {default as SoundManager} from "./SoundManager"; +export {default as Sounds} from "./Sounds"; \ No newline at end of file diff --git a/src/eterna/rscript/NovaPaintHint.ts b/src/eterna/rscript/NovaPaintHint.ts index d4668ac12..9df97305c 100644 --- a/src/eterna/rscript/NovaPaintHint.ts +++ b/src/eterna/rscript/NovaPaintHint.ts @@ -1,12 +1,12 @@ import {Point, Sprite, Texture} from "pixi.js"; -import {Updatable} from "../../flashbang/core/Updatable"; -import {Vector2} from "../../flashbang/geom/Vector2"; -import {ContainerObject} from "../../flashbang/objects/ContainerObject"; -import {Pose2D} from "../pose2D/Pose2D"; -import {BitmapManager} from "../resources/BitmapManager"; -import {Bitmaps} from "../resources/Bitmaps"; - -export class NovaPaintHint extends ContainerObject implements Updatable { +import {Updatable} from "flashbang/core"; +import {Vector2} from "flashbang/geom"; +import {ContainerObject} from "flashbang/objects"; +import {Pose2D} from "eterna/pose2D"; +import {BitmapManager} from "eterna/resources"; +import {Bitmaps} from "eterna/resources"; + +export default class NovaPaintHint extends ContainerObject implements Updatable { constructor(start: Point, end: Point, loop: boolean) { super(); this._active = false; diff --git a/src/eterna/rscript/RNAScript.ts b/src/eterna/rscript/RNAScript.ts index 31e53f353..685799c9e 100644 --- a/src/eterna/rscript/RNAScript.ts +++ b/src/eterna/rscript/RNAScript.ts @@ -1,17 +1,11 @@ -import {PoseEditMode} from "../mode/PoseEdit/PoseEditMode"; -import {Puzzle} from "../puzzle/Puzzle"; -import {ROPHighlight, ROPHighlightMode} from "./ROPHighlight"; -import {ROPHint} from "./ROPHint"; -import {ROPPre} from "./ROPPre"; -import {ROPRNA, ROPRNAType} from "./ROPRNA"; -import {ROPTextbox, ROPTextboxMode} from "./ROPTextbox"; -import {ROPUI} from "./ROPUI"; -import {ROPWait, ROPWaitType} from "./ROPWait"; -import {RScriptEnv} from "./RScriptEnv"; -import {RScriptOp} from "./RScriptOp"; -import {RScriptOpTree} from "./RScriptOpTree"; - -export class RNAScript { +import {PoseEditMode} from "eterna/mode"; +import {Puzzle} from "eterna/puzzle"; +import { + ROPHighlight, ROPHighlightMode, ROPHint, ROPPre, ROPRNA, ROPRNAType, ROPTextbox, ROPTextboxMode, + ROPUI, ROPWait, ROPWaitType, RScriptEnv, RScriptOp, RScriptOpTree +} from "."; + +export default class RNAScript { public constructor(puz: Puzzle, ui: PoseEditMode) { let strData: string = puz.rscript; diff --git a/src/eterna/rscript/ROPHighlight.ts b/src/eterna/rscript/ROPHighlight.ts index 6109ed595..c0423590e 100644 --- a/src/eterna/rscript/ROPHighlight.ts +++ b/src/eterna/rscript/ROPHighlight.ts @@ -1,25 +1,19 @@ import * as log from "loglevel"; import {Graphics, Point} from "pixi.js"; -import {GameObject} from "../../flashbang/core/GameObject"; -import {SceneObject} from "../../flashbang/objects/SceneObject"; -import {AlphaTask} from "../../flashbang/tasks/AlphaTask"; -import {RepeatingTask} from "../../flashbang/tasks/RepeatingTask"; -import {SerialTask} from "../../flashbang/tasks/SerialTask"; -import {Easing} from "../../flashbang/util/Easing"; -import {RNAHighlightState} from "../pose2D/Pose2D"; -import {ConstraintBox} from "../ui/ConstraintBox"; -import {EternaMenu} from "../ui/EternaMenu"; -import {ColorUtil} from "../../flashbang/util/ColorUtil"; -import {RScriptEnv} from "./RScriptEnv"; -import {RScriptOp} from "./RScriptOp"; -import {GetRScriptUIElementBounds, RScriptUIElement, RScriptUIElementID} from "./RScriptUIElement"; +import {GameObject} from "flashbang/core"; +import {SceneObject} from "flashbang/objects"; +import {AlphaTask, RepeatingTask, SerialTask} from "flashbang/tasks"; +import {ColorUtil, Easing} from "flashbang/util"; +import {RNAHighlightState} from "eterna/pose2D"; +import {ConstraintBox, EternaMenu} from "eterna/ui"; +import {RScriptEnv, RScriptOp, GetRScriptUIElementBounds, RScriptUIElement, RScriptUIElementID} from "."; export enum ROPHighlightMode { RNA = "RNA", UI = "UI" } -export class ROPHighlight extends RScriptOp { +export default class ROPHighlight extends RScriptOp { public static readonly ID_POSTFIX = "_highlight_"; public constructor(isVisible: boolean, inMode: ROPHighlightMode, env: RScriptEnv) { diff --git a/src/eterna/rscript/ROPHint.ts b/src/eterna/rscript/ROPHint.ts index 4217fd7f3..ab4ee79a3 100644 --- a/src/eterna/rscript/ROPHint.ts +++ b/src/eterna/rscript/ROPHint.ts @@ -1,9 +1,7 @@ import {Point} from "pixi.js"; -import {NovaPaintHint} from "./NovaPaintHint"; -import {RScriptEnv} from "./RScriptEnv"; -import {RScriptOp} from "./RScriptOp"; +import {NovaPaintHint, RScriptEnv, RScriptOp} from "."; -export class ROPHint extends RScriptOp { +export default class ROPHint extends RScriptOp { public constructor(isVisible: boolean, env: RScriptEnv) { super(env); this._opVisible = isVisible; diff --git a/src/eterna/rscript/ROPPre.ts b/src/eterna/rscript/ROPPre.ts index b1928b881..fca2a81cf 100644 --- a/src/eterna/rscript/ROPPre.ts +++ b/src/eterna/rscript/ROPPre.ts @@ -1,8 +1,7 @@ -import {PoseState} from "../puzzle/Puzzle"; -import {RScriptEnv} from "./RScriptEnv"; -import {RScriptOp} from "./RScriptOp"; +import {PoseState} from "eterna/puzzle"; +import {RScriptEnv, RScriptOp} from "."; -export class ROPPre extends RScriptOp { +export default class ROPPre extends RScriptOp { constructor(command: string, env: RScriptEnv) { super(env); this._type = null; diff --git a/src/eterna/rscript/ROPRNA.ts b/src/eterna/rscript/ROPRNA.ts index 804bd00d0..b4169aabd 100644 --- a/src/eterna/rscript/ROPRNA.ts +++ b/src/eterna/rscript/ROPRNA.ts @@ -1,8 +1,6 @@ -import {MathUtil} from "../../flashbang/util/MathUtil"; -import {PoseEditMode} from "../mode/PoseEdit/PoseEditMode"; -import {StringToPaletteTargetType} from "../ui/NucleotidePalette"; -import {RScriptEnv} from "./RScriptEnv"; -import {RScriptOp} from "./RScriptOp"; +import {MathUtil} from "flashbang/util"; +import {StringToPaletteTargetType} from "eterna/ui"; +import {RScriptEnv, RScriptOp} from "."; export enum ROPRNAType { SETBASE = "SETBASE", @@ -14,7 +12,7 @@ export enum ROPRNAType { SETPIP = "SETPIP", } -export class ROPRNA extends RScriptOp { +export default class ROPRNA extends RScriptOp { constructor(type: ROPRNAType, env: RScriptEnv) { super(env); this._type = type; diff --git a/src/eterna/rscript/ROPTextbox.ts b/src/eterna/rscript/ROPTextbox.ts index 69b8aa470..501e8da6a 100644 --- a/src/eterna/rscript/ROPTextbox.ts +++ b/src/eterna/rscript/ROPTextbox.ts @@ -1,19 +1,13 @@ import * as log from "loglevel"; import {ExtendedTextStyle} from "pixi-multistyle-text"; import {Point} from "pixi.js"; -import {Flashbang} from "../../flashbang/core/Flashbang"; -import {GameObject} from "../../flashbang/core/GameObject"; -import {Vector2} from "../../flashbang/geom/Vector2"; -import {ContainerObject} from "../../flashbang/objects/ContainerObject"; -import {StyledTextBuilder} from "../../flashbang/util/StyledTextBuilder"; -import {RNAAnchorObject} from "../pose2D/RNAAnchorObject"; -import {FancyTextBalloon} from "../ui/FancyTextBalloon"; -import {ColorUtil} from "../../flashbang/util/ColorUtil"; -import {Fonts} from "../util/Fonts"; -import {ROPWait} from "./ROPWait"; -import {RScriptArrow} from "./RScriptArrow"; -import {RScriptEnv} from "./RScriptEnv"; -import {RScriptOp} from "./RScriptOp"; +import {Flashbang, GameObject} from "flashbang/core"; +import {Vector2} from "flashbang/geom"; +import {ColorUtil, StyledTextBuilder} from "flashbang/util"; +import {RNAAnchorObject} from "eterna/pose2D"; +import {FancyTextBalloon} from "eterna/ui"; +import {Fonts} from "eterna/util"; +import {ROPWait, RScriptArrow, RScriptEnv, RScriptOp} from "."; export enum ROPTextboxMode { TEXTBOX_LOCATION = "TEXTBOX_LOCATION", @@ -24,7 +18,7 @@ export enum ROPTextboxMode { ARROW_DEFAULT = "ARROW_DEFAULT", } -export class ROPTextbox extends RScriptOp { +export default class ROPTextbox extends RScriptOp { public static readonly ID_POSTFIX = "_textbox_"; public constructor(env: RScriptEnv, show: boolean, mode: ROPTextboxMode) { diff --git a/src/eterna/rscript/ROPUI.ts b/src/eterna/rscript/ROPUI.ts index bfb8b906d..80c9c4abc 100644 --- a/src/eterna/rscript/ROPUI.ts +++ b/src/eterna/rscript/ROPUI.ts @@ -1,7 +1,6 @@ -import {RScriptOp} from "./RScriptOp"; -import {RScriptEnv} from "./RScriptEnv"; +import {RScriptOp, RScriptEnv} from "."; -export class ROPUI extends RScriptOp { +export default class ROPUI extends RScriptOp { constructor(env: RScriptEnv, isVisible: boolean, isDisabled: boolean) { super(env); this._visible = isVisible; diff --git a/src/eterna/rscript/ROPWait.ts b/src/eterna/rscript/ROPWait.ts index a4cc0addb..abf01dd06 100644 --- a/src/eterna/rscript/ROPWait.ts +++ b/src/eterna/rscript/ROPWait.ts @@ -1,7 +1,4 @@ -import {ROPTextbox} from "./ROPTextbox"; -import {RScriptEnv} from "./RScriptEnv"; -import {RScriptOp} from "./RScriptOp"; -import {RScriptUIElementID} from "./RScriptUIElement"; +import {ROPTextbox, RScriptEnv, RScriptOp, RScriptUIElementID} from "."; export enum ROPWaitType { MOVECAMERA = "MOVECAMERA", @@ -16,7 +13,7 @@ export enum ROPWaitType { BLUEMARK = "BLUEMARK", // 'magic glue' } -export class ROPWait extends RScriptOp { +export default class ROPWait extends RScriptOp { public static clearRopWait(): void { ROPWait._allROPWaitOps = new Map(); } diff --git a/src/eterna/rscript/RScriptArrow.ts b/src/eterna/rscript/RScriptArrow.ts index 7ac3a274b..bf5af434b 100644 --- a/src/eterna/rscript/RScriptArrow.ts +++ b/src/eterna/rscript/RScriptArrow.ts @@ -1,9 +1,9 @@ -import {SceneObject} from "../../flashbang/objects/SceneObject"; import {Graphics} from "pixi.js"; -import {MathUtil} from "../../flashbang/util/MathUtil"; -import {GraphicsUtil} from "../util/GraphicsUtil"; +import {SceneObject} from "flashbang/objects"; +import {MathUtil} from "flashbang/util"; +import {GraphicsUtil} from "eterna/util"; -export class RScriptArrow extends SceneObject { +export default class RScriptArrow extends SceneObject { public constructor(triSize: number = 75, baseLength: number = 60, outlineColor: number = 0xDAE8F6, fillColor: number = 0xDAE8F6) { let graphics = new Graphics(); super(graphics); diff --git a/src/eterna/rscript/RScriptEnv.ts b/src/eterna/rscript/RScriptEnv.ts index 6ebd760db..50cc8c76e 100644 --- a/src/eterna/rscript/RScriptEnv.ts +++ b/src/eterna/rscript/RScriptEnv.ts @@ -1,22 +1,19 @@ import * as log from "loglevel"; import {Container, DisplayObject} from "pixi.js"; -import {GameObject} from "../../flashbang/core/GameObject"; -import {ContainerObject} from "../../flashbang/objects/ContainerObject"; -import {Enableable} from "../../flashbang/objects/Enableable"; -import {EPars} from "../EPars"; -import {PoseEditMode} from "../mode/PoseEdit/PoseEditMode"; -import {Pose2D, RNAHighlightState} from "../pose2D/Pose2D"; -import {Puzzle} from "../puzzle/Puzzle"; -import {PaletteTargetType} from "../ui/NucleotidePalette"; -import {TextBalloon} from "../ui/TextBalloon"; -import {ToggleBar} from "../ui/ToggleBar"; -import {RScriptUIElement, RScriptUIElementID} from "./RScriptUIElement"; +import {GameObject} from "flashbang/core"; +import {ContainerObject, Enableable} from "flashbang/objects"; +import EPars from "eterna/EPars"; +import {PoseEditMode} from "eterna/mode"; +import {Pose2D, RNAHighlightState} from "eterna/pose2D"; +import {Puzzle} from "eterna/puzzle"; +import {PaletteTargetType, TextBalloon, ToggleBar} from "eterna/ui"; +import {RScriptUIElement, RScriptUIElementID} from "."; /** * RScript Environment. * Can take care of variables and scope and such. */ -export class RScriptEnv extends ContainerObject { +export default class RScriptEnv extends ContainerObject { public static convertNucleotideStringToInt(s: string): number { return EPars.stringToNucleotide(s, true, false); } diff --git a/src/eterna/rscript/RScriptOp.ts b/src/eterna/rscript/RScriptOp.ts index ea983bca5..263d461ed 100644 --- a/src/eterna/rscript/RScriptOp.ts +++ b/src/eterna/rscript/RScriptOp.ts @@ -1,11 +1,11 @@ -import {RScriptEnv} from "./RScriptEnv"; +import {RScriptEnv} from "."; /** * RScript Operation. * One instruction in RScript. * A node in RScriptOpTree. */ -export abstract class RScriptOp { +export default abstract class RScriptOp { protected constructor(env: RScriptEnv) { this._children = []; this._env = env; diff --git a/src/eterna/rscript/RScriptOpTree.ts b/src/eterna/rscript/RScriptOpTree.ts index 8974d2fd4..7e8c8b38a 100644 --- a/src/eterna/rscript/RScriptOpTree.ts +++ b/src/eterna/rscript/RScriptOpTree.ts @@ -1,5 +1,4 @@ -import {ROPWait} from "./ROPWait"; -import {RScriptOp} from "./RScriptOp"; +import {ROPWait, RScriptOp} from "."; /* * RScript Operation Tree. @@ -7,7 +6,7 @@ import {RScriptOp} from "./RScriptOp"; * :: Note - Use a tree so that we can support if conditionals easily in the near future. * :: Note - Only one entry point. */ -export class RScriptOpTree { +export default class RScriptOpTree { public addNode(node: RScriptOp): void { if (!node) { return; diff --git a/src/eterna/rscript/RScriptUIElement.ts b/src/eterna/rscript/RScriptUIElement.ts index 5e73c8493..29c28f8b1 100644 --- a/src/eterna/rscript/RScriptUIElement.ts +++ b/src/eterna/rscript/RScriptUIElement.ts @@ -1,6 +1,6 @@ import {DisplayObject, Rectangle} from "pixi.js"; -import {GameObject} from "../../flashbang/core/GameObject"; -import {DisplayUtil} from "../../flashbang/util/DisplayUtil"; +import {GameObject} from "flashbang/core"; +import {DisplayUtil} from "flashbang/util"; export type RScriptUIElement = GameObject | DisplayObject | Rectangle; diff --git a/src/eterna/rscript/index.ts b/src/eterna/rscript/index.ts new file mode 100644 index 000000000..65770fa22 --- /dev/null +++ b/src/eterna/rscript/index.ts @@ -0,0 +1,14 @@ +export {default as RScriptOp} from "./RScriptOp"; +export {default as NovaPaintHint} from "./NovaPaintHint"; +export {default as RNAScript} from "./RNAScript"; +export {default as ROPHighlight, ROPHighlightMode} from "./ROPHighlight"; +export {default as ROPHint} from "./ROPHint"; +export {default as ROPPre} from "./ROPPre"; +export {default as ROPRNA, ROPRNAType} from "./ROPRNA"; +export {default as ROPTextbox, ROPTextboxMode} from "./ROPTextbox"; +export {default as ROPUI} from "./ROPUI"; +export {default as ROPWait, ROPWaitType} from "./ROPWait"; +export {default as RScriptArrow} from "./RScriptArrow"; +export {default as RScriptEnv, RScriptVarType} from "./RScriptEnv"; +export {default as RScriptOpTree} from "./RScriptOpTree"; +export {RScriptUIElement, GetRScriptUIElementBounds, RScriptUIElementID} from "./RScriptUIElement"; \ No newline at end of file diff --git a/src/eterna/settings/EternaSettings.ts b/src/eterna/settings/EternaSettings.ts index b265d0c79..c798fec67 100644 --- a/src/eterna/settings/EternaSettings.ts +++ b/src/eterna/settings/EternaSettings.ts @@ -1,9 +1,8 @@ -import {Setting} from "../../flashbang/settings/Setting"; -import {Settings} from "../../flashbang/settings/Settings"; -import {DesignCategory} from "../mode/DesignBrowser/DesignBrowserMode"; -import {Eterna} from "../Eterna"; +import {Setting, Settings} from "flashbang/settings"; +import {DesignCategory} from "eterna/mode/DesignBrowser"; +import Eterna from "eterna/Eterna"; -export class EternaSettings extends Settings { +export default class EternaSettings extends Settings { public readonly showChat: Setting; public readonly showNumbers: Setting; public readonly showLetters: Setting; diff --git a/src/eterna/settings/index.ts b/src/eterna/settings/index.ts new file mode 100644 index 000000000..c458bb6ca --- /dev/null +++ b/src/eterna/settings/index.ts @@ -0,0 +1 @@ +export {default as EternaSettings} from "./EternaSettings"; \ No newline at end of file diff --git a/src/eterna/ui/ActionBar.ts b/src/eterna/ui/ActionBar.ts index 8e6770c75..ada237f07 100644 --- a/src/eterna/ui/ActionBar.ts +++ b/src/eterna/ui/ActionBar.ts @@ -1,9 +1,8 @@ import {Graphics, Point} from "pixi.js"; -import {ContainerObject} from "../../flashbang/objects/ContainerObject"; -import {SceneObject} from "../../flashbang/objects/SceneObject"; -import {DisplayUtil} from "../../flashbang/util/DisplayUtil"; +import {ContainerObject, SceneObject} from "flashbang/objects"; +import {DisplayUtil} from "flashbang/util"; -export class ActionBar extends ContainerObject { +export default class ActionBar extends ContainerObject { public constructor(height: number = 0) { super(); diff --git a/src/eterna/ui/AsyncProcessDialog.ts b/src/eterna/ui/AsyncProcessDialog.ts index 7acb42f18..469067c80 100644 --- a/src/eterna/ui/AsyncProcessDialog.ts +++ b/src/eterna/ui/AsyncProcessDialog.ts @@ -1,14 +1,12 @@ import {Point} from "pixi.js"; -import {Flashbang} from "../../flashbang/core/Flashbang"; -import {AlphaTask} from "../../flashbang/tasks/AlphaTask"; -import {RepeatingTask} from "../../flashbang/tasks/RepeatingTask"; -import {SerialTask} from "../../flashbang/tasks/SerialTask"; -import {Easing} from "../../flashbang/util/Easing"; -import {Fonts} from "../util/Fonts"; -import {Dialog} from "./Dialog"; +import {Flashbang} from "flashbang/core"; +import {AlphaTask, RepeatingTask, SerialTask} from "flashbang/tasks"; +import {Easing} from "flashbang/util"; +import {Fonts} from "eterna/util"; +import {Dialog} from "."; /** Dims the screen and shows a notification text that fades in and out */ -export class AsyncProcessDialog extends Dialog { +export default class AsyncProcessDialog extends Dialog { public constructor(text: string) { super(); this._text = text; diff --git a/src/eterna/ui/Band.ts b/src/eterna/ui/Band.ts index c63cdad01..1f8d02541 100644 --- a/src/eterna/ui/Band.ts +++ b/src/eterna/ui/Band.ts @@ -1,18 +1,13 @@ -import { - Graphics, Matrix, Point, Sprite, Text, Texture -} from "pixi.js"; -import {Updatable} from "../../flashbang/core/Updatable"; -import {ContainerObject} from "../../flashbang/objects/ContainerObject"; -import {MathUtil} from "../../flashbang/util/MathUtil"; -import {TextureUtil} from "../../flashbang/util/TextureUtil"; -import {BitmapManager} from "../resources/BitmapManager"; -import {Bitmaps} from "../resources/Bitmaps"; -import {ColorUtil} from "../../flashbang/util/ColorUtil"; -import {Fonts} from "../util/Fonts"; +import {Graphics, Matrix, Point, Sprite, Text, Texture} from "pixi.js"; +import {Updatable} from "flashbang/core"; +import {ContainerObject} from "flashbang/objects"; +import {ColorUtil, MathUtil, TextureUtil} from "flashbang/util"; +import {BitmapManager, Bitmaps} from "eterna/resources"; +import {Fonts} from "eterna/util"; type ColorMatrixFilter = PIXI.filters.ColorMatrixFilter; -export class Band extends ContainerObject implements Updatable { +export default class Band extends ContainerObject implements Updatable { constructor(farDist: number, closeDist: number, strength: number) { super(); diff --git a/src/eterna/ui/BaseGamePanel.ts b/src/eterna/ui/BaseGamePanel.ts index 290be4829..384e07651 100644 --- a/src/eterna/ui/BaseGamePanel.ts +++ b/src/eterna/ui/BaseGamePanel.ts @@ -1,6 +1,6 @@ -import {ContainerObject} from "../../flashbang/objects/ContainerObject"; +import {ContainerObject} from "flashbang/objects"; -export abstract class BaseGamePanel extends ContainerObject { +export default abstract class BaseGamePanel extends ContainerObject { public abstract setSize(width: number, height: number): void; public abstract set title(title: string); public abstract get titleHeight(): number diff --git a/src/eterna/ui/ConfirmDialog.ts b/src/eterna/ui/ConfirmDialog.ts index 127aa822e..b0171d604 100644 --- a/src/eterna/ui/ConfirmDialog.ts +++ b/src/eterna/ui/ConfirmDialog.ts @@ -1,16 +1,11 @@ import {Point} from "pixi.js"; -import {HAlign} from "../../flashbang/core/Align"; -import {Flashbang} from "../../flashbang/core/Flashbang"; -import {HLayoutContainer} from "../../flashbang/layout/HLayoutContainer"; -import {VLayoutContainer} from "../../flashbang/layout/VLayoutContainer"; -import {AlphaTask} from "../../flashbang/tasks/AlphaTask"; -import {Fonts} from "../util/Fonts"; -import {Dialog, DialogCanceledError} from "./Dialog"; -import {GameButton} from "./GameButton"; -import {GamePanel, GamePanelType} from "./GamePanel"; -import {HTMLTextObject} from "./HTMLTextObject"; +import {Flashbang, HAlign} from "flashbang/core"; +import {HLayoutContainer, VLayoutContainer} from "flashbang/layout"; +import {AlphaTask} from "flashbang/tasks"; +import {Fonts} from "eterna/util"; +import {Dialog, DialogCanceledError, GameButton,GamePanel, GamePanelType, HTMLTextObject } from "."; -export class ConfirmDialog extends Dialog { +export default class ConfirmDialog extends Dialog { public constructor(prompt: string, promptIsHTML: boolean = false) { super(); this._prompt = prompt; diff --git a/src/eterna/ui/ConstraintBox.ts b/src/eterna/ui/ConstraintBox.ts index 0325c85ad..f53609672 100644 --- a/src/eterna/ui/ConstraintBox.ts +++ b/src/eterna/ui/ConstraintBox.ts @@ -1,38 +1,22 @@ import MultiStyleText from "pixi-multistyle-text"; -import { - Container, Graphics, Point, Sprite, Text, Texture -} from "pixi.js"; -import {HAlign, VAlign} from "../../flashbang/core/Align"; -import {ContainerObject} from "../../flashbang/objects/ContainerObject"; -import {Enableable} from "../../flashbang/objects/Enableable"; -import {SceneObject} from "../../flashbang/objects/SceneObject"; -import {AlphaTask} from "../../flashbang/tasks/AlphaTask"; -import {DelayTask} from "../../flashbang/tasks/DelayTask"; -import {LocationTask} from "../../flashbang/tasks/LocationTask"; -import {ParallelTask} from "../../flashbang/tasks/ParallelTask"; -import {ScaleTask} from "../../flashbang/tasks/ScaleTask"; -import {SerialTask} from "../../flashbang/tasks/SerialTask"; -import {VisibleTask} from "../../flashbang/tasks/VisibleTask"; -import {DisplayUtil} from "../../flashbang/util/DisplayUtil"; -import {Easing} from "../../flashbang/util/Easing"; -import {StyledTextBuilder} from "../../flashbang/util/StyledTextBuilder"; -import {TextureUtil} from "../../flashbang/util/TextureUtil"; -import {RegistrationGroup} from "../../signals/RegistrationGroup"; -import {EPars} from "../EPars"; -import {ConstraintType} from "../puzzle/Constraints"; -import {BitmapManager} from "../resources/BitmapManager"; -import {Bitmaps} from "../resources/Bitmaps"; -import {Fonts} from "../util/Fonts"; -import {Band} from "./Band"; -import {PoseThumbnail, PoseThumbnailType} from "./PoseThumbnail"; -import {TextBalloon} from "./TextBalloon"; +import {Container, Graphics, Point, Sprite, Text, Texture} from "pixi.js"; +import {HAlign, VAlign} from "flashbang/core"; +import {ContainerObject, Enableable, SceneObject} from "flashbang/objects"; +import {AlphaTask, DelayTask, LocationTask, ParallelTask, ScaleTask, SerialTask, VisibleTask} from "flashbang/tasks"; +import {DisplayUtil, Easing, StyledTextBuilder, TextureUtil} from "flashbang/util"; +import {RegistrationGroup} from "signals"; +import EPars from "eterna/EPars"; +import {ConstraintType} from "eterna/puzzle"; +import {BitmapManager, Bitmaps} from "eterna/resources"; +import {Fonts} from "eterna/util"; +import {Band, PoseThumbnail, PoseThumbnailType, TextBalloon} from "."; export enum ConstraintBoxType { DEFAULT = "DEFAULT", MISSION_SCREEN = "MISSION_SCREEN" // slightly minimized, requirements text on the right } -export class ConstraintBox extends ContainerObject implements Enableable { +export default class ConstraintBox extends ContainerObject implements Enableable { public constructor(type: ConstraintBoxType = ConstraintBoxType.DEFAULT) { super(); diff --git a/src/eterna/ui/ContextMenu.ts b/src/eterna/ui/ContextMenu.ts index 18e435c4f..b361466bd 100644 --- a/src/eterna/ui/ContextMenu.ts +++ b/src/eterna/ui/ContextMenu.ts @@ -1,11 +1,10 @@ -import {HAlign} from "../../flashbang/core/Align"; -import {VLayoutContainer} from "../../flashbang/layout/VLayoutContainer"; -import {ContainerObject} from "../../flashbang/objects/ContainerObject"; -import {UnitSignal} from "../../signals/UnitSignal"; -import {GameButton} from "./GameButton"; -import {GamePanel, GamePanelType} from "./GamePanel"; - -export class ContextMenu extends ContainerObject { +import {HAlign} from "flashbang/core"; +import {VLayoutContainer} from "flashbang/layout"; +import {ContainerObject} from "flashbang/objects"; +import {UnitSignal} from "signals"; +import {GameButton, GamePanel, GamePanelType} from "."; + +export default class ContextMenu extends ContainerObject { /** Emitted when the user interacts with the menu. */ public readonly menuItemSelected = new UnitSignal(); diff --git a/src/eterna/ui/Dialog.ts b/src/eterna/ui/Dialog.ts index f23108a5c..6238ff2ad 100644 --- a/src/eterna/ui/Dialog.ts +++ b/src/eterna/ui/Dialog.ts @@ -1,16 +1,13 @@ import {Graphics} from "pixi.js"; -import {Flashbang} from "../../flashbang/core/Flashbang"; -import {IsLeftMouse} from "../../flashbang/input/InputUtil"; -import {KeyboardListener} from "../../flashbang/input/KeyboardInput"; -import {MouseWheelListener} from "../../flashbang/input/MouseWheelInput"; -import {ContainerObject} from "../../flashbang/objects/ContainerObject"; -import {DisplayObjectPointerTarget} from "../../flashbang/input/DisplayObjectPointerTarget"; +import {Flashbang} from "flashbang/core"; +import {InputUtil, KeyboardListener, MouseWheelListener, DisplayObjectPointerTarget} from "flashbang/input"; +import {ContainerObject} from "flashbang/objects"; /** Dialogs that expose a "confirmed" promise will reject with this error if the dialog is canceled */ export class DialogCanceledError extends Error {} /** Convenience base class for dialog objects. */ -export abstract class Dialog extends ContainerObject implements KeyboardListener, MouseWheelListener { +export default abstract class Dialog extends ContainerObject implements KeyboardListener, MouseWheelListener { /** A Promise that will resolve when the dialog is closed. */ public readonly closed: Promise; @@ -31,7 +28,7 @@ export abstract class Dialog extends ContainerObject implements KeyboardListe let bgTarget = new DisplayObjectPointerTarget(bg); bgTarget.pointerDown.connect((e) => { - if (IsLeftMouse(e)) { + if (InputUtil.IsLeftMouse(e)) { this.onBGClicked(); } e.stopPropagation(); diff --git a/src/eterna/ui/EternaMenu.ts b/src/eterna/ui/EternaMenu.ts index 1646f5d78..39d2cdfa5 100644 --- a/src/eterna/ui/EternaMenu.ts +++ b/src/eterna/ui/EternaMenu.ts @@ -1,15 +1,14 @@ import {Point} from "pixi.js"; -import {Enableable} from "../../flashbang/objects/Enableable"; -import {DisplayUtil} from "../../flashbang/util/DisplayUtil"; -import {GameButton} from "./GameButton"; -import {GamePanel, GamePanelType} from "./GamePanel"; -import {PointerCapture} from "../../flashbang/input/PointerCapture"; +import {PointerCapture} from "flashbang/input"; +import {Enableable} from "flashbang/objects"; +import {DisplayUtil} from "flashbang/util"; +import {GameButton, GamePanel, GamePanelType} from "."; export enum EternaMenuStyle { DEFAULT = 0, PULLUP } -export class EternaMenu extends GamePanel implements Enableable { +export default class EternaMenu extends GamePanel implements Enableable { public constructor(menu_style: EternaMenuStyle = EternaMenuStyle.DEFAULT) { super(); this._style = menu_style; diff --git a/src/eterna/ui/EternaViewOptionsDialog.ts b/src/eterna/ui/EternaViewOptionsDialog.ts index cc463c200..754edda8e 100644 --- a/src/eterna/ui/EternaViewOptionsDialog.ts +++ b/src/eterna/ui/EternaViewOptionsDialog.ts @@ -1,21 +1,17 @@ import {Point} from "pixi.js"; -import {HAlign, VAlign} from "../../flashbang/core/Align"; -import {HLayoutContainer} from "../../flashbang/layout/HLayoutContainer"; -import {VLayoutContainer} from "../../flashbang/layout/VLayoutContainer"; -import {Setting} from "../../flashbang/settings/Setting"; -import {DisplayUtil} from "../../flashbang/util/DisplayUtil"; -import {Eterna} from "../Eterna"; -import {Bitmaps} from "../resources/Bitmaps"; -import {Dialog} from "./Dialog"; -import {GameButton} from "./GameButton"; -import {GameCheckbox} from "./GameCheckbox"; -import {GamePanel, GamePanelType} from "./GamePanel"; +import {HAlign, VAlign} from "flashbang/core"; +import {HLayoutContainer, VLayoutContainer} from "flashbang/layout"; +import {Setting} from "flashbang/settings"; +import {DisplayUtil} from "flashbang/util"; +import Eterna from "eterna/Eterna"; +import {Bitmaps} from "eterna/resources"; +import {Dialog, GameButton, GameCheckbox, GamePanel, GamePanelType} from "."; export enum EternaViewOptionsMode { PUZZLE = 0, PUZZLEMAKER, LAB } -export class EternaViewOptionsDialog extends Dialog { +export default class EternaViewOptionsDialog extends Dialog { public constructor(mode: EternaViewOptionsMode) { super(); this._optionsMode = mode; diff --git a/src/eterna/ui/FancyGamePanel.ts b/src/eterna/ui/FancyGamePanel.ts index 5ae6fc707..fea54c1a8 100644 --- a/src/eterna/ui/FancyGamePanel.ts +++ b/src/eterna/ui/FancyGamePanel.ts @@ -1,12 +1,12 @@ import {Graphics, Point, Text} from "pixi.js"; -import {Fonts} from "../util/Fonts"; -import {BaseGamePanel} from "./BaseGamePanel"; +import {Fonts} from "eterna/util"; +import {BaseGamePanel} from "."; export enum FancyGamePanelType { NORMAL, INVISIBLE, NEW_NOVA } -export class FancyGamePanel extends BaseGamePanel { +export default class FancyGamePanel extends BaseGamePanel { constructor(type: FancyGamePanelType = FancyGamePanelType.NORMAL, alpha: number = 0.07, color: number = 0xffffff, outlineColor: number = 0xffffff, outlineAlpha: number = 0.2) { super(); diff --git a/src/eterna/ui/FancyTextBalloon.ts b/src/eterna/ui/FancyTextBalloon.ts index c1222ced1..ecb86eaa4 100644 --- a/src/eterna/ui/FancyTextBalloon.ts +++ b/src/eterna/ui/FancyTextBalloon.ts @@ -1,15 +1,12 @@ import {Point} from "pixi.js"; -import {HAlign, VAlign} from "../../flashbang/core/Align"; -import {Updatable} from "../../flashbang/core/Updatable"; -import {Vector2} from "../../flashbang/geom/Vector2"; -import {DisplayUtil} from "../../flashbang/util/DisplayUtil"; -import {Bitmaps} from "../resources/Bitmaps"; -import {RScriptArrow} from "../rscript/RScriptArrow"; -import {FancyGamePanel} from "./FancyGamePanel"; -import {GameButton} from "./GameButton"; -import {TextBalloon} from "./TextBalloon"; - -export class FancyTextBalloon extends TextBalloon implements Updatable { +import {HAlign, VAlign, Updatable} from "flashbang/core"; +import {Vector2} from "flashbang/geom"; +import {DisplayUtil} from "flashbang/util"; +import {Bitmaps} from "eterna/resources"; +import {RScriptArrow} from "eterna/rscript"; +import {FancyGamePanel, GameButton, TextBalloon} from "."; + +export default class FancyTextBalloon extends TextBalloon implements Updatable { public constructor(balloonColor: number = 0xFFFFFF, balloonAlpha: number = 0.07, showOutline: boolean = false, outlineColor: number = 0xFFFFFF, outlineAlpha: number = 0.70) { diff --git a/src/eterna/ui/FixedWidthTextField.ts b/src/eterna/ui/FixedWidthTextField.ts index 6e1730bc1..21ee582b6 100644 --- a/src/eterna/ui/FixedWidthTextField.ts +++ b/src/eterna/ui/FixedWidthTextField.ts @@ -1,9 +1,7 @@ -import { - Container, Graphics, Text, TextStyle -} from "pixi.js"; -import {HAlign} from "../../flashbang/core/Align"; +import {Container, Graphics, Text, TextStyle} from "pixi.js"; +import {HAlign} from "flashbang/core"; -export class FixedWidthTextField extends Container { +export default class FixedWidthTextField extends Container { public constructor(text: string, style: TextStyle, width: number, hAlign: HAlign = HAlign.LEFT) { super(); diff --git a/src/eterna/ui/GameButton.ts b/src/eterna/ui/GameButton.ts index 5dd9fad44..a612b88fe 100644 --- a/src/eterna/ui/GameButton.ts +++ b/src/eterna/ui/GameButton.ts @@ -1,21 +1,14 @@ -import { - Container, DisplayObject, Graphics, Point, Rectangle, Sprite, Text, Texture -} from "pixi.js"; -import {HAlign, VAlign} from "../../flashbang/core/Align"; -import {KeyboardEventType} from "../../flashbang/input/KeyboardEventType"; -import {KeyboardListener} from "../../flashbang/input/KeyboardInput"; -import {Button, ButtonState} from "../../flashbang/objects/Button"; -import {DisplayUtil} from "../../flashbang/util/DisplayUtil"; -import {TextBuilder} from "../../flashbang/util/TextBuilder"; -import {Registration} from "../../signals/Registration"; -import {Registrations} from "../../signals/Registrations"; -import {Value} from "../../signals/Value"; -import {ROPWait} from "../rscript/ROPWait"; -import {RScriptUIElementID} from "../rscript/RScriptUIElement"; -import {Fonts} from "../util/Fonts"; -import {Tooltips} from "./Tooltips"; - -export class GameButton extends Button implements KeyboardListener { +import {Container, DisplayObject, Graphics, Point, Rectangle, Sprite, Text, Texture} from "pixi.js"; +import {HAlign, VAlign} from "flashbang/core"; +import {KeyboardEventType, KeyboardListener} from "flashbang/input"; +import {Button, ButtonState} from "flashbang/objects"; +import {DisplayUtil, TextBuilder} from "flashbang/util"; +import {Registration, Registrations, Value} from "signals" +import {ROPWait, RScriptUIElementID} from "eterna/rscript"; +import {Fonts} from "eterna/util"; +import {Tooltips} from "."; + +export default class GameButton extends Button implements KeyboardListener { public readonly toggled: Value = new Value(false); public constructor() { diff --git a/src/eterna/ui/GameCheckbox.ts b/src/eterna/ui/GameCheckbox.ts index 9d0d30b87..2f22f0bb4 100644 --- a/src/eterna/ui/GameCheckbox.ts +++ b/src/eterna/ui/GameCheckbox.ts @@ -1,11 +1,10 @@ import {Graphics} from "pixi.js"; -import {HAlign, VAlign} from "../../flashbang/core/Align"; -import {ButtonState} from "../../flashbang/objects/Button"; -import {ToggleButton} from "../../flashbang/objects/ToggleButton"; -import {DisplayUtil} from "../../flashbang/util/DisplayUtil"; -import {Fonts} from "../util/Fonts"; +import {HAlign, VAlign} from "flashbang/core"; +import {ButtonState, ToggleButton} from "flashbang/objects"; +import {DisplayUtil} from "flashbang/util"; +import {Fonts} from "eterna/util"; -export class GameCheckbox extends ToggleButton { +export default class GameCheckbox extends ToggleButton { constructor(size: number, txt: string) { super(); diff --git a/src/eterna/ui/GamePanel.ts b/src/eterna/ui/GamePanel.ts index 86f60c9da..f7e499581 100644 --- a/src/eterna/ui/GamePanel.ts +++ b/src/eterna/ui/GamePanel.ts @@ -1,14 +1,12 @@ -import { - Graphics, Point, Text, Rectangle -} from "pixi.js"; -import {Fonts} from "../util/Fonts"; -import {BaseGamePanel} from "./BaseGamePanel"; +import {Graphics, Point, Text, Rectangle} from "pixi.js"; +import {Fonts} from "eterna/util"; +import {BaseGamePanel} from "."; export enum GamePanelType { NORMAL, INVISIBLE } -export class GamePanel extends BaseGamePanel { +export default class GamePanel extends BaseGamePanel { public constructor(type: GamePanelType = GamePanelType.NORMAL, alpha: number = 0.07, color: number = 0xffffff, borderAlpha: number = 0.0, borderColor: number = 0) { super(); diff --git a/src/eterna/ui/HTMLTextObject.ts b/src/eterna/ui/HTMLTextObject.ts index 9660b741d..e159f3abc 100644 --- a/src/eterna/ui/HTMLTextObject.ts +++ b/src/eterna/ui/HTMLTextObject.ts @@ -1,8 +1,8 @@ -import {DOMObject} from "../../flashbang/objects/DOMObject"; -import {Eterna} from "../Eterna"; +import {DOMObject} from "flashbang/objects"; +import Eterna from "eterna/Eterna"; /** A

object in the DOM that contains the given HTML. Floats on top of the PIXI canvas. */ -export class HTMLTextObject extends DOMObject { +export default class HTMLTextObject extends DOMObject { public constructor(htmlText: string, width?: number) { super(Eterna.OVERLAY_DIV_ID, document.createElement("p")); this._obj.innerHTML = htmlText; diff --git a/src/eterna/ui/NotificationDialog.ts b/src/eterna/ui/NotificationDialog.ts index a281f73d9..dd70e6f72 100644 --- a/src/eterna/ui/NotificationDialog.ts +++ b/src/eterna/ui/NotificationDialog.ts @@ -1,11 +1,9 @@ import {Point} from "pixi.js"; -import {Flashbang} from "../../flashbang/core/Flashbang"; -import {HLayoutContainer} from "../../flashbang/layout/HLayoutContainer"; -import {Dialog} from "./Dialog"; -import {GameButton} from "./GameButton"; -import {TextBalloon} from "./TextBalloon"; +import {Flashbang} from "flashbang/core"; +import {HLayoutContainer} from "flashbang/layout"; +import {Dialog, GameButton, TextBalloon} from "."; -export class NotificationDialog extends Dialog { +export default class NotificationDialog extends Dialog { /** Non-null if extraButtonTitle is specified */ public extraButton: GameButton; diff --git a/src/eterna/ui/NucleotidePalette.ts b/src/eterna/ui/NucleotidePalette.ts index acedeb74c..81e89838c 100644 --- a/src/eterna/ui/NucleotidePalette.ts +++ b/src/eterna/ui/NucleotidePalette.ts @@ -1,21 +1,13 @@ -import { - Point, Rectangle, Sprite, Text, Texture -} from "pixi.js"; -import {IsLeftMouse} from "../../flashbang/input/InputUtil"; -import {KeyboardEventType} from "../../flashbang/input/KeyboardEventType"; -import {KeyboardListener} from "../../flashbang/input/KeyboardInput"; -import {KeyCode} from "../../flashbang/input/KeyCode"; -import {ContainerObject} from "../../flashbang/objects/ContainerObject"; -import {Enableable} from "../../flashbang/objects/Enableable"; -import {StyledTextBuilder} from "../../flashbang/util/StyledTextBuilder"; -import {Signal} from "../../signals/Signal"; -import {EPars} from "../EPars"; -import {BitmapManager} from "../resources/BitmapManager"; -import {Bitmaps} from "../resources/Bitmaps"; -import {ROPWait} from "../rscript/ROPWait"; -import {RScriptUIElementID} from "../rscript/RScriptUIElement"; -import {Fonts} from "../util/Fonts"; -import {Tooltips} from "./Tooltips"; +import {Point, Rectangle, Sprite, Text, Texture} from "pixi.js"; +import {InputUtil, KeyboardEventType, KeyboardListener, KeyCode} from "flashbang/input"; +import {ContainerObject, Enableable} from "flashbang/objects"; +import {StyledTextBuilder} from "flashbang/util"; +import {Signal} from "signals"; +import EPars from "eterna/EPars"; +import {BitmapManager, Bitmaps} from "eterna/resources"; +import {ROPWait, RScriptUIElementID} from "eterna/rscript"; +import {Fonts} from "eterna/util"; +import {Tooltips} from "."; type InteractionEvent = PIXI.interaction.InteractionEvent; @@ -52,7 +44,7 @@ export function StringToPaletteTargetType(value: string): PaletteTargetType { * Nucleotide palette class. Handles the AUCG nucleotides options as well as the pairs. * Has the option to turn into a 'no pair' mode. */ -export class NucleotidePalette extends ContainerObject implements KeyboardListener, Enableable { +export default class NucleotidePalette extends ContainerObject implements KeyboardListener, Enableable { /** Emitted when a palette target is clicked */ public readonly targetClicked: Signal = new Signal(); @@ -134,7 +126,7 @@ export class NucleotidePalette extends ContainerObject implements KeyboardListen protected added(): void { super.added(); - this.regs.add(this.pointerDown.filter(IsLeftMouse).connect(e => this.onClick(e))); + this.regs.add(this.pointerDown.filter(InputUtil.IsLeftMouse).connect(e => this.onClick(e))); this.regs.add(this.pointerMove.connect(e => this.onMoveMouse(e))); this.regs.add(this.mode.keyboardInput.pushListener(this)); } diff --git a/src/eterna/ui/PasteSequenceDialog.ts b/src/eterna/ui/PasteSequenceDialog.ts index d3af56285..e5e710a8a 100644 --- a/src/eterna/ui/PasteSequenceDialog.ts +++ b/src/eterna/ui/PasteSequenceDialog.ts @@ -1,14 +1,13 @@ -import {Flashbang} from "../../flashbang/core/Flashbang"; -import {KeyCode} from "../../flashbang/input/KeyCode"; -import {GameMode} from "../mode/GameMode"; -import {Dialog} from "./Dialog"; -import {TextInputPanel} from "./TextInputPanel"; +import {Flashbang} from "flashbang/core"; +import {KeyCode} from "flashbang/input"; +import {GameMode} from "eterna/mode"; +import {Dialog, TextInputPanel} from "."; /** * Prompts the user to paste a sequence. * If OK is pressed, the dialog will be closed with the sequence string. */ -export class PasteSequenceDialog extends Dialog { +export default class PasteSequenceDialog extends Dialog { protected added(): void { super.added(); diff --git a/src/eterna/ui/PoseThumbnail.ts b/src/eterna/ui/PoseThumbnail.ts index 47d8506f3..f4de93845 100644 --- a/src/eterna/ui/PoseThumbnail.ts +++ b/src/eterna/ui/PoseThumbnail.ts @@ -1,13 +1,10 @@ -import { - Container, DisplayObject, Graphics, Sprite, Texture -} from "pixi.js"; -import {DisplayUtil} from "../../flashbang/util/DisplayUtil"; -import {TextureUtil} from "../../flashbang/util/TextureUtil"; -import {Constants} from "../Constants"; -import {EPars} from "../EPars"; -import {ExpPainter} from "../ExpPainter"; -import {RNALayout} from "../pose2D/RNALayout"; -import {Bitmaps} from "../resources/Bitmaps"; +import {Container, DisplayObject, Graphics, Sprite, Texture} from "pixi.js"; +import {DisplayUtil, TextureUtil} from "flashbang/util"; +import Constants from "eterna/Constants"; +import EPars from "eterna/EPars"; +import ExpPainter from "eterna/ExpPainter"; +import {RNALayout} from "eterna/pose2D"; +import {Bitmaps} from "eterna/resources"; export enum PoseThumbnailType { BASE_COLORED = "BASE_COLORED", @@ -16,7 +13,7 @@ export enum PoseThumbnailType { WRONG_COLORED = "WRONG_COLORED", } -export class PoseThumbnail { +export default class PoseThumbnail { public static createFramedBitmap(sequence: number[], pairs: number[], size: number = 1, type: PoseThumbnailType = PoseThumbnailType.BASE_COLORED, exp_start_index: number = 0, wrong_pairs: number[] = null, exp_use_threshold: boolean = false, exp_threshold: number = 0): Texture { let disp: DisplayObject = PoseThumbnail.create(sequence, pairs, size, type, exp_start_index, wrong_pairs, exp_use_threshold, exp_threshold); return TextureUtil.renderToTexture(disp); diff --git a/src/eterna/ui/ScrollContainer.ts b/src/eterna/ui/ScrollContainer.ts index b32085263..309642ea6 100644 --- a/src/eterna/ui/ScrollContainer.ts +++ b/src/eterna/ui/ScrollContainer.ts @@ -1,7 +1,7 @@ import {Container, Graphics} from "pixi.js"; -import {MathUtil} from "../../flashbang/util/MathUtil"; +import {MathUtil} from "flashbang/util"; -export class ScrollContainer extends Container { +export default class ScrollContainer extends Container { public readonly content = new Container(); public constructor(width: number, height: number) { diff --git a/src/eterna/ui/SliderBar.ts b/src/eterna/ui/SliderBar.ts index 2e43fa114..7e3d04432 100644 --- a/src/eterna/ui/SliderBar.ts +++ b/src/eterna/ui/SliderBar.ts @@ -1,12 +1,11 @@ import {Graphics, Point} from "pixi.js"; -import {Flashbang} from "../../flashbang/core/Flashbang"; -import {GameObjectRef} from "../../flashbang/core/GameObjectRef"; -import {DisplayObjectPointerTarget} from "../../flashbang/input/DisplayObjectPointerTarget"; -import {ContainerObject} from "../../flashbang/objects/ContainerObject"; -import {Dragger} from "../../flashbang/util/Dragger"; -import {Signal} from "../../signals/Signal"; - -export class SliderBar extends ContainerObject { +import {Flashbang, GameObjectRef} from "flashbang/core"; +import {DisplayObjectPointerTarget} from "flashbang/input"; +import {ContainerObject} from "flashbang/objects"; +import {Dragger} from "flashbang/util"; +import {Signal} from "signals"; + +export default class SliderBar extends ContainerObject { // The width (or height, for a horizontal SliderBar) of the thumb public static readonly THUMB_SIZE = 15; diff --git a/src/eterna/ui/SpecBox.ts b/src/eterna/ui/SpecBox.ts index 06dd732df..e6495c042 100644 --- a/src/eterna/ui/SpecBox.ts +++ b/src/eterna/ui/SpecBox.ts @@ -1,30 +1,22 @@ import * as log from "loglevel"; import MultiStyleText from "pixi-multistyle-text"; -import { - Graphics, Point, Sprite, Text -} from "pixi.js"; -import {HAlign, VAlign} from "../../flashbang/core/Align"; -import {DisplayObjectPointerTarget} from "../../flashbang/input/DisplayObjectPointerTarget"; -import {IsLeftMouse} from "../../flashbang/input/InputUtil"; -import {KeyCode} from "../../flashbang/input/KeyCode"; -import {ContainerObject} from "../../flashbang/objects/ContainerObject"; -import {DisplayUtil} from "../../flashbang/util/DisplayUtil"; -import {StyledTextBuilder} from "../../flashbang/util/StyledTextBuilder"; -import {UnitSignal} from "../../signals/UnitSignal"; -import {EPars} from "../EPars"; -import {EternaURL} from "../net/EternaURL"; -import {Plot} from "../Plot"; -import {Bitmaps} from "../resources/Bitmaps"; -import {UndoBlock, UndoBlockParam} from "../UndoBlock"; -import {Fonts} from "../util/Fonts"; -import {GameButton} from "./GameButton"; -import {GamePanel} from "./GamePanel"; -import {HTMLTextObject} from "./HTMLTextObject"; -import {TextBalloon} from "./TextBalloon"; +import {Graphics, Point, Sprite, Text} from "pixi.js"; +import {HAlign, VAlign} from "flashbang/core"; +import {DisplayObjectPointerTarget, InputUtil, KeyCode} from "flashbang/input"; +import {ContainerObject} from "flashbang/objects"; +import {DisplayUtil, StyledTextBuilder} from "flashbang/util"; +import {UnitSignal} from "signals"; +import EPars from "eterna/EPars"; +import Plot from "eterna/Plot"; +import {EternaURL} from "eterna/net"; +import {Bitmaps} from "eterna/resources"; +import {default as UndoBlock, UndoBlockParam} from "eterna/UndoBlock"; +import {Fonts} from "eterna/util"; +import {GameButton, GamePanel, HTMLTextObject, TextBalloon} from "."; type InteractionEvent = PIXI.interaction.InteractionEvent; -export class SpecBox extends ContainerObject { +export default class SpecBox extends ContainerObject { /** Emitted when a docked SpecBox's maximize button is clicked */ public readonly shouldMaximize = new UnitSignal(); @@ -113,8 +105,8 @@ export class SpecBox extends ContainerObject { pointerTarget.pointerMove.connect(e => this.onDotPlotMouseMove(e)); pointerTarget.pointerOver.connect(() => this.onDotPlotMouseEnter()); pointerTarget.pointerOut.connect(() => this.onDotPlotMouseExit()); - pointerTarget.pointerDown.filter(IsLeftMouse).connect(e => this.onDotPlotMouseDown(e)); - pointerTarget.pointerUp.filter(IsLeftMouse).connect(() => this.onDotPlotMouseUp()); + pointerTarget.pointerDown.filter(InputUtil.IsLeftMouse).connect(e => this.onDotPlotMouseDown(e)); + pointerTarget.pointerUp.filter(InputUtil.IsLeftMouse).connect(() => this.onDotPlotMouseUp()); } this.updateLayout(); diff --git a/src/eterna/ui/SpecBoxDialog.ts b/src/eterna/ui/SpecBoxDialog.ts index bb8d4ca0b..4e83c5310 100644 --- a/src/eterna/ui/SpecBoxDialog.ts +++ b/src/eterna/ui/SpecBoxDialog.ts @@ -1,19 +1,16 @@ import {Point} from "pixi.js"; -import {HAlign, VAlign} from "../../flashbang/core/Align"; -import {Flashbang} from "../../flashbang/core/Flashbang"; -import {KeyCode} from "../../flashbang/input/KeyCode"; -import {DisplayUtil} from "../../flashbang/util/DisplayUtil"; -import {UndoBlock} from "../UndoBlock"; -import {Dialog} from "./Dialog"; -import {GameButton} from "./GameButton"; -import {SpecBox} from "./SpecBox"; +import {Flashbang, HAlign, VAlign} from "flashbang/core"; +import {KeyCode} from "flashbang/input"; +import {DisplayUtil} from "flashbang/util"; +import UndoBlock from "eterna/UndoBlock"; +import {Dialog, GameButton, SpecBox} from "."; /** * Displays a SpecBox in a modal dialog. * If the "Minimize Window" button is clicked, the dialog will be closed with "true". The owning mode * should display a docked SpecBox. */ -export class SpecBoxDialog extends Dialog { +export default class SpecBoxDialog extends Dialog { public constructor(datablock: UndoBlock, showMinimizeButton: boolean = true) { super(); this._datablock = datablock; diff --git a/src/eterna/ui/TextBalloon.ts b/src/eterna/ui/TextBalloon.ts index c5c38adef..40a666d8c 100644 --- a/src/eterna/ui/TextBalloon.ts +++ b/src/eterna/ui/TextBalloon.ts @@ -1,14 +1,11 @@ import MultiStyleText from "pixi-multistyle-text"; import {Point, Text} from "pixi.js"; -import {ContainerObject} from "../../flashbang/objects/ContainerObject"; -import {DisplayUtil} from "../../flashbang/util/DisplayUtil"; -import {StyledTextBuilder} from "../../flashbang/util/StyledTextBuilder"; -import {Fonts} from "../util/Fonts"; -import {BaseGamePanel} from "./BaseGamePanel"; -import {GameButton} from "./GameButton"; -import {GamePanel, GamePanelType} from "./GamePanel"; - -export class TextBalloon extends ContainerObject { +import {ContainerObject} from "flashbang/objects"; +import {DisplayUtil, StyledTextBuilder} from "flashbang/util"; +import {Fonts} from "eterna/util"; +import {BaseGamePanel, GameButton, GamePanel, GamePanelType} from "."; + +export default class TextBalloon extends ContainerObject { public constructor(text: string = "", balloonColor: number = 0xFFFFFF, balloonAlpha: number = 0.07, borderColor: number = 0, borderAlpha: number = 0) { super(); diff --git a/src/eterna/ui/TextInputObject.ts b/src/eterna/ui/TextInputObject.ts index f10b6dafe..edca516b7 100644 --- a/src/eterna/ui/TextInputObject.ts +++ b/src/eterna/ui/TextInputObject.ts @@ -1,17 +1,16 @@ import {Graphics, Point, Sprite} from "pixi.js"; -import {DisplayObjectPointerTarget} from "../../flashbang/input/DisplayObjectPointerTarget"; -import {DOMObject} from "../../flashbang/objects/DOMObject"; -import {TextBuilder} from "../../flashbang/util/TextBuilder"; -import {Signal} from "../../signals/Signal"; -import {Eterna} from "../Eterna"; -import {Fonts} from "../util/Fonts"; -import {int} from "../util/int"; +import {DisplayObjectPointerTarget} from "flashbang/input"; +import {DOMObject} from "flashbang/objects"; +import {TextBuilder} from "flashbang/util"; +import {Signal} from "signals"; +import Eterna from "eterna/Eterna"; +import {Fonts} from "eterna/util"; /** * A text input object in the DOM. Floats on top of the PIXI canvas. * When it loses focus, it creates a fake text input display placeholder, and hides the DOM element. */ -export class TextInputObject extends DOMObject { +export default class TextInputObject extends DOMObject { public readonly valueChanged: Signal = new Signal(); public constructor(fontSize: number, width: number = 100, rows: number = 1) { diff --git a/src/eterna/ui/TextInputPanel.ts b/src/eterna/ui/TextInputPanel.ts index 157c478b5..70bfc909d 100644 --- a/src/eterna/ui/TextInputPanel.ts +++ b/src/eterna/ui/TextInputPanel.ts @@ -1,12 +1,10 @@ import {Point, Text} from "pixi.js"; -import {Signal} from "../../signals/Signal"; -import {UnitSignal} from "../../signals/UnitSignal"; -import {Fonts} from "../util/Fonts"; -import {GameButton} from "./GameButton"; -import {GamePanel} from "./GamePanel"; -import {TextInputObject} from "./TextInputObject"; - -export class TextInputPanel extends GamePanel { +import {Signal} from "signals"; +import {UnitSignal} from "signals"; +import {Fonts} from "eterna/util"; +import {GameButton, GamePanel, TextInputObject} from "."; + +export default class TextInputPanel extends GamePanel { public readonly cancelClicked: UnitSignal = new UnitSignal(); public readonly okClicked: Signal> = new Signal(); diff --git a/src/eterna/ui/ToggleBar.ts b/src/eterna/ui/ToggleBar.ts index 46508e586..8bdebc751 100644 --- a/src/eterna/ui/ToggleBar.ts +++ b/src/eterna/ui/ToggleBar.ts @@ -1,21 +1,17 @@ import {Graphics, Point, Text} from "pixi.js"; -import {KeyboardEventType} from "../../flashbang/input/KeyboardEventType"; -import {KeyboardListener} from "../../flashbang/input/KeyboardInput"; -import {KeyCode} from "../../flashbang/input/KeyCode"; -import {ContainerObject} from "../../flashbang/objects/ContainerObject"; -import {Enableable} from "../../flashbang/objects/Enableable"; -import {LocationTask} from "../../flashbang/tasks/LocationTask"; -import {Easing} from "../../flashbang/util/Easing"; -import {Signal} from "../../signals/Signal"; -import {Eterna} from "../Eterna"; -import {Sounds} from "../resources/Sounds"; -import {ROPWait} from "../rscript/ROPWait"; -import {RScriptUIElementID} from "../rscript/RScriptUIElement"; -import {Fonts} from "../util/Fonts"; +import {KeyboardEventType, KeyboardListener, KeyCode} from "flashbang/input"; +import {ContainerObject, Enableable} from "flashbang/objects"; +import {LocationTask} from "flashbang/tasks"; +import {Easing} from "flashbang/util"; +import {Signal} from "signals"; +import Eterna from "eterna/Eterna"; +import {Sounds} from "eterna/resources"; +import {ROPWait, RScriptUIElementID} from "eterna/rscript"; +import {Fonts} from "eterna/util"; type InteractionEvent = PIXI.interaction.InteractionEvent; -export class ToggleBar extends ContainerObject implements KeyboardListener, Enableable { +export default class ToggleBar extends ContainerObject implements KeyboardListener, Enableable { /** Emitted when our state changes */ public readonly stateChanged: Signal = new Signal(); diff --git a/src/eterna/ui/Tooltips.ts b/src/eterna/ui/Tooltips.ts index ed45760ac..971553f97 100644 --- a/src/eterna/ui/Tooltips.ts +++ b/src/eterna/ui/Tooltips.ts @@ -1,24 +1,16 @@ import {ExtendedTextStyle} from "pixi-multistyle-text"; -import { - Container, DisplayObject, Graphics, Point, Rectangle, Text -} from "pixi.js"; -import {Flashbang} from "../../flashbang/core/Flashbang"; -import {GameObject} from "../../flashbang/core/GameObject"; -import {GameObjectRef} from "../../flashbang/core/GameObjectRef"; -import {Button} from "../../flashbang/objects/Button"; -import {AlphaTask} from "../../flashbang/tasks/AlphaTask"; -import {DelayTask} from "../../flashbang/tasks/DelayTask"; -import {SerialTask} from "../../flashbang/tasks/SerialTask"; -import {Easing} from "../../flashbang/util/Easing"; -import {StyledTextBuilder} from "../../flashbang/util/StyledTextBuilder"; -import {Registration} from "../../signals/Registration"; -import {RegistrationGroup} from "../../signals/RegistrationGroup"; -import {Fonts} from "../util/Fonts"; +import {Container, DisplayObject, Graphics, Point, Rectangle, Text} from "pixi.js"; +import {Flashbang, GameObject, GameObjectRef} from "flashbang/core"; +import {Button} from "flashbang/objects"; +import {AlphaTask, DelayTask, SerialTask} from "flashbang/tasks"; +import {Easing, StyledTextBuilder} from "flashbang/util"; +import {Registration, RegistrationGroup} from "signals"; +import {Fonts} from "eterna/util"; /** A tooltip can be a string, styled text, or a function that creates a DisplayObject */ export type Tooltip = (() => DisplayObject) | string | StyledTextBuilder; -export class Tooltips extends GameObject { +export default class Tooltips extends GameObject { /** Default text style for tooltips */ public static readonly DEFAULT_STYLE: ExtendedTextStyle = { fontFamily: Fonts.ARIAL, diff --git a/src/eterna/ui/UILockDialog.ts b/src/eterna/ui/UILockDialog.ts index 8e75776c1..0693d7ad9 100644 --- a/src/eterna/ui/UILockDialog.ts +++ b/src/eterna/ui/UILockDialog.ts @@ -1,9 +1,9 @@ import * as log from "loglevel"; -import {AlphaTask} from "../../flashbang/tasks/AlphaTask"; -import {Dialog} from "./Dialog"; +import {AlphaTask} from "flashbang/tasks"; +import {Dialog} from "."; /** A "dialog" that simply dims the screen and eats UI events */ -export class UILockDialog extends Dialog { +export default class UILockDialog extends Dialog { protected added(): void { super.added(); this.container.alpha = 0; diff --git a/src/eterna/ui/URLButton.ts b/src/eterna/ui/URLButton.ts index 935444b91..b0de23ea3 100644 --- a/src/eterna/ui/URLButton.ts +++ b/src/eterna/ui/URLButton.ts @@ -1,8 +1,8 @@ import {Graphics} from "pixi.js"; -import {HTMLTextObject} from "./HTMLTextObject"; +import {HTMLTextObject} from "."; /** A DOM-based underlined text link with some background styling. */ -export class URLButton extends HTMLTextObject { +export default class URLButton extends HTMLTextObject { public constructor(text: string, url: string) { super(URLButton.createHTML(text, url)); } diff --git a/src/eterna/ui/VScrollBox.ts b/src/eterna/ui/VScrollBox.ts index e05afb1d3..d336bfb74 100644 --- a/src/eterna/ui/VScrollBox.ts +++ b/src/eterna/ui/VScrollBox.ts @@ -1,11 +1,10 @@ import {Container} from "pixi.js"; -import {SceneObject} from "../../flashbang/objects/SceneObject"; -import {MathUtil} from "../../flashbang/util/MathUtil"; -import {ScrollContainer} from "./ScrollContainer"; -import {SliderBar} from "./SliderBar"; +import {SceneObject} from "flashbang/objects"; +import {MathUtil} from "flashbang/util"; +import {ScrollContainer, SliderBar} from "."; /** Contains scrollable content and a vertical sliderbar */ -export class VScrollBox extends SceneObject { +export default class VScrollBox extends SceneObject { public constructor(width: number, height: number) { super(new ScrollContainer(width - SliderBar.THUMB_SIZE, height)); this._width = width; diff --git a/src/eterna/ui/index.ts b/src/eterna/ui/index.ts new file mode 100644 index 000000000..2701df30a --- /dev/null +++ b/src/eterna/ui/index.ts @@ -0,0 +1,35 @@ +export {default as ActionBar} from "./ActionBar"; +export {default as Dialog, DialogCanceledError} from "./Dialog"; +export {default as TextBalloon} from "./TextBalloon"; +export {default as BaseGamePanel} from "./BaseGamePanel"; +export {default as GamePanel, GamePanelType} from "./GamePanel"; +export {default as AsyncProcessDialog} from "./AsyncProcessDialog"; +export {default as Band} from "./Band"; +export {default as ConfirmDialog} from "./ConfirmDialog"; +export {default as ConstraintBox, ConstraintBoxType} from "./ConstraintBox"; +export {default as ContextMenu} from "./ContextMenu"; +export {default as EternaMenu, EternaMenuStyle} from "./EternaMenu"; +export {default as EternaViewOptionsDialog, EternaViewOptionsMode} from "./EternaViewOptionsDialog"; +export {default as FancyGamePanel, FancyGamePanelType} from "./FancyGamePanel"; +export {default as FancyTextBalloon} from "./FancyTextBalloon"; +export {default as FixedWidthTextField} from "./FixedWidthTextField"; +export {default as GameButton} from "./GameButton"; +export {default as GameCheckbox} from "./GameCheckbox"; +export {default as HTMLTextObject} from "./HTMLTextObject"; +export {default as NotificationDialog} from "./NotificationDialog"; +export { + default as NucleotidePalette, PaletteTargetType, GetPaletteTargetBaseType, StringToPaletteTargetType +} from "./NucleotidePalette"; +export {default as PasteSequenceDialog} from "./PasteSequenceDialog"; +export {default as PoseThumbnail, PoseThumbnailType} from "./PoseThumbnail"; +export {default as ScrollContainer} from "./ScrollContainer"; +export {default as SliderBar} from "./SliderBar"; +export {default as SpecBox} from "./SpecBox"; +export {default as SpecBoxDialog} from "./SpecBoxDialog"; +export {default as TextInputObject} from "./TextInputObject"; +export {default as TextInputPanel} from "./TextInputPanel"; +export {default as ToggleBar} from "./ToggleBar"; +export {default as Tooltips, Tooltip} from "./Tooltips"; +export {default as UILockDialog} from "./UILockDialog"; +export {default as URLButton} from "./URLButton"; +export {default as VScrollBox} from "./VScrollBox"; \ No newline at end of file diff --git a/src/eterna/util/CSVParser.ts b/src/eterna/util/CSVParser.ts index 91571d061..fcbc637a2 100644 --- a/src/eterna/util/CSVParser.ts +++ b/src/eterna/util/CSVParser.ts @@ -1,4 +1,4 @@ -export class CSVParser { +export default class CSVParser { public static splitOnComma(csl: string): string[] { let vals: string[] = []; let last_comma = -1; diff --git a/src/eterna/util/EternaTextureUtil.ts b/src/eterna/util/EternaTextureUtil.ts index d7a6b64a5..269d95243 100644 --- a/src/eterna/util/EternaTextureUtil.ts +++ b/src/eterna/util/EternaTextureUtil.ts @@ -1,9 +1,7 @@ import {Matrix, Sprite, Texture} from "pixi.js"; -import {TextureUtil} from "../../flashbang/util/TextureUtil"; -import {ColorUtil} from "../../flashbang/util/ColorUtil"; -import {MathUtil} from "../../flashbang/util/MathUtil"; +import {ColorUtil, MathUtil, TextureUtil} from "flashbang/util"; -export class EternaTextureUtil { +export default class EternaTextureUtil { /** * Creates scaled versions of each texture in the given array. * @param textures an Array of textures to append to diff --git a/src/eterna/util/ExternalInterface.ts b/src/eterna/util/ExternalInterface.ts index d2d667cfc..37dc8a98d 100644 --- a/src/eterna/util/ExternalInterface.ts +++ b/src/eterna/util/ExternalInterface.ts @@ -1,8 +1,6 @@ import * as log from "loglevel"; -import {Assert} from "../../flashbang/util/Assert"; -import {Deferred} from "../../flashbang/util/Deferred"; -import {Registration} from "../../signals/Registration"; -import {UnitSignal} from "../../signals/UnitSignal"; +import {Assert, Deferred} from "flashbang/util"; +import {Registration, UnitSignal} from "signals"; /** * A collection of externally registered callbacks. @@ -39,7 +37,7 @@ export interface RunScriptOptions { * app lives inside, and also calls into functions exposed by `script-interface.coffee`, a set of javascript functions * loaded by the page. */ -export class ExternalInterface { +export default class ExternalInterface { public static init(scriptRoot: HTMLElement) { Assert.isTrue(this._scriptRoot === undefined, "Already initialized"); this._scriptRoot = scriptRoot; diff --git a/src/eterna/util/Fonts.ts b/src/eterna/util/Fonts.ts index cc01f649b..ebb4c25bb 100644 --- a/src/eterna/util/Fonts.ts +++ b/src/eterna/util/Fonts.ts @@ -1,8 +1,8 @@ import * as log from "loglevel"; -import {FontLoader} from "../../flashbang/resources/FontLoader"; -import {TextBuilder} from "../../flashbang/util/TextBuilder"; +import {FontLoader} from "flashbang/resources"; +import {TextBuilder} from "flashbang/util"; -export class Fonts { +export default class Fonts { public static readonly ARIAL = "Arial"; public static readonly MONOSPACE = "monospace"; diff --git a/src/eterna/util/GraphicsUtil.ts b/src/eterna/util/GraphicsUtil.ts index ae77d0850..a1b1fa3d3 100644 --- a/src/eterna/util/GraphicsUtil.ts +++ b/src/eterna/util/GraphicsUtil.ts @@ -1,7 +1,7 @@ import {Graphics, Point} from "pixi.js"; -import {Vector2} from "../../flashbang/geom/Vector2"; +import {Vector2} from "flashbang/geom"; -export class GraphicsUtil { +export default class GraphicsUtil { /** Draw a left-facing arrow, with its tip anchored at (0, 0) */ public static drawArrow(triSize: number, baseLength: number, outlineColor: number, fillColor: number, graphics: Graphics = null): Graphics { if (graphics == null) { diff --git a/src/eterna/util/Utility.ts b/src/eterna/util/Utility.ts index bf1536bee..f53cac33b 100644 --- a/src/eterna/util/Utility.ts +++ b/src/eterna/util/Utility.ts @@ -1,6 +1,6 @@ import {Point} from "pixi.js"; -export class Utility { +export default class Utility { public static roundTo(num: number, floating: number): number { let div: number = Math.pow(10, floating); let temp: number = num * div; diff --git a/src/eterna/util/index.ts b/src/eterna/util/index.ts new file mode 100644 index 000000000..da2570035 --- /dev/null +++ b/src/eterna/util/index.ts @@ -0,0 +1,7 @@ +export {default as CSVParser} from "./CSVParser"; +export {default as EternaTextureUtil} from "./EternaTextureUtil"; +export {default as ExternalInterface, ExternalInterfaceCtx, RunScriptOptions} from "./ExternalInterface"; +export {default as Fonts} from "./Fonts"; +export {default as GraphicsUtil} from "./GraphicsUtil"; +export {default as int} from "./int"; +export {default as Utility} from "./Utility"; \ No newline at end of file diff --git a/src/eterna/util/int.ts b/src/eterna/util/int.ts index 49c58ccae..3b5f3cafa 100644 --- a/src/eterna/util/int.ts +++ b/src/eterna/util/int.ts @@ -1,4 +1,4 @@ /** Emulates the int() function in AS3: casts the given value to a number and floors it */ -export function int(value: string | number): number { +export default function int(value: string | number): number { return Math.floor(Number(value)); } diff --git a/src/eterna/vfx/Background.ts b/src/eterna/vfx/Background.ts index 2b600f4f2..8aa7a9fcb 100644 --- a/src/eterna/vfx/Background.ts +++ b/src/eterna/vfx/Background.ts @@ -1,8 +1,8 @@ -import {ContainerObject} from "../../flashbang/objects/ContainerObject"; -import {Eterna} from "../Eterna"; -import {Bubble} from "./Bubble"; +import {ContainerObject} from "flashbang/objects"; +import Eterna from "eterna/Eterna"; +import {Bubble} from "."; -export class Background extends ContainerObject { +export default class Background extends ContainerObject { constructor(bubbleCount: number = 20, foreground: boolean = false) { super(); this._bubbleCount = bubbleCount; diff --git a/src/eterna/vfx/BaseGlow.ts b/src/eterna/vfx/BaseGlow.ts index a6fa45f2f..6565ec832 100644 --- a/src/eterna/vfx/BaseGlow.ts +++ b/src/eterna/vfx/BaseGlow.ts @@ -1,9 +1,8 @@ import {Point, Sprite, Texture} from "pixi.js"; -import {BitmapManager} from "../resources/BitmapManager"; -import {Bitmaps} from "../resources/Bitmaps"; -import {EternaTextureUtil} from "../util/EternaTextureUtil"; +import {BitmapManager, Bitmaps} from "eterna/resources"; +import {EternaTextureUtil} from "eterna/util"; -export class BaseGlow extends Sprite { +export default class BaseGlow extends Sprite { public constructor() { super(); BaseGlow.initTextures(); diff --git a/src/eterna/vfx/Bubble.ts b/src/eterna/vfx/Bubble.ts index c5d243736..33aa06e19 100644 --- a/src/eterna/vfx/Bubble.ts +++ b/src/eterna/vfx/Bubble.ts @@ -1,14 +1,11 @@ import {Point, Texture} from "pixi.js"; -import {Flashbang} from "../../flashbang/core/Flashbang"; -import {Updatable} from "../../flashbang/core/Updatable"; -import {SpriteObject} from "../../flashbang/objects/SpriteObject"; -import {AlphaTask} from "../../flashbang/tasks/AlphaTask"; -import {ParallelTask} from "../../flashbang/tasks/ParallelTask"; -import {ScaleTask} from "../../flashbang/tasks/ScaleTask"; -import {Easing} from "../../flashbang/util/Easing"; -import {Bitmaps} from "../resources/Bitmaps"; - -export class Bubble extends SpriteObject implements Updatable { +import {Flashbang, Updatable} from "flashbang/core"; +import {SpriteObject} from "flashbang/objects"; +import {AlphaTask, ParallelTask, ScaleTask} from "flashbang/tasks"; +import {Easing} from "flashbang/util"; +import {Bitmaps} from "eterna/resources"; + +export default class Bubble extends SpriteObject implements Updatable { public isPaused: boolean = false; constructor(foreground: boolean) { @@ -160,7 +157,6 @@ export class Bubble extends SpriteObject implements Updatable { private static readonly P = new Point(); } - class NormalDistPRNG { private static s: number = 0; private static cached: boolean = false; diff --git a/src/eterna/vfx/BubbleSweep.ts b/src/eterna/vfx/BubbleSweep.ts index e7bf0142f..7c442157c 100644 --- a/src/eterna/vfx/BubbleSweep.ts +++ b/src/eterna/vfx/BubbleSweep.ts @@ -1,7 +1,7 @@ -import {ContainerObject} from "../../flashbang/objects/ContainerObject"; -import {Bubble} from "./Bubble"; +import {ContainerObject} from "flashbang/objects"; +import {Bubble} from "."; -export class BubbleSweep extends ContainerObject { +export default class BubbleSweep extends ContainerObject { public constructor(numBubbles: number) { super(); this._bubbles = []; diff --git a/src/eterna/vfx/LightRay.ts b/src/eterna/vfx/LightRay.ts index 3e22c1884..1822bc6fb 100644 --- a/src/eterna/vfx/LightRay.ts +++ b/src/eterna/vfx/LightRay.ts @@ -1,13 +1,10 @@ -import {GlowFilter} from "pixi-filters"; import {Graphics} from "pixi.js"; -import {Vector2} from "../../flashbang/geom/Vector2"; -import {SceneObject} from "../../flashbang/objects/SceneObject"; -import {AlphaTask} from "../../flashbang/tasks/AlphaTask"; -import {SerialTask} from "../../flashbang/tasks/SerialTask"; -import {VisibleTask} from "../../flashbang/tasks/VisibleTask"; -import {EPars} from "../EPars"; +import {Vector2} from "flashbang/geom"; +import {SceneObject} from "flashbang/objects"; +import {AlphaTask, SerialTask, VisibleTask} from "flashbang/tasks"; +import EPars from "eterna/EPars"; -export class LightRay extends SceneObject { +export default class LightRay extends SceneObject { constructor() { super(new Graphics()); } diff --git a/src/eterna/vfx/VibrateTask.ts b/src/eterna/vfx/VibrateTask.ts index faf615c34..63108001f 100644 --- a/src/eterna/vfx/VibrateTask.ts +++ b/src/eterna/vfx/VibrateTask.ts @@ -1,8 +1,8 @@ -import {DisplayObjectTask} from "../../flashbang/tasks/DisplayObjectTask"; import {DisplayObject, Point} from "pixi.js"; -import {Easing} from "../../flashbang/util/Easing"; +import {DisplayObjectTask} from "flashbang/tasks"; +import {Easing} from "flashbang/util"; -export class VibrateTask extends DisplayObjectTask { +export default class VibrateTask extends DisplayObjectTask { public constructor(duration: number, target: DisplayObject = null) { super(duration, Easing.linear, target); } diff --git a/src/eterna/vfx/index.ts b/src/eterna/vfx/index.ts new file mode 100644 index 000000000..4e397d96a --- /dev/null +++ b/src/eterna/vfx/index.ts @@ -0,0 +1,6 @@ +export {default as Background} from "./Background"; +export {default as BaseGlow} from "./BaseGlow"; +export {default as Bubble} from "./Bubble"; +export {default as BubbleSweep} from "./BubbleSweep"; +export {default as LightRay} from "./LightRay"; +export {default as VibrateTask} from "./VibrateTask"; \ No newline at end of file diff --git a/src/flashbang/core/AppMode.ts b/src/flashbang/core/AppMode.ts index dacd16ae0..26a142184 100644 --- a/src/flashbang/core/AppMode.ts +++ b/src/flashbang/core/AppMode.ts @@ -1,19 +1,10 @@ import {Container} from "pixi.js"; -import {RegistrationGroup} from "../../signals/RegistrationGroup"; -import {Signal} from "../../signals/Signal"; -import {SignalView} from "../../signals/SignalView"; -import {UnitSignal} from "../../signals/UnitSignal"; -import {KeyboardInput} from "../input/KeyboardInput"; -import {MouseWheelInput} from "../input/MouseWheelInput"; -import {Assert} from "../util/Assert"; -import {GameObject} from "./GameObject"; -import {GameObjectBase} from "./GameObjectBase"; -import {GameObjectRef} from "./GameObjectRef"; -import {LateUpdatable} from "./LateUpdatable"; -import {ModeStack} from "./ModeStack"; -import {Updatable} from "./Updatable"; - -export class AppMode { +import {RegistrationGroup, Signal, SignalView, UnitSignal} from "signals"; +import {KeyboardInput, MouseWheelInput} from "../input"; +import {Assert} from "../util"; +import {GameObject, GameObjectBase, GameObjectRef, LateUpdatable, ModeStack, Updatable} from "."; + +export default class AppMode { /** Default keyboard input processor */ public readonly keyboardInput: KeyboardInput = new KeyboardInput(); /** Default mouse wheel input processor */ diff --git a/src/flashbang/core/Flashbang.ts b/src/flashbang/core/Flashbang.ts index 16242fc9d..eedc9e9c2 100644 --- a/src/flashbang/core/Flashbang.ts +++ b/src/flashbang/core/Flashbang.ts @@ -1,12 +1,11 @@ import * as PIXI from "pixi.js"; import {Point} from "pixi.js"; -import {Assert} from "../util/Assert"; -import {AppMode} from "./AppMode"; -import {FlashbangApp} from "./FlashbangApp"; +import {Assert} from "../util"; +import {FlashbangApp, AppMode} from "."; type InteractionManager = PIXI.interaction.InteractionManager; -export class Flashbang { +export default class Flashbang { public static get app(): FlashbangApp { return Flashbang._app; } diff --git a/src/flashbang/core/FlashbangApp.ts b/src/flashbang/core/FlashbangApp.ts index 0db43771d..d94efd1f2 100644 --- a/src/flashbang/core/FlashbangApp.ts +++ b/src/flashbang/core/FlashbangApp.ts @@ -1,17 +1,12 @@ import * as log from "loglevel"; -import {RegistrationGroup} from "../../signals/RegistrationGroup"; -import {Value} from "../../signals/Value"; -import {KeyboardEventType} from "../input/KeyboardEventType"; -import {KeyCode} from "../input/KeyCode"; -import {ErrorUtil} from "../util/ErrorUtil"; -import {Flashbang} from "./Flashbang"; -import {ModeStack} from "./ModeStack"; -import {Updatable} from "./Updatable"; +import {RegistrationGroup, Value} from "signals"; +import {KeyboardEventType, KeyCode} from "../input"; +import {Flashbang, ModeStack, Updatable} from "."; // Adds KeyboardEvent.code support to Edge import "js-polyfills/keyboard"; -export class FlashbangApp { +export default class FlashbangApp { /** True if the app is foregrounded */ public readonly isActive: Value = new Value(true); diff --git a/src/flashbang/core/GameObject.ts b/src/flashbang/core/GameObject.ts index 4f5a273bf..8fc14d9f3 100644 --- a/src/flashbang/core/GameObject.ts +++ b/src/flashbang/core/GameObject.ts @@ -1,10 +1,10 @@ import * as log from "loglevel"; import {Container, DisplayObject} from "pixi.js"; -import {Assert} from "../util/Assert"; -import {GameObjectBase} from "./GameObjectBase"; -import {GameObjectRef} from "./GameObjectRef"; +// Full path, not module path, has to be used here to prevent cyclic dependency/module load order issue +import Assert from "../util/Assert"; +import {GameObjectBase, GameObjectRef} from "."; -export class GameObject extends GameObjectBase { +export default class GameObject extends GameObjectBase { /** The DisplayObject that this GameObject manages, if any */ public get display(): DisplayObject { return null; diff --git a/src/flashbang/core/GameObjectBase.ts b/src/flashbang/core/GameObjectBase.ts index a739fc639..6d29a29fa 100644 --- a/src/flashbang/core/GameObjectBase.ts +++ b/src/flashbang/core/GameObjectBase.ts @@ -1,12 +1,8 @@ import {Container} from "pixi.js"; -import {RegistrationGroup} from "../../signals/RegistrationGroup"; -import {UnitSignal} from "../../signals/UnitSignal"; -import {AppMode} from "./AppMode"; -import {GameObject} from "./GameObject"; -import {GameObjectRef} from "./GameObjectRef"; -import {ModeStack} from "./ModeStack"; - -export class GameObjectBase { +import {RegistrationGroup, UnitSignal} from "signals"; +import {AppMode, ModeStack, GameObject, GameObjectRef} from "."; + +export default class GameObjectBase { public get destroyed(): UnitSignal { if (this._destroyed == null) { this._destroyed = new UnitSignal(); diff --git a/src/flashbang/core/GameObjectRef.ts b/src/flashbang/core/GameObjectRef.ts index a3cb609b4..806158d18 100644 --- a/src/flashbang/core/GameObjectRef.ts +++ b/src/flashbang/core/GameObjectRef.ts @@ -1,7 +1,6 @@ -import {GameObject} from "./GameObject"; -import {GameObjectBase} from "./GameObjectBase"; +import {GameObject, GameObjectBase} from "."; -export class GameObjectRef { +export default class GameObjectRef { public static readonly NULL: GameObjectRef = new GameObjectRef(); /** @return the GameObjectRef for the given GameObject, or GameObjectRef.Null() if obj is null */ diff --git a/src/flashbang/core/LateUpdatable.ts b/src/flashbang/core/LateUpdatable.ts index 352c2b173..d8bca8499 100644 --- a/src/flashbang/core/LateUpdatable.ts +++ b/src/flashbang/core/LateUpdatable.ts @@ -1,4 +1,4 @@ -export interface LateUpdatable { +export default interface LateUpdatable { /** * Update this object. dt is the number of seconds that have elapsed since the last update. * (lateUpdate() is called after all update() functions have completed. They're a good place diff --git a/src/flashbang/core/ModeStack.ts b/src/flashbang/core/ModeStack.ts index f8afdd057..be38a962d 100644 --- a/src/flashbang/core/ModeStack.ts +++ b/src/flashbang/core/ModeStack.ts @@ -1,14 +1,13 @@ import {Container} from "pixi.js"; -import {UnitSignal} from "../../signals/UnitSignal"; -import {Assert} from "../util/Assert"; -import {MathUtil} from "../util/MathUtil"; -import {AppMode} from "./AppMode"; +import {UnitSignal} from "signals"; +import {Assert, MathUtil} from "../util"; +import {AppMode} from "."; /** * A stack of AppModes. Only the top-most mode in the stack gets updates * and other events - all other modes are inactive. */ -export class ModeStack { +export default class ModeStack { public readonly topModeChanged: UnitSignal = new UnitSignal(); constructor(parentSprite: Container) { diff --git a/src/flashbang/core/ObjectTask.ts b/src/flashbang/core/ObjectTask.ts index 2ba1d044c..ac146f9c6 100644 --- a/src/flashbang/core/ObjectTask.ts +++ b/src/flashbang/core/ObjectTask.ts @@ -1,7 +1,7 @@ import {Container} from "pixi.js"; -import {GameObjectBase} from "./GameObjectBase"; +import {GameObjectBase} from "."; -export class ObjectTask extends GameObjectBase { +export default class ObjectTask extends GameObjectBase { /* internal */ _attachToDisplayList(displayParent: Container, displayIdx: number): void { throw new Error("Tasks cannot manage DisplayObjects"); diff --git a/src/flashbang/core/Updatable.ts b/src/flashbang/core/Updatable.ts index ae0adf7bf..2168b75f7 100644 --- a/src/flashbang/core/Updatable.ts +++ b/src/flashbang/core/Updatable.ts @@ -1,4 +1,4 @@ -export interface Updatable { +export default interface Updatable { /** Update this object. dt is the number of seconds that have elapsed since the last update. */ update(dt: number): void; } diff --git a/src/flashbang/core/index.ts b/src/flashbang/core/index.ts new file mode 100644 index 000000000..6a8290e4a --- /dev/null +++ b/src/flashbang/core/index.ts @@ -0,0 +1,11 @@ +export {HAlign, VAlign} from "./Align"; +export {default as GameObjectBase} from "./GameObjectBase"; +export {default as GameObject} from "./GameObject"; +export {default as AppMode} from "./AppMode"; +export {default as Flashbang} from "./Flashbang"; +export {default as FlashbangApp} from "./FlashbangApp"; +export {default as GameObjectRef} from "./GameObjectRef"; +export {default as LateUpdatable} from "./LateUpdatable"; +export {default as ModeStack} from "./ModeStack"; +export {default as ObjectTask} from "./ObjectTask"; +export {default as Updatable} from "./Updatable"; \ No newline at end of file diff --git a/src/flashbang/geom/Vector2.ts b/src/flashbang/geom/Vector2.ts index f51fbfda6..06e05be1f 100644 --- a/src/flashbang/geom/Vector2.ts +++ b/src/flashbang/geom/Vector2.ts @@ -1,7 +1,7 @@ import {Point} from "pixi.js"; /** A 2D vector */ -export class Vector2 { +export default class Vector2 { public x: number = 0; public y: number = 0; diff --git a/src/flashbang/geom/index.ts b/src/flashbang/geom/index.ts new file mode 100644 index 000000000..772e78c94 --- /dev/null +++ b/src/flashbang/geom/index.ts @@ -0,0 +1 @@ +export {default as Vector2} from "./Vector2"; \ No newline at end of file diff --git a/src/flashbang/input/DisplayObjectPointerTarget.ts b/src/flashbang/input/DisplayObjectPointerTarget.ts index c0d528bcc..5c1cdb268 100644 --- a/src/flashbang/input/DisplayObjectPointerTarget.ts +++ b/src/flashbang/input/DisplayObjectPointerTarget.ts @@ -1,11 +1,11 @@ import {DisplayObject} from "pixi.js"; -import {SignalView} from "../../signals/SignalView"; -import {EventSignal} from "../util/EventSignal"; -import {PointerTarget} from "./PointerTarget"; +import {SignalView} from "signals"; +import {EventSignal} from "../util"; +import {PointerTarget} from "."; type InteractionEvent = PIXI.interaction.InteractionEvent; -export class DisplayObjectPointerTarget implements PointerTarget { +export default class DisplayObjectPointerTarget implements PointerTarget { public readonly target: DisplayObject; public constructor(disp: DisplayObject) { diff --git a/src/flashbang/input/InputUtil.ts b/src/flashbang/input/InputUtil.ts index 976994d93..b34cc830d 100644 --- a/src/flashbang/input/InputUtil.ts +++ b/src/flashbang/input/InputUtil.ts @@ -1,3 +1,4 @@ type InteractionEvent = PIXI.interaction.InteractionEvent; - -export const IsLeftMouse = (e: InteractionEvent) => e.data.isPrimary; +export default class InputUtil { + public static IsLeftMouse = (e: InteractionEvent): boolean => e.data.isPrimary; +} diff --git a/src/flashbang/input/KeyCode.ts b/src/flashbang/input/KeyCode.ts index e63290de1..2e2790048 100644 --- a/src/flashbang/input/KeyCode.ts +++ b/src/flashbang/input/KeyCode.ts @@ -8,7 +8,7 @@ * NB: as of 9/8/2018, Edge doesn't support KeyboardEvent.code * For Edge, use the keyboard.js polyfill here: https://github.com/inexorabletash/polyfill */ -export enum KeyCode { +enum KeyCode { // 3.1.1.1. Writing System Keys Backquote = "Backquote", // `~ on a US keyboard. This is the 半角/全角/漢字 (hankaku/zenkaku/kanji) key on Japanese keyboards Backslash = "Backslash", // Used for both the US \| (on the 101-key layout) and also for the key located between the " and Enter keys on row C of the 102-, 104- and 106-key layouts. Labelled #~ on a UK (102) keyboard. @@ -178,3 +178,5 @@ export enum KeyCode { AudioVolumeUp = "AudioVolumeUp", WakeUp = "WakeUp", } + +export default KeyCode; diff --git a/src/flashbang/input/KeyboardEventType.ts b/src/flashbang/input/KeyboardEventType.ts index a7f630ffc..d982112ac 100644 --- a/src/flashbang/input/KeyboardEventType.ts +++ b/src/flashbang/input/KeyboardEventType.ts @@ -1,4 +1,6 @@ -export enum KeyboardEventType { +enum KeyboardEventType { KEY_DOWN = "keydown", KEY_UP = "keyup" } + +export default KeyboardEventType; \ No newline at end of file diff --git a/src/flashbang/input/KeyboardInput.ts b/src/flashbang/input/KeyboardInput.ts index dbfde388a..95c2ef98e 100644 --- a/src/flashbang/input/KeyboardInput.ts +++ b/src/flashbang/input/KeyboardInput.ts @@ -1,5 +1,5 @@ -import {Registration} from "../../signals/Registration"; -import {LinkedElement, LinkedList} from "../util/LinkedList"; +import {Registration} from "signals"; +import {LinkedElement, LinkedList} from "../util"; export interface KeyboardListener { /** @@ -9,7 +9,7 @@ export interface KeyboardListener { onKeyboardEvent(e: KeyboardEvent): boolean; } -export class KeyboardInput { +export default class KeyboardInput { public dispose(): void { this._listeners.dispose(); this._listeners = null; diff --git a/src/flashbang/input/MouseWheelInput.ts b/src/flashbang/input/MouseWheelInput.ts index 4b9e44c0f..7a5053142 100644 --- a/src/flashbang/input/MouseWheelInput.ts +++ b/src/flashbang/input/MouseWheelInput.ts @@ -1,5 +1,5 @@ -import {Registration} from "../../signals/Registration"; -import {LinkedElement, LinkedList} from "../util/LinkedList"; +import {Registration} from "signals"; +import {LinkedElement, LinkedList} from "../util"; export interface MouseWheelListener { /** @@ -9,7 +9,7 @@ export interface MouseWheelListener { onMouseWheelEvent(e: WheelEvent): boolean; } -export class MouseWheelInput { +export default class MouseWheelInput { public dispose(): void { this._listeners.dispose(); this._listeners = null; diff --git a/src/flashbang/input/PointerCapture.ts b/src/flashbang/input/PointerCapture.ts index 404691ba9..24c14b93b 100644 --- a/src/flashbang/input/PointerCapture.ts +++ b/src/flashbang/input/PointerCapture.ts @@ -1,10 +1,10 @@ import {DisplayObject} from "pixi.js"; -import {Flashbang} from "../core/Flashbang"; +import {Flashbang} from "../core"; type InteractionPointerEvents = PIXI.interaction.InteractionPointerEvents; type InteractionEvent = PIXI.interaction.InteractionEvent; -export class PointerCapture { +export default class PointerCapture { public constructor(root: DisplayObject) { this._root = root; } diff --git a/src/flashbang/input/PointerTarget.ts b/src/flashbang/input/PointerTarget.ts index 42737414b..dd4d9f317 100644 --- a/src/flashbang/input/PointerTarget.ts +++ b/src/flashbang/input/PointerTarget.ts @@ -1,10 +1,10 @@ import {DisplayObject} from "pixi.js"; -import {SignalView} from "../../signals/SignalView"; +import {SignalView} from "signals"; type InteractionEvent = PIXI.interaction.InteractionEvent; /** Exposes signals for an interactive object */ -export interface PointerTarget { +export default interface PointerTarget { /** the DisplayObject associated with this PointerTarget */ target: DisplayObject; diff --git a/src/flashbang/input/index.ts b/src/flashbang/input/index.ts new file mode 100644 index 000000000..94219099f --- /dev/null +++ b/src/flashbang/input/index.ts @@ -0,0 +1,8 @@ +export {default as DisplayObjectPointerTarget} from "./DisplayObjectPointerTarget"; +export {default as InputUtil} from "./InputUtil"; +export {default as KeyboardEventType} from "./KeyboardEventType"; +export {default as KeyboardInput, KeyboardListener} from "./KeyboardInput"; +export {default as KeyCode} from "./KeyCode"; +export {default as MouseWheelInput, MouseWheelListener} from "./MouseWheelInput"; +export {default as PointerCapture} from "./PointerCapture"; +export {default as PointerTarget} from "./PointerTarget"; \ No newline at end of file diff --git a/src/flashbang/layout/HLayoutContainer.ts b/src/flashbang/layout/HLayoutContainer.ts index d0dbf59e7..01ce42004 100644 --- a/src/flashbang/layout/HLayoutContainer.ts +++ b/src/flashbang/layout/HLayoutContainer.ts @@ -1,13 +1,13 @@ import {Rectangle} from "pixi.js"; -import {VAlign} from "../core/Align"; -import {DisplayUtil} from "../util/DisplayUtil"; -import {LayoutContainer} from "./LayoutContainer"; +import {VAlign} from "../core"; +import {DisplayUtil} from "../util"; +import {LayoutContainer} from "."; /** * A Container that arranges its children horizontally. * Call layout() after adding or removing children to update the sprite's layout. */ -export class HLayoutContainer extends LayoutContainer { +export default class HLayoutContainer extends LayoutContainer { public constructor(hOffset: number = 0, vAlign: VAlign = VAlign.CENTER) { super(); this._hOffset = hOffset; diff --git a/src/flashbang/layout/LayoutContainer.ts b/src/flashbang/layout/LayoutContainer.ts index 809a2f471..7a479122e 100644 --- a/src/flashbang/layout/LayoutContainer.ts +++ b/src/flashbang/layout/LayoutContainer.ts @@ -1,7 +1,7 @@ import {Container, DisplayObject, Sprite} from "pixi.js"; /** A base class for Containers that arrange their children automatically. */ -export abstract class LayoutContainer extends Container { +export default abstract class LayoutContainer extends Container { public get needsLayout(): boolean { return this._needsLayout; } diff --git a/src/flashbang/layout/VLayoutContainer.ts b/src/flashbang/layout/VLayoutContainer.ts index 85b2bdc70..238c70e6b 100644 --- a/src/flashbang/layout/VLayoutContainer.ts +++ b/src/flashbang/layout/VLayoutContainer.ts @@ -1,13 +1,13 @@ import {Rectangle} from "pixi.js"; -import {HAlign} from "../core/Align"; -import {DisplayUtil} from "../util/DisplayUtil"; -import {LayoutContainer} from "./LayoutContainer"; +import {HAlign} from "../core"; +import {DisplayUtil} from "../util"; +import {LayoutContainer} from "."; /** * A Container that arranges its children vertically. * Call layout() after adding or removing children to update the sprite's layout. */ -export class VLayoutContainer extends LayoutContainer { +export default class VLayoutContainer extends LayoutContainer { public constructor(vOffset: number = 0, hAlign: HAlign = HAlign.CENTER) { super(); this._vOffset = vOffset; diff --git a/src/flashbang/layout/index.ts b/src/flashbang/layout/index.ts new file mode 100644 index 000000000..4f1c2fe6b --- /dev/null +++ b/src/flashbang/layout/index.ts @@ -0,0 +1,3 @@ +export {default as LayoutContainer} from "./LayoutContainer"; +export {default as HLayoutContainer} from "./HLayoutContainer"; +export {default as VLayoutContainer} from "./VLayoutContainer"; \ No newline at end of file diff --git a/src/flashbang/objects/Button.ts b/src/flashbang/objects/Button.ts index d23dbfbeb..c002e6eef 100644 --- a/src/flashbang/objects/Button.ts +++ b/src/flashbang/objects/Button.ts @@ -1,20 +1,16 @@ import {Point} from "pixi.js"; -import {Eterna} from "../../eterna/Eterna"; -import {Sounds} from "../../eterna/resources/Sounds"; -import {UnitSignal} from "../../signals/UnitSignal"; -import {IsLeftMouse} from "../input/InputUtil"; -import {PointerCapture} from "../input/PointerCapture"; -import {CallbackTask} from "../tasks/CallbackTask"; -import {DelayTask} from "../tasks/DelayTask"; -import {SerialTask} from "../tasks/SerialTask"; -import {DisplayUtil} from "../util/DisplayUtil"; -import {ContainerObject} from "./ContainerObject"; -import {Enableable} from "./Enableable"; +import Eterna from "eterna/Eterna"; +import {Sounds} from "eterna/resources"; +import {UnitSignal} from "signals"; +import {InputUtil, PointerCapture} from "../input"; +import {CallbackTask, DelayTask, SerialTask} from "../tasks"; +import {DisplayUtil} from "../util"; +import {ContainerObject, Enableable} from "."; type InteractionEvent = PIXI.interaction.InteractionEvent; /** A button base class. */ -export abstract class Button extends ContainerObject implements Enableable { +export default abstract class Button extends ContainerObject implements Enableable { public static readonly DEFAULT_DOWN_SOUND: string = Sounds.SoundButtonClick; /** Fired when the button is clicked */ @@ -41,8 +37,8 @@ export abstract class Button extends ContainerObject implements Enableable { this.regs.add(this.pointerOver.connect(() => this.onPointerOver())); this.regs.add(this.pointerOut.connect(() => this.onPointerOut())); - this.regs.add(this.pointerDown.filter(IsLeftMouse).connect(() => this.onPointerDown())); - this.regs.add(this.pointerUp.filter(IsLeftMouse).connect(() => this.onPointerUp(true))); + this.regs.add(this.pointerDown.filter(InputUtil.IsLeftMouse).connect(() => this.onPointerDown())); + this.regs.add(this.pointerUp.filter(InputUtil.IsLeftMouse).connect(() => this.onPointerUp(true))); } /* override */ @@ -133,7 +129,7 @@ export abstract class Button extends ContainerObject implements Enableable { this._pointerCapture.beginCapture((e: InteractionEvent) => { e.stopPropagation(); - if (IsLeftMouse(e) && (e.type === "pointerup" || e.type === "pointerupoutside")) { + if (InputUtil.IsLeftMouse(e) && (e.type === "pointerup" || e.type === "pointerupoutside")) { this.onPointerUp(false); } else if (e.type === "pointercancel") { this.endCapture(true); diff --git a/src/flashbang/objects/ContainerObject.ts b/src/flashbang/objects/ContainerObject.ts index bab04ba72..9a2dfbf86 100644 --- a/src/flashbang/objects/ContainerObject.ts +++ b/src/flashbang/objects/ContainerObject.ts @@ -1,8 +1,8 @@ import {Container} from "pixi.js"; -import {SceneObject} from "./SceneObject"; +import {SceneObject} from "."; /** A GameObject that manages a PIXI Container */ -export class ContainerObject extends SceneObject { +export default class ContainerObject extends SceneObject { public constructor(container?: Container) { super(container || new Container()); } diff --git a/src/flashbang/objects/DOMObject.ts b/src/flashbang/objects/DOMObject.ts index b182a6a09..c4815bcc0 100644 --- a/src/flashbang/objects/DOMObject.ts +++ b/src/flashbang/objects/DOMObject.ts @@ -1,13 +1,12 @@ import {DisplayObject, Graphics, Matrix} from "pixi.js"; -import {Flashbang} from "../core/Flashbang"; -import {GameObject} from "../core/GameObject"; -import {MatrixUtil} from "../util/MatrixUtil"; +import {Flashbang, GameObject} from "../core"; +import {MatrixUtil} from "../util"; /** * Wraps an HTML element that lives in the DOM and is drawn on top of the PIXI canvas. * Contains a "dummy" that mirrors the element's transform. */ -export abstract class DOMObject extends GameObject { +export default abstract class DOMObject extends GameObject { /** * Applies the given style to the DOM object and all children who do not already have the given style property set. * This will not overrwrite existing properties, unless replaceIfExists is true. diff --git a/src/flashbang/objects/Enableable.ts b/src/flashbang/objects/Enableable.ts index 37811b17f..6eafca2fc 100644 --- a/src/flashbang/objects/Enableable.ts +++ b/src/flashbang/objects/Enableable.ts @@ -1,3 +1,3 @@ -export interface Enableable { +export default interface Enableable { enabled: boolean; } diff --git a/src/flashbang/objects/ImageButton.ts b/src/flashbang/objects/ImageButton.ts index 6ff4b15b5..652458bd1 100644 --- a/src/flashbang/objects/ImageButton.ts +++ b/src/flashbang/objects/ImageButton.ts @@ -1,7 +1,7 @@ -import {Button, ButtonState} from "./Button"; import {Texture, Sprite} from "pixi.js"; +import {Button, ButtonState} from "."; -export class ImageButton extends Button { +export default class ImageButton extends Button { public constructor(textures: Texture[]) { super(); diff --git a/src/flashbang/objects/SceneObject.ts b/src/flashbang/objects/SceneObject.ts index 3062e6a57..115c686ee 100644 --- a/src/flashbang/objects/SceneObject.ts +++ b/src/flashbang/objects/SceneObject.ts @@ -1,13 +1,12 @@ import {DisplayObject} from "pixi.js"; -import {SignalView} from "../../signals/SignalView"; -import {GameObject} from "../core/GameObject"; -import {PointerTarget} from "../input/PointerTarget"; -import {DisplayObjectPointerTarget} from "../input/DisplayObjectPointerTarget"; +import {SignalView} from "signals"; +import {GameObject} from "../core"; +import {PointerTarget, DisplayObjectPointerTarget} from "../input"; type InteractionEvent = PIXI.interaction.InteractionEvent; /** A convenience class that manages a DisplayObject directly. */ -export class SceneObject extends GameObject implements PointerTarget { +export default class SceneObject extends GameObject implements PointerTarget { constructor(displayObject: T) { super(); this._display = displayObject; diff --git a/src/flashbang/objects/SimpleTextButton.ts b/src/flashbang/objects/SimpleTextButton.ts index b51ab669d..a4f4df00b 100644 --- a/src/flashbang/objects/SimpleTextButton.ts +++ b/src/flashbang/objects/SimpleTextButton.ts @@ -1,9 +1,9 @@ import {Graphics, Text} from "pixi.js"; -import {TextBuilder} from "../util/TextBuilder"; -import {Button, ButtonState} from "./Button"; +import {TextBuilder} from "../util"; +import {Button, ButtonState} from "."; /** A deliberately unstylish button that displays text on a rectangle. (For debugging.) */ -export class SimpleTextButton extends Button { +export default class SimpleTextButton extends Button { constructor(text: string, fontSize: number = 24, fontName: string = "Arial") { super(); diff --git a/src/flashbang/objects/SpriteObject.ts b/src/flashbang/objects/SpriteObject.ts index 5f63c3be3..463f49c5d 100644 --- a/src/flashbang/objects/SpriteObject.ts +++ b/src/flashbang/objects/SpriteObject.ts @@ -1,8 +1,8 @@ import {Sprite} from "pixi.js"; -import {SceneObject} from "./SceneObject"; +import {SceneObject} from "."; /** A GameObject that manages a PIXI Sprite */ -export class SpriteObject extends SceneObject { +export default class SpriteObject extends SceneObject { public constructor(sprite?: Sprite) { super(sprite || new Sprite()); } diff --git a/src/flashbang/objects/ToggleButton.ts b/src/flashbang/objects/ToggleButton.ts index 2364bf12f..52bd0626e 100644 --- a/src/flashbang/objects/ToggleButton.ts +++ b/src/flashbang/objects/ToggleButton.ts @@ -1,8 +1,8 @@ -import {Value} from "../../signals/Value"; -import {Button} from "./Button"; +import {Value} from "signals"; +import {Button} from "."; /** A two-state Button whose value is toggled on click (e.g. a checkbox). */ -export abstract class ToggleButton extends Button { +export default abstract class ToggleButton extends Button { public readonly toggled: Value = new Value(false); protected constructor() { diff --git a/src/flashbang/objects/index.ts b/src/flashbang/objects/index.ts new file mode 100644 index 000000000..0e9de84ce --- /dev/null +++ b/src/flashbang/objects/index.ts @@ -0,0 +1,9 @@ +export {default as Enableable} from "./Enableable"; +export {default as SceneObject} from "./SceneObject"; +export {default as ContainerObject} from "./ContainerObject"; +export {default as Button, ButtonState} from "./Button"; +export {default as DOMObject} from "./DOMObject"; +export {default as ImageButton} from "./ImageButton"; +export {default as SimpleTextButton} from "./SimpleTextButton"; +export {default as SpriteObject} from "./SpriteObject"; +export {default as ToggleButton} from "./ToggleButton"; \ No newline at end of file diff --git a/src/flashbang/resources/FontLoader.ts b/src/flashbang/resources/FontLoader.ts index 313b46822..05b08bfdd 100644 --- a/src/flashbang/resources/FontLoader.ts +++ b/src/flashbang/resources/FontLoader.ts @@ -1,6 +1,6 @@ import * as WebFont from "webfontloader"; -export class FontLoader { +export default class FontLoader { /** * Loads a font defined in a @font-face element in a CSS file. * Return a Promise that will resolve when the given font is loaded diff --git a/src/flashbang/resources/index.ts b/src/flashbang/resources/index.ts new file mode 100644 index 000000000..448407753 --- /dev/null +++ b/src/flashbang/resources/index.ts @@ -0,0 +1 @@ +export {default as FontLoader} from "./FontLoader"; \ No newline at end of file diff --git a/src/flashbang/settings/SaveGameManager.ts b/src/flashbang/settings/SaveGameManager.ts index 8ee5b8034..6a2eb2767 100644 --- a/src/flashbang/settings/SaveGameManager.ts +++ b/src/flashbang/settings/SaveGameManager.ts @@ -1,6 +1,6 @@ import * as localforage from "localforage"; -export class SaveGameManager { +export default class SaveGameManager { constructor(namespace: string) { if (SaveGameManager.ALL_NAMESPACES.has(namespace)) { throw new Error(`SaveGameManager namespace '${namespace}' already taken`); diff --git a/src/flashbang/settings/Setting.ts b/src/flashbang/settings/Setting.ts index 20aa40c1a..378353dea 100644 --- a/src/flashbang/settings/Setting.ts +++ b/src/flashbang/settings/Setting.ts @@ -1,8 +1,6 @@ -import {AbstractValue} from "../../signals/AbstractValue"; -import {MappedValue} from "../../signals/MappedValue"; -import {ValueView} from "../../signals/ValueView"; +import {AbstractValue, MappedValue, ValueView} from "signals"; -export class Setting extends AbstractValue { +export default class Setting extends AbstractValue { public constructor(store: StoreJsAPI, name: string, defaultVal: T) { super(); this._store = store; diff --git a/src/flashbang/settings/Settings.ts b/src/flashbang/settings/Settings.ts index 567d24999..140ed7775 100644 --- a/src/flashbang/settings/Settings.ts +++ b/src/flashbang/settings/Settings.ts @@ -1,7 +1,7 @@ -import {Setting} from "./Setting"; import * as storejs from "store"; +import {Setting} from "."; -export abstract class Settings { +export default abstract class Settings { protected constructor(namespace: string) { if (Settings.ALL_NAMESPACES.has(namespace)) { throw new Error(`Settings namespace '${namespace}' already taken`); diff --git a/src/flashbang/settings/index.ts b/src/flashbang/settings/index.ts new file mode 100644 index 000000000..dbe4fad36 --- /dev/null +++ b/src/flashbang/settings/index.ts @@ -0,0 +1,3 @@ +export {default as SaveGameManager} from "./SaveGameManager"; +export {default as Setting} from "./Setting"; +export {default as Settings} from "./Settings"; \ No newline at end of file diff --git a/src/flashbang/tasks/AlphaTask.ts b/src/flashbang/tasks/AlphaTask.ts index fde02fe97..7c9e4f40c 100644 --- a/src/flashbang/tasks/AlphaTask.ts +++ b/src/flashbang/tasks/AlphaTask.ts @@ -1,8 +1,8 @@ import {DisplayObject} from "pixi.js"; -import {EasingFunc} from "../util/Easing"; -import {DisplayObjectTask} from "./DisplayObjectTask"; +import {EasingFunc} from "../util"; +import {DisplayObjectTask} from "."; -export class AlphaTask extends DisplayObjectTask { +export default class AlphaTask extends DisplayObjectTask { constructor(alpha: number, time: number = 0, easingFn: EasingFunc = null, target: DisplayObject = null) { super(time, easingFn, target); this._to = alpha; diff --git a/src/flashbang/tasks/CallbackTask.ts b/src/flashbang/tasks/CallbackTask.ts index dba0dea27..707c8f2c8 100644 --- a/src/flashbang/tasks/CallbackTask.ts +++ b/src/flashbang/tasks/CallbackTask.ts @@ -1,7 +1,7 @@ -import {ObjectTask} from "../core/ObjectTask"; +import {ObjectTask} from "../core"; /** A Task that calls a function once and then completes. */ -export class CallbackTask extends ObjectTask { +export default class CallbackTask extends ObjectTask { constructor(callback: () => void) { super(); this._callback = callback; diff --git a/src/flashbang/tasks/DelayTask.ts b/src/flashbang/tasks/DelayTask.ts index 6c4c7c1ba..11b1bad20 100644 --- a/src/flashbang/tasks/DelayTask.ts +++ b/src/flashbang/tasks/DelayTask.ts @@ -1,7 +1,6 @@ -import {ObjectTask} from "../core/ObjectTask"; -import {Updatable} from "../core/Updatable"; +import {ObjectTask, Updatable} from "../core"; -export class DelayTask extends ObjectTask implements Updatable { +export default class DelayTask extends ObjectTask implements Updatable { constructor(time: number) { super(); this._time = time; diff --git a/src/flashbang/tasks/DisplayObjectTask.ts b/src/flashbang/tasks/DisplayObjectTask.ts index 83f814200..880794dcf 100644 --- a/src/flashbang/tasks/DisplayObjectTask.ts +++ b/src/flashbang/tasks/DisplayObjectTask.ts @@ -1,9 +1,8 @@ -import {Assert} from "../util/Assert"; -import {EasingFunc} from "../util/Easing"; -import {InterpolatingTask} from "./InterpolatingTask"; import {DisplayObject} from "pixi.js"; +import {Assert, EasingFunc} from "../util"; +import {InterpolatingTask} from "."; -export class DisplayObjectTask extends InterpolatingTask { +export default class DisplayObjectTask extends InterpolatingTask { constructor(time: number, easing: EasingFunc, target: DisplayObject) { super(time, easing); this._target = target; diff --git a/src/flashbang/tasks/FrameDelayTask.ts b/src/flashbang/tasks/FrameDelayTask.ts index 0bda72981..e93ecf3fb 100644 --- a/src/flashbang/tasks/FrameDelayTask.ts +++ b/src/flashbang/tasks/FrameDelayTask.ts @@ -1,8 +1,7 @@ -import {ObjectTask} from "../core/ObjectTask"; -import {Updatable} from "../core/Updatable"; +import {ObjectTask, Updatable} from "../core"; /** Delays for the given number of frames. (Unlike DelayTask, which delays for a specific amount of time.) */ -export class FrameDelayTask extends ObjectTask implements Updatable { +export default class FrameDelayTask extends ObjectTask implements Updatable { constructor(frames: number = 1) { super(); this._frames = frames; diff --git a/src/flashbang/tasks/FunctionTask.ts b/src/flashbang/tasks/FunctionTask.ts index 9b422522c..303f670e9 100644 --- a/src/flashbang/tasks/FunctionTask.ts +++ b/src/flashbang/tasks/FunctionTask.ts @@ -1,8 +1,7 @@ -import {ObjectTask} from "../core/ObjectTask"; -import {Updatable} from "../core/Updatable"; +import {ObjectTask, Updatable} from "../core"; /** A Task that calls a function continuously until the function returns true */ -export class FunctionTask extends ObjectTask implements Updatable { +export default class FunctionTask extends ObjectTask implements Updatable { constructor(callback: (dt: number) => boolean) { super(); this._callback = callback; diff --git a/src/flashbang/tasks/InterpolatingTask.ts b/src/flashbang/tasks/InterpolatingTask.ts index a0b73cce2..04ee879c4 100644 --- a/src/flashbang/tasks/InterpolatingTask.ts +++ b/src/flashbang/tasks/InterpolatingTask.ts @@ -1,8 +1,7 @@ -import {ObjectTask} from "../core/ObjectTask"; -import {Updatable} from "../core/Updatable"; -import {Easing, EasingFunc} from "../util/Easing"; +import {ObjectTask, Updatable} from "../core"; +import {Easing, EasingFunc} from "../util"; -export class InterpolatingTask extends ObjectTask implements Updatable { +export default class InterpolatingTask extends ObjectTask implements Updatable { constructor(time: number = 0, easingFn: EasingFunc = null) { super(); this._totalTime = Math.max(time, 0); diff --git a/src/flashbang/tasks/LocationTask.ts b/src/flashbang/tasks/LocationTask.ts index 1de6af6e8..eca0a6ef6 100644 --- a/src/flashbang/tasks/LocationTask.ts +++ b/src/flashbang/tasks/LocationTask.ts @@ -1,8 +1,8 @@ import {DisplayObject} from "pixi.js"; -import {EasingFunc} from "../util/Easing"; -import {DisplayObjectTask} from "./DisplayObjectTask"; +import {EasingFunc} from "../util"; +import {DisplayObjectTask} from "."; -export class LocationTask extends DisplayObjectTask { +export default class LocationTask extends DisplayObjectTask { constructor(x: number, y: number, time: number = 0, easingFn: EasingFunc = null, target: DisplayObject = null) { super(time, easingFn, target); this._toX = x; diff --git a/src/flashbang/tasks/ParallelTask.ts b/src/flashbang/tasks/ParallelTask.ts index f8f47cfb0..b648fc39c 100644 --- a/src/flashbang/tasks/ParallelTask.ts +++ b/src/flashbang/tasks/ParallelTask.ts @@ -1,7 +1,7 @@ -import {ObjectTask} from "../core/ObjectTask"; -import {Assert} from "../util/Assert"; +import {ObjectTask} from "../core"; +import {Assert} from "../util"; -export class ParallelTask extends ObjectTask { +export default class ParallelTask extends ObjectTask { constructor(...tasks: ObjectTask[]) { super(); this._subtasks = tasks.concat(); diff --git a/src/flashbang/tasks/RepeatingTask.ts b/src/flashbang/tasks/RepeatingTask.ts index 6a4565039..faf72f6bc 100644 --- a/src/flashbang/tasks/RepeatingTask.ts +++ b/src/flashbang/tasks/RepeatingTask.ts @@ -1,4 +1,4 @@ -import {ObjectTask} from "../core/ObjectTask"; +import {ObjectTask} from "../core"; type TaskCreator = () => ObjectTask; @@ -9,7 +9,7 @@ type TaskCreator = () => ObjectTask; * When the RepeatingTask completes its task, it will call taskCreator to regenerate the task. * If taskCreator returns null, the RepeatingTask will complete; else it will keep running. */ -export class RepeatingTask extends ObjectTask { +export default class RepeatingTask extends ObjectTask { constructor(taskCreator: TaskCreator) { super(); this._taskCreator = taskCreator; diff --git a/src/flashbang/tasks/RotationTask.ts b/src/flashbang/tasks/RotationTask.ts index 2f2b5557f..daa7258e7 100644 --- a/src/flashbang/tasks/RotationTask.ts +++ b/src/flashbang/tasks/RotationTask.ts @@ -1,8 +1,8 @@ import {DisplayObject} from "pixi.js"; -import {EasingFunc} from "../util/Easing"; -import {DisplayObjectTask} from "./DisplayObjectTask"; +import {EasingFunc} from "../util"; +import {DisplayObjectTask} from "."; -export class RotationTask extends DisplayObjectTask { +export default class RotationTask extends DisplayObjectTask { constructor(radians: number, time: number = 0, easingFn: EasingFunc = null, target: DisplayObject = null) { super(time, easingFn, target); this._to = radians; diff --git a/src/flashbang/tasks/ScaleTask.ts b/src/flashbang/tasks/ScaleTask.ts index 5cf570eb7..642f9d0e6 100644 --- a/src/flashbang/tasks/ScaleTask.ts +++ b/src/flashbang/tasks/ScaleTask.ts @@ -1,8 +1,8 @@ import {DisplayObject} from "pixi.js"; -import {EasingFunc} from "../util/Easing"; -import {DisplayObjectTask} from "./DisplayObjectTask"; +import {EasingFunc} from "../util"; +import {DisplayObjectTask} from "."; -export class ScaleTask extends DisplayObjectTask { +export default class ScaleTask extends DisplayObjectTask { constructor(x: number, y: number, time: number = 0, easingFn: EasingFunc = null, target: DisplayObject = null) { super(time, easingFn, target); this._toX = x; diff --git a/src/flashbang/tasks/SelfDestructTask.ts b/src/flashbang/tasks/SelfDestructTask.ts index 979f6d696..5059450fb 100644 --- a/src/flashbang/tasks/SelfDestructTask.ts +++ b/src/flashbang/tasks/SelfDestructTask.ts @@ -1,9 +1,9 @@ -import {ObjectTask} from "../core/ObjectTask"; +import {ObjectTask} from "../core"; /** * A Task that destroys its parent. */ -export class SelfDestructTask extends ObjectTask { +export default class SelfDestructTask extends ObjectTask { /* override */ protected added(): void { this.parent.destroySelf(); diff --git a/src/flashbang/tasks/SerialTask.ts b/src/flashbang/tasks/SerialTask.ts index 3ffe0669f..b07901478 100644 --- a/src/flashbang/tasks/SerialTask.ts +++ b/src/flashbang/tasks/SerialTask.ts @@ -1,7 +1,7 @@ -import {ObjectTask} from "../core/ObjectTask"; -import {Assert} from "../util/Assert"; +import {ObjectTask} from "../core"; +import {Assert} from "../util"; -export class SerialTask extends ObjectTask { +export default class SerialTask extends ObjectTask { constructor(...tasks: ObjectTask[]) { super(); this._subtasks = tasks.concat(); diff --git a/src/flashbang/tasks/VisibleTask.ts b/src/flashbang/tasks/VisibleTask.ts index 7f5687b1b..e60818583 100644 --- a/src/flashbang/tasks/VisibleTask.ts +++ b/src/flashbang/tasks/VisibleTask.ts @@ -1,8 +1,8 @@ import {DisplayObject} from "pixi.js"; -import {ObjectTask} from "../core/ObjectTask"; -import {Assert} from "../util/Assert"; +import {ObjectTask} from "../core"; +import {Assert} from "../util"; -export class VisibleTask extends ObjectTask { +export default class VisibleTask extends ObjectTask { constructor(visible: boolean, target: DisplayObject = null) { super(); this._visible = visible; diff --git a/src/flashbang/tasks/index.ts b/src/flashbang/tasks/index.ts new file mode 100644 index 000000000..1681d96bb --- /dev/null +++ b/src/flashbang/tasks/index.ts @@ -0,0 +1,15 @@ +export {default as InterpolatingTask} from "./InterpolatingTask"; +export {default as DisplayObjectTask} from "./DisplayObjectTask"; +export {default as AlphaTask} from "./AlphaTask"; +export {default as CallbackTask} from "./CallbackTask"; +export {default as DelayTask} from "./DelayTask"; +export {default as FrameDelayTask} from "./FrameDelayTask"; +export {default as FunctionTask} from "./FunctionTask"; +export {default as LocationTask} from "./LocationTask"; +export {default as ParallelTask} from "./ParallelTask"; +export {default as RepeatingTask, Repeat} from "./RepeatingTask"; +export {default as RotationTask} from "./RotationTask"; +export {default as ScaleTask} from "./ScaleTask"; +export {default as SelfDestructTask} from "./SelfDestructTask"; +export {default as SerialTask} from "./SerialTask"; +export {default as VisibleTask} from "./VisibleTask"; \ No newline at end of file diff --git a/src/flashbang/util/Arrays.ts b/src/flashbang/util/Arrays.ts index ab0a9d34d..b8d9822e9 100644 --- a/src/flashbang/util/Arrays.ts +++ b/src/flashbang/util/Arrays.ts @@ -1,4 +1,4 @@ -export class Arrays { +export default class Arrays { /** True if two Arrays hold the same contents */ public static shallowEqual(a: T[], b: T[]): boolean { if (a === b) { diff --git a/src/flashbang/util/Assert.ts b/src/flashbang/util/Assert.ts index c2833c73f..27fa8c55f 100644 --- a/src/flashbang/util/Assert.ts +++ b/src/flashbang/util/Assert.ts @@ -1,4 +1,4 @@ -export class Assert { +export default class Assert { public static ok(predicate: () => boolean, message?: string): void { if (process.env.NODE_ENV !== "production" && !predicate()) { throw new Error(message || "assertion failure!"); diff --git a/src/flashbang/util/Base64.ts b/src/flashbang/util/Base64.ts index 2c98a3f47..4a2d2a9fa 100644 --- a/src/flashbang/util/Base64.ts +++ b/src/flashbang/util/Base64.ts @@ -1,8 +1,8 @@ import * as base64js from "base64-js"; import {DisplayObject, Sprite, Texture} from "pixi.js"; -import {DisplayUtil} from "./DisplayUtil"; +import {DisplayUtil} from "."; -export class Base64 { +export default class Base64 { /** Renders a DisplayObject or Texture to a PNG and base64-encodes it */ public static encodeDisplayObjectPNG(disp: DisplayObject | Texture) { let target: DisplayObject = disp instanceof DisplayObject ? disp : new Sprite(disp); diff --git a/src/flashbang/util/ColorUtil.ts b/src/flashbang/util/ColorUtil.ts index 54a1fcb71..cb6d1e802 100644 --- a/src/flashbang/util/ColorUtil.ts +++ b/src/flashbang/util/ColorUtil.ts @@ -1,7 +1,6 @@ -import {MathUtil} from "./MathUtil"; -import {StringUtil} from "./StringUtil"; +import {MathUtil, StringUtil} from "."; -export class ColorUtil { +export default class ColorUtil { public static fromString(str: string): number { if (str.length === 0 || str.charAt(0) !== "#") { throw new Error(`Invalid color string: ${str}`); diff --git a/src/flashbang/util/Deferred.ts b/src/flashbang/util/Deferred.ts index ceeb14f2f..07e7d615e 100644 --- a/src/flashbang/util/Deferred.ts +++ b/src/flashbang/util/Deferred.ts @@ -1,5 +1,5 @@ /** Wraps a Promise and allows it to be resolved or rejected later. */ -export class Deferred { +export default class Deferred { public readonly promise: Promise; public constructor() { diff --git a/src/flashbang/util/DisplayUtil.ts b/src/flashbang/util/DisplayUtil.ts index bb8eabf65..c8b25d39f 100644 --- a/src/flashbang/util/DisplayUtil.ts +++ b/src/flashbang/util/DisplayUtil.ts @@ -1,14 +1,11 @@ -import { - DisplayObject, Graphics, Matrix, Point, Rectangle -} from "pixi.js"; -import {HAlign, VAlign} from "../core/Align"; -import {Flashbang} from "../core/Flashbang"; -import {RectangleUtil} from "./RectangleUtil"; +import {DisplayObject, Graphics, Matrix, Point, Rectangle} from "pixi.js"; +import {Flashbang, HAlign, VAlign} from "../core"; +import {RectangleUtil} from "."; // the @types file for upng-js is broken, so we just require it directly const UPNG = require("upng-js"); -export class DisplayUtil { +export default class DisplayUtil { public static renderToPNG(target: DisplayObject): ArrayBuffer { let pixels = Flashbang.app.pixi.renderer.extract.pixels(target); // Floor our target width/height - UPNG.encode doesn't handle fractional sizes diff --git a/src/flashbang/util/Dragger.ts b/src/flashbang/util/Dragger.ts index 722cd87e1..d623e8774 100644 --- a/src/flashbang/util/Dragger.ts +++ b/src/flashbang/util/Dragger.ts @@ -1,11 +1,10 @@ import {Container, Graphics} from "pixi.js"; -import {UnitSignal} from "../../signals/UnitSignal"; -import {Flashbang} from "../core/Flashbang"; -import {GameObject} from "../core/GameObject"; -import {DisplayObjectPointerTarget} from "../input/DisplayObjectPointerTarget"; +import {UnitSignal} from "signals"; +import {Flashbang, GameObject} from "../core"; +import {DisplayObjectPointerTarget} from "../input"; /** A utility object that captures mouse input and dispatches update events until a mouseUp occurs */ -export class Dragger extends GameObject { +export default class Dragger extends GameObject { public readonly dragged = new UnitSignal(); public readonly dragComplete = new UnitSignal(); diff --git a/src/flashbang/util/Easing.ts b/src/flashbang/util/Easing.ts index 0b4d4095d..3a3ff7731 100644 --- a/src/flashbang/util/Easing.ts +++ b/src/flashbang/util/Easing.ts @@ -1,8 +1,8 @@ -import {PowerEaser} from "./PowerEaser"; +import {PowerEaser} from "."; export type EasingFunc = (from: number, to: number, dt: number, t: number) => number; -export class Easing { +export default class Easing { public static quadratic: PowerEaser = new PowerEaser(2); public static cubic: PowerEaser = new PowerEaser(3); public static quartic: PowerEaser = new PowerEaser(4); diff --git a/src/flashbang/util/ErrorUtil.ts b/src/flashbang/util/ErrorUtil.ts index 9dd152717..ab46ee73e 100644 --- a/src/flashbang/util/ErrorUtil.ts +++ b/src/flashbang/util/ErrorUtil.ts @@ -1,4 +1,4 @@ -export class ErrorUtil { +export default class ErrorUtil { /** Returns an appropriate Error object, if e can be coerced to one */ public static getErrorObj(e: any): Error | null { if (e instanceof Error) { diff --git a/src/flashbang/util/EventSignal.ts b/src/flashbang/util/EventSignal.ts index 71af384cf..be88e8c23 100644 --- a/src/flashbang/util/EventSignal.ts +++ b/src/flashbang/util/EventSignal.ts @@ -1,13 +1,10 @@ -import {AbstractSignal} from "../../signals/AbstractSignal"; -import {FilteredSignal} from "../../signals/FilteredSignal"; -import {MappedSignal} from "../../signals/MappedSignal"; -import {SignalView} from "../../signals/SignalView"; +import {AbstractSignal, FilteredSignal, MappedSignal, SignalView} from "signals"; type InteractionEvent = PIXI.interaction.InteractionEvent; type EventEmitter = PIXI.utils.EventEmitter; /** Redispatches a pixi InteractionEvent as a Signal */ -export class EventSignal extends AbstractSignal implements SignalView { +export default class EventSignal extends AbstractSignal implements SignalView { public constructor(target: EventEmitter, eventType: string | symbol) { super(); this._target = target; diff --git a/src/flashbang/util/JSONUtil.ts b/src/flashbang/util/JSONUtil.ts index 4ed63aa94..6fc671f9e 100644 --- a/src/flashbang/util/JSONUtil.ts +++ b/src/flashbang/util/JSONUtil.ts @@ -1,4 +1,4 @@ -export class JSONUtil { +export default class JSONUtil { public static require(json: any, name: string): T { if (!json.hasOwnProperty(name)) { throw new Error(`Missing required property '${name}'`); diff --git a/src/flashbang/util/LinkedList.ts b/src/flashbang/util/LinkedList.ts index fcbb6e966..a9e7380b9 100644 --- a/src/flashbang/util/LinkedList.ts +++ b/src/flashbang/util/LinkedList.ts @@ -1,4 +1,4 @@ -import {Registration} from "../../signals/Registration"; +import {Registration} from "signals"; export interface LinkedElement { next: LinkedElement; @@ -6,7 +6,7 @@ export interface LinkedElement { } /** A singly-linked list. */ -export class LinkedList { +export default class LinkedList { /** Return true if the list is empty. During iteration, isEmpty will always return false. */ public get isEmpty(): boolean { return this._head == null; diff --git a/src/flashbang/util/MathUtil.ts b/src/flashbang/util/MathUtil.ts index 21b26a377..34fbcff24 100644 --- a/src/flashbang/util/MathUtil.ts +++ b/src/flashbang/util/MathUtil.ts @@ -1,4 +1,4 @@ -export class MathUtil { +export default class MathUtil { /** Degrees-to-radians */ public static readonly deg2Rad: number = Math.PI / 180; diff --git a/src/flashbang/util/MatrixUtil.ts b/src/flashbang/util/MatrixUtil.ts index fbddfe78f..9fb23446d 100644 --- a/src/flashbang/util/MatrixUtil.ts +++ b/src/flashbang/util/MatrixUtil.ts @@ -11,7 +11,7 @@ import {Matrix, Point} from "pixi.js"; /** A utility class containing methods related to the Matrix class. */ -export class MatrixUtil { +export default class MatrixUtil { public static equals(a: Matrix, b: Matrix): boolean { return a.a === b.a && a.b === b.b && a.c === b.c && a.d === b.d && a.tx === b.tx && a.ty === b.ty; } diff --git a/src/flashbang/util/PowerEaser.ts b/src/flashbang/util/PowerEaser.ts index b25b42618..171230dff 100644 --- a/src/flashbang/util/PowerEaser.ts +++ b/src/flashbang/util/PowerEaser.ts @@ -1,4 +1,4 @@ -export class PowerEaser { +export default class PowerEaser { constructor(pow: number) { this._pow = pow; } diff --git a/src/flashbang/util/RectangleUtil.ts b/src/flashbang/util/RectangleUtil.ts index a0198abff..82bc8348f 100644 --- a/src/flashbang/util/RectangleUtil.ts +++ b/src/flashbang/util/RectangleUtil.ts @@ -9,10 +9,10 @@ // ================================================================================================= import {Point, Rectangle, Matrix} from "pixi.js"; -import {MatrixUtil} from "./MatrixUtil"; +import {MatrixUtil} from "."; /** A utility class containing methods related to the Rectangle class. */ -export class RectangleUtil { +export default class RectangleUtil { public static setTo(r: Rectangle, left: number, top: number, width: number, height: number): void { r.x = left; r.y = top; diff --git a/src/flashbang/util/StringUtil.ts b/src/flashbang/util/StringUtil.ts index 522050ee0..6880973d8 100644 --- a/src/flashbang/util/StringUtil.ts +++ b/src/flashbang/util/StringUtil.ts @@ -1,5 +1,5 @@ /** Contains useful static function for performing operations on Strings. */ -export class StringUtil { +export default class StringUtil { /** * Get a hashCode for the specified String. null returns 0. * This hashes identically to Java's String.hashCode(). diff --git a/src/flashbang/util/StyledTextBuilder.ts b/src/flashbang/util/StyledTextBuilder.ts index c277baf4b..61857d836 100644 --- a/src/flashbang/util/StyledTextBuilder.ts +++ b/src/flashbang/util/StyledTextBuilder.ts @@ -1,8 +1,8 @@ import * as log from "loglevel"; import {default as MultiStyleText, ExtendedTextStyle, TextStyleSet} from "pixi-multistyle-text"; -import {ColorUtil} from "./ColorUtil"; +import {ColorUtil} from "."; -export class StyledTextBuilder { +export default class StyledTextBuilder { public constructor(defaultStyle?: ExtendedTextStyle) { if (defaultStyle !== undefined) { this.defaultStyle(defaultStyle); diff --git a/src/flashbang/util/TextBuilder.ts b/src/flashbang/util/TextBuilder.ts index 568cdb139..536df9218 100644 --- a/src/flashbang/util/TextBuilder.ts +++ b/src/flashbang/util/TextBuilder.ts @@ -1,6 +1,6 @@ import {Text, TextStyle, TextStyleOptions} from "pixi.js"; -export class TextBuilder { +export default class TextBuilder { public constructor(text: string = "") { this.text(text); } diff --git a/src/flashbang/util/TextUtil.ts b/src/flashbang/util/TextUtil.ts index 985618b21..1b821322a 100644 --- a/src/flashbang/util/TextUtil.ts +++ b/src/flashbang/util/TextUtil.ts @@ -1,6 +1,6 @@ import {Text} from "pixi.js"; -export class TextUtil { +export default class TextUtil { /** * Trims the given text field to fit into the given max width, if possible. * If trimmedPostfix is non-null, and the textfield must be trimmed, the diff --git a/src/flashbang/util/TextureUtil.ts b/src/flashbang/util/TextureUtil.ts index d3114175d..1c9a0f94f 100644 --- a/src/flashbang/util/TextureUtil.ts +++ b/src/flashbang/util/TextureUtil.ts @@ -1,10 +1,8 @@ -import { - BaseRenderTexture, BaseTexture, Container, DisplayObject, Rectangle, RenderTexture, Texture -} from "pixi.js"; -import {Flashbang} from "../core/Flashbang"; -import {Assert} from "./Assert"; +import {BaseRenderTexture, BaseTexture, Container, DisplayObject, Rectangle, RenderTexture, Texture} from "pixi.js"; +import {Flashbang} from "../core"; +import {Assert} from "."; -export class TextureUtil { +export default class TextureUtil { public static fromBase64PNG(base64PNG: string): Promise { // elements can be created from base64 strings. // We create an img, set its src data to the base64 string, diff --git a/src/flashbang/util/index.ts b/src/flashbang/util/index.ts new file mode 100644 index 000000000..3a3114e9d --- /dev/null +++ b/src/flashbang/util/index.ts @@ -0,0 +1,21 @@ +export {default as Assert} from "./Assert"; +export {default as Dragger} from "./Dragger"; +export {default as Arrays} from "./Arrays"; +export {default as Base64} from "./Base64"; +export {default as ColorUtil} from "./ColorUtil"; +export {default as Deferred} from "./Deferred"; +export {default as DisplayUtil} from "./DisplayUtil"; +export {default as PowerEaser} from "./PowerEaser"; +export {default as Easing, EasingFunc} from "./Easing"; +export {default as ErrorUtil} from "./ErrorUtil"; +export {default as EventSignal} from "./EventSignal"; +export {default as JSONUtil} from "./JSONUtil"; +export {default as LinkedList, LinkedElement} from "./LinkedList"; +export {default as MathUtil} from "./MathUtil"; +export {default as MatrixUtil} from "./MatrixUtil"; +export {default as RectangleUtil} from "./RectangleUtil"; +export {default as StringUtil} from "./StringUtil"; +export {default as StyledTextBuilder} from "./StyledTextBuilder"; +export {default as TextBuilder} from "./TextBuilder"; +export {default as TextureUtil} from "./TextureUtil"; +export {default as TextUtil} from "./TextUtil"; \ No newline at end of file diff --git a/src/signals/AbstractSignal.ts b/src/signals/AbstractSignal.ts index 19e9253ee..2dbf1a043 100644 --- a/src/signals/AbstractSignal.ts +++ b/src/signals/AbstractSignal.ts @@ -1,13 +1,14 @@ -import {Reactor} from "./Reactor"; -import {SignalView} from "./SignalView"; -import {Connection} from "./Connection"; +/*import Reactor from "./Reactor"; +import SignalView from "./SignalView"; +import Connection from "./Connection";*/ +import {Reactor, SignalView, Connection} from "."; /** * Handles the machinery of connecting slots to a signal and emitting events to them, without * exposing a public interface for emitting events. This can be used by entities which wish to * expose a signal-like interface for listening, without allowing external callers to emit signals. */ -export abstract class AbstractSignal extends Reactor implements SignalView { +export default abstract class AbstractSignal extends Reactor implements SignalView { public abstract map(func: (value: T) => U): SignalView; public abstract filter(pred: (value: T) => boolean): SignalView; diff --git a/src/signals/AbstractValue.ts b/src/signals/AbstractValue.ts index bb6c67a81..53bbfebe7 100644 --- a/src/signals/AbstractValue.ts +++ b/src/signals/AbstractValue.ts @@ -1,7 +1,8 @@ -import {Connection} from "./Connection"; -import {Cons} from "./Cons"; -import {Reactor} from "./Reactor"; -import {ValueView} from "./ValueView"; +/*import Connection from "./Connection"; +import Cons from "./Cons"; +import Reactor from "./Reactor"; +import ValueView from "./ValueView";*/ +import {Connection, Cons, Reactor, ValueView} from "."; /** * Handles the machinery of connecting listeners to a value and notifying them, without exposing a @@ -9,7 +10,7 @@ import {ValueView} from "./ValueView"; * observable values, but must manage the maintenance and distribution of value updates themselves * (so that they may send them over the network, for example). */ -export abstract class AbstractValue extends Reactor implements ValueView { +export default abstract class AbstractValue extends Reactor implements ValueView { public abstract get value(): T; /** Returns a "slot" Function which simply calls through to the Value's setter function. */ diff --git a/src/signals/Connection.ts b/src/signals/Connection.ts index a5eccb923..55329b38b 100644 --- a/src/signals/Connection.ts +++ b/src/signals/Connection.ts @@ -1,10 +1,11 @@ -import {Registration} from "./Registration"; +//import Registration from "./Registration"; +import {Registration} from "."; /** * Provides a mechanism to cancel a slot or listener registration, or to perform post-registration * adjustment like making the registration single-shot. */ -export interface Connection extends Registration { +export default interface Connection extends Registration { /** * Converts this connection into a one-shot connection. After the first time the slot or * listener is notified, it will automatically be disconnected. diff --git a/src/signals/Cons.ts b/src/signals/Cons.ts index e2697800a..59a3a9e41 100644 --- a/src/signals/Cons.ts +++ b/src/signals/Cons.ts @@ -1,10 +1,12 @@ -import {Connection} from "./Connection"; -import {Reactor, RListener} from "./Reactor"; +/*import Reactor from "./Reactor"; +import {RListener} from "./Reactor"; +import Connection from "./Connection";*/ +import {Reactor, RListener, Connection} from "."; /** * Implements {@link Connection} and a linked-list style listener list for {@link Reactor}s. */ -export class Cons implements Connection { +export default class Cons implements Connection { /** The next connection in our chain. */ public next: Cons; diff --git a/src/signals/FilteredSignal.ts b/src/signals/FilteredSignal.ts index 521885819..9f7e6e7bf 100644 --- a/src/signals/FilteredSignal.ts +++ b/src/signals/FilteredSignal.ts @@ -1,8 +1,9 @@ -import {MappedSignal} from "./MappedSignal"; -import {SignalView} from "./SignalView"; -import {Connection} from "./Connection"; +/*import MappedSignal from "./MappedSignal"; +import SignalView from "./SignalView"; +import Connection from "./Connection";*/ +import {MappedSignal, SignalView, Connection} from "."; -export class FilteredSignal extends MappedSignal { +export default class FilteredSignal extends MappedSignal { constructor(source: SignalView, pred: (value: T) => boolean) { super(); this._source = source; diff --git a/src/signals/MappedSignal.ts b/src/signals/MappedSignal.ts index 02e3e6f90..1c663233f 100644 --- a/src/signals/MappedSignal.ts +++ b/src/signals/MappedSignal.ts @@ -1,7 +1,8 @@ -import {AbstractSignal} from "./AbstractSignal"; -import {FilteredSignal} from "./FilteredSignal"; -import {SignalView} from "./SignalView"; -import {Connection} from "./Connection"; +/*import AbstractSignal from "./AbstractSignal"; +import FilteredSignal from "./FilteredSignal"; +import SignalView from "./SignalView"; +import Connection from "./Connection";*/ +import {AbstractSignal, FilteredSignal, SignalView, Connection} from "."; /** * Plumbing to implement mapped signals in such a way that they automatically manage a connection @@ -9,7 +10,7 @@ import {Connection} from "./Connection"; * connection to the underlying signal, and when it removes its last connection it clears its * connection from the underlying signal. */ -export abstract class MappedSignal extends AbstractSignal { +export default abstract class MappedSignal extends AbstractSignal { public static create( source: SignalView, f: (value: TSource) => TMapped diff --git a/src/signals/MappedValue.ts b/src/signals/MappedValue.ts index 7c0f4210a..bea14ca27 100644 --- a/src/signals/MappedValue.ts +++ b/src/signals/MappedValue.ts @@ -1,6 +1,7 @@ -import {AbstractValue} from "./AbstractValue"; -import {ValueView} from "./ValueView"; -import {Connection} from "./Connection"; +/*import AbstractValue from "./AbstractValue"; +import ValueView from "./ValueView"; +import Connection from "./Connection";*/ +import {AbstractValue, ValueView, Connection} from "."; /** * Plumbing to implement mapped values in such a way that they automatically manage a connection to @@ -8,7 +9,7 @@ import {Connection} from "./Connection"; * connection to the underlying value, and when it removes its last connection it clears its * connection from the underlying value. */ -export abstract class MappedValue extends AbstractValue { +export default abstract class MappedValue extends AbstractValue { public static create(source: ValueView, map: (value: T) => U): ValueView { return new MappedValueImpl(source, map); } diff --git a/src/signals/MultiFailureError.ts b/src/signals/MultiFailureError.ts index fde71d3ff..8b218ba97 100644 --- a/src/signals/MultiFailureError.ts +++ b/src/signals/MultiFailureError.ts @@ -1,7 +1,7 @@ /** * An exception thrown to communicate multiple listener failures. */ -export class MultiFailureError extends Error { +export default class MultiFailureError extends Error { public get failures(): any[] { return this._failures; } diff --git a/src/signals/Reactor.ts b/src/signals/Reactor.ts index 0c371ca02..beced10ba 100644 --- a/src/signals/Reactor.ts +++ b/src/signals/Reactor.ts @@ -1,4 +1,5 @@ -import {Cons} from "./Cons"; +//import Cons from "./Cons"; +import {Cons} from "."; export type RListener = (arg1?: any, arg2?: any, arg3?: any) => void; @@ -6,7 +7,7 @@ export type RListener = (arg1?: any, arg2?: any, arg3?: any) => void; * A base class for all reactive classes. This is an implementation detail, but is public so that * third parties may use it to create their own reactive classes, if desired. */ -export abstract class Reactor { +export default abstract class Reactor { /** true if this reactor has at least one connection. */ public get hasConnections(): boolean { return this._listeners != null; diff --git a/src/signals/Registration.ts b/src/signals/Registration.ts index f947b5141..3fefb2b7e 100644 --- a/src/signals/Registration.ts +++ b/src/signals/Registration.ts @@ -1,4 +1,4 @@ -export interface Registration { +export default interface Registration { /** Closes this resource stream, freeing all resources associated with it. */ close(): void; } diff --git a/src/signals/RegistrationGroup.ts b/src/signals/RegistrationGroup.ts index 049687ff2..47c19af5b 100644 --- a/src/signals/RegistrationGroup.ts +++ b/src/signals/RegistrationGroup.ts @@ -1,8 +1,9 @@ -import {MultiFailureError} from "./MultiFailureError"; -import {Registration} from "./Registration"; +/*import MultiFailureError from "./MultiFailureError"; +import Registration from "./Registration";*/ +import {MultiFailureError, Registration} from "."; /** Collects Registrations to allow mass operations on them. */ -export class RegistrationGroup implements Registration { +export default class RegistrationGroup implements Registration { /** * Adds a Registration to the manager. * @return the Registration passed to the function. diff --git a/src/signals/Registrations.ts b/src/signals/Registrations.ts index 7c97cfcfd..4d50b37bd 100644 --- a/src/signals/Registrations.ts +++ b/src/signals/Registrations.ts @@ -1,6 +1,7 @@ -import {Registration} from "./Registration"; +//import Registration from "./Registration"; +import {Registration} from "."; -export class Registrations { +export default class Registrations { /** Returns a Registration that will call the given function when disconnected */ public static createWithFunction(f: () => void): Registration { return new FunctionRegistration(f); diff --git a/src/signals/Signal.ts b/src/signals/Signal.ts index ec08dfd13..f2eb20399 100644 --- a/src/signals/Signal.ts +++ b/src/signals/Signal.ts @@ -1,10 +1,11 @@ -import {AbstractSignal} from "./AbstractSignal"; -import {FilteredSignal} from "./FilteredSignal"; -import {MappedSignal} from "./MappedSignal"; -import {SignalView} from "./SignalView"; +/*import AbstractSignal from "./AbstractSignal"; +import FilteredSignal from "./FilteredSignal"; +import MappedSignal from "./MappedSignal"; +import SignalView from "./SignalView"; */ +import {AbstractSignal, FilteredSignal, MappedSignal, SignalView} from "."; /** A signal that emits events of type {@code T}. */ -export class Signal extends AbstractSignal { +export default class Signal extends AbstractSignal { public map(func: (value: T) => U): SignalView { return MappedSignal.create(this, func); } diff --git a/src/signals/SignalView.ts b/src/signals/SignalView.ts index 7bb0eca8f..e72ea6f47 100644 --- a/src/signals/SignalView.ts +++ b/src/signals/SignalView.ts @@ -1,11 +1,12 @@ -import {Connection} from "./Connection"; +//import Connection from "./Connection"; +import {Connection} from "."; /** * A view of a {@link Signal}, on which slots may listen, but to which one cannot emit events. This * is generally used to provide signal-like views of changing entities. See {@link AbstractValue} * for an example. */ -export interface SignalView { +export default interface SignalView { /** * Creates a signal that maps this signal via a function. When this signal emits a value, the * mapped signal will emit that value as transformed by the supplied function. The mapped value diff --git a/src/signals/UnitSignal.ts b/src/signals/UnitSignal.ts index 57746339a..3f108fc11 100644 --- a/src/signals/UnitSignal.ts +++ b/src/signals/UnitSignal.ts @@ -1,10 +1,11 @@ -import {AbstractSignal} from "./AbstractSignal"; -import {FilteredSignal} from "./FilteredSignal"; -import {MappedSignal} from "./MappedSignal"; -import {SignalView} from "./SignalView"; +/*import AbstractSignal from "./AbstractSignal"; +import FilteredSignal from "./FilteredSignal"; +import MappedSignal from "./MappedSignal"; +import SignalView from "./SignalView";*/ +import {AbstractSignal, FilteredSignal, MappedSignal, SignalView} from "."; /** A signal that emits an event with no associated data. */ -export class UnitSignal extends AbstractSignal { +export default class UnitSignal extends AbstractSignal { public map(func: (value: void) => U): SignalView { return MappedSignal.create(this, func); } diff --git a/src/signals/Value.ts b/src/signals/Value.ts index e3c24b4ec..035e6ad69 100644 --- a/src/signals/Value.ts +++ b/src/signals/Value.ts @@ -1,8 +1,9 @@ -import {AbstractValue} from "./AbstractValue"; -import {MappedValue} from "./MappedValue"; -import {ValueView} from "./ValueView"; +/*import AbstractValue from "./AbstractValue"; +import MappedValue from "./MappedValue"; +import ValueView from "./ValueView";*/ +import {AbstractValue, MappedValue, ValueView} from "."; -export class Value extends AbstractValue implements ValueView { +export default class Value extends AbstractValue implements ValueView { /** Creates an instance with the supplied starting value. */ constructor(value: T) { super(); diff --git a/src/signals/ValueView.ts b/src/signals/ValueView.ts index 176f48cd9..5efefb307 100644 --- a/src/signals/ValueView.ts +++ b/src/signals/ValueView.ts @@ -1,11 +1,12 @@ -import {Connection} from "./Connection"; +//import Connection from "./Connection"; +import {Connection} from "."; /** * A view of a {@link AbstractValue} subclass, to which listeners may be added, but which one * cannot update. Value consumers should require only a view on a value, rather than a * concrete value. */ -export interface ValueView { +export default interface ValueView { /** Returns the current value. */ value: T; diff --git a/src/signals/index.ts b/src/signals/index.ts new file mode 100644 index 000000000..15e09b5db --- /dev/null +++ b/src/signals/index.ts @@ -0,0 +1,17 @@ +export {default as Cons} from "./Cons"; +export {default as Reactor, RListener} from "./Reactor"; +export {default as AbstractSignal} from "./AbstractSignal"; +export {default as AbstractValue} from "./AbstractValue"; +export {default as Connection} from "./Connection"; +export {default as MappedSignal} from "./MappedSignal"; +export {default as FilteredSignal} from "./FilteredSignal"; +export {default as MappedValue} from "./MappedValue"; +export {default as MultiFailureError} from "./MultiFailureError"; +export {default as Registration} from "./Registration"; +export {default as RegistrationGroup} from "./RegistrationGroup"; +export {default as Registrations} from "./Registrations"; +export {default as Signal} from "./Signal"; +export {default as SignalView} from "./SignalView"; +export {default as UnitSignal} from "./UnitSignal"; +export {default as Value} from "./Value"; +export {default as ValueView} from "./ValueView"; \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 8bf9f8788..8647f6311 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,8 @@ "moduleResolution": "node", "strictFunctionTypes": true, "strictPropertyInitialization": false, - "strictNullChecks": false + "strictNullChecks": false, + "baseUrl": "./src", }, "include": [ "./src/**/*.ts" diff --git a/webpack.common.js b/webpack.common.js index 44f2bf5e8..a308c0871 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -26,6 +26,9 @@ module.exports = { extensions: [".ts", ".tsx", ".js", ".json"], alias: { assets: path.resolve(__dirname, 'assets/'), + signals: path.resolve(__dirname, 'src/signals'), + flashbang: path.resolve(__dirname, 'src/flashbang'), + eterna: path.resolve(__dirname, 'src/eterna'), } }, From 5ab5a0ae36cb404cab9add885c0305ebd823eb14 Mon Sep 17 00:00:00 2001 From: LFP6 Date: Thu, 6 Jun 2019 15:33:16 -0400 Subject: [PATCH 03/39] Lint autofix --- src/eterna/EternaApp.ts | 8 ++++++-- src/eterna/achievements/AchievementBox.ts | 4 +++- src/eterna/achievements/AchievementManager.ts | 4 +++- src/eterna/achievements/index.ts | 2 +- src/eterna/debug/TestMode.ts | 4 +++- src/eterna/debug/index.ts | 2 +- src/eterna/emscripten/index.ts | 2 +- src/eterna/folding/FolderManager.ts | 4 +++- src/eterna/folding/index.ts | 2 +- .../CustomizeColumnOrderDialog.ts | 4 +++- src/eterna/mode/DesignBrowser/DataCol.ts | 8 ++++++-- .../mode/DesignBrowser/DesignBrowserMode.ts | 12 +++++++++--- .../DesignBrowser/SequenceStringListView.ts | 4 +++- .../mode/DesignBrowser/SolutionDescBox.ts | 4 +++- src/eterna/mode/DesignBrowser/SortOptions.ts | 19 +++++++++---------- .../mode/DesignBrowser/SortOptionsDialog.ts | 8 ++++++-- .../mode/DesignBrowser/ViewSolutionDialog.ts | 8 ++++++-- src/eterna/mode/DesignBrowser/index.ts | 2 +- .../mode/FeedbackView/FeedbackViewMode.ts | 8 +++++--- src/eterna/mode/FeedbackView/index.ts | 2 +- src/eterna/mode/GameMode.ts | 4 +++- src/eterna/mode/LoadingMode.ts | 4 +++- .../mode/PoseEdit/MissionClearedPanel.ts | 8 ++++++-- src/eterna/mode/PoseEdit/MissionIntroMode.ts | 8 ++++++-- src/eterna/mode/PoseEdit/PoseEditToolbar.ts | 4 +++- src/eterna/mode/PoseEdit/index.ts | 2 +- src/eterna/mode/PuzzleEdit/PuzzleEditMode.ts | 12 +++++++++--- src/eterna/mode/PuzzleEdit/StructureInput.ts | 4 ++-- src/eterna/mode/PuzzleEdit/index.ts | 2 +- src/eterna/mode/index.ts | 2 +- src/eterna/net/index.ts | 2 +- src/eterna/puzzle/index.ts | 6 ++++-- src/eterna/rank/index.ts | 2 +- src/eterna/resources/index.ts | 2 +- src/eterna/rscript/NovaPaintHint.ts | 4 ++-- src/eterna/rscript/ROPHighlight.ts | 4 +++- src/eterna/rscript/ROPTextbox.ts | 4 +++- src/eterna/rscript/ROPWait.ts | 4 +++- src/eterna/rscript/index.ts | 2 +- src/eterna/settings/index.ts | 2 +- src/eterna/ui/Band.ts | 4 +++- src/eterna/ui/ConfirmDialog.ts | 4 +++- src/eterna/ui/ConstraintBox.ts | 16 ++++++++++++---- src/eterna/ui/Dialog.ts | 4 +++- src/eterna/ui/EternaViewOptionsDialog.ts | 4 +++- src/eterna/ui/FixedWidthTextField.ts | 4 +++- src/eterna/ui/GameButton.ts | 6 ++++-- src/eterna/ui/GamePanel.ts | 4 +++- src/eterna/ui/NucleotidePalette.ts | 8 ++++++-- src/eterna/ui/PoseThumbnail.ts | 4 +++- src/eterna/ui/SpecBox.ts | 8 ++++++-- src/eterna/ui/TextBalloon.ts | 4 +++- src/eterna/ui/TextInputPanel.ts | 4 ++-- src/eterna/ui/Tooltips.ts | 4 +++- src/eterna/ui/index.ts | 2 +- src/eterna/util/index.ts | 2 +- src/eterna/vfx/index.ts | 2 +- src/flashbang/core/AppMode.ts | 8 ++++++-- src/flashbang/core/GameObjectBase.ts | 4 +++- src/flashbang/core/index.ts | 2 +- src/flashbang/geom/index.ts | 2 +- src/flashbang/input/KeyboardEventType.ts | 2 +- src/flashbang/input/index.ts | 2 +- src/flashbang/layout/index.ts | 2 +- src/flashbang/objects/index.ts | 2 +- src/flashbang/resources/index.ts | 2 +- src/flashbang/settings/index.ts | 2 +- src/flashbang/tasks/index.ts | 2 +- src/flashbang/util/DisplayUtil.ts | 4 +++- src/flashbang/util/EventSignal.ts | 4 +++- src/flashbang/util/TextureUtil.ts | 4 +++- src/flashbang/util/index.ts | 2 +- src/signals/AbstractSignal.ts | 4 ++-- src/signals/AbstractValue.ts | 8 +++++--- src/signals/Connection.ts | 2 +- src/signals/Cons.ts | 4 ++-- src/signals/FilteredSignal.ts | 4 ++-- src/signals/MappedSignal.ts | 8 +++++--- src/signals/MappedValue.ts | 4 ++-- src/signals/Reactor.ts | 2 +- src/signals/RegistrationGroup.ts | 4 ++-- src/signals/Registrations.ts | 2 +- src/signals/Signal.ts | 6 ++++-- src/signals/SignalView.ts | 2 +- src/signals/UnitSignal.ts | 8 +++++--- src/signals/Value.ts | 4 ++-- src/signals/ValueView.ts | 2 +- src/signals/index.ts | 2 +- 88 files changed, 254 insertions(+), 133 deletions(-) diff --git a/src/eterna/EternaApp.ts b/src/eterna/EternaApp.ts index 3094e7a4f..a9d48175d 100644 --- a/src/eterna/EternaApp.ts +++ b/src/eterna/EternaApp.ts @@ -6,13 +6,17 @@ import {ErrorUtil, TextureUtil} from "flashbang/util"; import ChatManager from "eterna/ChatManager"; import {TestMode} from "eterna/debug"; import Eterna from "eterna/Eterna"; -import {Folder, FolderManager, LinearFoldC, LinearFoldV, NuPACK, RNAFoldBasic, Vienna, Vienna2} from "eterna/folding"; +import { + Folder, FolderManager, LinearFoldC, LinearFoldV, NuPACK, RNAFoldBasic, Vienna, Vienna2 +} from "eterna/folding"; import { LoadingMode, FeedbackViewMode, DesignBrowserFilter, DesignBrowserMode, PoseEditMode, PoseEditParams, PuzzleEditMode, PuzzleEditPoseData } from "eterna/mode"; import {GameClient} from "eterna/net"; -import {Puzzle, PuzzleManager, Solution, SolutionManager} from "eterna/puzzle"; +import { + Puzzle, PuzzleManager, Solution, SolutionManager +} from "eterna/puzzle"; import {Bitmaps, SoundManager} from "eterna/resources"; import {EternaSettings} from "eterna/settings"; import {ExternalInterface, ExternalInterfaceCtx, Fonts} from "eterna/util"; diff --git a/src/eterna/achievements/AchievementBox.ts b/src/eterna/achievements/AchievementBox.ts index 5cc12ac51..83c80edf1 100644 --- a/src/eterna/achievements/AchievementBox.ts +++ b/src/eterna/achievements/AchievementBox.ts @@ -1,7 +1,9 @@ import * as log from "loglevel"; import {Point, Sprite, Text} from "pixi.js"; import {ContainerObject} from "flashbang/objects"; -import {AlphaTask, DelayTask, ParallelTask, ScaleTask, SerialTask} from "flashbang/tasks"; +import { + AlphaTask, DelayTask, ParallelTask, ScaleTask, SerialTask +} from "flashbang/tasks"; import {Easing, TextureUtil} from "flashbang/util"; import {PlaySoundTask, Sounds} from "eterna/resources"; import {GameButton, GamePanel, GamePanelType} from "eterna/ui"; diff --git a/src/eterna/achievements/AchievementManager.ts b/src/eterna/achievements/AchievementManager.ts index 8d9fd0ffc..e016c15dc 100644 --- a/src/eterna/achievements/AchievementManager.ts +++ b/src/eterna/achievements/AchievementManager.ts @@ -1,4 +1,6 @@ -import {HAlign, VAlign, GameObject, GameObjectRef} from "flashbang/core"; +import { + HAlign, VAlign, GameObject, GameObjectRef +} from "flashbang/core"; import {CallbackTask, FunctionTask, SerialTask} from "flashbang/tasks"; import {DisplayUtil} from "flashbang/util"; import {GameMode} from "eterna/mode"; diff --git a/src/eterna/achievements/index.ts b/src/eterna/achievements/index.ts index a7cd6ffc3..ef5ad0f3a 100644 --- a/src/eterna/achievements/index.ts +++ b/src/eterna/achievements/index.ts @@ -1,2 +1,2 @@ export {default as AchievementBox} from "./AchievementBox"; -export {default as AchievementManager} from "./AchievementManager"; \ No newline at end of file +export {default as AchievementManager} from "./AchievementManager"; diff --git a/src/eterna/debug/TestMode.ts b/src/eterna/debug/TestMode.ts index 46ee3d2ab..2260ba475 100644 --- a/src/eterna/debug/TestMode.ts +++ b/src/eterna/debug/TestMode.ts @@ -1,6 +1,8 @@ import {GameMode} from "../mode"; import {ViewSolutionDialog} from "../mode/DesignBrowser"; -import {Puzzle, PuzzleManager, Solution, SolutionManager} from "../puzzle"; +import { + Puzzle, PuzzleManager, Solution, SolutionManager +} from "../puzzle"; export default class TestMode extends GameMode { protected setup(): void { diff --git a/src/eterna/debug/index.ts b/src/eterna/debug/index.ts index 80fb07b2e..8623b3889 100644 --- a/src/eterna/debug/index.ts +++ b/src/eterna/debug/index.ts @@ -1 +1 @@ -export {default as TestMode} from "./TestMode"; \ No newline at end of file +export {default as TestMode} from "./TestMode"; diff --git a/src/eterna/emscripten/index.ts b/src/eterna/emscripten/index.ts index c4ed37bc6..880d272ac 100644 --- a/src/eterna/emscripten/index.ts +++ b/src/eterna/emscripten/index.ts @@ -1 +1 @@ -export {default as EmscriptenUtil} from "./EmscriptenUtil"; \ No newline at end of file +export {default as EmscriptenUtil} from "./EmscriptenUtil"; diff --git a/src/eterna/folding/FolderManager.ts b/src/eterna/folding/FolderManager.ts index 6456aa0be..1b55b87fb 100644 --- a/src/eterna/folding/FolderManager.ts +++ b/src/eterna/folding/FolderManager.ts @@ -1,5 +1,7 @@ import Eterna from "eterna/Eterna"; -import {Folder, LinearFoldC, RNAFoldBasic, Vienna} from "."; +import { + Folder, LinearFoldC, RNAFoldBasic, Vienna +} from "."; export default class FolderManager { public static get instance(): FolderManager { diff --git a/src/eterna/folding/index.ts b/src/eterna/folding/index.ts index 5a9509da1..078281637 100644 --- a/src/eterna/folding/index.ts +++ b/src/eterna/folding/index.ts @@ -7,4 +7,4 @@ export {default as LinearFoldV} from "./LinearFoldV"; export {default as NuPACK} from "./NuPACK"; export {default as RNAFoldBasic} from "./RNAFoldBasic"; export {default as Vienna} from "./Vienna"; -export {default as Vienna2} from "./Vienna2"; \ No newline at end of file +export {default as Vienna2} from "./Vienna2"; diff --git a/src/eterna/mode/DesignBrowser/CustomizeColumnOrderDialog.ts b/src/eterna/mode/DesignBrowser/CustomizeColumnOrderDialog.ts index 47987ceef..bfde1da0c 100644 --- a/src/eterna/mode/DesignBrowser/CustomizeColumnOrderDialog.ts +++ b/src/eterna/mode/DesignBrowser/CustomizeColumnOrderDialog.ts @@ -4,7 +4,9 @@ import {HLayoutContainer, VLayoutContainer} from "flashbang/layout"; import {Arrays, DisplayUtil} from "flashbang/util"; import {Signal} from "signals"; import {Bitmaps} from "eterna/resources"; -import {Dialog, FixedWidthTextField, GameButton, GamePanel, GamePanelType} from "eterna/ui"; +import { + Dialog, FixedWidthTextField, GameButton, GamePanel, GamePanelType +} from "eterna/ui"; import {Fonts, GraphicsUtil} from "eterna/util"; import {DesignCategory} from "."; diff --git a/src/eterna/mode/DesignBrowser/DataCol.ts b/src/eterna/mode/DesignBrowser/DataCol.ts index 0fe3a64d2..efd94549a 100644 --- a/src/eterna/mode/DesignBrowser/DataCol.ts +++ b/src/eterna/mode/DesignBrowser/DataCol.ts @@ -1,4 +1,6 @@ -import {Container, Graphics, Point, Text} from "pixi.js"; +import { + Container, Graphics, Point, Text +} from "pixi.js"; import {Flashbang} from "flashbang/core"; import {ContainerObject} from "flashbang/objects"; import {TextBuilder} from "flashbang/util"; @@ -7,7 +9,9 @@ import Feedback from "eterna/Feedback"; import {Solution} from "eterna/puzzle"; import {GameButton, TextInputObject} from "eterna/ui"; import {Fonts, int, Utility} from "eterna/util"; -import {DesignBrowserDataType, DesignCategory, SequenceStringListView, SortOrder} from "."; +import { + DesignBrowserDataType, DesignCategory, SequenceStringListView, SortOrder +} from "."; export default class DataCol extends ContainerObject { public readonly sortOrderChanged = new Signal(); diff --git a/src/eterna/mode/DesignBrowser/DesignBrowserMode.ts b/src/eterna/mode/DesignBrowser/DesignBrowserMode.ts index 572ee375b..fdffbbe98 100644 --- a/src/eterna/mode/DesignBrowser/DesignBrowserMode.ts +++ b/src/eterna/mode/DesignBrowser/DesignBrowserMode.ts @@ -1,17 +1,23 @@ import * as log from "loglevel"; import MultiStyleText from "pixi-multistyle-text"; -import {Container, Graphics, Point, Sprite, Text} from "pixi.js"; +import { + Container, Graphics, Point, Sprite, Text +} from "pixi.js"; import {Flashbang, HAlign, VAlign} from "flashbang/core"; import {HLayoutContainer} from "flashbang/layout"; import {ContainerObject, SceneObject} from "flashbang/objects"; -import {AlphaTask, CallbackTask, DelayTask, LocationTask, RepeatingTask, SerialTask} from "flashbang/tasks"; +import { + AlphaTask, CallbackTask, DelayTask, LocationTask, RepeatingTask, SerialTask +} from "flashbang/tasks"; import {DisplayUtil, Easing, MathUtil} from "flashbang/util"; import EPars from "eterna/EPars"; import Eterna from "eterna/Eterna"; import Feedback from "eterna/Feedback"; import {Puzzle, Solution, SolutionManager} from "eterna/puzzle"; import {BitmapManager, Bitmaps} from "eterna/resources"; -import {GameButton, GamePanel, HTMLTextObject, SliderBar, URLButton} from "eterna/ui"; +import { + GameButton, GamePanel, HTMLTextObject, SliderBar, URLButton +} from "eterna/ui"; import {Fonts, int} from "eterna/util"; import {GameMode} from "eterna/mode"; import { diff --git a/src/eterna/mode/DesignBrowser/SequenceStringListView.ts b/src/eterna/mode/DesignBrowser/SequenceStringListView.ts index 302294d3d..a9158f5f8 100644 --- a/src/eterna/mode/DesignBrowser/SequenceStringListView.ts +++ b/src/eterna/mode/DesignBrowser/SequenceStringListView.ts @@ -1,4 +1,6 @@ -import {Container, Graphics, Sprite, Texture} from "pixi.js"; +import { + Container, Graphics, Sprite, Texture +} from "pixi.js"; import {TextBuilder, TextureUtil} from "flashbang/util"; import EPars from "eterna/EPars"; import Eterna from "eterna/Eterna"; diff --git a/src/eterna/mode/DesignBrowser/SolutionDescBox.ts b/src/eterna/mode/DesignBrowser/SolutionDescBox.ts index 0bfaecdbf..dd60bf6e3 100644 --- a/src/eterna/mode/DesignBrowser/SolutionDescBox.ts +++ b/src/eterna/mode/DesignBrowser/SolutionDescBox.ts @@ -8,7 +8,9 @@ import Eterna from "eterna/Eterna"; import Feedback from "eterna/Feedback"; import {EternaURL} from "eterna/net"; import {Puzzle, Solution} from "eterna/puzzle"; -import {GameButton, GamePanel, GamePanelType, HTMLTextObject, TextInputObject, VScrollBox} from "eterna/ui"; +import { + GameButton, GamePanel, GamePanelType, HTMLTextObject, TextInputObject, VScrollBox +} from "eterna/ui"; import {Fonts, Utility} from "eterna/util"; import {CopyTextDialogMode, GameMode} from "eterna/mode"; import {LabComments} from "."; diff --git a/src/eterna/mode/DesignBrowser/SortOptions.ts b/src/eterna/mode/DesignBrowser/SortOptions.ts index 13752a860..eda8e8c40 100644 --- a/src/eterna/mode/DesignBrowser/SortOptions.ts +++ b/src/eterna/mode/DesignBrowser/SortOptions.ts @@ -65,9 +65,9 @@ export default class SortOptions { if (criterion.category == DesignCategory.Sequence) { let anchor_sequence: string = criterion.arg; let a_string: string = a.sequence; - if (a_string == null) throw new Error(`solution ${ a.nodeID } invalid`); + if (a_string == null) throw new Error(`solution ${a.nodeID} invalid`); let b_string: string = b.sequence; - if (b_string == null) throw new Error(`solution ${ b.nodeID } invalid`); + if (b_string == null) throw new Error(`solution ${b.nodeID} invalid`); if (a_string.length != anchor_sequence.length || b_string.length != anchor_sequence.length) { throw new Error("Wrong anchor sequence length"); } @@ -99,11 +99,10 @@ export default class SortOptions { return -1; } } else if (aProperty < bProperty) { - return -1; - } else if (aProperty > bProperty) { - return 1; - } - + return -1; + } else if (aProperty > bProperty) { + return 1; + } } if (a.nodeID < b.nodeID) { @@ -131,7 +130,7 @@ export default class SortOptions { public removeCriteria(category: DesignCategory): void { let idx = this.getCriterionIdx(category); if (idx < 0) { - throw new Error(`Can't find sort_category ${ category}`); + throw new Error(`Can't find sort_category ${category}`); } this._criteria.splice(idx, 1); @@ -142,7 +141,7 @@ export default class SortOptions { public toggleSort(category: DesignCategory): SortOrder { let criterion = this.getCriterion(category); if (criterion == null) { - throw new Error(`Can't find category ${ category}`); + throw new Error(`Can't find category ${category}`); } criterion.sortOrder *= -1; @@ -154,7 +153,7 @@ export default class SortOptions { public setCriteriaIdx(category: DesignCategory, newIdx: number): void { let curIdx = this.getCriterionIdx(category); if (curIdx < 0) { - throw new Error(`Can't find sort_category ${ category}`); + throw new Error(`Can't find sort_category ${category}`); } if (newIdx === curIdx || newIdx < 0 || newIdx >= this._criteria.length) { diff --git a/src/eterna/mode/DesignBrowser/SortOptionsDialog.ts b/src/eterna/mode/DesignBrowser/SortOptionsDialog.ts index e04b4bb59..de344c34c 100644 --- a/src/eterna/mode/DesignBrowser/SortOptionsDialog.ts +++ b/src/eterna/mode/DesignBrowser/SortOptionsDialog.ts @@ -1,9 +1,13 @@ -import {Container, Graphics, Point, Text} from "pixi.js"; +import { + Container, Graphics, Point, Text +} from "pixi.js"; import {HAlign, VAlign} from "flashbang/core"; import {HLayoutContainer, VLayoutContainer} from "flashbang/layout"; import {Arrays, DisplayUtil} from "flashbang/util"; import {Bitmaps} from "eterna/resources"; -import {Dialog, FixedWidthTextField, GameButton, GamePanel, GamePanelType} from "eterna/ui"; +import { + Dialog, FixedWidthTextField, GameButton, GamePanel, GamePanelType +} from "eterna/ui"; import {Fonts, GraphicsUtil} from "eterna/util"; import {DesignCategory, SortOptions, SortOrder} from "."; diff --git a/src/eterna/mode/DesignBrowser/ViewSolutionDialog.ts b/src/eterna/mode/DesignBrowser/ViewSolutionDialog.ts index d828b098e..e4627b5b9 100644 --- a/src/eterna/mode/DesignBrowser/ViewSolutionDialog.ts +++ b/src/eterna/mode/DesignBrowser/ViewSolutionDialog.ts @@ -1,4 +1,6 @@ -import {Container, Graphics, Point, Sprite, Text} from "pixi.js"; +import { + Container, Graphics, Point, Sprite, Text +} from "pixi.js"; import {Flashbang, HAlign, VAlign} from "flashbang/core"; import {HLayoutContainer} from "flashbang/layout"; import {DisplayUtil, MathUtil} from "flashbang/util"; @@ -8,7 +10,9 @@ import Eterna from "eterna/Eterna"; import ExpPainter from "eterna/ExpPainter"; import {Puzzle, Solution} from "eterna/puzzle"; import {Bitmaps} from "eterna/resources"; -import {Dialog, GameButton, GamePanel, PoseThumbnail, PoseThumbnailType} from "eterna/ui"; +import { + Dialog, GameButton, GamePanel, PoseThumbnail, PoseThumbnailType +} from "eterna/ui"; import {Fonts} from "eterna/util"; import {SolutionDescBox} from "."; diff --git a/src/eterna/mode/DesignBrowser/index.ts b/src/eterna/mode/DesignBrowser/index.ts index be87452ff..58f6e0622 100644 --- a/src/eterna/mode/DesignBrowser/index.ts +++ b/src/eterna/mode/DesignBrowser/index.ts @@ -13,4 +13,4 @@ export {default as SolutionDescBox} from "./SolutionDescBox"; export {default as SortOptions, SortOrder, SortCriterion} from "./SortOptions"; export {default as SortOptionsDialog} from "./SortOptionsDialog"; export {default as ViewSolutionDialog} from "./ViewSolutionDialog"; -export {default as VoteProcessor} from "./VoteProcessor"; \ No newline at end of file +export {default as VoteProcessor} from "./VoteProcessor"; diff --git a/src/eterna/mode/FeedbackView/FeedbackViewMode.ts b/src/eterna/mode/FeedbackView/FeedbackViewMode.ts index e0ff240a7..d3c61d5fe 100644 --- a/src/eterna/mode/FeedbackView/FeedbackViewMode.ts +++ b/src/eterna/mode/FeedbackView/FeedbackViewMode.ts @@ -11,9 +11,11 @@ import UndoBlock from "eterna/UndoBlock"; import {Folder, FolderManager, Vienna} from "eterna/folding"; import {PoseField} from "eterna/pose2D"; import {Puzzle, Solution} from "eterna/puzzle"; -import {EternaViewOptionsDialog, EternaViewOptionsMode, SpecBoxDialog, URLButton} from "eterna/ui"; -import {Fonts} from "eterna/util"; -import {Utility} from "eterna/util"; +import { + EternaViewOptionsDialog, EternaViewOptionsMode, SpecBoxDialog, URLButton +} from "eterna/ui"; +import {Fonts, Utility} from "eterna/util"; + import {Background} from "eterna/vfx"; import {GameMode} from "eterna/mode"; import {FeedbackViewToolbar} from "."; diff --git a/src/eterna/mode/FeedbackView/index.ts b/src/eterna/mode/FeedbackView/index.ts index 4d582c378..e44e426c9 100644 --- a/src/eterna/mode/FeedbackView/index.ts +++ b/src/eterna/mode/FeedbackView/index.ts @@ -1,2 +1,2 @@ export {default as FeedbackViewMode} from "./FeedbackViewMode"; -export {default as FeedbackViewToolbar} from "./FeedbackViewToolbar";`` \ No newline at end of file +export {default as FeedbackViewToolbar} from "./FeedbackViewToolbar"; ""; diff --git a/src/eterna/mode/GameMode.ts b/src/eterna/mode/GameMode.ts index ed1f227f0..3f631e405 100644 --- a/src/eterna/mode/GameMode.ts +++ b/src/eterna/mode/GameMode.ts @@ -6,7 +6,9 @@ import {AchievementManager} from "eterna/achievements"; import Eterna from "eterna/Eterna"; import {EternaURL} from "eterna/net"; import {Pose2D, PoseField} from "eterna/pose2D"; -import {ConfirmDialog, ContextMenu, Dialog, NotificationDialog, Tooltips, UILockDialog, URLButton} from "eterna/ui"; +import { + ConfirmDialog, ContextMenu, Dialog, NotificationDialog, Tooltips, UILockDialog, URLButton +} from "eterna/ui"; import {ExternalInterface, ExternalInterfaceCtx} from "eterna/util"; import {Folder} from "eterna/folding"; import UndoBlock from "eterna/UndoBlock"; diff --git a/src/eterna/mode/LoadingMode.ts b/src/eterna/mode/LoadingMode.ts index e396d9e5a..bf3effdd0 100644 --- a/src/eterna/mode/LoadingMode.ts +++ b/src/eterna/mode/LoadingMode.ts @@ -1,7 +1,9 @@ import {Text} from "pixi.js"; import {Flashbang, AppMode, ObjectTask} from "flashbang/core"; import {ContainerObject} from "flashbang/objects"; -import {DelayTask, RepeatingTask, ScaleTask, SerialTask} from "flashbang/tasks"; +import { + DelayTask, RepeatingTask, ScaleTask, SerialTask +} from "flashbang/tasks"; import {Easing} from "flashbang/util"; import Eterna from "eterna/Eterna"; import {Fonts} from "eterna/util"; diff --git a/src/eterna/mode/PoseEdit/MissionClearedPanel.ts b/src/eterna/mode/PoseEdit/MissionClearedPanel.ts index 7110dd8c9..18e9eda51 100644 --- a/src/eterna/mode/PoseEdit/MissionClearedPanel.ts +++ b/src/eterna/mode/PoseEdit/MissionClearedPanel.ts @@ -1,4 +1,6 @@ -import {Container, Graphics, Point, Text} from "pixi.js"; +import { + Container, Graphics, Point, Text +} from "pixi.js"; import {Flashbang, HAlign, VAlign} from "flashbang/core"; import {VLayoutContainer} from "flashbang/layout"; import {ContainerObject, DOMObject} from "flashbang/objects"; @@ -6,7 +8,9 @@ import {AlphaTask} from "flashbang/tasks"; import {DisplayUtil} from "flashbang/util"; import {RankScroll} from "eterna/rank"; import {Bitmaps} from "eterna/resources"; -import {GameButton, GamePanel, GamePanelType, HTMLTextObject} from "eterna/ui"; +import { + GameButton, GamePanel, GamePanelType, HTMLTextObject +} from "eterna/ui"; import {Fonts} from "eterna/util"; export default class MissionClearedPanel extends ContainerObject { diff --git a/src/eterna/mode/PoseEdit/MissionIntroMode.ts b/src/eterna/mode/PoseEdit/MissionIntroMode.ts index af1be5e15..f08c01e82 100644 --- a/src/eterna/mode/PoseEdit/MissionIntroMode.ts +++ b/src/eterna/mode/PoseEdit/MissionIntroMode.ts @@ -1,11 +1,15 @@ -import {Container, Graphics, Point, Sprite} from "pixi.js"; +import { + Container, Graphics, Point, Sprite +} from "pixi.js"; import {Flashbang, AppMode} from "flashbang/core"; import {DisplayObjectPointerTarget, InputUtil, KeyCode} from "flashbang/input"; import {DisplayUtil, StyledTextBuilder} from "flashbang/util"; import EPars from "eterna/EPars"; import Eterna from "eterna/Eterna"; import {Bitmaps} from "eterna/resources"; -import {ConstraintBox, GameButton, HTMLTextObject, PoseThumbnail, PoseThumbnailType} from "eterna/ui"; +import { + ConstraintBox, GameButton, HTMLTextObject, PoseThumbnail, PoseThumbnailType +} from "eterna/ui"; import {Fonts} from "eterna/util"; export default class MissionIntroMode extends AppMode { diff --git a/src/eterna/mode/PoseEdit/PoseEditToolbar.ts b/src/eterna/mode/PoseEdit/PoseEditToolbar.ts index 4732e8ee3..25557edda 100644 --- a/src/eterna/mode/PoseEdit/PoseEditToolbar.ts +++ b/src/eterna/mode/PoseEdit/PoseEditToolbar.ts @@ -10,7 +10,9 @@ import Eterna from "eterna/Eterna"; import {BoostersData, Puzzle, PuzzleType} from "eterna/puzzle"; import {Bitmaps} from "eterna/resources"; import {RScriptUIElementID} from "eterna/rscript"; -import {EternaMenu, EternaMenuStyle, GameButton, NucleotidePalette, ToggleBar} from "eterna/ui"; +import { + EternaMenu, EternaMenuStyle, GameButton, NucleotidePalette, ToggleBar +} from "eterna/ui"; import {ExternalInterfaceCtx} from "eterna/util"; import {GameMode} from "eterna/mode"; import {Booster, PoseEditMode} from "."; diff --git a/src/eterna/mode/PoseEdit/index.ts b/src/eterna/mode/PoseEdit/index.ts index 45c26afc0..3f9c9e906 100644 --- a/src/eterna/mode/PoseEdit/index.ts +++ b/src/eterna/mode/PoseEdit/index.ts @@ -5,4 +5,4 @@ export {default as PoseEditMode, PuzzleState, PoseEditParams} from "./PoseEditMo export {default as PoseEditToolbar} from "./PoseEditToolbar"; export {default as SubmitPoseDetails} from "./SubmitPoseDetails"; export {default as SubmitPoseDialog} from "./SubmitPoseDialog"; -export {default as SubmittingDialog} from "./SubmittingDialog"; \ No newline at end of file +export {default as SubmittingDialog} from "./SubmittingDialog"; diff --git a/src/eterna/mode/PuzzleEdit/PuzzleEditMode.ts b/src/eterna/mode/PuzzleEdit/PuzzleEditMode.ts index cf64d3073..a22c32fb9 100644 --- a/src/eterna/mode/PuzzleEdit/PuzzleEditMode.ts +++ b/src/eterna/mode/PuzzleEdit/PuzzleEditMode.ts @@ -4,8 +4,12 @@ import {KeyCode} from "flashbang/input"; import {Base64, DisplayUtil} from "flashbang/util"; import EPars from "eterna/EPars"; import Eterna from "eterna/Eterna"; -import {Folder, FolderManager, LinearFoldC, LinearFoldV, NuPACK, Vienna, Vienna2} from "eterna/folding"; -import {Molecule, Pose2D, PoseField, PuzzleEditOp} from "eterna/pose2D"; +import { + Folder, FolderManager, LinearFoldC, LinearFoldV, NuPACK, Vienna, Vienna2 +} from "eterna/folding"; +import { + Molecule, Pose2D, PoseField, PuzzleEditOp +} from "eterna/pose2D"; import {ConstraintType} from "eterna/puzzle"; import {Bitmaps} from "eterna/resources"; import { @@ -17,7 +21,9 @@ import {default as UndoBlock, UndoBlockParam} from "eterna/UndoBlock"; import {ExternalInterfaceCtx, Fonts} from "eterna/util"; import {Background, BaseGlow} from "eterna/vfx"; import {CopyTextDialogMode, GameMode} from "eterna/mode"; -import {PuzzleEditToolbar, StructureInput, SubmitPuzzleDialog, SubmitPuzzleDetails} from "."; +import { + PuzzleEditToolbar, StructureInput, SubmitPuzzleDialog, SubmitPuzzleDetails +} from "."; type InteractionEvent = PIXI.interaction.InteractionEvent; diff --git a/src/eterna/mode/PuzzleEdit/StructureInput.ts b/src/eterna/mode/PuzzleEdit/StructureInput.ts index 4825bf33a..5522d590a 100644 --- a/src/eterna/mode/PuzzleEdit/StructureInput.ts +++ b/src/eterna/mode/PuzzleEdit/StructureInput.ts @@ -5,9 +5,9 @@ import {DisplayUtil} from "flashbang/util"; import EPars from "eterna/EPars"; import Eterna from "eterna/Eterna"; import {Pose2D, PuzzleEditOp} from "eterna/pose2D"; -import {GamePanel, TextInputObject} from "eterna/ui"; +import {GamePanel, TextInputObject, TextBalloon} from "eterna/ui"; import {Fonts} from "eterna/util"; -import {TextBalloon} from "eterna/ui"; + function IsArrowKey(keyCode: string): boolean { return keyCode === KeyCode.ArrowRight diff --git a/src/eterna/mode/PuzzleEdit/index.ts b/src/eterna/mode/PuzzleEdit/index.ts index 2a6b6f9f3..552e11b20 100644 --- a/src/eterna/mode/PuzzleEdit/index.ts +++ b/src/eterna/mode/PuzzleEdit/index.ts @@ -1,4 +1,4 @@ export {default as PuzzleEditMode, PuzzleEditPoseData} from "./PuzzleEditMode"; export {default as PuzzleEditToolbar} from "./PuzzleEditToolbar"; export {default as StructureInput} from "./StructureInput"; -export {default as SubmitPuzzleDialog, SubmitPuzzleDetails} from "./SubmitPuzzleDialog"; \ No newline at end of file +export {default as SubmitPuzzleDialog, SubmitPuzzleDetails} from "./SubmitPuzzleDialog"; diff --git a/src/eterna/mode/index.ts b/src/eterna/mode/index.ts index 915c445fa..5b340842e 100644 --- a/src/eterna/mode/index.ts +++ b/src/eterna/mode/index.ts @@ -5,4 +5,4 @@ export {default as LoadingMode} from "./LoadingMode"; export {DesignBrowserMode, DesignBrowserFilter} from "./DesignBrowser"; export {FeedbackViewMode} from "./FeedbackView"; export {PoseEditMode, PoseEditParams} from "./PoseEdit"; -export {PuzzleEditMode, PuzzleEditPoseData} from "./PuzzleEdit"; \ No newline at end of file +export {PuzzleEditMode, PuzzleEditPoseData} from "./PuzzleEdit"; diff --git a/src/eterna/net/index.ts b/src/eterna/net/index.ts index 00ad0da0c..47165f57f 100644 --- a/src/eterna/net/index.ts +++ b/src/eterna/net/index.ts @@ -1,2 +1,2 @@ export {default as EternaURL} from "./EternaURL"; -export {default as GameClient} from "./GameClient"; \ No newline at end of file +export {default as GameClient} from "./GameClient"; diff --git a/src/eterna/puzzle/index.ts b/src/eterna/puzzle/index.ts index 8e7a5d4cc..c1ece4b96 100644 --- a/src/eterna/puzzle/index.ts +++ b/src/eterna/puzzle/index.ts @@ -1,5 +1,7 @@ export {default as Constraints, ConstraintType} from "./Constraints"; -export {default as Puzzle, BoostersData, PuzzleType, PoseState} from "./Puzzle"; +export { + default as Puzzle, BoostersData, PuzzleType, PoseState +} from "./Puzzle"; export {default as PuzzleManager} from "./PuzzleManager"; export {default as Solution} from "./Solution"; -export {default as SolutionManager} from "./SolutionManager"; \ No newline at end of file +export {default as SolutionManager} from "./SolutionManager"; diff --git a/src/eterna/rank/index.ts b/src/eterna/rank/index.ts index 2623ae8b3..eb0c56890 100644 --- a/src/eterna/rank/index.ts +++ b/src/eterna/rank/index.ts @@ -1,4 +1,4 @@ export {default as PlayerRank} from "./PlayerRank"; export {default as RankBoard} from "./RankBoard"; export {default as RankRowLayout} from "./RankRowLayout"; -export {default as RankScroll} from "./RankScroll"; \ No newline at end of file +export {default as RankScroll} from "./RankScroll"; diff --git a/src/eterna/resources/index.ts b/src/eterna/resources/index.ts index 6444fd4b8..6080dfb2a 100644 --- a/src/eterna/resources/index.ts +++ b/src/eterna/resources/index.ts @@ -2,4 +2,4 @@ export {default as BitmapManager} from "./BitmapManager"; export {default as Bitmaps} from "./Bitmaps"; export {default as PlaySoundTask} from "./PlaySoundTask"; export {default as SoundManager} from "./SoundManager"; -export {default as Sounds} from "./Sounds"; \ No newline at end of file +export {default as Sounds} from "./Sounds"; diff --git a/src/eterna/rscript/NovaPaintHint.ts b/src/eterna/rscript/NovaPaintHint.ts index 9df97305c..61a4d0dd2 100644 --- a/src/eterna/rscript/NovaPaintHint.ts +++ b/src/eterna/rscript/NovaPaintHint.ts @@ -3,8 +3,8 @@ import {Updatable} from "flashbang/core"; import {Vector2} from "flashbang/geom"; import {ContainerObject} from "flashbang/objects"; import {Pose2D} from "eterna/pose2D"; -import {BitmapManager} from "eterna/resources"; -import {Bitmaps} from "eterna/resources"; +import {BitmapManager, Bitmaps} from "eterna/resources"; + export default class NovaPaintHint extends ContainerObject implements Updatable { constructor(start: Point, end: Point, loop: boolean) { diff --git a/src/eterna/rscript/ROPHighlight.ts b/src/eterna/rscript/ROPHighlight.ts index c0423590e..1f60dc97d 100644 --- a/src/eterna/rscript/ROPHighlight.ts +++ b/src/eterna/rscript/ROPHighlight.ts @@ -6,7 +6,9 @@ import {AlphaTask, RepeatingTask, SerialTask} from "flashbang/tasks"; import {ColorUtil, Easing} from "flashbang/util"; import {RNAHighlightState} from "eterna/pose2D"; import {ConstraintBox, EternaMenu} from "eterna/ui"; -import {RScriptEnv, RScriptOp, GetRScriptUIElementBounds, RScriptUIElement, RScriptUIElementID} from "."; +import { + RScriptEnv, RScriptOp, GetRScriptUIElementBounds, RScriptUIElement, RScriptUIElementID +} from "."; export enum ROPHighlightMode { RNA = "RNA", diff --git a/src/eterna/rscript/ROPTextbox.ts b/src/eterna/rscript/ROPTextbox.ts index 501e8da6a..9293bbb32 100644 --- a/src/eterna/rscript/ROPTextbox.ts +++ b/src/eterna/rscript/ROPTextbox.ts @@ -7,7 +7,9 @@ import {ColorUtil, StyledTextBuilder} from "flashbang/util"; import {RNAAnchorObject} from "eterna/pose2D"; import {FancyTextBalloon} from "eterna/ui"; import {Fonts} from "eterna/util"; -import {ROPWait, RScriptArrow, RScriptEnv, RScriptOp} from "."; +import { + ROPWait, RScriptArrow, RScriptEnv, RScriptOp +} from "."; export enum ROPTextboxMode { TEXTBOX_LOCATION = "TEXTBOX_LOCATION", diff --git a/src/eterna/rscript/ROPWait.ts b/src/eterna/rscript/ROPWait.ts index abf01dd06..e465945d8 100644 --- a/src/eterna/rscript/ROPWait.ts +++ b/src/eterna/rscript/ROPWait.ts @@ -1,4 +1,6 @@ -import {ROPTextbox, RScriptEnv, RScriptOp, RScriptUIElementID} from "."; +import { + ROPTextbox, RScriptEnv, RScriptOp, RScriptUIElementID +} from "."; export enum ROPWaitType { MOVECAMERA = "MOVECAMERA", diff --git a/src/eterna/rscript/index.ts b/src/eterna/rscript/index.ts index 65770fa22..e192cc1c3 100644 --- a/src/eterna/rscript/index.ts +++ b/src/eterna/rscript/index.ts @@ -11,4 +11,4 @@ export {default as ROPWait, ROPWaitType} from "./ROPWait"; export {default as RScriptArrow} from "./RScriptArrow"; export {default as RScriptEnv, RScriptVarType} from "./RScriptEnv"; export {default as RScriptOpTree} from "./RScriptOpTree"; -export {RScriptUIElement, GetRScriptUIElementBounds, RScriptUIElementID} from "./RScriptUIElement"; \ No newline at end of file +export {RScriptUIElement, GetRScriptUIElementBounds, RScriptUIElementID} from "./RScriptUIElement"; diff --git a/src/eterna/settings/index.ts b/src/eterna/settings/index.ts index c458bb6ca..8acdc3c6d 100644 --- a/src/eterna/settings/index.ts +++ b/src/eterna/settings/index.ts @@ -1 +1 @@ -export {default as EternaSettings} from "./EternaSettings"; \ No newline at end of file +export {default as EternaSettings} from "./EternaSettings"; diff --git a/src/eterna/ui/Band.ts b/src/eterna/ui/Band.ts index 1f8d02541..b5c1fc1e0 100644 --- a/src/eterna/ui/Band.ts +++ b/src/eterna/ui/Band.ts @@ -1,4 +1,6 @@ -import {Graphics, Matrix, Point, Sprite, Text, Texture} from "pixi.js"; +import { + Graphics, Matrix, Point, Sprite, Text, Texture +} from "pixi.js"; import {Updatable} from "flashbang/core"; import {ContainerObject} from "flashbang/objects"; import {ColorUtil, MathUtil, TextureUtil} from "flashbang/util"; diff --git a/src/eterna/ui/ConfirmDialog.ts b/src/eterna/ui/ConfirmDialog.ts index b0171d604..7218a0fae 100644 --- a/src/eterna/ui/ConfirmDialog.ts +++ b/src/eterna/ui/ConfirmDialog.ts @@ -3,7 +3,9 @@ import {Flashbang, HAlign} from "flashbang/core"; import {HLayoutContainer, VLayoutContainer} from "flashbang/layout"; import {AlphaTask} from "flashbang/tasks"; import {Fonts} from "eterna/util"; -import {Dialog, DialogCanceledError, GameButton,GamePanel, GamePanelType, HTMLTextObject } from "."; +import { + Dialog, DialogCanceledError, GameButton, GamePanel, GamePanelType, HTMLTextObject +} from "."; export default class ConfirmDialog extends Dialog { public constructor(prompt: string, promptIsHTML: boolean = false) { diff --git a/src/eterna/ui/ConstraintBox.ts b/src/eterna/ui/ConstraintBox.ts index f53609672..7480f3da6 100644 --- a/src/eterna/ui/ConstraintBox.ts +++ b/src/eterna/ui/ConstraintBox.ts @@ -1,15 +1,23 @@ import MultiStyleText from "pixi-multistyle-text"; -import {Container, Graphics, Point, Sprite, Text, Texture} from "pixi.js"; +import { + Container, Graphics, Point, Sprite, Text, Texture +} from "pixi.js"; import {HAlign, VAlign} from "flashbang/core"; import {ContainerObject, Enableable, SceneObject} from "flashbang/objects"; -import {AlphaTask, DelayTask, LocationTask, ParallelTask, ScaleTask, SerialTask, VisibleTask} from "flashbang/tasks"; -import {DisplayUtil, Easing, StyledTextBuilder, TextureUtil} from "flashbang/util"; +import { + AlphaTask, DelayTask, LocationTask, ParallelTask, ScaleTask, SerialTask, VisibleTask +} from "flashbang/tasks"; +import { + DisplayUtil, Easing, StyledTextBuilder, TextureUtil +} from "flashbang/util"; import {RegistrationGroup} from "signals"; import EPars from "eterna/EPars"; import {ConstraintType} from "eterna/puzzle"; import {BitmapManager, Bitmaps} from "eterna/resources"; import {Fonts} from "eterna/util"; -import {Band, PoseThumbnail, PoseThumbnailType, TextBalloon} from "."; +import { + Band, PoseThumbnail, PoseThumbnailType, TextBalloon +} from "."; export enum ConstraintBoxType { DEFAULT = "DEFAULT", diff --git a/src/eterna/ui/Dialog.ts b/src/eterna/ui/Dialog.ts index 6238ff2ad..a2341e3c2 100644 --- a/src/eterna/ui/Dialog.ts +++ b/src/eterna/ui/Dialog.ts @@ -1,6 +1,8 @@ import {Graphics} from "pixi.js"; import {Flashbang} from "flashbang/core"; -import {InputUtil, KeyboardListener, MouseWheelListener, DisplayObjectPointerTarget} from "flashbang/input"; +import { + InputUtil, KeyboardListener, MouseWheelListener, DisplayObjectPointerTarget +} from "flashbang/input"; import {ContainerObject} from "flashbang/objects"; /** Dialogs that expose a "confirmed" promise will reject with this error if the dialog is canceled */ diff --git a/src/eterna/ui/EternaViewOptionsDialog.ts b/src/eterna/ui/EternaViewOptionsDialog.ts index 754edda8e..c2f78bba5 100644 --- a/src/eterna/ui/EternaViewOptionsDialog.ts +++ b/src/eterna/ui/EternaViewOptionsDialog.ts @@ -5,7 +5,9 @@ import {Setting} from "flashbang/settings"; import {DisplayUtil} from "flashbang/util"; import Eterna from "eterna/Eterna"; import {Bitmaps} from "eterna/resources"; -import {Dialog, GameButton, GameCheckbox, GamePanel, GamePanelType} from "."; +import { + Dialog, GameButton, GameCheckbox, GamePanel, GamePanelType +} from "."; export enum EternaViewOptionsMode { PUZZLE = 0, PUZZLEMAKER, LAB diff --git a/src/eterna/ui/FixedWidthTextField.ts b/src/eterna/ui/FixedWidthTextField.ts index 21ee582b6..f3fdf44e6 100644 --- a/src/eterna/ui/FixedWidthTextField.ts +++ b/src/eterna/ui/FixedWidthTextField.ts @@ -1,4 +1,6 @@ -import {Container, Graphics, Text, TextStyle} from "pixi.js"; +import { + Container, Graphics, Text, TextStyle +} from "pixi.js"; import {HAlign} from "flashbang/core"; export default class FixedWidthTextField extends Container { diff --git a/src/eterna/ui/GameButton.ts b/src/eterna/ui/GameButton.ts index a612b88fe..a2606722f 100644 --- a/src/eterna/ui/GameButton.ts +++ b/src/eterna/ui/GameButton.ts @@ -1,9 +1,11 @@ -import {Container, DisplayObject, Graphics, Point, Rectangle, Sprite, Text, Texture} from "pixi.js"; +import { + Container, DisplayObject, Graphics, Point, Rectangle, Sprite, Text, Texture +} from "pixi.js"; import {HAlign, VAlign} from "flashbang/core"; import {KeyboardEventType, KeyboardListener} from "flashbang/input"; import {Button, ButtonState} from "flashbang/objects"; import {DisplayUtil, TextBuilder} from "flashbang/util"; -import {Registration, Registrations, Value} from "signals" +import {Registration, Registrations, Value} from "signals"; import {ROPWait, RScriptUIElementID} from "eterna/rscript"; import {Fonts} from "eterna/util"; import {Tooltips} from "."; diff --git a/src/eterna/ui/GamePanel.ts b/src/eterna/ui/GamePanel.ts index f7e499581..dc6b67cdd 100644 --- a/src/eterna/ui/GamePanel.ts +++ b/src/eterna/ui/GamePanel.ts @@ -1,4 +1,6 @@ -import {Graphics, Point, Text, Rectangle} from "pixi.js"; +import { + Graphics, Point, Text, Rectangle +} from "pixi.js"; import {Fonts} from "eterna/util"; import {BaseGamePanel} from "."; diff --git a/src/eterna/ui/NucleotidePalette.ts b/src/eterna/ui/NucleotidePalette.ts index 81e89838c..8d2af7fea 100644 --- a/src/eterna/ui/NucleotidePalette.ts +++ b/src/eterna/ui/NucleotidePalette.ts @@ -1,5 +1,9 @@ -import {Point, Rectangle, Sprite, Text, Texture} from "pixi.js"; -import {InputUtil, KeyboardEventType, KeyboardListener, KeyCode} from "flashbang/input"; +import { + Point, Rectangle, Sprite, Text, Texture +} from "pixi.js"; +import { + InputUtil, KeyboardEventType, KeyboardListener, KeyCode +} from "flashbang/input"; import {ContainerObject, Enableable} from "flashbang/objects"; import {StyledTextBuilder} from "flashbang/util"; import {Signal} from "signals"; diff --git a/src/eterna/ui/PoseThumbnail.ts b/src/eterna/ui/PoseThumbnail.ts index f4de93845..d0e18ce14 100644 --- a/src/eterna/ui/PoseThumbnail.ts +++ b/src/eterna/ui/PoseThumbnail.ts @@ -1,4 +1,6 @@ -import {Container, DisplayObject, Graphics, Sprite, Texture} from "pixi.js"; +import { + Container, DisplayObject, Graphics, Sprite, Texture +} from "pixi.js"; import {DisplayUtil, TextureUtil} from "flashbang/util"; import Constants from "eterna/Constants"; import EPars from "eterna/EPars"; diff --git a/src/eterna/ui/SpecBox.ts b/src/eterna/ui/SpecBox.ts index e6495c042..de8fb4d77 100644 --- a/src/eterna/ui/SpecBox.ts +++ b/src/eterna/ui/SpecBox.ts @@ -1,6 +1,8 @@ import * as log from "loglevel"; import MultiStyleText from "pixi-multistyle-text"; -import {Graphics, Point, Sprite, Text} from "pixi.js"; +import { + Graphics, Point, Sprite, Text +} from "pixi.js"; import {HAlign, VAlign} from "flashbang/core"; import {DisplayObjectPointerTarget, InputUtil, KeyCode} from "flashbang/input"; import {ContainerObject} from "flashbang/objects"; @@ -12,7 +14,9 @@ import {EternaURL} from "eterna/net"; import {Bitmaps} from "eterna/resources"; import {default as UndoBlock, UndoBlockParam} from "eterna/UndoBlock"; import {Fonts} from "eterna/util"; -import {GameButton, GamePanel, HTMLTextObject, TextBalloon} from "."; +import { + GameButton, GamePanel, HTMLTextObject, TextBalloon +} from "."; type InteractionEvent = PIXI.interaction.InteractionEvent; diff --git a/src/eterna/ui/TextBalloon.ts b/src/eterna/ui/TextBalloon.ts index 40a666d8c..edf88aabf 100644 --- a/src/eterna/ui/TextBalloon.ts +++ b/src/eterna/ui/TextBalloon.ts @@ -3,7 +3,9 @@ import {Point, Text} from "pixi.js"; import {ContainerObject} from "flashbang/objects"; import {DisplayUtil, StyledTextBuilder} from "flashbang/util"; import {Fonts} from "eterna/util"; -import {BaseGamePanel, GameButton, GamePanel, GamePanelType} from "."; +import { + BaseGamePanel, GameButton, GamePanel, GamePanelType +} from "."; export default class TextBalloon extends ContainerObject { public constructor(text: string = "", balloonColor: number = 0xFFFFFF, balloonAlpha: number = 0.07, borderColor: number = 0, borderAlpha: number = 0) { diff --git a/src/eterna/ui/TextInputPanel.ts b/src/eterna/ui/TextInputPanel.ts index 70bfc909d..cfb358bbb 100644 --- a/src/eterna/ui/TextInputPanel.ts +++ b/src/eterna/ui/TextInputPanel.ts @@ -1,6 +1,6 @@ import {Point, Text} from "pixi.js"; -import {Signal} from "signals"; -import {UnitSignal} from "signals"; +import {Signal, UnitSignal} from "signals"; + import {Fonts} from "eterna/util"; import {GameButton, GamePanel, TextInputObject} from "."; diff --git a/src/eterna/ui/Tooltips.ts b/src/eterna/ui/Tooltips.ts index 971553f97..ad7bfa3f9 100644 --- a/src/eterna/ui/Tooltips.ts +++ b/src/eterna/ui/Tooltips.ts @@ -1,5 +1,7 @@ import {ExtendedTextStyle} from "pixi-multistyle-text"; -import {Container, DisplayObject, Graphics, Point, Rectangle, Text} from "pixi.js"; +import { + Container, DisplayObject, Graphics, Point, Rectangle, Text +} from "pixi.js"; import {Flashbang, GameObject, GameObjectRef} from "flashbang/core"; import {Button} from "flashbang/objects"; import {AlphaTask, DelayTask, SerialTask} from "flashbang/tasks"; diff --git a/src/eterna/ui/index.ts b/src/eterna/ui/index.ts index 2701df30a..0b5960229 100644 --- a/src/eterna/ui/index.ts +++ b/src/eterna/ui/index.ts @@ -32,4 +32,4 @@ export {default as ToggleBar} from "./ToggleBar"; export {default as Tooltips, Tooltip} from "./Tooltips"; export {default as UILockDialog} from "./UILockDialog"; export {default as URLButton} from "./URLButton"; -export {default as VScrollBox} from "./VScrollBox"; \ No newline at end of file +export {default as VScrollBox} from "./VScrollBox"; diff --git a/src/eterna/util/index.ts b/src/eterna/util/index.ts index da2570035..d75e13a42 100644 --- a/src/eterna/util/index.ts +++ b/src/eterna/util/index.ts @@ -4,4 +4,4 @@ export {default as ExternalInterface, ExternalInterfaceCtx, RunScriptOptions} fr export {default as Fonts} from "./Fonts"; export {default as GraphicsUtil} from "./GraphicsUtil"; export {default as int} from "./int"; -export {default as Utility} from "./Utility"; \ No newline at end of file +export {default as Utility} from "./Utility"; diff --git a/src/eterna/vfx/index.ts b/src/eterna/vfx/index.ts index 4e397d96a..d91d700b0 100644 --- a/src/eterna/vfx/index.ts +++ b/src/eterna/vfx/index.ts @@ -3,4 +3,4 @@ export {default as BaseGlow} from "./BaseGlow"; export {default as Bubble} from "./Bubble"; export {default as BubbleSweep} from "./BubbleSweep"; export {default as LightRay} from "./LightRay"; -export {default as VibrateTask} from "./VibrateTask"; \ No newline at end of file +export {default as VibrateTask} from "./VibrateTask"; diff --git a/src/flashbang/core/AppMode.ts b/src/flashbang/core/AppMode.ts index 26a142184..e337723af 100644 --- a/src/flashbang/core/AppMode.ts +++ b/src/flashbang/core/AppMode.ts @@ -1,8 +1,12 @@ import {Container} from "pixi.js"; -import {RegistrationGroup, Signal, SignalView, UnitSignal} from "signals"; +import { + RegistrationGroup, Signal, SignalView, UnitSignal +} from "signals"; import {KeyboardInput, MouseWheelInput} from "../input"; import {Assert} from "../util"; -import {GameObject, GameObjectBase, GameObjectRef, LateUpdatable, ModeStack, Updatable} from "."; +import { + GameObject, GameObjectBase, GameObjectRef, LateUpdatable, ModeStack, Updatable +} from "."; export default class AppMode { /** Default keyboard input processor */ diff --git a/src/flashbang/core/GameObjectBase.ts b/src/flashbang/core/GameObjectBase.ts index 6d29a29fa..98a8b805c 100644 --- a/src/flashbang/core/GameObjectBase.ts +++ b/src/flashbang/core/GameObjectBase.ts @@ -1,6 +1,8 @@ import {Container} from "pixi.js"; import {RegistrationGroup, UnitSignal} from "signals"; -import {AppMode, ModeStack, GameObject, GameObjectRef} from "."; +import { + AppMode, ModeStack, GameObject, GameObjectRef +} from "."; export default class GameObjectBase { public get destroyed(): UnitSignal { diff --git a/src/flashbang/core/index.ts b/src/flashbang/core/index.ts index 6a8290e4a..6266d4ead 100644 --- a/src/flashbang/core/index.ts +++ b/src/flashbang/core/index.ts @@ -8,4 +8,4 @@ export {default as GameObjectRef} from "./GameObjectRef"; export {default as LateUpdatable} from "./LateUpdatable"; export {default as ModeStack} from "./ModeStack"; export {default as ObjectTask} from "./ObjectTask"; -export {default as Updatable} from "./Updatable"; \ No newline at end of file +export {default as Updatable} from "./Updatable"; diff --git a/src/flashbang/geom/index.ts b/src/flashbang/geom/index.ts index 772e78c94..65c8820b3 100644 --- a/src/flashbang/geom/index.ts +++ b/src/flashbang/geom/index.ts @@ -1 +1 @@ -export {default as Vector2} from "./Vector2"; \ No newline at end of file +export {default as Vector2} from "./Vector2"; diff --git a/src/flashbang/input/KeyboardEventType.ts b/src/flashbang/input/KeyboardEventType.ts index d982112ac..d2018563e 100644 --- a/src/flashbang/input/KeyboardEventType.ts +++ b/src/flashbang/input/KeyboardEventType.ts @@ -3,4 +3,4 @@ enum KeyboardEventType { KEY_UP = "keyup" } -export default KeyboardEventType; \ No newline at end of file +export default KeyboardEventType; diff --git a/src/flashbang/input/index.ts b/src/flashbang/input/index.ts index 94219099f..3671d39e2 100644 --- a/src/flashbang/input/index.ts +++ b/src/flashbang/input/index.ts @@ -5,4 +5,4 @@ export {default as KeyboardInput, KeyboardListener} from "./KeyboardInput"; export {default as KeyCode} from "./KeyCode"; export {default as MouseWheelInput, MouseWheelListener} from "./MouseWheelInput"; export {default as PointerCapture} from "./PointerCapture"; -export {default as PointerTarget} from "./PointerTarget"; \ No newline at end of file +export {default as PointerTarget} from "./PointerTarget"; diff --git a/src/flashbang/layout/index.ts b/src/flashbang/layout/index.ts index 4f1c2fe6b..67d6f99b7 100644 --- a/src/flashbang/layout/index.ts +++ b/src/flashbang/layout/index.ts @@ -1,3 +1,3 @@ export {default as LayoutContainer} from "./LayoutContainer"; export {default as HLayoutContainer} from "./HLayoutContainer"; -export {default as VLayoutContainer} from "./VLayoutContainer"; \ No newline at end of file +export {default as VLayoutContainer} from "./VLayoutContainer"; diff --git a/src/flashbang/objects/index.ts b/src/flashbang/objects/index.ts index 0e9de84ce..674653941 100644 --- a/src/flashbang/objects/index.ts +++ b/src/flashbang/objects/index.ts @@ -6,4 +6,4 @@ export {default as DOMObject} from "./DOMObject"; export {default as ImageButton} from "./ImageButton"; export {default as SimpleTextButton} from "./SimpleTextButton"; export {default as SpriteObject} from "./SpriteObject"; -export {default as ToggleButton} from "./ToggleButton"; \ No newline at end of file +export {default as ToggleButton} from "./ToggleButton"; diff --git a/src/flashbang/resources/index.ts b/src/flashbang/resources/index.ts index 448407753..1b64debaf 100644 --- a/src/flashbang/resources/index.ts +++ b/src/flashbang/resources/index.ts @@ -1 +1 @@ -export {default as FontLoader} from "./FontLoader"; \ No newline at end of file +export {default as FontLoader} from "./FontLoader"; diff --git a/src/flashbang/settings/index.ts b/src/flashbang/settings/index.ts index dbe4fad36..2e59ef748 100644 --- a/src/flashbang/settings/index.ts +++ b/src/flashbang/settings/index.ts @@ -1,3 +1,3 @@ export {default as SaveGameManager} from "./SaveGameManager"; export {default as Setting} from "./Setting"; -export {default as Settings} from "./Settings"; \ No newline at end of file +export {default as Settings} from "./Settings"; diff --git a/src/flashbang/tasks/index.ts b/src/flashbang/tasks/index.ts index 1681d96bb..c8a98b86a 100644 --- a/src/flashbang/tasks/index.ts +++ b/src/flashbang/tasks/index.ts @@ -12,4 +12,4 @@ export {default as RotationTask} from "./RotationTask"; export {default as ScaleTask} from "./ScaleTask"; export {default as SelfDestructTask} from "./SelfDestructTask"; export {default as SerialTask} from "./SerialTask"; -export {default as VisibleTask} from "./VisibleTask"; \ No newline at end of file +export {default as VisibleTask} from "./VisibleTask"; diff --git a/src/flashbang/util/DisplayUtil.ts b/src/flashbang/util/DisplayUtil.ts index c8b25d39f..11c778d91 100644 --- a/src/flashbang/util/DisplayUtil.ts +++ b/src/flashbang/util/DisplayUtil.ts @@ -1,4 +1,6 @@ -import {DisplayObject, Graphics, Matrix, Point, Rectangle} from "pixi.js"; +import { + DisplayObject, Graphics, Matrix, Point, Rectangle +} from "pixi.js"; import {Flashbang, HAlign, VAlign} from "../core"; import {RectangleUtil} from "."; diff --git a/src/flashbang/util/EventSignal.ts b/src/flashbang/util/EventSignal.ts index be88e8c23..9e733751a 100644 --- a/src/flashbang/util/EventSignal.ts +++ b/src/flashbang/util/EventSignal.ts @@ -1,4 +1,6 @@ -import {AbstractSignal, FilteredSignal, MappedSignal, SignalView} from "signals"; +import { + AbstractSignal, FilteredSignal, MappedSignal, SignalView +} from "signals"; type InteractionEvent = PIXI.interaction.InteractionEvent; type EventEmitter = PIXI.utils.EventEmitter; diff --git a/src/flashbang/util/TextureUtil.ts b/src/flashbang/util/TextureUtil.ts index 1c9a0f94f..31fdc88a0 100644 --- a/src/flashbang/util/TextureUtil.ts +++ b/src/flashbang/util/TextureUtil.ts @@ -1,4 +1,6 @@ -import {BaseRenderTexture, BaseTexture, Container, DisplayObject, Rectangle, RenderTexture, Texture} from "pixi.js"; +import { + BaseRenderTexture, BaseTexture, Container, DisplayObject, Rectangle, RenderTexture, Texture +} from "pixi.js"; import {Flashbang} from "../core"; import {Assert} from "."; diff --git a/src/flashbang/util/index.ts b/src/flashbang/util/index.ts index 3a3114e9d..76c8d51ab 100644 --- a/src/flashbang/util/index.ts +++ b/src/flashbang/util/index.ts @@ -18,4 +18,4 @@ export {default as StringUtil} from "./StringUtil"; export {default as StyledTextBuilder} from "./StyledTextBuilder"; export {default as TextBuilder} from "./TextBuilder"; export {default as TextureUtil} from "./TextureUtil"; -export {default as TextUtil} from "./TextUtil"; \ No newline at end of file +export {default as TextUtil} from "./TextUtil"; diff --git a/src/signals/AbstractSignal.ts b/src/signals/AbstractSignal.ts index 2dbf1a043..40a109806 100644 --- a/src/signals/AbstractSignal.ts +++ b/src/signals/AbstractSignal.ts @@ -1,6 +1,6 @@ -/*import Reactor from "./Reactor"; +/* import Reactor from "./Reactor"; import SignalView from "./SignalView"; -import Connection from "./Connection";*/ +import Connection from "./Connection"; */ import {Reactor, SignalView, Connection} from "."; /** diff --git a/src/signals/AbstractValue.ts b/src/signals/AbstractValue.ts index 53bbfebe7..d5465f87b 100644 --- a/src/signals/AbstractValue.ts +++ b/src/signals/AbstractValue.ts @@ -1,8 +1,10 @@ -/*import Connection from "./Connection"; +/* import Connection from "./Connection"; import Cons from "./Cons"; import Reactor from "./Reactor"; -import ValueView from "./ValueView";*/ -import {Connection, Cons, Reactor, ValueView} from "."; +import ValueView from "./ValueView"; */ +import { + Connection, Cons, Reactor, ValueView +} from "."; /** * Handles the machinery of connecting listeners to a value and notifying them, without exposing a diff --git a/src/signals/Connection.ts b/src/signals/Connection.ts index 55329b38b..0ee66135e 100644 --- a/src/signals/Connection.ts +++ b/src/signals/Connection.ts @@ -1,4 +1,4 @@ -//import Registration from "./Registration"; +// import Registration from "./Registration"; import {Registration} from "."; /** diff --git a/src/signals/Cons.ts b/src/signals/Cons.ts index 59a3a9e41..ae3f791d2 100644 --- a/src/signals/Cons.ts +++ b/src/signals/Cons.ts @@ -1,6 +1,6 @@ -/*import Reactor from "./Reactor"; +/* import Reactor from "./Reactor"; import {RListener} from "./Reactor"; -import Connection from "./Connection";*/ +import Connection from "./Connection"; */ import {Reactor, RListener, Connection} from "."; /** diff --git a/src/signals/FilteredSignal.ts b/src/signals/FilteredSignal.ts index 9f7e6e7bf..ff23d9a36 100644 --- a/src/signals/FilteredSignal.ts +++ b/src/signals/FilteredSignal.ts @@ -1,6 +1,6 @@ -/*import MappedSignal from "./MappedSignal"; +/* import MappedSignal from "./MappedSignal"; import SignalView from "./SignalView"; -import Connection from "./Connection";*/ +import Connection from "./Connection"; */ import {MappedSignal, SignalView, Connection} from "."; export default class FilteredSignal extends MappedSignal { diff --git a/src/signals/MappedSignal.ts b/src/signals/MappedSignal.ts index 1c663233f..458f87a73 100644 --- a/src/signals/MappedSignal.ts +++ b/src/signals/MappedSignal.ts @@ -1,8 +1,10 @@ -/*import AbstractSignal from "./AbstractSignal"; +/* import AbstractSignal from "./AbstractSignal"; import FilteredSignal from "./FilteredSignal"; import SignalView from "./SignalView"; -import Connection from "./Connection";*/ -import {AbstractSignal, FilteredSignal, SignalView, Connection} from "."; +import Connection from "./Connection"; */ +import { + AbstractSignal, FilteredSignal, SignalView, Connection +} from "."; /** * Plumbing to implement mapped signals in such a way that they automatically manage a connection diff --git a/src/signals/MappedValue.ts b/src/signals/MappedValue.ts index bea14ca27..a9d41c5da 100644 --- a/src/signals/MappedValue.ts +++ b/src/signals/MappedValue.ts @@ -1,6 +1,6 @@ -/*import AbstractValue from "./AbstractValue"; +/* import AbstractValue from "./AbstractValue"; import ValueView from "./ValueView"; -import Connection from "./Connection";*/ +import Connection from "./Connection"; */ import {AbstractValue, ValueView, Connection} from "."; /** diff --git a/src/signals/Reactor.ts b/src/signals/Reactor.ts index beced10ba..a25080b12 100644 --- a/src/signals/Reactor.ts +++ b/src/signals/Reactor.ts @@ -1,4 +1,4 @@ -//import Cons from "./Cons"; +// import Cons from "./Cons"; import {Cons} from "."; export type RListener = (arg1?: any, arg2?: any, arg3?: any) => void; diff --git a/src/signals/RegistrationGroup.ts b/src/signals/RegistrationGroup.ts index 47c19af5b..35244e462 100644 --- a/src/signals/RegistrationGroup.ts +++ b/src/signals/RegistrationGroup.ts @@ -1,5 +1,5 @@ -/*import MultiFailureError from "./MultiFailureError"; -import Registration from "./Registration";*/ +/* import MultiFailureError from "./MultiFailureError"; +import Registration from "./Registration"; */ import {MultiFailureError, Registration} from "."; /** Collects Registrations to allow mass operations on them. */ diff --git a/src/signals/Registrations.ts b/src/signals/Registrations.ts index 4d50b37bd..0c8918c30 100644 --- a/src/signals/Registrations.ts +++ b/src/signals/Registrations.ts @@ -1,4 +1,4 @@ -//import Registration from "./Registration"; +// import Registration from "./Registration"; import {Registration} from "."; export default class Registrations { diff --git a/src/signals/Signal.ts b/src/signals/Signal.ts index f2eb20399..fa6273891 100644 --- a/src/signals/Signal.ts +++ b/src/signals/Signal.ts @@ -1,8 +1,10 @@ -/*import AbstractSignal from "./AbstractSignal"; +/* import AbstractSignal from "./AbstractSignal"; import FilteredSignal from "./FilteredSignal"; import MappedSignal from "./MappedSignal"; import SignalView from "./SignalView"; */ -import {AbstractSignal, FilteredSignal, MappedSignal, SignalView} from "."; +import { + AbstractSignal, FilteredSignal, MappedSignal, SignalView +} from "."; /** A signal that emits events of type {@code T}. */ export default class Signal extends AbstractSignal { diff --git a/src/signals/SignalView.ts b/src/signals/SignalView.ts index e72ea6f47..ccb865dec 100644 --- a/src/signals/SignalView.ts +++ b/src/signals/SignalView.ts @@ -1,4 +1,4 @@ -//import Connection from "./Connection"; +// import Connection from "./Connection"; import {Connection} from "."; /** diff --git a/src/signals/UnitSignal.ts b/src/signals/UnitSignal.ts index 3f108fc11..ffe079091 100644 --- a/src/signals/UnitSignal.ts +++ b/src/signals/UnitSignal.ts @@ -1,8 +1,10 @@ -/*import AbstractSignal from "./AbstractSignal"; +/* import AbstractSignal from "./AbstractSignal"; import FilteredSignal from "./FilteredSignal"; import MappedSignal from "./MappedSignal"; -import SignalView from "./SignalView";*/ -import {AbstractSignal, FilteredSignal, MappedSignal, SignalView} from "."; +import SignalView from "./SignalView"; */ +import { + AbstractSignal, FilteredSignal, MappedSignal, SignalView +} from "."; /** A signal that emits an event with no associated data. */ export default class UnitSignal extends AbstractSignal { diff --git a/src/signals/Value.ts b/src/signals/Value.ts index 035e6ad69..ecbdea297 100644 --- a/src/signals/Value.ts +++ b/src/signals/Value.ts @@ -1,6 +1,6 @@ -/*import AbstractValue from "./AbstractValue"; +/* import AbstractValue from "./AbstractValue"; import MappedValue from "./MappedValue"; -import ValueView from "./ValueView";*/ +import ValueView from "./ValueView"; */ import {AbstractValue, MappedValue, ValueView} from "."; export default class Value extends AbstractValue implements ValueView { diff --git a/src/signals/ValueView.ts b/src/signals/ValueView.ts index 5efefb307..2dcdf133f 100644 --- a/src/signals/ValueView.ts +++ b/src/signals/ValueView.ts @@ -1,4 +1,4 @@ -//import Connection from "./Connection"; +// import Connection from "./Connection"; import {Connection} from "."; /** diff --git a/src/signals/index.ts b/src/signals/index.ts index 15e09b5db..c1da78afb 100644 --- a/src/signals/index.ts +++ b/src/signals/index.ts @@ -14,4 +14,4 @@ export {default as Signal} from "./Signal"; export {default as SignalView} from "./SignalView"; export {default as UnitSignal} from "./UnitSignal"; export {default as Value} from "./Value"; -export {default as ValueView} from "./ValueView"; \ No newline at end of file +export {default as ValueView} from "./ValueView"; From 48c96381d9140a4e075ef4a2911fc603e026bd4f Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Sat, 29 Jun 2019 22:26:57 -0400 Subject: [PATCH 04/39] Fix code xref to GH permalink --- src/eterna/puzzle/Puzzle.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/eterna/puzzle/Puzzle.ts b/src/eterna/puzzle/Puzzle.ts index 18cd49e0b..6854b20a8 100644 --- a/src/eterna/puzzle/Puzzle.ts +++ b/src/eterna/puzzle/Puzzle.ts @@ -513,7 +513,7 @@ export default class Puzzle { } } - // FIXME: This needs revision, see PoseEditMode:2163 + // FIXME: This needs revision, see https://github.com/EteRNAgame/eterna/blob/1e537defaad17674b189df697ee6f1c7cca070c0/flash-rna/flash-rna/PoseEdit.as#L2163 let len: number = this._beginningSequence != null ? this._beginningSequence.length : this._secstructs[index].length; for (let ii = 0; ii < len; ii++) { if (this._beginningSequence != null) { From 2ca77a4e7ef002e7f590e38d21e8a5db28bbfd3c Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Mon, 1 Jul 2019 12:08:46 -0400 Subject: [PATCH 05/39] Unify toolbars into one class --- .../mode/FeedbackView/FeedbackViewToolbar.ts | 196 ------ src/eterna/mode/FeedbackView/index.ts | 2 - .../{FeedbackView => }/FeedbackViewMode.ts | 35 +- src/eterna/mode/PoseEdit/PoseEditMode.ts | 58 +- src/eterna/mode/PoseEdit/PoseEditToolbar.ts | 481 ------------- src/eterna/mode/PoseEdit/index.ts | 1 - src/eterna/mode/PuzzleEdit/PuzzleEditMode.ts | 37 +- .../mode/PuzzleEdit/PuzzleEditToolbar.ts | 280 -------- src/eterna/mode/PuzzleEdit/index.ts | 1 - src/eterna/mode/index.ts | 2 +- src/eterna/rscript/RScriptEnv.ts | 8 +- src/eterna/ui/EternaViewOptionsDialog.ts | 3 +- src/eterna/ui/Toolbar.ts | 642 ++++++++++++++++++ src/eterna/ui/index.ts | 2 + 14 files changed, 708 insertions(+), 1040 deletions(-) delete mode 100644 src/eterna/mode/FeedbackView/FeedbackViewToolbar.ts delete mode 100644 src/eterna/mode/FeedbackView/index.ts rename src/eterna/mode/{FeedbackView => }/FeedbackViewMode.ts (94%) delete mode 100644 src/eterna/mode/PoseEdit/PoseEditToolbar.ts delete mode 100644 src/eterna/mode/PuzzleEdit/PuzzleEditToolbar.ts create mode 100644 src/eterna/ui/Toolbar.ts diff --git a/src/eterna/mode/FeedbackView/FeedbackViewToolbar.ts b/src/eterna/mode/FeedbackView/FeedbackViewToolbar.ts deleted file mode 100644 index f0a4942e0..000000000 --- a/src/eterna/mode/FeedbackView/FeedbackViewToolbar.ts +++ /dev/null @@ -1,196 +0,0 @@ -import {Container, Graphics} from "pixi.js"; -import {Flashbang, HAlign, VAlign} from "flashbang/core"; -import {KeyCode} from "flashbang/input"; -import {HLayoutContainer} from "flashbang/layout"; -import {ContainerObject} from "flashbang/objects"; -import {DisplayUtil} from "flashbang/util"; -import {Puzzle} from "eterna/puzzle"; -import {Bitmaps} from "eterna/resources"; -import {RScriptUIElementID} from "eterna/rscript"; -import {GameButton, ToggleBar} from "eterna/ui"; - -export default class FeedbackViewToolbar extends ContainerObject { - public screenshotButton: GameButton; - - public zoomOutButton: GameButton; - public zoomInButton: GameButton; - - public specButton: GameButton; - public pipButton: GameButton; - public showTargetButton: GameButton; - public showEstimateButton: GameButton; - - public toggleBar: ToggleBar; - public viewSolutionsButton: GameButton; - public viewOptionsButton: GameButton; - public letterColorButton: GameButton; - public expColorButton: GameButton; - - public constructor(puzzle: Puzzle) { - super(); - this._puzzle = puzzle; - } - - protected added(): void { - super.added(); - - let secstructs: string[] = this._puzzle.getSecstructs(); - - const SPACE_NARROW = 7; - const SPACE_WIDE = 25; - - this._invisibleBackground = new Graphics(); - this._invisibleBackground - .beginFill(0, 0) - .drawRect(0, 0, Flashbang.stageWidth, 100) - .endFill(); - this._invisibleBackground.y = -this._invisibleBackground.height; - this.container.addChild(this._invisibleBackground); - - this._content = new Container(); - this.container.addChild(this._content); - - this._toolbarLayout = new HLayoutContainer(); - this._content.addChild(this._toolbarLayout); - - this.screenshotButton = new GameButton() - .up(Bitmaps.ImgScreenshot) - .over(Bitmaps.ImgScreenshotOver) - .down(Bitmaps.ImgScreenshotHit) - .tooltip("Screenshot"); - this.addObject(this.screenshotButton, this._toolbarLayout); - - this._toolbarLayout.addHSpacer(SPACE_NARROW); - - this.viewOptionsButton = new GameButton() - .up(Bitmaps.ImgSettings) - .over(Bitmaps.ImgSettingsOver) - .down(Bitmaps.ImgSettingsHit) - .tooltip("Game options"); - this.addObject(this.viewOptionsButton, this._toolbarLayout); - - this._toolbarLayout.addHSpacer(SPACE_NARROW); - - this.specButton = new GameButton() - .up(Bitmaps.ImgSpec) - .over(Bitmaps.ImgSpecOver) - .down(Bitmaps.ImgSpecHit) - .tooltip("View RNA's melting point, dotplot and other specs") - .hotkey(KeyCode.KeyS); - this.addObject(this.specButton, this._toolbarLayout); - - this._toolbarLayout.addHSpacer(SPACE_NARROW); - - this.pipButton = new GameButton() - .up(Bitmaps.ImgPip) - .over(Bitmaps.ImgPipOver) - .down(Bitmaps.ImgPipHit) - .selected(Bitmaps.ImgPipHit) - .tooltip("Set PiP mode") - .hotkey(KeyCode.KeyP); - - if (secstructs.length > 1) { - this.addObject(this.pipButton, this._toolbarLayout); - this._toolbarLayout.addHSpacer(SPACE_NARROW); - } - - this.zoomInButton = new GameButton() - .up(Bitmaps.ImgZoomIn) - .over(Bitmaps.ImgZoomInOver) - .down(Bitmaps.ImgZoomInHit) - .disabled(Bitmaps.ImgZoomInDisable) - .tooltip("Zoom in") - .hotkey(KeyCode.Equal) - .rscriptID(RScriptUIElementID.ZOOMIN); - this.addObject(this.zoomInButton, this._toolbarLayout); - - this.zoomOutButton = new GameButton() - .up(Bitmaps.ImgZoomOut) - .over(Bitmaps.ImgZoomOutOver) - .down(Bitmaps.ImgZoomOutHit) - .disabled(Bitmaps.ImgZoomOutDisable) - .tooltip("Zoom out") - .hotkey(KeyCode.Minus) - .rscriptID(RScriptUIElementID.ZOOMOUT); - this.addObject(this.zoomOutButton, this._toolbarLayout); - - this._toolbarLayout.addHSpacer(SPACE_NARROW); - - this.showEstimateButton = new GameButton() - .up(Bitmaps.ImgEstimate) - .over(Bitmaps.ImgEstimateOver) - .down(Bitmaps.ImgEstimateSelected) - .selected(Bitmaps.ImgEstimateSelected) - .tooltip("Estimate Mode. The game approximates how the RNA actually folded in a test tube."); - this.addObject(this.showEstimateButton, this._toolbarLayout); - - this.showTargetButton = new GameButton() - .up(Bitmaps.ImgTarget) - .over(Bitmaps.ImgTargetOver) - .down(Bitmaps.ImgTargetSelected) - .selected(Bitmaps.ImgTargetSelected) - .tooltip("Target Mode. RNA freezes in the target shape."); - this.addObject(this.showTargetButton, this._toolbarLayout); - - this._toolbarLayout.addHSpacer(SPACE_NARROW); - - this.letterColorButton = new GameButton() - .up(Bitmaps.ImgColoring) - .over(Bitmaps.ImgColoringOver) - .down(Bitmaps.ImgColoringSelected) - .selected(Bitmaps.ImgColoringSelected) - .tooltip("Color sequences based on base colors as in the game."); - this.letterColorButton.toggled.value = false; - this.addObject(this.letterColorButton, this._toolbarLayout); - - this.expColorButton = new GameButton() - .up(Bitmaps.ImgFlask) - .over(Bitmaps.ImgFlaskOver) - .down(Bitmaps.ImgFlaskSelected) - .selected(Bitmaps.ImgFlaskSelected) - .tooltip("Color sequences based on experimental data."); - this.expColorButton.toggled.value = true; - this.addObject(this.expColorButton, this._toolbarLayout); - - this._toolbarLayout.addHSpacer(SPACE_NARROW); - - this.viewSolutionsButton = new GameButton() - .up(Bitmaps.ImgFile) - .over(Bitmaps.ImgFileOver) - .down(Bitmaps.ImgFileHit) - .tooltip("View all submitted designs for this puzzle."); - this.addObject(this.viewSolutionsButton, this._toolbarLayout); - - // TOGGLE_BAR - this.toggleBar = new ToggleBar(secstructs.length); - if (secstructs.length > 1) { - // We create the _toggle_bar even if we don't add it to the mode, - // as scripts may rely on its existence - this.addObject(this.toggleBar, this._content); - } - - this.updateLayout(); - } - - private updateLayout(): void { - this._toolbarLayout.layout(true); - - if (this.toggleBar.isLiveObject) { - DisplayUtil.positionRelative( - this.toggleBar.display, HAlign.CENTER, VAlign.BOTTOM, - this._toolbarLayout, HAlign.CENTER, VAlign.TOP, 0, -5 - ); - } - - DisplayUtil.positionRelative( - this._content, HAlign.CENTER, VAlign.BOTTOM, - this._invisibleBackground, HAlign.CENTER, VAlign.BOTTOM, - 0, 0 - ); - } - - private readonly _puzzle: Puzzle; - private _invisibleBackground: Graphics; - private _content: Container; - private _toolbarLayout: HLayoutContainer; -} diff --git a/src/eterna/mode/FeedbackView/index.ts b/src/eterna/mode/FeedbackView/index.ts deleted file mode 100644 index e44e426c9..000000000 --- a/src/eterna/mode/FeedbackView/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export {default as FeedbackViewMode} from "./FeedbackViewMode"; -export {default as FeedbackViewToolbar} from "./FeedbackViewToolbar"; ""; diff --git a/src/eterna/mode/FeedbackView/FeedbackViewMode.ts b/src/eterna/mode/FeedbackViewMode.ts similarity index 94% rename from src/eterna/mode/FeedbackView/FeedbackViewMode.ts rename to src/eterna/mode/FeedbackViewMode.ts index d3c61d5fe..51884f442 100644 --- a/src/eterna/mode/FeedbackView/FeedbackViewMode.ts +++ b/src/eterna/mode/FeedbackViewMode.ts @@ -15,10 +15,9 @@ import { EternaViewOptionsDialog, EternaViewOptionsMode, SpecBoxDialog, URLButton } from "eterna/ui"; import {Fonts, Utility} from "eterna/util"; - import {Background} from "eterna/vfx"; import {GameMode} from "eterna/mode"; -import {FeedbackViewToolbar} from "."; +import Toolbar, {ToolbarType} from "eterna/ui/Toolbar"; export default class FeedbackViewMode extends GameMode { public constructor(solution: Solution, puzzle: Puzzle) { @@ -49,7 +48,7 @@ export default class FeedbackViewMode extends GameMode { this._homeButton.hideWhenModeInactive(); this.addObject(this._homeButton, this.uiLayer); - this._toolbar = new FeedbackViewToolbar(this._puzzle); + this._toolbar = new Toolbar(ToolbarType.FEEDBACK, {states: this._puzzle.getSecstructs().length}); this.addObject(this._toolbar, this.uiLayer); this._toolbar.zoomOutButton.clicked.connect(() => { @@ -71,8 +70,8 @@ export default class FeedbackViewMode extends GameMode { this._toolbar.expColorButton.clicked.connect(() => this.showExperimentalColors()); this._toolbar.specButton.clicked.connect(() => this.showSpec()); this._toolbar.pipButton.clicked.connect(() => this.togglePip()); - this._toolbar.showEstimateButton.clicked.connect(() => this.setToEstimateMode()); - this._toolbar.showTargetButton.clicked.connect(() => this.setToTargetMode()); + this._toolbar.estimateButton.clicked.connect(() => this.setToEstimateMode()); + this._toolbar.targetButton.clicked.connect(() => this.setToTargetMode()); this._feedback = this._solution.expFeedback; this._targetConditions = this._puzzle.targetConditions; @@ -179,8 +178,8 @@ export default class FeedbackViewMode extends GameMode { /* override */ protected onSetPip(pip_mode: boolean): void { if (pip_mode) { - if (this._toolbar.toggleBar != null) { - this._toolbar.toggleBar.display.visible = false; + if (this._toolbar.stateToggle != null) { + this._toolbar.stateToggle.display.visible = false; } if (this._foldMode == PoseFoldMode.ESTIMATE) { @@ -215,8 +214,8 @@ export default class FeedbackViewMode extends GameMode { this.showExperimentalColors(); } } else { - if (this._toolbar.toggleBar != null) { - this._toolbar.toggleBar.display.visible = true; + if (this._toolbar.stateToggle != null) { + this._toolbar.stateToggle.display.visible = true; } this.changeTarget(this._currentIndex); @@ -275,10 +274,10 @@ export default class FeedbackViewMode extends GameMode { private setToTargetMode(): void { this._foldMode = PoseFoldMode.TARGET; - this._toolbar.showTargetButton.hotkey(null); - this._toolbar.showEstimateButton.hotkey(KeyCode.Space); - this._toolbar.showEstimateButton.toggled.value = false; - this._toolbar.showTargetButton.toggled.value = true; + this._toolbar.targetButton.hotkey(null); + this._toolbar.estimateButton.hotkey(KeyCode.Space); + this._toolbar.estimateButton.toggled.value = false; + this._toolbar.targetButton.toggled.value = true; if (this._isPipMode) { for (let ii = 0; ii < this._pairs.length; ii++) { this._poseFields[ii].pose.pairs = this._pairs[ii]; @@ -290,10 +289,10 @@ export default class FeedbackViewMode extends GameMode { private setToEstimateMode(): void { this._foldMode = PoseFoldMode.ESTIMATE; - this._toolbar.showEstimateButton.hotkey(null); - this._toolbar.showTargetButton.hotkey(KeyCode.Space); - this._toolbar.showEstimateButton.toggled.value = true; - this._toolbar.showTargetButton.toggled.value = false; + this._toolbar.estimateButton.hotkey(null); + this._toolbar.targetButton.hotkey(KeyCode.Space); + this._toolbar.estimateButton.toggled.value = true; + this._toolbar.targetButton.toggled.value = false; if (this._isPipMode) { for (let ii = 0; ii < this._pairs.length; ii++) { this._poseFields[ii].pose.pairs = this._shapePairs[ii]; @@ -510,7 +509,7 @@ export default class FeedbackViewMode extends GameMode { private readonly _solution: Solution; private readonly _puzzle: Puzzle; - private _toolbar: FeedbackViewToolbar; + private _toolbar: Toolbar; private _homeButton: URLButton; private _undoBlocks: UndoBlock[] = []; diff --git a/src/eterna/mode/PoseEdit/PoseEditMode.ts b/src/eterna/mode/PoseEdit/PoseEditMode.ts index b9096cb5c..69780f00d 100644 --- a/src/eterna/mode/PoseEdit/PoseEditMode.ts +++ b/src/eterna/mode/PoseEdit/PoseEditMode.ts @@ -8,6 +8,7 @@ import {Assert, DisplayUtil, Easing} from "flashbang/util"; import EPars from "eterna/EPars"; import Eterna from "eterna/Eterna"; import {Folder, FolderManager, FoldUtil} from "eterna/folding"; +import {CopyTextDialogMode, GameMode, PuzzleEditPoseData} from "eterna/mode"; import {EternaURL} from "eterna/net"; import {Oligo, Pose2D, PoseField, PoseOp, PuzzleEditOp} from "eterna/pose2D"; import { @@ -22,11 +23,10 @@ import { PasteSequenceDialog, SpecBox, SpecBoxDialog, URLButton } from "eterna/ui"; import {default as UndoBlock, UndoBlockParam} from "eterna/UndoBlock"; -import {ExternalInterface, ExternalInterfaceCtx} from "eterna/util"; -import {Fonts, int} from "eterna/util"; +import {ExternalInterface, ExternalInterfaceCtx, Fonts, int} from "eterna/util"; import {Background, BubbleSweep} from "eterna/vfx"; -import {CopyTextDialogMode, GameMode, PuzzleEditPoseData} from "eterna/mode"; -import {MissionClearedPanel, MissionIntroMode, PoseEditToolbar, SubmitPoseDetails, SubmitPoseDialog, SubmittingDialog} from "."; +import {MissionClearedPanel, MissionIntroMode, SubmitPoseDetails, SubmitPoseDialog, SubmittingDialog} from "."; +import Toolbar, { ToolbarType } from "eterna/ui/Toolbar"; type InteractionEvent = PIXI.interaction.InteractionEvent; @@ -73,7 +73,12 @@ export default class PoseEditMode extends GameMode { this._background = new Background(); this.addObject(this._background, this.bgLayer); - this._toolbar = new PoseEditToolbar(this._puzzle, this._scriptInterface); + let toolbarType = this._puzzle.puzzleType == PuzzleType.EXPERIMENTAL ? ToolbarType.LAB : ToolbarType.PUZZLE; + this._toolbar = new Toolbar(toolbarType, { + states: this._puzzle.getSecstructs().length, + showHint: this._puzzle.hint != null, + boosters: this._puzzle.boosters + }); this.addObject(this._toolbar, this.uiLayer); this._toolbar.undoButton.clicked.connect(() => this.moveUndoStackBackward()); @@ -98,8 +103,8 @@ export default class PoseEditMode extends GameMode { this.popUILock(); }); }); - this._toolbar.retryButton.clicked.connect(() => this.showResetPrompt()); - this._toolbar.nativeButton.clicked.connect(() => this.togglePoseState()); + this._toolbar.resetButton.clicked.connect(() => this.showResetPrompt()); + this._toolbar.naturalButton.clicked.connect(() => this.togglePoseState()); this._toolbar.targetButton.clicked.connect(() => this.togglePoseState()); this._toolbar.specButton.clicked.connect(() => this.showSpec()); this._toolbar.copyButton.clicked.connect(() => this.showCopySequenceDialog()); @@ -109,17 +114,13 @@ export default class PoseEditMode extends GameMode { this._toolbar.pipButton.clicked.connect(() => this.togglePip()); - this._toolbar.puzzleStateToggle.stateChanged.connect((targetIdx) => this.changeTarget(targetIdx)); + this._toolbar.stateToggle.stateChanged.connect((targetIdx) => this.changeTarget(targetIdx)); this._toolbar.freezeButton.clicked.connect(() => this.toggleFreeze()); this._toolbar.palette.targetClicked.connect((targetType) => this.onPaletteTargetSelected(targetType)); this._toolbar.pairSwapButton.clicked.connect(() => this.onSwapClicked()); this._toolbar.hintButton.clicked.connect(() => this.onHintClicked()); - this.regs.add(Eterna.settings.autohideToolbar.connectNotify((value) => { - this._toolbar.setToolbarAutohide(value); - })); - // Add our docked SpecBox at the bottom of uiLayer this._dockedSpecBox = new SpecBox(true); this._dockedSpecBox.display.position = new Point(15, 190); @@ -231,7 +232,7 @@ export default class PoseEditMode extends GameMode { this._dockedSpecBox.setSize(s + 55, s * 2 + 51); } - public get toolbar(): PoseEditToolbar { + public get toolbar(): Toolbar { return this._toolbar; } @@ -271,8 +272,8 @@ export default class PoseEditMode extends GameMode { public ropChangeTarget(target_index: number): void { this.changeTarget(target_index); - if (this._toolbar.puzzleStateToggle != null) { - this._toolbar.puzzleStateToggle.state = target_index; + if (this._toolbar.stateToggle != null) { + this._toolbar.stateToggle.state = target_index; } } @@ -329,13 +330,10 @@ export default class PoseEditMode extends GameMode { public onPaletteTargetSelected(type: PaletteTargetType): void { let baseType: number = GetPaletteTargetBaseType(type); this.setPosesColor(baseType); - this.deselectAllColorings(); } public onSwapClicked(): void { this.setPosesColor(EPars.RNABASE_PAIR); - this.deselectAllColorings(); - this._toolbar.pairSwapButton.toggled.value = true; } public onHintClicked(): void { @@ -1110,7 +1108,7 @@ export default class PoseEditMode extends GameMode { Eterna.settings.pipEnabled.value = pip_mode; if (pip_mode) { - this._toolbar.puzzleStateToggle.display.visible = false; + this._toolbar.stateToggle.display.visible = false; this._targetName.visible = false; for (let ii = 0; ii < this._poses.length; ii++) { @@ -1137,7 +1135,7 @@ export default class PoseEditMode extends GameMode { } } else { - this._toolbar.puzzleStateToggle.display.visible = true; + this._toolbar.stateToggle.display.visible = true; this._targetName.visible = true; this.changeTarget(this._curTargetIndex); @@ -1206,7 +1204,7 @@ export default class PoseEditMode extends GameMode { `Player: ${Eterna.playerName}\n` + `Puzzle ID: ${this._puzzle.nodeID}\n` + `Puzzle Title: ${this._puzzle.getName()}\n` + - `Mode: ${this.toolbar.nativeButton.isSelected ? "NativeMode" : "TargetMode"}`; + `Mode: ${this.toolbar.naturalButton.isSelected ? "NativeMode" : "TargetMode"}`; let infoText = Fonts.arial(info).color(0xffffff).build(); this.container.addChild(infoText); @@ -1371,9 +1369,9 @@ export default class PoseEditMode extends GameMode { this._poseState = PoseState.NATIVE; this._toolbar.targetButton.toggled.value = false; - this._toolbar.nativeButton.toggled.value = true; + this._toolbar.naturalButton.toggled.value = true; this._toolbar.targetButton.hotkey(KeyCode.Space); - this._toolbar.nativeButton.hotkey(null); + this._toolbar.naturalButton.hotkey(null); this.savePosesMarkersContexts(); this._paused = false; @@ -1385,8 +1383,8 @@ export default class PoseEditMode extends GameMode { this._poseState = PoseState.TARGET; this._toolbar.targetButton.toggled.value = true; - this._toolbar.nativeButton.toggled.value = false; - this._toolbar.nativeButton.hotkey(KeyCode.Space); + this._toolbar.naturalButton.toggled.value = false; + this._toolbar.naturalButton.hotkey(KeyCode.Space); this._toolbar.targetButton.hotkey(null); this.savePosesMarkersContexts(); @@ -1837,14 +1835,6 @@ export default class PoseEditMode extends GameMode { missionClearedPanel.closeButton.clicked.connect(() => keepPlaying()); } - public deselectAllColorings(): void { - this._toolbar.palette.clearSelection(); - this._toolbar.pairSwapButton.toggled.value = false; - for (let button of this._toolbar.dynPaintTools) { - button.toggled.value = false; - } - } - public setPosesColor(paintColor: number): void { for (let pose of this._poses) { pose.currentColor = paintColor; @@ -3598,7 +3588,7 @@ export default class PoseEditMode extends GameMode { private _background: Background; - private _toolbar: PoseEditToolbar; + private _toolbar: Toolbar; protected _folder: Folder; /// Asynch folding diff --git a/src/eterna/mode/PoseEdit/PoseEditToolbar.ts b/src/eterna/mode/PoseEdit/PoseEditToolbar.ts deleted file mode 100644 index 25557edda..000000000 --- a/src/eterna/mode/PoseEdit/PoseEditToolbar.ts +++ /dev/null @@ -1,481 +0,0 @@ -import {Container, Graphics, Point} from "pixi.js"; -import {Flashbang, HAlign, VAlign} from "flashbang/core"; -import {KeyCode} from "flashbang/input"; -import {HLayoutContainer} from "flashbang/layout"; -import {ContainerObject} from "flashbang/objects"; -import {LocationTask} from "flashbang/tasks"; -import {DisplayUtil, Easing} from "flashbang/util"; -import {RegistrationGroup} from "signals"; -import Eterna from "eterna/Eterna"; -import {BoostersData, Puzzle, PuzzleType} from "eterna/puzzle"; -import {Bitmaps} from "eterna/resources"; -import {RScriptUIElementID} from "eterna/rscript"; -import { - EternaMenu, EternaMenuStyle, GameButton, NucleotidePalette, ToggleBar -} from "eterna/ui"; -import {ExternalInterfaceCtx} from "eterna/util"; -import {GameMode} from "eterna/mode"; -import {Booster, PoseEditMode} from "."; - -export default class PoseEditToolbar extends ContainerObject { - public palette: NucleotidePalette; - - public nativeButton: GameButton; - public targetButton: GameButton; - public pipButton: GameButton; - public freezeButton: GameButton; - - public puzzleStateToggle: ToggleBar; - - public actionMenu: EternaMenu; - public boostersMenu: GameButton; - public undoButton: GameButton; - public redoButton: GameButton; - public zoomInButton: GameButton; - public zoomOutButton: GameButton; - public copyButton: GameButton; - public pasteButton: GameButton; - public viewOptionsButton: GameButton; - public retryButton: GameButton; - public specButton: GameButton; - public screenshotButton: GameButton; - - public pairSwapButton: GameButton; - public hintButton: GameButton; - public dynPaintTools: GameButton[] = []; - public dynActionTools: GameButton[] = []; - - public submitButton: GameButton; - public viewSolutionsButton: GameButton; - - public constructor(puz: Puzzle, scriptInterface: ExternalInterfaceCtx) { - super(); - this._puzzle = puz; - this._scriptInterface = scriptInterface; - } - - protected added(): void { - super.added(); - - const SPACE_NARROW = 7; - const SPACE_WIDE = 25; - - this._invisibleBackground = new Graphics(); - this._invisibleBackground - .beginFill(0, 0) - .drawRect(0, 0, Flashbang.stageWidth, 100) - .endFill(); - this._invisibleBackground.y = -this._invisibleBackground.height; - this.container.addChild(this._invisibleBackground); - - this._content = new Container(); - this.container.addChild(this._content); - - this._toolbarLayout = new HLayoutContainer(); - this._content.addChild(this._toolbarLayout); - - const isExperimental = this._puzzle.puzzleType === PuzzleType.EXPERIMENTAL; - - this.actionMenu = new EternaMenu(EternaMenuStyle.PULLUP); - this.addObject(this.actionMenu, this._toolbarLayout); - - // ACTION MENU - this.actionMenu.addMenuButton(new GameButton().allStates(Bitmaps.NovaMenu).disabled(null)); - - this.screenshotButton = new GameButton() - .allStates(Bitmaps.ImgScreenshot) - .disabled(null) - .label("Screenshot", 14) - .scaleBitmapToLabel() - .tooltip("Screenshot"); - this.actionMenu.addSubMenuButton(0, this.screenshotButton); - - this.viewOptionsButton = new GameButton() - .allStates(Bitmaps.ImgSettings) - .disabled(null) - .label("Settings", 14) - .scaleBitmapToLabel() - .tooltip("Game options"); - this.actionMenu.addSubMenuButton(0, this.viewOptionsButton); - - this.viewSolutionsButton = new GameButton() - .allStates(Bitmaps.ImgFile) - .disabled(null) - .label("Designs", 14) - .scaleBitmapToLabel() - .tooltip("View all submitted designs for this puzzle."); - - this.specButton = new GameButton() - .allStates(Bitmaps.ImgSpec) - .disabled(null) - .label("Specs", 14) - .scaleBitmapToLabel() - .tooltip("View RNA's melting point, dotplot and other specs") - .hotkey(KeyCode.KeyS); - - if (isExperimental) { - this.actionMenu.addSubMenuButton(0, this.viewSolutionsButton); - this.actionMenu.addSubMenuButton(0, this.specButton); - } - - this.retryButton = new GameButton() - .allStates(Bitmaps.ImgReset) - .disabled(null) - .label("Reset", 14) - .scaleBitmapToLabel() - .tooltip("Reset and try this puzzle again.") - .rscriptID(RScriptUIElementID.RESET); - this.actionMenu.addSubMenuButton(0, this.retryButton); - - this.copyButton = new GameButton() - .allStates(Bitmaps.ImgCopy) - .disabled(null) - .label("Copy", 14) - .scaleBitmapToLabel() - .tooltip("Copy the current sequence"); - - this.pasteButton = new GameButton() - .allStates(Bitmaps.ImgPaste) - .disabled(null) - .label("Paste", 14) - .scaleBitmapToLabel() - .tooltip("Type in a sequence"); - - if (this._puzzle.puzzleType !== PuzzleType.BASIC) { - this.actionMenu.addSubMenuButton(0, this.copyButton); - this.actionMenu.addSubMenuButton(0, this.pasteButton); - } - - // BOOSTERS - ACTIONS - let boostersData: BoostersData = this._puzzle.boosters; - if (boostersData != null && boostersData.actions != null) { - this.boostersMenu = new GameButton().allStates(Bitmaps.NovaBoosters).disabled(null); - let boosterMenuIdx = this.actionMenu.addMenuButton(this.boostersMenu); - for (let ii = 0; ii < boostersData.actions.length; ii++) { - let data = boostersData.actions[ii]; - Booster.create(this.mode as GameMode, data).then((booster) => { - let button: GameButton = booster.createButton(14); - button.clicked.connect(() => booster.onRun()); - this.actionMenu.addSubMenuButtonAt(boosterMenuIdx, button, ii); - this.dynActionTools.push(button); - }); - } - } - - // SUBMIT BUTTON - this.submitButton = new GameButton() - .up(Bitmaps.ImgSubmit) - .over(Bitmaps.ImgSubmitOver) - .down(Bitmaps.ImgSubmitHit) - .tooltip("Publish your solution!"); - if (isExperimental) { - this._toolbarLayout.addHSpacer(SPACE_NARROW); - this.addObject(this.submitButton, this._toolbarLayout); - } - - this._toolbarLayout.addHSpacer(SPACE_WIDE); - - // FREEZE - this.freezeButton = new GameButton() - .up(Bitmaps.ImgFreeze) - .over(Bitmaps.ImgFreezeOver) - .down(Bitmaps.ImgFreezeSelected) - .selected(Bitmaps.ImgFreezeSelected) - .tooltip("Frozen mode. Suspends/resumes folding engine calculations.") - .hotkey(KeyCode.KeyF) - .rscriptID(RScriptUIElementID.FREEZE); - this.addObject(this.freezeButton, this._toolbarLayout); - this._toolbarLayout.addHSpacer(SPACE_NARROW); - this.freezeButton.display.visible = Eterna.settings.freezeButtonAlwaysVisible.value; - this.regs.add(Eterna.settings.freezeButtonAlwaysVisible.connect((visible) => { - this.freezeButton.display.visible = visible; - this.updateLayout(); - })); - - // PIP BUTTON - this.pipButton = new GameButton() - .up(Bitmaps.ImgPip) - .over(Bitmaps.ImgPipOver) - .down(Bitmaps.ImgPipHit) - .tooltip("Set PiP mode") - .hotkey(KeyCode.KeyP) - .rscriptID(RScriptUIElementID.PIP); - if (this._puzzle.getSecstructs().length > 1) { - this.addObject(this.pipButton, this._toolbarLayout); - this._toolbarLayout.addHSpacer(SPACE_NARROW); - } - - // NATIVE - this.nativeButton = new GameButton() - .up(Bitmaps.ImgNative) - .over(Bitmaps.ImgNativeOver) - .down(Bitmaps.ImgNativeSelected) - .selected(Bitmaps.ImgNativeSelected) - .tooltip("Natural Mode. RNA folds into the most stable shape.") - .rscriptID(RScriptUIElementID.TOGGLENATURAL); - this.addObject(this.nativeButton, this._toolbarLayout); - - // TARGET - this.targetButton = new GameButton() - .up(Bitmaps.ImgTarget) - .over(Bitmaps.ImgTargetOver) - .down(Bitmaps.ImgTargetSelected) - .selected(Bitmaps.ImgTargetSelected) - .tooltip("Target Mode. RNA freezes into the desired shape.") - .rscriptID(RScriptUIElementID.TOGGLETARGET); - this.addObject(this.targetButton, this._toolbarLayout); - - this._toolbarLayout.addHSpacer(SPACE_WIDE); - - // PALETTE - this.palette = new NucleotidePalette(); - this.addObject(this.palette, this._toolbarLayout); - if (this._puzzle.isPalleteAllowed) { - if (this._puzzle.isPairBrushAllowed) { - this.palette.changeDefaultMode(); - - this._toolbarLayout.addHSpacer(SPACE_NARROW); - - this.pairSwapButton = new GameButton() - .up(Bitmaps.ImgSwap) - .over(Bitmaps.ImgSwapOver) - .down(Bitmaps.ImgSwapOver) - .selected(Bitmaps.ImgSwapSelect) - .hotkey(KeyCode.Digit5) - .tooltip("Swap paired bases.") - .rscriptID(RScriptUIElementID.SWAP); - this.addObject(this.pairSwapButton, this._toolbarLayout); - } else { - this.palette.changeNoPairMode(); - } - } else { - this.palette.enabled = false; - } - - // BOOSTERS - PAINT TOOLS - if (boostersData != null && boostersData.paint_tools != null) { - let mode: PoseEditMode = this.mode as PoseEditMode; - let boosterPaintToolsLayout = new HLayoutContainer(); - this._toolbarLayout.addHSpacer(SPACE_NARROW); - this._toolbarLayout.addChild(boosterPaintToolsLayout); - for (let data of boostersData.paint_tools) { - Booster.create(mode, data).then((booster) => { - booster.onLoad(); - let button: GameButton = booster.createButton(); - button.clicked.connect(() => { - mode.setPosesColor(booster.toolColor); - mode.deselectAllColorings(); - }); - this.dynPaintTools.push(button); - this.addObject(button, boosterPaintToolsLayout); - this.updateLayout(); - }); - } - } - - // ZOOM IN, ZOOM OUT, UNDO, REDO - this.zoomInButton = new GameButton() - .up(Bitmaps.ImgZoomIn) - .over(Bitmaps.ImgZoomInOver) - .down(Bitmaps.ImgZoomInHit) - .disabled(Bitmaps.ImgZoomInDisable) - .tooltip("Zoom in") - .hotkey(KeyCode.Equal) - .rscriptID(RScriptUIElementID.ZOOMIN); - - this.zoomOutButton = new GameButton() - .up(Bitmaps.ImgZoomOut) - .over(Bitmaps.ImgZoomOutOver) - .down(Bitmaps.ImgZoomOutHit) - .disabled(Bitmaps.ImgZoomOutDisable) - .tooltip("Zoom out") - .hotkey(KeyCode.Minus) - .rscriptID(RScriptUIElementID.ZOOMOUT); - - this.undoButton = new GameButton() - .up(Bitmaps.ImgUndo) - .over(Bitmaps.ImgUndoOver) - .down(Bitmaps.ImgUndoHit) - .tooltip("Undo") - .hotkey(KeyCode.KeyZ) - .rscriptID(RScriptUIElementID.UNDO); - - this.redoButton = new GameButton() - .up(Bitmaps.ImgRedo) - .over(Bitmaps.ImgRedoOver) - .down(Bitmaps.ImgRedoHit) - .tooltip("Redo") - .hotkey(KeyCode.KeyY) - .rscriptID(RScriptUIElementID.REDO); - - if (this._puzzle.isUndoZoomAllowed) { - this._toolbarLayout.addHSpacer(SPACE_WIDE); - this.addObject(this.zoomInButton, this._toolbarLayout); - this.addObject(this.zoomOutButton, this._toolbarLayout); - - this._toolbarLayout.addHSpacer(SPACE_NARROW); - this.addObject(this.undoButton, this._toolbarLayout); - this.addObject(this.redoButton, this._toolbarLayout); - } - - this.hintButton = new GameButton() - .up(Bitmaps.ImgHint) - .over(Bitmaps.ImgHintOver) - .down(Bitmaps.ImgHintHit) - .hotkey(KeyCode.KeyH) - .tooltip("Hint") - .rscriptID(RScriptUIElementID.HINT); - if (this._puzzle.hint != null) { - this.addObject(this.hintButton, this._toolbarLayout); - } - - // TOGGLE_BAR - let target_secstructs: string[] = this._puzzle.getSecstructs(); - this.puzzleStateToggle = new ToggleBar(target_secstructs.length); - if (target_secstructs.length > 1) { - // We create the puzzleStateToggle even if we don't add it to the mode, - // as scripts may rely on its existence - this.addObject(this.puzzleStateToggle, this._content); - } - - this.updateLayout(); - this._uncollapsedContentLoc = new Point(this._content.position.x, this._content.position.y); - } - - private updateLayout(): void { - this._toolbarLayout.layout(true); - - if (this.puzzleStateToggle.isLiveObject) { - DisplayUtil.positionRelative( - this.puzzleStateToggle.display, HAlign.CENTER, VAlign.BOTTOM, - this._toolbarLayout, HAlign.CENTER, VAlign.TOP, 0, -5 - ); - } - - // If we have no boosters menu, we offset our entire layout by the .5 width of - // the boosters button. The tutorial hardcodes screen locations for its - // point-at-toolbar-buttons tips, so everything needs to be laid out *just so*, - // unfortunately. - let hOffset = (this.boostersMenu == null ? 27 : 0); - - DisplayUtil.positionRelative( - this._content, HAlign.CENTER, VAlign.BOTTOM, - this._invisibleBackground, HAlign.CENTER, VAlign.BOTTOM, - hOffset, 0 - ); - } - - public setToolbarAutohide(enabled: boolean): void { - const COLLAPSE_ANIM = "CollapseAnim"; - - if (this._autoCollapse === enabled) { - return; - } - - this._autoCollapse = enabled; - - if (this._autoCollapse) { - this.display.interactive = true; - - let collapsed = false; - - const uncollapse = () => { - if (collapsed) { - collapsed = false; - this.removeNamedObjects(COLLAPSE_ANIM); - this.addNamedObject( - COLLAPSE_ANIM, - new LocationTask( - this._uncollapsedContentLoc.x, - this._uncollapsedContentLoc.y, - 0.25, Easing.easeOut, this._content - ) - ); - } - }; - - const collapse = () => { - if (!collapsed) { - collapsed = true; - this.removeNamedObjects(COLLAPSE_ANIM); - this.addNamedObject( - COLLAPSE_ANIM, - new LocationTask( - this._uncollapsedContentLoc.x, - this._uncollapsedContentLoc.y + 72, - 0.25, Easing.easeOut, this._content - ) - ); - } - }; - - this._autoCollapseRegs = new RegistrationGroup(); - this._autoCollapseRegs.add(this.pointerOver.connect(uncollapse)); - this._autoCollapseRegs.add(this.pointerOut.connect(collapse)); - - collapse(); - } else { - if (this._autoCollapseRegs != null) { - this._autoCollapseRegs.close(); - this._autoCollapseRegs = null; - } - - this.removeNamedObjects(COLLAPSE_ANIM); - this._content.position = this._uncollapsedContentLoc; - this.display.interactive = false; - } - } - - public disableTools(disable: boolean): void { - this.palette.enabled = !disable; - this.pairSwapButton.enabled = !disable; - for (let k = 0; k < this.dynPaintTools.length; k++) { - this.dynPaintTools[k].enabled = !disable; - } - - this.targetButton.enabled = !disable; - this.nativeButton.enabled = !disable; - - this.zoomInButton.enabled = !disable; - this.zoomOutButton.enabled = !disable; - - this.nativeButton.enabled = !disable; - this.targetButton.enabled = !disable; - - this.viewOptionsButton.enabled = !disable; - this.retryButton.enabled = !disable; - this.copyButton.enabled = !disable; - this.pasteButton.enabled = !disable; - this.specButton.enabled = !disable; - - this.undoButton.enabled = !disable; - this.redoButton.enabled = !disable; - - this.submitButton.enabled = !disable; - this.viewSolutionsButton.enabled = !disable; - - this.hintButton.enabled = !disable; - - this.freezeButton.enabled = !disable; - this.specButton.enabled = !disable; - - this.pipButton.enabled = !disable; - - if (this.puzzleStateToggle != null) { - this.puzzleStateToggle.enabled = !disable; - } - - this.actionMenu.enabled = !disable; - } - - private readonly _puzzle: Puzzle; - private readonly _scriptInterface: ExternalInterfaceCtx; - - private _invisibleBackground: Graphics; - private _content: Container; - private _toolbarLayout: HLayoutContainer; - - private _uncollapsedContentLoc: Point; - private _autoCollapse: boolean; - private _autoCollapseRegs: RegistrationGroup; -} diff --git a/src/eterna/mode/PoseEdit/index.ts b/src/eterna/mode/PoseEdit/index.ts index 3f9c9e906..f5ba3f742 100644 --- a/src/eterna/mode/PoseEdit/index.ts +++ b/src/eterna/mode/PoseEdit/index.ts @@ -2,7 +2,6 @@ export {default as Booster, BoosterType} from "./Booster"; export {default as MissionClearedPanel} from "./MissionClearedPanel"; export {default as MissionIntroMode} from "./MissionIntroMode"; export {default as PoseEditMode, PuzzleState, PoseEditParams} from "./PoseEditMode"; -export {default as PoseEditToolbar} from "./PoseEditToolbar"; export {default as SubmitPoseDetails} from "./SubmitPoseDetails"; export {default as SubmitPoseDialog} from "./SubmitPoseDialog"; export {default as SubmittingDialog} from "./SubmittingDialog"; diff --git a/src/eterna/mode/PuzzleEdit/PuzzleEditMode.ts b/src/eterna/mode/PuzzleEdit/PuzzleEditMode.ts index a22c32fb9..02f00a77d 100644 --- a/src/eterna/mode/PuzzleEdit/PuzzleEditMode.ts +++ b/src/eterna/mode/PuzzleEdit/PuzzleEditMode.ts @@ -17,12 +17,13 @@ import { GameButton, GetPaletteTargetBaseType, PaletteTargetType, PasteSequenceDialog, PoseThumbnail, PoseThumbnailType, URLButton } from "eterna/ui"; +import {default as Toolbar, ToolbarType} from "eterna/ui/Toolbar"; import {default as UndoBlock, UndoBlockParam} from "eterna/UndoBlock"; import {ExternalInterfaceCtx, Fonts} from "eterna/util"; import {Background, BaseGlow} from "eterna/vfx"; import {CopyTextDialogMode, GameMode} from "eterna/mode"; import { - PuzzleEditToolbar, StructureInput, SubmitPuzzleDialog, SubmitPuzzleDetails + StructureInput, SubmitPuzzleDialog, SubmitPuzzleDetails } from "."; type InteractionEvent = PIXI.interaction.InteractionEvent; @@ -82,17 +83,18 @@ export default class PuzzleEditMode extends GameMode { this._homeButton.hideWhenModeInactive(); this.addObject(this._homeButton, this.uiLayer); - this._toolbar = new PuzzleEditToolbar(this._embedded); + let toolbarType = this._embedded ? ToolbarType.PUZZLEMAKER_EMBEDDED : ToolbarType.PUZZLEMAKER; + this._toolbar = new Toolbar(toolbarType, {states: this._numTargets}); this.addObject(this._toolbar, this.uiLayer); - this._toolbar.addbaseButton.clicked.connect(() => this.onEditButtonClicked(this._toolbar.addbaseButton, EPars.RNABASE_ADD_BASE)); - this._toolbar.addpairButton.clicked.connect(() => this.onEditButtonClicked(this._toolbar.addpairButton, EPars.RNABASE_ADD_PAIR)); - this._toolbar.deleteButton.clicked.connect(() => this.onEditButtonClicked(this._toolbar.deleteButton, EPars.RNABASE_DELETE)); - this._toolbar.lockButton.clicked.connect(() => this.onEditButtonClicked(this._toolbar.lockButton, EPars.RNABASE_LOCK)); - this._toolbar.siteButton.clicked.connect(() => this.onEditButtonClicked(this._toolbar.siteButton, EPars.RNABASE_BINDING_SITE)); - this._toolbar.pairSwapButton.clicked.connect(() => this.onEditButtonClicked(this._toolbar.pairSwapButton, EPars.RNABASE_PAIR)); + this._toolbar.addbaseButton.clicked.connect(() => this.onEditButtonClicked(EPars.RNABASE_ADD_BASE)); + this._toolbar.addpairButton.clicked.connect(() => this.onEditButtonClicked(EPars.RNABASE_ADD_PAIR)); + this._toolbar.deleteButton.clicked.connect(() => this.onEditButtonClicked(EPars.RNABASE_DELETE)); + this._toolbar.lockButton.clicked.connect(() => this.onEditButtonClicked(EPars.RNABASE_LOCK)); + this._toolbar.moleculeButton.clicked.connect(() => this.onEditButtonClicked(EPars.RNABASE_BINDING_SITE)); + this._toolbar.pairSwapButton.clicked.connect(() => this.onEditButtonClicked(EPars.RNABASE_PAIR)); - this._toolbar.nativeButton.clicked.connect(() => this.setToNativeMode()); + this._toolbar.naturalButton.clicked.connect(() => this.setToNativeMode()); this._toolbar.targetButton.clicked.connect(() => this.setToTargetMode()); this._toolbar.undoButton.clicked.connect(() => this.moveUndoStackBackward()); this._toolbar.redoButton.clicked.connect(() => this.moveUndoStackForward()); @@ -598,10 +600,10 @@ export default class PuzzleEditMode extends GameMode { private setToNativeMode(): void { this._toolbar.targetButton.toggled.value = false; - this._toolbar.nativeButton.toggled.value = true; + this._toolbar.naturalButton.toggled.value = true; this._toolbar.targetButton.hotkey(KeyCode.Space); - this._toolbar.nativeButton.hotkey(null); + this._toolbar.naturalButton.hotkey(null); this._paused = false; this.updateScore(); @@ -609,9 +611,9 @@ export default class PuzzleEditMode extends GameMode { private setToTargetMode(): void { this._toolbar.targetButton.toggled.value = true; - this._toolbar.nativeButton.toggled.value = false; + this._toolbar.naturalButton.toggled.value = false; - this._toolbar.nativeButton.hotkey(KeyCode.Space); + this._toolbar.naturalButton.hotkey(KeyCode.Space); this._toolbar.targetButton.hotkey(null); for (let ii = 0; ii < this._poses.length; ii++) { @@ -733,21 +735,16 @@ export default class PuzzleEditMode extends GameMode { } private onPaletteTargetSelected(type: PaletteTargetType): void { - this._toolbar.deselectAllColorings(); - let baseType: number = GetPaletteTargetBaseType(type); for (let pose of this._poses) { pose.currentColor = baseType; } } - private onEditButtonClicked(button: GameButton, poseColor: number): void { + private onEditButtonClicked(poseColor: number): void { for (let pose of this._poses) { pose.currentColor = poseColor; } - - this._toolbar.deselectAllColorings(); - button.toggled.value = true; } private poseEditByTarget(index: number): void { @@ -900,7 +897,7 @@ export default class PuzzleEditMode extends GameMode { private _stackSize: number; private _paused: boolean; - private _toolbar: PuzzleEditToolbar; + private _toolbar: Toolbar; private _folderButton: GameButton; private _homeButton: URLButton; private _constraintBoxes: ConstraintBox[] = []; diff --git a/src/eterna/mode/PuzzleEdit/PuzzleEditToolbar.ts b/src/eterna/mode/PuzzleEdit/PuzzleEditToolbar.ts deleted file mode 100644 index f7fadfea7..000000000 --- a/src/eterna/mode/PuzzleEdit/PuzzleEditToolbar.ts +++ /dev/null @@ -1,280 +0,0 @@ -import {Graphics} from "pixi.js"; -import {Flashbang, HAlign, VAlign} from "flashbang/core"; -import {KeyCode} from "flashbang/input"; -import {HLayoutContainer, VLayoutContainer} from "flashbang/layout"; -import {ContainerObject} from "flashbang/objects"; -import {DisplayUtil} from "flashbang/util"; -import {Bitmaps} from "eterna/resources"; -import {RScriptUIElementID} from "eterna/rscript"; -import {GameButton, NucleotidePalette} from "eterna/ui"; - -export default class PuzzleEditToolbar extends ContainerObject { - public palette: NucleotidePalette; - - public addbaseButton: GameButton; - public addpairButton: GameButton; - public deleteButton: GameButton; - public lockButton: GameButton; - public siteButton: GameButton; - - public nativeButton: GameButton; - public targetButton: GameButton; - - public undoButton: GameButton; - public redoButton: GameButton; - public zoomInButton: GameButton; - public zoomOutButton: GameButton; - public copyButton: GameButton; - public pasteButton: GameButton; - public viewOptionsButton: GameButton; - public screenshotButton: GameButton; - - public pairSwapButton: GameButton; - public resetButton: GameButton; - - public submitButton: GameButton; - - public constructor(embedded: boolean) { - super(); - this._embedded = embedded; - } - - protected added(): void { - super.added(); - - const SPACE_NARROW = 7; - const SPACE_WIDE = 25; - - this._invisibleBackground = new Graphics(); - this._invisibleBackground - .beginFill(0, 0) - .drawRect(0, 0, Flashbang.stageWidth, 100) - .endFill(); - this._invisibleBackground.y = -this._invisibleBackground.height; - this.container.addChild(this._invisibleBackground); - - this._content = new VLayoutContainer(SPACE_NARROW); - this.container.addChild(this._content); - - // UPPER TOOLBAR (structure editing tools) - let upperToolbarLayout = new HLayoutContainer(SPACE_NARROW); - this._content.addChild(upperToolbarLayout); - - this.addbaseButton = new GameButton() - .up(Bitmaps.ImgAddBase) - .over(Bitmaps.ImgAddBaseOver) - .down(Bitmaps.ImgAddBaseSelect) - .selected(Bitmaps.ImgAddBaseSelect) - .hotkey(KeyCode.Digit6) - .tooltip("Add a single base."); - this.addObject(this.addbaseButton, upperToolbarLayout); - - this.addpairButton = new GameButton() - .up(Bitmaps.ImgAddPair) - .over(Bitmaps.ImgAddPairOver) - .down(Bitmaps.ImgAddPairSelect) - .selected(Bitmaps.ImgAddPairSelect) - .hotkey(KeyCode.Digit7) - .tooltip("Add a pair."); - this.addObject(this.addpairButton, upperToolbarLayout); - - this.deleteButton = new GameButton() - .up(Bitmaps.ImgErase) - .over(Bitmaps.ImgEraseOver) - .down(Bitmaps.ImgEraseSelect) - .selected(Bitmaps.ImgEraseSelect) - .hotkey(KeyCode.Digit8) - .tooltip("Delete a base or a pair."); - this.addObject(this.deleteButton, upperToolbarLayout); - - this.lockButton = new GameButton() - .up(Bitmaps.ImgLock) - .over(Bitmaps.ImgLockOver) - .down(Bitmaps.ImgLockSelect) - .selected(Bitmaps.ImgLockSelect) - .hotkey(KeyCode.Digit9) - .tooltip("Lock or unlock a base."); - this.addObject(this.lockButton, upperToolbarLayout); - - this.siteButton = new GameButton() - .up(Bitmaps.ImgMolecule) - .over(Bitmaps.ImgMoleculeOver) - .down(Bitmaps.ImgMoleculeSelect) - .selected(Bitmaps.ImgMoleculeSelect) - .hotkey(KeyCode.Digit0) - .tooltip("Create or remove a molecular binding site."); - this.addObject(this.siteButton, upperToolbarLayout); - - // LOWER TOOLBAR (palette, zoom, settings, etc) - - let lowerToolbarLayout = new HLayoutContainer(); - this._content.addChild(lowerToolbarLayout); - - // SCREENSHOT - this.screenshotButton = new GameButton() - .up(Bitmaps.ImgScreenshot) - .over(Bitmaps.ImgScreenshotOver) - .down(Bitmaps.ImgScreenshotHit) - .tooltip("Screenshot"); - this.addObject(this.screenshotButton, lowerToolbarLayout); - - // SETTINGS - this.viewOptionsButton = new GameButton() - .up(Bitmaps.ImgSettings) - .over(Bitmaps.ImgSettingsOver) - .down(Bitmaps.ImgSettingsHit) - .tooltip("Game options"); - this.addObject(this.viewOptionsButton, lowerToolbarLayout); - - // ZOOM IN - this.zoomInButton = new GameButton() - .up(Bitmaps.ImgZoomIn) - .over(Bitmaps.ImgZoomInOver) - .down(Bitmaps.ImgZoomInHit) - .disabled(Bitmaps.ImgZoomInDisable) - .tooltip("Zoom in") - .hotkey(KeyCode.Equal) - .rscriptID(RScriptUIElementID.ZOOMIN); - this.addObject(this.zoomInButton, lowerToolbarLayout); - - // ZOOM OUT - this.zoomOutButton = new GameButton() - .up(Bitmaps.ImgZoomOut) - .over(Bitmaps.ImgZoomOutOver) - .down(Bitmaps.ImgZoomOutHit) - .disabled(Bitmaps.ImgZoomOutDisable) - .tooltip("Zoom out") - .hotkey(KeyCode.Minus) - .rscriptID(RScriptUIElementID.ZOOMOUT); - this.addObject(this.zoomOutButton, lowerToolbarLayout); - - lowerToolbarLayout.addHSpacer(SPACE_NARROW); - - // NATIVE - this.nativeButton = new GameButton() - .up(Bitmaps.ImgNative) - .over(Bitmaps.ImgNativeOver) - .down(Bitmaps.ImgNativeSelected) - .selected(Bitmaps.ImgNativeSelected) - .tooltip("Natural Mode. RNA folds into the most stable shape.") - .rscriptID(RScriptUIElementID.TOGGLENATURAL); - if (!this._embedded) { - this.addObject(this.nativeButton, lowerToolbarLayout); - } - - // TARGET - this.targetButton = new GameButton() - .up(Bitmaps.ImgTarget) - .over(Bitmaps.ImgTargetOver) - .down(Bitmaps.ImgTargetSelected) - .selected(Bitmaps.ImgTargetSelected) - .tooltip("Target Mode. RNA freezes into the desired shape.") - .rscriptID(RScriptUIElementID.TOGGLETARGET); - if (!this._embedded) { - this.addObject(this.targetButton, lowerToolbarLayout); - } - - lowerToolbarLayout.addHSpacer(SPACE_WIDE); - - // PALETTE - this.palette = new NucleotidePalette(); - this.addObject(this.palette, lowerToolbarLayout); - this.palette.changeDefaultMode(); - - lowerToolbarLayout.addHSpacer(SPACE_NARROW); - - // SWAP - this.pairSwapButton = new GameButton() - .up(Bitmaps.ImgSwap) - .over(Bitmaps.ImgSwapOver) - .down(Bitmaps.ImgSwapOver) - .selected(Bitmaps.ImgSwapSelect) - .hotkey(KeyCode.Digit5) - .tooltip("Swap paired bases.") - .rscriptID(RScriptUIElementID.SWAP); - this.addObject(this.pairSwapButton, lowerToolbarLayout); - - lowerToolbarLayout.addHSpacer(SPACE_WIDE); - - this.undoButton = new GameButton() - .up(Bitmaps.ImgUndo) - .over(Bitmaps.ImgUndoOver) - .down(Bitmaps.ImgUndoHit) - .disabled(Bitmaps.ImgUndo) - .tooltip("Undo") - .hotkey(KeyCode.KeyZ) - .rscriptID(RScriptUIElementID.UNDO); - this.addObject(this.undoButton, lowerToolbarLayout); - - this.redoButton = new GameButton() - .up(Bitmaps.ImgRedo) - .over(Bitmaps.ImgRedoOver) - .down(Bitmaps.ImgRedoHit) - .disabled(Bitmaps.ImgRedo) - .tooltip("Redo") - .hotkey(KeyCode.KeyY) - .rscriptID(RScriptUIElementID.REDO); - this.addObject(this.redoButton, lowerToolbarLayout); - - // COPY - this.copyButton = new GameButton() - .up(Bitmaps.ImgCopy) - .over(Bitmaps.ImgCopyOver) - .down(Bitmaps.ImgCopyHit) - .tooltip("Copy the current sequence"); - this.addObject(this.copyButton, lowerToolbarLayout); - - // PASTE - this.pasteButton = new GameButton() - .up(Bitmaps.ImgPaste) - .over(Bitmaps.ImgPasteOver) - .down(Bitmaps.ImgPasteHit) - .tooltip("Type in a sequence"); - this.addObject(this.pasteButton, lowerToolbarLayout); - - // RESET - this.resetButton = new GameButton() - .up(Bitmaps.ImgReset) - .over(Bitmaps.ImgResetOver) - .down(Bitmaps.ImgResetHit) - .tooltip("Reset all bases to A."); - this.addObject(this.resetButton, lowerToolbarLayout); - - // SUBMIT BUTTON - this.submitButton = new GameButton() - .up(Bitmaps.ImgSubmit) - .over(Bitmaps.ImgSubmitOver) - .down(Bitmaps.ImgSubmitHit) - .tooltip("Publish your puzzle!"); - lowerToolbarLayout.addHSpacer(SPACE_NARROW); - if (!this._embedded) { - this.addObject(this.submitButton, lowerToolbarLayout); - } - - this.updateLayout(); - } - - public deselectAllColorings(): void { - this.palette.clearSelection(); - this.pairSwapButton.toggled.value = false; - this.addbaseButton.toggled.value = false; - this.addpairButton.toggled.value = false; - this.deleteButton.toggled.value = false; - this.lockButton.toggled.value = false; - this.siteButton.toggled.value = false; - } - - private updateLayout(): void { - this._content.layout(true); - - DisplayUtil.positionRelative( - this._content, HAlign.CENTER, VAlign.BOTTOM, - this._invisibleBackground, HAlign.CENTER, VAlign.BOTTOM - ); - } - - private readonly _embedded: boolean; - - private _invisibleBackground: Graphics; - private _content: VLayoutContainer; -} diff --git a/src/eterna/mode/PuzzleEdit/index.ts b/src/eterna/mode/PuzzleEdit/index.ts index 552e11b20..9b8e48acf 100644 --- a/src/eterna/mode/PuzzleEdit/index.ts +++ b/src/eterna/mode/PuzzleEdit/index.ts @@ -1,4 +1,3 @@ export {default as PuzzleEditMode, PuzzleEditPoseData} from "./PuzzleEditMode"; -export {default as PuzzleEditToolbar} from "./PuzzleEditToolbar"; export {default as StructureInput} from "./StructureInput"; export {default as SubmitPuzzleDialog, SubmitPuzzleDetails} from "./SubmitPuzzleDialog"; diff --git a/src/eterna/mode/index.ts b/src/eterna/mode/index.ts index 5b340842e..07ccc4f02 100644 --- a/src/eterna/mode/index.ts +++ b/src/eterna/mode/index.ts @@ -3,6 +3,6 @@ export {default as ErrorDialogMode} from "./ErrorDialogMode"; export {default as GameMode} from "./GameMode"; export {default as LoadingMode} from "./LoadingMode"; export {DesignBrowserMode, DesignBrowserFilter} from "./DesignBrowser"; -export {FeedbackViewMode} from "./FeedbackView"; +export {default as FeedbackViewMode} from "./FeedbackViewMode"; export {PoseEditMode, PoseEditParams} from "./PoseEdit"; export {PuzzleEditMode, PuzzleEditPoseData} from "./PuzzleEdit"; diff --git a/src/eterna/rscript/RScriptEnv.ts b/src/eterna/rscript/RScriptEnv.ts index 50cc8c76e..925ec0002 100644 --- a/src/eterna/rscript/RScriptEnv.ts +++ b/src/eterna/rscript/RScriptEnv.ts @@ -176,7 +176,7 @@ export default class RScriptEnv extends ContainerObject { case RScriptUIElementID.OBJECTIVE: return this.ui.getConstraint(i); case RScriptUIElementID.SWITCH: - return this.ui.toolbar.puzzleStateToggle; + return this.ui.toolbar.stateToggle; case RScriptUIElementID.TOTALENERGY: case RScriptUIElementID.PRIMARY_ENERGY: return this.pose.primaryScoreDisplay; @@ -186,12 +186,12 @@ export default class RScriptEnv extends ContainerObject { case RScriptUIElementID.PALETTEALT: return this.ui.toolbar.palette; case RScriptUIElementID.TOGGLENATURAL: - return this.ui.toolbar.nativeButton; + return this.ui.toolbar.naturalButton; case RScriptUIElementID.TOGGLETARGET: return this.ui.toolbar.targetButton; case RScriptUIElementID.TOGGLEBAR: // NOTE: There is no longer a toggle bar... - return this.ui.toolbar.nativeButton; + return this.ui.toolbar.naturalButton; case RScriptUIElementID.ZOOMIN: return this.ui.toolbar.zoomInButton; case RScriptUIElementID.ZOOMOUT: @@ -200,7 +200,7 @@ export default class RScriptEnv extends ContainerObject { // NOTE: There is no longer an action bar... return this.ui.toolbar.zoomInButton; case RScriptUIElementID.RESET: - return this.ui.toolbar.retryButton; + return this.ui.toolbar.resetButton; case RScriptUIElementID.UNDO: return this.ui.toolbar.undoButton; case RScriptUIElementID.REDO: diff --git a/src/eterna/ui/EternaViewOptionsDialog.ts b/src/eterna/ui/EternaViewOptionsDialog.ts index c2f78bba5..191d5e345 100644 --- a/src/eterna/ui/EternaViewOptionsDialog.ts +++ b/src/eterna/ui/EternaViewOptionsDialog.ts @@ -34,9 +34,8 @@ export default class EternaViewOptionsDialog extends Dialog { bind(Eterna.settings.highlightRestricted, "Highlight restricted sequences"); bind(Eterna.settings.showChat, "In-game chat"); bind(Eterna.settings.simpleGraphics, "Use simpler, less animated graphics"); - + bind(Eterna.settings.autohideToolbar, "Autohide toolbar"); if (this._optionsMode !== EternaViewOptionsMode.PUZZLEMAKER) { - bind(Eterna.settings.autohideToolbar, "Autohide toolbar"); bind(Eterna.settings.freezeButtonAlwaysVisible, "Freeze button always visible"); } diff --git a/src/eterna/ui/Toolbar.ts b/src/eterna/ui/Toolbar.ts new file mode 100644 index 000000000..b3cc70730 --- /dev/null +++ b/src/eterna/ui/Toolbar.ts @@ -0,0 +1,642 @@ +import {Graphics, Container, Point} from "pixi.js"; +import {RegistrationGroup} from "signals"; +import {Flashbang, HAlign, VAlign} from "flashbang/core"; +import {KeyCode} from "flashbang/input"; +import {HLayoutContainer, VLayoutContainer} from "flashbang/layout"; +import {ContainerObject} from "flashbang/objects"; +import {LocationTask} from "flashbang/tasks"; +import {Easing, DisplayUtil} from "flashbang/util"; +import Eterna from "eterna/Eterna"; +import {Booster, PoseEditMode} from "eterna/mode/PoseEdit"; +import {Bitmaps} from "eterna/resources"; +import {RScriptUIElementID} from "eterna/rscript"; +import {BoostersData} from "eterna/puzzle"; +import { + NucleotidePalette, GameButton, ToggleBar, EternaMenu, EternaMenuStyle +} from "."; + +export enum ToolbarType { + PUZZLE, + PUZZLEMAKER, + PUZZLEMAKER_EMBEDDED, + LAB, + FEEDBACK +} + +export default class Toolbar extends ContainerObject { + // Core + public zoomInButton: GameButton; + public zoomOutButton: GameButton; + public pipButton: GameButton; + public stateToggle: ToggleBar; + + public targetButton: GameButton; + + public viewOptionsButton: GameButton; + + public screenshotButton: GameButton; + + public specButton: GameButton; + + public actionMenu: EternaMenu; + + // Pose Editing + public palette: NucleotidePalette; + public pairSwapButton: GameButton; + + public naturalButton: GameButton; + + public undoButton: GameButton; + public redoButton: GameButton; + public resetButton: GameButton; + public copyButton: GameButton; + public pasteButton: GameButton; + + public freezeButton: GameButton; + + public boostersMenu: GameButton; + + public dynPaintTools: GameButton[] = []; + public dynActionTools: GameButton[] = []; + + // Puzzle Maker + public addbaseButton: GameButton; + public addpairButton: GameButton; + public deleteButton: GameButton; + public lockButton: GameButton; + public moleculeButton: GameButton; + + // Puzzle Solving + public hintButton: GameButton; + + // Feedback + public estimateButton: GameButton; + public letterColorButton: GameButton; + public expColorButton: GameButton; + + // Lab + Feedback + public viewSolutionsButton: GameButton; + + // Puzzle Maker + Lab + public submitButton: GameButton; + + constructor(type: ToolbarType, + {states = 1, showHint = false, boosters = null}: {states?: number; showHint?: boolean; boosters?: BoostersData}) { + super(); + this._type = type; + this._states = states; + this._showHint = showHint; + this._boostersData = boosters; + } + + protected added(): void { + super.added(); + + const SPACE_NARROW = 7; + const SPACE_WIDE = 25; + + this._invisibleBackground = new Graphics(); + this._invisibleBackground + .beginFill(0, 0) + .drawRect(0, 0, Flashbang.stageWidth, 100) + .endFill(); + this._invisibleBackground.y = -this._invisibleBackground.height; + this.container.addChild(this._invisibleBackground); + + this._content = new VLayoutContainer(SPACE_NARROW); + this.container.addChild(this._content); + + this.stateToggle = new ToggleBar(this._states); + if (this._states > 1 && this._type !== ToolbarType.PUZZLEMAKER && this._type !== ToolbarType.PUZZLEMAKER_EMBEDDED) { + // We create the stateToggle even if we don't add it to the mode, + // as scripts may rely on its existence + this.addObject(this.stateToggle, this._content); + } + + // UPPER TOOLBAR (structure editing tools) + let upperToolbarLayout = new HLayoutContainer(SPACE_NARROW); + if (this._type == ToolbarType.PUZZLEMAKER || this._type == ToolbarType.PUZZLEMAKER_EMBEDDED) { + this._content.addChild(upperToolbarLayout); + } + + this.addbaseButton = new GameButton() + .up(Bitmaps.ImgAddBase) + .over(Bitmaps.ImgAddBaseOver) + .down(Bitmaps.ImgAddBaseSelect) + .selected(Bitmaps.ImgAddBaseSelect) + .hotkey(KeyCode.Digit6) + .tooltip("Add a single base."); + + this.addpairButton = new GameButton() + .up(Bitmaps.ImgAddPair) + .over(Bitmaps.ImgAddPairOver) + .down(Bitmaps.ImgAddPairSelect) + .selected(Bitmaps.ImgAddPairSelect) + .hotkey(KeyCode.Digit7) + .tooltip("Add a pair."); + + this.deleteButton = new GameButton() + .up(Bitmaps.ImgErase) + .over(Bitmaps.ImgEraseOver) + .down(Bitmaps.ImgEraseSelect) + .selected(Bitmaps.ImgEraseSelect) + .hotkey(KeyCode.Digit8) + .tooltip("Delete a base or a pair."); + + this.lockButton = new GameButton() + .up(Bitmaps.ImgLock) + .over(Bitmaps.ImgLockOver) + .down(Bitmaps.ImgLockSelect) + .selected(Bitmaps.ImgLockSelect) + .hotkey(KeyCode.Digit9) + .tooltip("Lock or unlock a base."); + + this.moleculeButton = new GameButton() + .up(Bitmaps.ImgMolecule) + .over(Bitmaps.ImgMoleculeOver) + .down(Bitmaps.ImgMoleculeSelect) + .selected(Bitmaps.ImgMoleculeSelect) + .hotkey(KeyCode.Digit0) + .tooltip("Create or remove a molecular binding site."); + + if (this._type == ToolbarType.PUZZLEMAKER || this._type == ToolbarType.PUZZLEMAKER_EMBEDDED) { + this.addObject(this.addbaseButton, upperToolbarLayout); + this.addObject(this.addpairButton, upperToolbarLayout); + this.addObject(this.deleteButton, upperToolbarLayout); + this.addObject(this.lockButton, upperToolbarLayout); + this.addObject(this.moleculeButton, upperToolbarLayout); + + this.regs.add(this.addbaseButton.clicked.connect(() => { + this._deselectAllPaintTools(); + this.addbaseButton.toggled.value = true; + })); + this.regs.add(this.addpairButton.clicked.connect(() => { + this._deselectAllPaintTools(); + this.addpairButton.toggled.value = true; + })); + this.regs.add(this.deleteButton.clicked.connect(() => { + this._deselectAllPaintTools(); + this.deleteButton.toggled.value = true; + })); + this.regs.add(this.lockButton.clicked.connect(() => { + this._deselectAllPaintTools(); + this.lockButton.toggled.value = true; + })); + this.regs.add(this.moleculeButton.clicked.connect(() => { + this._deselectAllPaintTools(); + this.moleculeButton.toggled.value = true; + })); + } + + // LOWER TOOLBAR (palette, zoom, settings, etc) + let lowerToolbarLayout = new HLayoutContainer(); + this._content.addChild(lowerToolbarLayout); + + this.actionMenu = new EternaMenu(EternaMenuStyle.PULLUP); + this.addObject(this.actionMenu, lowerToolbarLayout); + this.actionMenu.addMenuButton(new GameButton().allStates(Bitmaps.NovaMenu).disabled(null)); + + this.screenshotButton = new GameButton() + .allStates(Bitmaps.ImgScreenshot) + .disabled(null) + .label("Screenshot", 14) + .scaleBitmapToLabel() + .tooltip("Screenshot"); + this.actionMenu.addSubMenuButton(0, this.screenshotButton); + + this.viewOptionsButton = new GameButton() + .allStates(Bitmaps.ImgSettings) + .disabled(null) + .label("Settings", 14) + .scaleBitmapToLabel() + .tooltip("Game options"); + this.actionMenu.addSubMenuButton(0, this.viewOptionsButton); + + this.viewSolutionsButton = new GameButton() + .allStates(Bitmaps.ImgFile) + .disabled(null) + .label("Designs", 14) + .scaleBitmapToLabel() + .tooltip("View all submitted designs for this puzzle."); + + if (this._type == ToolbarType.LAB || this._type == ToolbarType.FEEDBACK) { + this.actionMenu.addSubMenuButton(0, this.viewSolutionsButton); + } + + this.specButton = new GameButton() + .allStates(Bitmaps.ImgSpec) + .disabled(null) + .label("Specs", 14) + .scaleBitmapToLabel() + .tooltip("View RNA's melting point, dotplot and other specs") + .hotkey(KeyCode.KeyS); + + if (this._type == ToolbarType.FEEDBACK || this._type == ToolbarType.LAB) { + this.actionMenu.addSubMenuButton(0, this.specButton); + } + + let resetTooltip = this._type == ToolbarType.PUZZLEMAKER || this._type == ToolbarType.PUZZLEMAKER_EMBEDDED + ? "Reset all bases to A" : "Reset and try this puzzle again."; + + this.resetButton = new GameButton() + .allStates(Bitmaps.ImgReset) + .disabled(null) + .label("Reset", 14) + .scaleBitmapToLabel() + .tooltip(resetTooltip) + .rscriptID(RScriptUIElementID.RESET); + + this.copyButton = new GameButton() + .allStates(Bitmaps.ImgCopy) + .disabled(null) + .label("Copy", 14) + .scaleBitmapToLabel() + .tooltip("Copy the current sequence"); + + this.pasteButton = new GameButton() + .allStates(Bitmaps.ImgPaste) + .disabled(null) + .label("Paste", 14) + .scaleBitmapToLabel() + .tooltip("Type in a sequence"); + + if (this._type != ToolbarType.FEEDBACK) { + this.actionMenu.addSubMenuButton(0, this.resetButton); + this.actionMenu.addSubMenuButton(0, this.copyButton); + this.actionMenu.addSubMenuButton(0, this.pasteButton); + } + + if (this._boostersData != null && this._boostersData.actions != null) { + this.boostersMenu = new GameButton().allStates(Bitmaps.NovaBoosters).disabled(null); + let boosterMenuIdx = this.actionMenu.addMenuButton(this.boostersMenu); + for (let ii = 0; ii < this._boostersData.actions.length; ii++) { + let data = this._boostersData.actions[ii]; + Booster.create(this.mode as PoseEditMode, data).then((booster) => { + let button: GameButton = booster.createButton(14); + button.clicked.connect(() => booster.onRun()); + this.actionMenu.addSubMenuButtonAt(boosterMenuIdx, button, ii); + this.dynActionTools.push(button); + }); + } + } + + this.submitButton = new GameButton() + .up(Bitmaps.ImgSubmit) + .over(Bitmaps.ImgSubmitOver) + .down(Bitmaps.ImgSubmitHit) + .tooltip("Publish your solution!"); + + if (this._type == ToolbarType.LAB) { + lowerToolbarLayout.addHSpacer(SPACE_NARROW); + this.addObject(this.submitButton, lowerToolbarLayout); + } + + lowerToolbarLayout.addHSpacer(SPACE_WIDE); + + this.freezeButton = new GameButton() + .up(Bitmaps.ImgFreeze) + .over(Bitmaps.ImgFreezeOver) + .down(Bitmaps.ImgFreezeSelected) + .selected(Bitmaps.ImgFreezeSelected) + .tooltip("Frozen mode. Suspends/resumes folding engine calculations.") + .hotkey(KeyCode.KeyF) + .rscriptID(RScriptUIElementID.FREEZE); + + if (this._type == ToolbarType.LAB || this._type == ToolbarType.PUZZLE) { + this.addObject(this.freezeButton, lowerToolbarLayout); + lowerToolbarLayout.addHSpacer(SPACE_NARROW); + this.freezeButton.display.visible = Eterna.settings.freezeButtonAlwaysVisible.value; + this.regs.add(Eterna.settings.freezeButtonAlwaysVisible.connect((visible) => { + this.freezeButton.display.visible = visible; + this.updateLayout(); + })); + } + + this.pipButton = new GameButton() + .up(Bitmaps.ImgPip) + .over(Bitmaps.ImgPipOver) + .down(Bitmaps.ImgPipHit) + .tooltip("Set PiP mode") + .hotkey(KeyCode.KeyP) + .rscriptID(RScriptUIElementID.PIP); + + if (this._states > 1 && this._type !== ToolbarType.PUZZLEMAKER && this._type !== ToolbarType.PUZZLEMAKER_EMBEDDED) { + this.addObject(this.pipButton, lowerToolbarLayout); + lowerToolbarLayout.addHSpacer(SPACE_NARROW); + } + + this.naturalButton = new GameButton() + .up(Bitmaps.ImgNative) + .over(Bitmaps.ImgNativeOver) + .down(Bitmaps.ImgNativeSelected) + .selected(Bitmaps.ImgNativeSelected) + .tooltip("Natural Mode. RNA folds into the most stable shape.") + .rscriptID(RScriptUIElementID.TOGGLENATURAL); + + this.estimateButton = new GameButton() + .up(Bitmaps.ImgEstimate) + .over(Bitmaps.ImgEstimateOver) + .down(Bitmaps.ImgEstimateSelected) + .selected(Bitmaps.ImgEstimateSelected) + .tooltip("Estimate Mode. The game approximates how the RNA actually folded in a test tube."); + + this.targetButton = new GameButton() + .up(Bitmaps.ImgTarget) + .over(Bitmaps.ImgTargetOver) + .down(Bitmaps.ImgTargetSelected) + .selected(Bitmaps.ImgTargetSelected) + .tooltip("Target Mode. RNA freezes into the desired shape.") + .rscriptID(RScriptUIElementID.TOGGLETARGET); + + if (this._type != ToolbarType.PUZZLEMAKER_EMBEDDED) { + if (this._type != ToolbarType.FEEDBACK) { + this.addObject(this.naturalButton, lowerToolbarLayout); + } else { + this.addObject(this.estimateButton, lowerToolbarLayout); + } + + this.addObject(this.targetButton, lowerToolbarLayout); + } + + this.letterColorButton = new GameButton() + .up(Bitmaps.ImgColoring) + .over(Bitmaps.ImgColoringOver) + .down(Bitmaps.ImgColoringSelected) + .selected(Bitmaps.ImgColoringSelected) + .tooltip("Color sequences based on base colors as in the game."); + + this.expColorButton = new GameButton() + .up(Bitmaps.ImgFlask) + .over(Bitmaps.ImgFlaskOver) + .down(Bitmaps.ImgFlaskSelected) + .selected(Bitmaps.ImgFlaskSelected) + .tooltip("Color sequences based on experimental data."); + + if (this._type == ToolbarType.FEEDBACK) { + lowerToolbarLayout.addHSpacer(SPACE_NARROW); + + this.letterColorButton.toggled.value = false; + this.addObject(this.letterColorButton, lowerToolbarLayout); + + this.expColorButton.toggled.value = true; + this.addObject(this.expColorButton, lowerToolbarLayout); + } + + this.palette = new NucleotidePalette(); + + this.regs.add(this.palette.targetClicked.connect(() => { + this._deselectAllPaintTools(); + })); + + this.pairSwapButton = new GameButton() + .up(Bitmaps.ImgSwap) + .over(Bitmaps.ImgSwapOver) + .down(Bitmaps.ImgSwapOver) + .selected(Bitmaps.ImgSwapSelect) + .hotkey(KeyCode.Digit5) + .tooltip("Swap paired bases.") + .rscriptID(RScriptUIElementID.SWAP); + + if (this._type != ToolbarType.FEEDBACK) { + lowerToolbarLayout.addHSpacer(SPACE_WIDE); + + this.addObject(this.palette, lowerToolbarLayout); + this.palette.changeDefaultMode(); + + lowerToolbarLayout.addHSpacer(SPACE_NARROW); + + this.addObject(this.pairSwapButton, lowerToolbarLayout); + + this.regs.add(this.pairSwapButton.clicked.connect(() => { + this._deselectAllPaintTools(); + this.pairSwapButton.toggled.value = true; + })); + + if (this._boostersData != null && this._boostersData.paint_tools != null) { + let mode: PoseEditMode = this.mode as PoseEditMode; + let boosterPaintToolsLayout = new HLayoutContainer(); + lowerToolbarLayout.addHSpacer(SPACE_NARROW); + lowerToolbarLayout.addChild(boosterPaintToolsLayout); + for (let data of this._boostersData.paint_tools) { + Booster.create(mode, data).then((booster) => { + booster.onLoad(); + let button: GameButton = booster.createButton(); + button.clicked.connect(() => { + mode.setPosesColor(booster.toolColor); + this._deselectAllPaintTools(); + }); + this.dynPaintTools.push(button); + this.addObject(button, boosterPaintToolsLayout); + this.updateLayout(); + }); + } + } + } + + lowerToolbarLayout.addHSpacer(SPACE_WIDE); + + this.zoomInButton = new GameButton() + .up(Bitmaps.ImgZoomIn) + .over(Bitmaps.ImgZoomInOver) + .down(Bitmaps.ImgZoomInHit) + .disabled(Bitmaps.ImgZoomInDisable) + .tooltip("Zoom in") + .hotkey(KeyCode.Equal) + .rscriptID(RScriptUIElementID.ZOOMIN); + this.addObject(this.zoomInButton, lowerToolbarLayout); + + this.zoomOutButton = new GameButton() + .up(Bitmaps.ImgZoomOut) + .over(Bitmaps.ImgZoomOutOver) + .down(Bitmaps.ImgZoomOutHit) + .disabled(Bitmaps.ImgZoomOutDisable) + .tooltip("Zoom out") + .hotkey(KeyCode.Minus) + .rscriptID(RScriptUIElementID.ZOOMOUT); + this.addObject(this.zoomOutButton, lowerToolbarLayout); + + lowerToolbarLayout.addHSpacer(SPACE_NARROW); + + this.undoButton = new GameButton() + .up(Bitmaps.ImgUndo) + .over(Bitmaps.ImgUndoOver) + .down(Bitmaps.ImgUndoHit) + .tooltip("Undo") + .hotkey(KeyCode.KeyZ) + .rscriptID(RScriptUIElementID.UNDO); + + this.redoButton = new GameButton() + .up(Bitmaps.ImgRedo) + .over(Bitmaps.ImgRedoOver) + .down(Bitmaps.ImgRedoHit) + .tooltip("Redo") + .hotkey(KeyCode.KeyY) + .rscriptID(RScriptUIElementID.REDO); + + if (this._type != ToolbarType.FEEDBACK) { + this.addObject(this.undoButton, lowerToolbarLayout); + this.addObject(this.redoButton, lowerToolbarLayout); + } + + this.hintButton = new GameButton() + .up(Bitmaps.ImgHint) + .over(Bitmaps.ImgHintOver) + .down(Bitmaps.ImgHintHit) + .hotkey(KeyCode.KeyH) + .tooltip("Hint") + .rscriptID(RScriptUIElementID.HINT); + + if (this._showHint) { + this.addObject(this.hintButton, lowerToolbarLayout); + } + + this.submitButton = new GameButton() + .up(Bitmaps.ImgSubmit) + .over(Bitmaps.ImgSubmitOver) + .down(Bitmaps.ImgSubmitHit) + .tooltip("Publish your puzzle!"); + + if (this._type == ToolbarType.PUZZLEMAKER) { + this.addObject(this.submitButton, lowerToolbarLayout); + } + + this.updateLayout(); + this._uncollapsedContentLoc = new Point(this._content.position.x, this._content.position.y); + this.regs.add(Eterna.settings.autohideToolbar.connectNotify((value) => { + this.setToolbarAutohide(value); + })); + } + + private updateLayout(): void { + this._content.layout(true); + + // If we have no boosters menu, we offset our entire layout by the .5 width of + // the boosters button. The tutorial hardcodes screen locations for its + // point-at-toolbar-buttons tips, so everything needs to be laid out *just so*, + // unfortunately. + let hOffset = (this.boostersMenu == null && this._type == ToolbarType.PUZZLE ? 27 : 0); + + DisplayUtil.positionRelative( + this._content, HAlign.CENTER, VAlign.BOTTOM, + this._invisibleBackground, HAlign.CENTER, VAlign.BOTTOM, + hOffset, 0 + ); + } + + private setToolbarAutohide(enabled: boolean): void { + const COLLAPSE_ANIM = "CollapseAnim"; + if (enabled) { + this.display.interactive = true; + + let collapsed = false; + + const uncollapse = () => { + if (collapsed) { + collapsed = false; + this.removeNamedObjects(COLLAPSE_ANIM); + this.addNamedObject( + COLLAPSE_ANIM, + new LocationTask( + this._uncollapsedContentLoc.x, + this._uncollapsedContentLoc.y, + 0.25, Easing.easeOut, this._content + ) + ); + } + }; + + const collapse = () => { + if (!collapsed) { + collapsed = true; + this.removeNamedObjects(COLLAPSE_ANIM); + this.addNamedObject( + COLLAPSE_ANIM, + new LocationTask( + this._uncollapsedContentLoc.x, + this._uncollapsedContentLoc.y + 72, + 0.25, Easing.easeOut, this._content + ) + ); + } + }; + + this._autoCollapseRegs = new RegistrationGroup(); + this._autoCollapseRegs.add(this.pointerOver.connect(uncollapse)); + this._autoCollapseRegs.add(this.pointerOut.connect(collapse)); + + collapse(); + } else { + if (this._autoCollapseRegs != null) { + this._autoCollapseRegs.close(); + this._autoCollapseRegs = null; + } + + this.removeNamedObjects(COLLAPSE_ANIM); + this._content.position = this._uncollapsedContentLoc; + this.display.interactive = false; + } + } + + public disableTools(disable: boolean): void { + this.zoomInButton.enabled = !disable; + this.zoomOutButton.enabled = !disable; + this.pipButton.enabled = !disable; + this.stateToggle.enabled = !disable; + + this.targetButton.enabled = !disable; + + this.actionMenu.enabled = !disable; + + this.palette.enabled = !disable; + this.pairSwapButton.enabled = !disable; + + this.naturalButton.enabled = !disable; + + this.undoButton.enabled = !disable; + this.redoButton.enabled = !disable; + + this.freezeButton.enabled = !disable; + + this.boostersMenu.enabled = !disable; + + this.addbaseButton.enabled = !disable; + this.addpairButton.enabled = !disable; + this.deleteButton.enabled = !disable; + this.lockButton.enabled = !disable; + this.moleculeButton.enabled = !disable; + + this.hintButton.enabled = !disable; + + this.estimateButton.enabled = !disable; + this.letterColorButton.enabled = !disable; + this.expColorButton.enabled = !disable; + + this.submitButton.enabled = !disable; + } + + private _deselectAllPaintTools(): void { + this.palette.clearSelection(); + this.pairSwapButton.toggled.value = false; + this.addbaseButton.toggled.value = false; + this.addpairButton.toggled.value = false; + this.deleteButton.toggled.value = false; + this.lockButton.toggled.value = false; + this.moleculeButton.toggled.value = false; + + for (let button of this.dynPaintTools) { + button.toggled.value = false; + } + } + + private readonly _type: ToolbarType; + private readonly _states: number; + private readonly _showHint: boolean; + private readonly _boostersData: BoostersData; + + private _invisibleBackground: Graphics; + private _content: VLayoutContainer; + private _toolbarLayout: HLayoutContainer; + + private _uncollapsedContentLoc: Point; + private _autoCollapseRegs: RegistrationGroup; +} diff --git a/src/eterna/ui/index.ts b/src/eterna/ui/index.ts index 0b5960229..7f69b192f 100644 --- a/src/eterna/ui/index.ts +++ b/src/eterna/ui/index.ts @@ -28,6 +28,8 @@ export {default as SpecBox} from "./SpecBox"; export {default as SpecBoxDialog} from "./SpecBoxDialog"; export {default as TextInputObject} from "./TextInputObject"; export {default as TextInputPanel} from "./TextInputPanel"; +// TODO: Weird circular dependancy issue. Once importing from eterna/mode/PoseEdit is gone, we can bring this back +// export {default as Toolbar} from "./Toolbar"; export {default as ToggleBar} from "./ToggleBar"; export {default as Tooltips, Tooltip} from "./Tooltips"; export {default as UILockDialog} from "./UILockDialog"; From d47997576f88a94ee40b6dabf6fbb539f6b8e04b Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Mon, 1 Jul 2019 17:00:11 -0400 Subject: [PATCH 06/39] UndoBlock.getOrderMap: minor bugfix from bad AS->TS translation --- src/eterna/UndoBlock.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/eterna/UndoBlock.ts b/src/eterna/UndoBlock.ts index 52fdbf5de..e646cc860 100644 --- a/src/eterna/UndoBlock.ts +++ b/src/eterna/UndoBlock.ts @@ -329,7 +329,7 @@ export default class UndoBlock { ofs[kk] = ii; ii += 1 + this._targetOligos[kk].sequence.length; } - for (let ii = 0; ii < this._sequence.length; ii++) idx_map[ii] = ii; + for (ii = 0; ii < this._sequence.length; ii++) idx_map[ii] = ii; for (let jj = 0; jj < this._targetOligos.length; jj++) { let kk = ofs[jj]; let xx: number; From 94c0076440ead610e6a1011c2ce4a2ab40185267 Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Mon, 1 Jul 2019 19:13:21 -0400 Subject: [PATCH 07/39] Clarify UndoBlock.getOrderMap (rename reorderedOligosMap) --- src/eterna/UndoBlock.ts | 40 +++++++++++++----------- src/eterna/mode/PoseEdit/PoseEditMode.ts | 5 ++- src/eterna/util/Utility.ts | 10 ++++++ 3 files changed, 34 insertions(+), 21 deletions(-) diff --git a/src/eterna/UndoBlock.ts b/src/eterna/UndoBlock.ts index e646cc860..8be070227 100644 --- a/src/eterna/UndoBlock.ts +++ b/src/eterna/UndoBlock.ts @@ -3,6 +3,7 @@ import EPars from "eterna/EPars"; import {Folder} from "eterna/folding"; import {default as Plot, PlotType} from "eterna/Plot"; import {Oligo, Pose2D} from "eterna/pose2D"; +import { Utility } from "./util"; export enum UndoBlockParam { GU = 0, @@ -318,27 +319,30 @@ export default class UndoBlock { return plot; } - public getOrderMap(other_order: number[]): number[] { + /** + * Return map of current base indices to adjusted base indices when oligos are rearranged + * according to otherorder + * @param otherOrder An array of indexes, where the index refers to the new index the oligo at the given position in the old + * array should be placed at. E.g., given oligos in order A B C, [1,2,0] means their new order should be C, A, B + * (oligo A, with the old index of 0, should be at new index 1) + */ + public reorderedOligosIndexMap(otherOrder: number[]): number[] { if (this._targetOligos == null) return null; - let idx_map: number[] = []; - let ofs: number[] = []; - let ii: number = this._sequence.length; - for (let jj = 0; jj < this._targetOligos.length; jj++) { - let kk = (other_order == null ? jj : other_order[jj]); - ofs[kk] = ii; - ii += 1 + this._targetOligos[kk].sequence.length; + let originalIndices: number[][] = []; + let oligoFirstBaseIndex = this._sequence.length; + + for (let oligo of this._targetOligos) { + // The + 1 is used to account for the "cut" base denoting split points between strands + originalIndices.push(Utility.range(oligoFirstBaseIndex, oligoFirstBaseIndex + oligo.sequence.length + 1)) + oligoFirstBaseIndex += oligo.sequence.length; } - for (ii = 0; ii < this._sequence.length; ii++) idx_map[ii] = ii; - for (let jj = 0; jj < this._targetOligos.length; jj++) { - let kk = ofs[jj]; - let xx: number; - for (xx = 0; xx <= this._targetOligos[jj].sequence.length; xx++) { - idx_map[ii + xx] = kk + xx; - } - ii += xx; - } - return idx_map; + + let newOrder = otherOrder || Utility.range(this._targetOligos.length); + + return Utility.range(this._sequence.length).concat( + ...Utility.range(this._targetOligos.length).map(idx => originalIndices[newOrder.indexOf(idx)]) + ); } private _sequence: number[]; diff --git a/src/eterna/mode/PoseEdit/PoseEditMode.ts b/src/eterna/mode/PoseEdit/PoseEditMode.ts index b9096cb5c..9b31534b7 100644 --- a/src/eterna/mode/PoseEdit/PoseEditMode.ts +++ b/src/eterna/mode/PoseEdit/PoseEditMode.ts @@ -2255,7 +2255,6 @@ export default class PoseEditMode extends GameMode { if (render) { box.setContent(ConstraintType.MUTATION, value, isSatisfied, sequence_diff); } - } else if (type === ConstraintType.SHAPE) { const target_index = Number(value); const ublk: UndoBlock = this.getCurrentUndoBlock(target_index); @@ -2265,8 +2264,8 @@ export default class PoseEditMode extends GameMode { structure_constraints = this._targetConditions[target_index]['structure_constraints']; if (ublk.oligoOrder != null) { - let np_map: number[] = ublk.getOrderMap(ublk.oligoOrder); - let tp_map: number[] = ublk.getOrderMap(ublk.targetOligoOrder); + let np_map: number[] = ublk.reorderedOligosIndexMap(ublk.oligoOrder); + let tp_map: number[] = ublk.reorderedOligosIndexMap(ublk.targetOligoOrder); if (np_map != null) { let new_pairs: number[] = []; let new_sc: number[] = []; diff --git a/src/eterna/util/Utility.ts b/src/eterna/util/Utility.ts index f53cac33b..6c7a35ce7 100644 --- a/src/eterna/util/Utility.ts +++ b/src/eterna/util/Utility.ts @@ -111,4 +111,14 @@ export default class Utility { } return ip; } + + public static range(start: number, stop: number): number[]; + public static range(length: number): number[]; + + public static range(a: number, b?: number): number[] { + let start = b ? a : 0; + let stop = b || a; + + return new Array(stop - start).fill(0).map((_, i) => i + start); + } } From ee20f0fe3fb849ef5b494cb8c230b6764e562ea3 Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Tue, 2 Jul 2019 15:45:42 -0400 Subject: [PATCH 08/39] Fix a bunch of import related stuff, imports in the same package shouldn't import from the index --- src/eterna/achievements/AchievementManager.ts | 2 +- src/eterna/folding/FolderManager.ts | 7 +++--- src/eterna/folding/LinearFoldBase.ts | 3 ++- src/eterna/folding/LinearFoldC.ts | 2 +- src/eterna/folding/LinearFoldV.ts | 2 +- src/eterna/folding/NuPACK.ts | 3 ++- src/eterna/folding/RNAFoldBasic.ts | 2 +- src/eterna/folding/Vienna.ts | 3 ++- src/eterna/folding/Vienna2.ts | 3 ++- src/eterna/folding/__tests__/Folder.test.ts | 10 ++++----- .../CustomizeColumnOrderDialog.ts | 2 +- src/eterna/mode/DesignBrowser/DataCol.ts | 6 ++--- .../mode/DesignBrowser/DesignBrowserMode.ts | 14 ++++++++---- .../mode/DesignBrowser/MarkerBoxView.ts | 2 +- .../mode/DesignBrowser/SolutionDescBox.ts | 2 +- src/eterna/mode/DesignBrowser/SortOptions.ts | 2 +- .../mode/DesignBrowser/SortOptionsDialog.ts | 3 ++- .../mode/DesignBrowser/ViewSolutionDialog.ts | 2 +- src/eterna/mode/FeedbackViewMode.ts | 5 ++--- src/eterna/mode/PoseEdit/PoseEditMode.ts | 9 +++++--- src/eterna/mode/PoseEdit/SubmitPoseDialog.ts | 2 +- src/eterna/mode/PuzzleEdit/PuzzleEditMode.ts | 8 +++---- src/eterna/pose2D/Base.ts | 4 +++- src/eterna/pose2D/BaseAssets.ts | 4 +++- src/eterna/pose2D/BaseTextures.ts | 3 ++- src/eterna/pose2D/ExplosionFactorPanel.ts | 2 +- src/eterna/pose2D/HighlightBox.ts | 2 +- src/eterna/pose2D/Pose2D.ts | 22 +++++++++++++------ src/eterna/pose2D/PoseField.ts | 5 ++--- src/eterna/pose2D/PoseUtil.ts | 2 +- src/eterna/puzzle/Puzzle.ts | 2 +- src/eterna/puzzle/PuzzleManager.ts | 3 ++- src/eterna/puzzle/SolutionManager.ts | 2 +- src/eterna/rank/RankBoard.ts | 3 ++- src/eterna/rank/RankRowLayout.ts | 2 +- src/eterna/rank/RankScroll.ts | 4 +++- src/eterna/resources/BitmapManager.ts | 2 +- src/eterna/rscript/RNAScript.ts | 14 ++++++++---- src/eterna/rscript/ROPHighlight.ts | 6 ++--- src/eterna/rscript/ROPHint.ts | 4 +++- src/eterna/rscript/ROPPre.ts | 3 ++- src/eterna/rscript/ROPRNA.ts | 3 ++- src/eterna/rscript/ROPTextbox.ts | 7 +++--- src/eterna/rscript/ROPUI.ts | 3 ++- src/eterna/rscript/ROPWait.ts | 7 +++--- src/eterna/rscript/RScriptEnv.ts | 2 +- src/eterna/rscript/RScriptOp.ts | 2 +- src/eterna/rscript/RScriptOpTree.ts | 3 ++- src/eterna/ui/AsyncProcessDialog.ts | 2 +- src/eterna/ui/ConfirmDialog.ts | 7 +++--- src/eterna/ui/ConstraintBox.ts | 6 ++--- src/eterna/ui/ContextMenu.ts | 3 ++- src/eterna/ui/EternaMenu.ts | 3 ++- src/eterna/ui/EternaViewOptionsDialog.ts | 7 +++--- src/eterna/ui/FancyGamePanel.ts | 2 +- src/eterna/ui/FancyTextBalloon.ts | 4 +++- src/eterna/ui/GameButton.ts | 4 ++-- src/eterna/ui/GamePanel.ts | 2 +- src/eterna/ui/NotificationDialog.ts | 4 +++- src/eterna/ui/NucleotidePalette.ts | 2 +- src/eterna/ui/PasteSequenceDialog.ts | 3 ++- src/eterna/ui/SliderBar.ts | 3 +-- src/eterna/ui/SpecBox.ts | 7 +++--- src/eterna/ui/SpecBoxDialog.ts | 4 +++- src/eterna/ui/TextBalloon.ts | 6 ++--- src/eterna/ui/TextInputPanel.ts | 4 +++- src/eterna/ui/Toolbar.ts | 11 ++++++---- src/eterna/ui/UILockDialog.ts | 2 +- src/eterna/ui/URLButton.ts | 2 +- src/eterna/ui/VScrollBox.ts | 3 ++- src/eterna/ui/index.ts | 7 +++--- src/eterna/vfx/Background.ts | 2 +- src/eterna/vfx/BubbleSweep.ts | 2 +- src/flashbang/core/AppMode.ts | 9 +++++--- src/flashbang/core/Flashbang.ts | 3 ++- src/flashbang/core/FlashbangApp.ts | 6 +++-- src/flashbang/core/GameObject.ts | 4 ++-- src/flashbang/core/GameObjectBase.ts | 7 +++--- src/flashbang/core/GameObjectRef.ts | 3 ++- src/flashbang/core/ModeStack.ts | 2 +- src/flashbang/core/ObjectTask.ts | 2 +- src/flashbang/core/index.ts | 2 +- .../input/DisplayObjectPointerTarget.ts | 2 +- src/flashbang/layout/HLayoutContainer.ts | 2 +- src/flashbang/layout/VLayoutContainer.ts | 2 +- src/flashbang/objects/Button.ts | 3 ++- src/flashbang/objects/ContainerObject.ts | 2 +- src/flashbang/{util => objects}/Dragger.ts | 0 src/flashbang/objects/ImageButton.ts | 2 +- src/flashbang/objects/SimpleTextButton.ts | 2 +- src/flashbang/objects/SpriteObject.ts | 2 +- src/flashbang/objects/ToggleButton.ts | 2 +- src/flashbang/objects/index.ts | 1 + src/flashbang/settings/Settings.ts | 2 +- src/flashbang/tasks/AlphaTask.ts | 2 +- src/flashbang/tasks/DisplayObjectTask.ts | 2 +- src/flashbang/tasks/LocationTask.ts | 2 +- src/flashbang/tasks/RotationTask.ts | 2 +- src/flashbang/tasks/ScaleTask.ts | 2 +- src/flashbang/util/Base64.ts | 2 +- src/flashbang/util/ColorUtil.ts | 3 ++- src/flashbang/util/DisplayUtil.ts | 2 +- src/flashbang/util/Easing.ts | 2 +- src/flashbang/util/RectangleUtil.ts | 2 +- src/flashbang/util/StyledTextBuilder.ts | 2 +- src/flashbang/util/TextureUtil.ts | 2 +- src/flashbang/util/index.ts | 3 +-- src/signals/AbstractSignal.ts | 5 ++--- src/signals/AbstractValue.ts | 7 ++---- src/signals/Connection.ts | 3 +-- src/signals/Cons.ts | 5 ++--- src/signals/FilteredSignal.ts | 5 ++--- src/signals/MappedSignal.ts | 9 +++----- src/signals/MappedValue.ts | 5 ++--- src/signals/Reactor.ts | 3 +-- src/signals/RegistrationGroup.ts | 5 ++--- src/signals/Registrations.ts | 3 +-- src/signals/Signal.ts | 7 ++---- src/signals/SignalView.ts | 3 +-- src/signals/UnitSignal.ts | 7 ++---- src/signals/Value.ts | 5 ++--- src/signals/ValueView.ts | 3 +-- src/signals/__tests__/Counter.ts | 2 +- .../__tests__/RegistrationGroup.test.ts | 6 ++--- src/signals/__tests__/Signal.test.ts | 7 ++---- src/signals/__tests__/Value.test.ts | 6 ++--- src/signals/index.ts | 2 +- 127 files changed, 269 insertions(+), 229 deletions(-) rename src/flashbang/{util => objects}/Dragger.ts (100%) diff --git a/src/eterna/achievements/AchievementManager.ts b/src/eterna/achievements/AchievementManager.ts index e016c15dc..57355dff5 100644 --- a/src/eterna/achievements/AchievementManager.ts +++ b/src/eterna/achievements/AchievementManager.ts @@ -4,7 +4,7 @@ import { import {CallbackTask, FunctionTask, SerialTask} from "flashbang/tasks"; import {DisplayUtil} from "flashbang/util"; import {GameMode} from "eterna/mode"; -import {AchievementBox} from "."; +import AchievementBox from "./AchievementBox"; export default class AchievementManager extends GameObject { /** True if there's an achievement animation playing, or about to play */ diff --git a/src/eterna/folding/FolderManager.ts b/src/eterna/folding/FolderManager.ts index 1b55b87fb..3719dcdd6 100644 --- a/src/eterna/folding/FolderManager.ts +++ b/src/eterna/folding/FolderManager.ts @@ -1,7 +1,8 @@ import Eterna from "eterna/Eterna"; -import { - Folder, LinearFoldC, RNAFoldBasic, Vienna -} from "."; +import Folder from "./Folder"; +import RNAFoldBasic from "./RNAFoldBasic"; +import Vienna from "./Vienna"; +import LinearFoldC from "./LinearFoldC"; export default class FolderManager { public static get instance(): FolderManager { diff --git a/src/eterna/folding/LinearFoldBase.ts b/src/eterna/folding/LinearFoldBase.ts index 203976e72..bfc2978f5 100644 --- a/src/eterna/folding/LinearFoldBase.ts +++ b/src/eterna/folding/LinearFoldBase.ts @@ -4,7 +4,8 @@ import EPars from "eterna/EPars"; import {FullFoldResult} from "./engines/LinearFold_lib"; import * as LinearFold_lib from "./engines/LinearFold_lib/index"; import {FullEvalResult} from "./engines/vienna_lib"; -import {Folder, FoldUtil} from "."; +import Folder from "./Folder"; +import FoldUtil from "./FoldUtil"; export default abstract class LinearFoldBase extends Folder { protected constructor(lib: LinearFold_lib) { diff --git a/src/eterna/folding/LinearFoldC.ts b/src/eterna/folding/LinearFoldC.ts index 421edea82..a5f0b408c 100644 --- a/src/eterna/folding/LinearFoldC.ts +++ b/src/eterna/folding/LinearFoldC.ts @@ -1,5 +1,5 @@ import {EmscriptenUtil} from "eterna/emscripten"; -import {LinearFoldBase} from "."; +import LinearFoldBase from "./LinearFoldBase"; export default class LinearFoldC extends LinearFoldBase { public static readonly NAME = "LinearFoldC"; diff --git a/src/eterna/folding/LinearFoldV.ts b/src/eterna/folding/LinearFoldV.ts index fc9244bc0..420ab37ca 100644 --- a/src/eterna/folding/LinearFoldV.ts +++ b/src/eterna/folding/LinearFoldV.ts @@ -1,5 +1,5 @@ import {EmscriptenUtil} from "eterna/emscripten"; -import {LinearFoldBase} from "."; +import LinearFoldBase from "./LinearFoldBase"; export default class LinearFoldV extends LinearFoldBase { public static readonly NAME = "LinearFoldV"; diff --git a/src/eterna/folding/NuPACK.ts b/src/eterna/folding/NuPACK.ts index b8146cf5b..7dce295b0 100644 --- a/src/eterna/folding/NuPACK.ts +++ b/src/eterna/folding/NuPACK.ts @@ -5,7 +5,8 @@ import {PoseOp} from "eterna/pose2D"; import {int} from "eterna/util"; import * as nupack_lib from "./engines/nupack_lib/index"; import {DotPlotResult, FullEvalResult, FullFoldResult} from "./engines/nupack_lib/index"; -import {Folder, FoldUtil} from "."; +import Folder from "./Folder"; +import FoldUtil from "./FoldUtil"; export default class NuPACK extends Folder { public static NAME = "NuPACK"; diff --git a/src/eterna/folding/RNAFoldBasic.ts b/src/eterna/folding/RNAFoldBasic.ts index d936a8faa..c698eac4c 100644 --- a/src/eterna/folding/RNAFoldBasic.ts +++ b/src/eterna/folding/RNAFoldBasic.ts @@ -1,5 +1,5 @@ import EPars from "eterna/EPars"; -import {Folder} from "."; +import Folder from "./Folder"; export default class RNAFoldBasic extends Folder { public static readonly NAME = "Basic"; diff --git a/src/eterna/folding/Vienna.ts b/src/eterna/folding/Vienna.ts index 1bae88c94..37498951c 100644 --- a/src/eterna/folding/Vienna.ts +++ b/src/eterna/folding/Vienna.ts @@ -5,7 +5,8 @@ import {RNALayout} from "eterna/pose2D"; import {CSVParser} from "eterna/util"; import * as vienna_lib from "./engines/vienna_lib/index"; import {DotPlotResult, FullEvalResult, FullFoldResult} from "./engines/vienna_lib/index"; -import {Folder, FoldUtil} from "."; +import Folder from "./Folder"; +import FoldUtil from "./FoldUtil"; export default class Vienna extends Folder { public static readonly NAME: string = "Vienna"; diff --git a/src/eterna/folding/Vienna2.ts b/src/eterna/folding/Vienna2.ts index 4f6e4eaba..36f08fc30 100644 --- a/src/eterna/folding/Vienna2.ts +++ b/src/eterna/folding/Vienna2.ts @@ -5,7 +5,8 @@ import {RNALayout} from "eterna/pose2D"; import {CSVParser} from "eterna/util"; import * as vrna2_lib from "./engines/vrna2_lib/index"; import {DotPlotResult, FullEvalResult, FullFoldResult} from "./engines/vrna2_lib/index"; -import {Folder, FoldUtil} from "."; +import Folder from "./Folder"; +import FoldUtil from "./FoldUtil"; export default class Vienna2 extends Folder { public static NAME = "Vienna2"; diff --git a/src/eterna/folding/__tests__/Folder.test.ts b/src/eterna/folding/__tests__/Folder.test.ts index beb83aaaa..ddcbc98e1 100644 --- a/src/eterna/folding/__tests__/Folder.test.ts +++ b/src/eterna/folding/__tests__/Folder.test.ts @@ -1,8 +1,8 @@ -import {EPars} from "../../EPars"; -import {Folder} from "../Folder"; -import {NuPACK} from "../NuPACK"; -import {Vienna} from "../Vienna"; -import {Vienna2} from "../Vienna2"; +import EPars from "eterna/EPars"; +import Folder from "../Folder"; +import NuPACK from "../NuPACK"; +import Vienna from "../Vienna"; +import Vienna2 from "../Vienna2"; import "./jest-matcher-deep-close-to"; const SNOWFLAKE_SEQ = 'GUGGACAAGAUGAAACAUCAGUAACAAGCGCAAAGCGCGGGCAAAGCCCCCGGAAACCGGAAGUUACAGAACAAAGUUCAAGUUUACAAGUGGACAAGUUGAAACAACAGUUACAAGACGAAACGUCGGCCAAAGGCCCCAUAAAAUGGAAGUAACACUUGAAACAAGAAGUUUACAAGUUGACAAGUUCAAAGAACAGUUACAAGUGGAAACCACGCGCAAAGCGCCUCCAAAGGAGAAGUAACAGAAGAAACUUCAAGUUAGCAAGUGGUCAAGUACAAAGUACAGUAACAACAUCAAAGAUGGCGCAAAGCGCGAGCAAAGCUCAAGUUACAGAACAAAGUUCAAGAUUACAAGAGUGCAAGAAGAAACUUCAGAUAGAACUGCAAAGCAGCACCAAAGGUGGGGCAAAGCCCAACUAUCAGUUGAAACAACAAGUAUUCAAGAGGUCAAGAUCAAAGAUCAGUAACAAGUGCAAAGCACGGGCAAAGCCCGACCAAAGGUCAAGUUACAGUUCAAAGAACAAGAUUUC'; diff --git a/src/eterna/mode/DesignBrowser/CustomizeColumnOrderDialog.ts b/src/eterna/mode/DesignBrowser/CustomizeColumnOrderDialog.ts index bfde1da0c..d3f21519b 100644 --- a/src/eterna/mode/DesignBrowser/CustomizeColumnOrderDialog.ts +++ b/src/eterna/mode/DesignBrowser/CustomizeColumnOrderDialog.ts @@ -8,7 +8,7 @@ import { Dialog, FixedWidthTextField, GameButton, GamePanel, GamePanelType } from "eterna/ui"; import {Fonts, GraphicsUtil} from "eterna/util"; -import {DesignCategory} from "."; +import {DesignCategory} from "./DesignBrowserMode"; export default class CustomizeColumnOrderDialog extends Dialog { public readonly columnsReorganized = new Signal(); diff --git a/src/eterna/mode/DesignBrowser/DataCol.ts b/src/eterna/mode/DesignBrowser/DataCol.ts index efd94549a..b5103ff3a 100644 --- a/src/eterna/mode/DesignBrowser/DataCol.ts +++ b/src/eterna/mode/DesignBrowser/DataCol.ts @@ -9,9 +9,9 @@ import Feedback from "eterna/Feedback"; import {Solution} from "eterna/puzzle"; import {GameButton, TextInputObject} from "eterna/ui"; import {Fonts, int, Utility} from "eterna/util"; -import { - DesignBrowserDataType, DesignCategory, SequenceStringListView, SortOrder -} from "."; +import {DesignBrowserDataType, DesignCategory} from "./DesignBrowserMode"; +import SequenceStringListView from "./SequenceStringListView"; +import {SortOrder} from "./SortOptions"; export default class DataCol extends ContainerObject { public readonly sortOrderChanged = new Signal(); diff --git a/src/eterna/mode/DesignBrowser/DesignBrowserMode.ts b/src/eterna/mode/DesignBrowser/DesignBrowserMode.ts index fdffbbe98..8f993ac2a 100644 --- a/src/eterna/mode/DesignBrowser/DesignBrowserMode.ts +++ b/src/eterna/mode/DesignBrowser/DesignBrowserMode.ts @@ -20,10 +20,16 @@ import { } from "eterna/ui"; import {Fonts, int} from "eterna/util"; import {GameMode} from "eterna/mode"; -import { - CustomizeColumnOrderDialog, DataCol, DotLine, GridLines, MarkerBoxView, - SelectionBox, SortOptions, SortOrder, SortOptionsDialog, ViewSolutionDialog, VoteProcessor -} from "."; +import CustomizeColumnOrderDialog from "./CustomizeColumnOrderDialog"; +import DataCol from "./DataCol"; +import DotLine from "./DotLine" +import GridLines from "./GridLines"; +import MarkerBoxView from "./MarkerBoxView"; +import SelectionBox from "./SelectionBox"; +import SortOptions, {SortOrder} from "./SortOptions"; +import SortOptionsDialog from "./SortOptionsDialog"; +import ViewSolutionDialog from "./ViewSolutionDialog"; +import VoteProcessor from "./VoteProcessor"; export enum DesignBrowserDataType { INT = 0, diff --git a/src/eterna/mode/DesignBrowser/MarkerBoxView.ts b/src/eterna/mode/DesignBrowser/MarkerBoxView.ts index 886e5fe22..ef90105a3 100644 --- a/src/eterna/mode/DesignBrowser/MarkerBoxView.ts +++ b/src/eterna/mode/DesignBrowser/MarkerBoxView.ts @@ -1,5 +1,5 @@ import {Container, Point} from "pixi.js"; -import {SelectionBox} from "."; +import SelectionBox from "./SelectionBox"; export default class MarkerBoxView extends Container { constructor(color: number, markerHeight: number) { diff --git a/src/eterna/mode/DesignBrowser/SolutionDescBox.ts b/src/eterna/mode/DesignBrowser/SolutionDescBox.ts index dd60bf6e3..741e38a53 100644 --- a/src/eterna/mode/DesignBrowser/SolutionDescBox.ts +++ b/src/eterna/mode/DesignBrowser/SolutionDescBox.ts @@ -13,7 +13,7 @@ import { } from "eterna/ui"; import {Fonts, Utility} from "eterna/util"; import {CopyTextDialogMode, GameMode} from "eterna/mode"; -import {LabComments} from "."; +import LabComments from "./LabComments"; export default class SolutionDescBox extends GamePanel { constructor(solution: Solution, puzzle: Puzzle) { diff --git a/src/eterna/mode/DesignBrowser/SortOptions.ts b/src/eterna/mode/DesignBrowser/SortOptions.ts index eda8e8c40..b0f95fd4d 100644 --- a/src/eterna/mode/DesignBrowser/SortOptions.ts +++ b/src/eterna/mode/DesignBrowser/SortOptions.ts @@ -1,7 +1,7 @@ import {Arrays} from "flashbang/util"; import {UnitSignal} from "signals"; import {Solution} from "eterna/puzzle"; -import {DesignCategory} from "."; +import {DesignCategory} from "./DesignBrowserMode"; export enum SortOrder { INCREASING = 1, diff --git a/src/eterna/mode/DesignBrowser/SortOptionsDialog.ts b/src/eterna/mode/DesignBrowser/SortOptionsDialog.ts index de344c34c..a9530b184 100644 --- a/src/eterna/mode/DesignBrowser/SortOptionsDialog.ts +++ b/src/eterna/mode/DesignBrowser/SortOptionsDialog.ts @@ -9,7 +9,8 @@ import { Dialog, FixedWidthTextField, GameButton, GamePanel, GamePanelType } from "eterna/ui"; import {Fonts, GraphicsUtil} from "eterna/util"; -import {DesignCategory, SortOptions, SortOrder} from "."; +import {DesignCategory} from "./DesignBrowserMode"; +import SortOptions, {SortOrder} from "./SortOptions"; export default class SortOptionsDialog extends Dialog { public readonly options: SortOptions; diff --git a/src/eterna/mode/DesignBrowser/ViewSolutionDialog.ts b/src/eterna/mode/DesignBrowser/ViewSolutionDialog.ts index e4627b5b9..f6ea1aab1 100644 --- a/src/eterna/mode/DesignBrowser/ViewSolutionDialog.ts +++ b/src/eterna/mode/DesignBrowser/ViewSolutionDialog.ts @@ -14,7 +14,7 @@ import { Dialog, GameButton, GamePanel, PoseThumbnail, PoseThumbnailType } from "eterna/ui"; import {Fonts} from "eterna/util"; -import {SolutionDescBox} from "."; +import SolutionDescBox from "./SolutionDescBox"; export default class ViewSolutionDialog extends Dialog { public readonly playClicked = new UnitSignal(); diff --git a/src/eterna/mode/FeedbackViewMode.ts b/src/eterna/mode/FeedbackViewMode.ts index 51884f442..6cd17c540 100644 --- a/src/eterna/mode/FeedbackViewMode.ts +++ b/src/eterna/mode/FeedbackViewMode.ts @@ -9,15 +9,14 @@ import Eterna from "eterna/Eterna"; import Feedback from "eterna/Feedback"; import UndoBlock from "eterna/UndoBlock"; import {Folder, FolderManager, Vienna} from "eterna/folding"; +import {GameMode} from "eterna/mode"; import {PoseField} from "eterna/pose2D"; import {Puzzle, Solution} from "eterna/puzzle"; import { - EternaViewOptionsDialog, EternaViewOptionsMode, SpecBoxDialog, URLButton + EternaViewOptionsDialog, EternaViewOptionsMode, SpecBoxDialog, URLButton, Toolbar, ToolbarType } from "eterna/ui"; import {Fonts, Utility} from "eterna/util"; import {Background} from "eterna/vfx"; -import {GameMode} from "eterna/mode"; -import Toolbar, {ToolbarType} from "eterna/ui/Toolbar"; export default class FeedbackViewMode extends GameMode { public constructor(solution: Solution, puzzle: Puzzle) { diff --git a/src/eterna/mode/PoseEdit/PoseEditMode.ts b/src/eterna/mode/PoseEdit/PoseEditMode.ts index 85aae3427..4ed73edaa 100644 --- a/src/eterna/mode/PoseEdit/PoseEditMode.ts +++ b/src/eterna/mode/PoseEdit/PoseEditMode.ts @@ -20,13 +20,16 @@ import {RNAScript} from "eterna/rscript"; import { ActionBar, ConstraintBox, ConstraintBoxType, ContextMenu, EternaViewOptionsDialog, EternaViewOptionsMode, GameButton, GamePanel, HTMLTextObject, GetPaletteTargetBaseType, PaletteTargetType, - PasteSequenceDialog, SpecBox, SpecBoxDialog, URLButton + PasteSequenceDialog, SpecBox, SpecBoxDialog, URLButton, Toolbar, ToolbarType } from "eterna/ui"; import {default as UndoBlock, UndoBlockParam} from "eterna/UndoBlock"; import {ExternalInterface, ExternalInterfaceCtx, Fonts, int} from "eterna/util"; import {Background, BubbleSweep} from "eterna/vfx"; -import {MissionClearedPanel, MissionIntroMode, SubmitPoseDetails, SubmitPoseDialog, SubmittingDialog} from "."; -import Toolbar, { ToolbarType } from "eterna/ui/Toolbar"; +import MissionClearedPanel from "./MissionClearedPanel"; +import MissionIntroMode from "./MissionIntroMode"; +import SubmitPoseDetails from "./SubmitPoseDetails"; +import SubmitPoseDialog from "./SubmitPoseDialog"; +import SubmittingDialog from "./SubmittingDialog"; type InteractionEvent = PIXI.interaction.InteractionEvent; diff --git a/src/eterna/mode/PoseEdit/SubmitPoseDialog.ts b/src/eterna/mode/PoseEdit/SubmitPoseDialog.ts index c2509d615..91be38a8d 100644 --- a/src/eterna/mode/PoseEdit/SubmitPoseDialog.ts +++ b/src/eterna/mode/PoseEdit/SubmitPoseDialog.ts @@ -1,7 +1,7 @@ import {Flashbang} from "flashbang/core"; import {KeyCode} from "flashbang/input"; import {Dialog, TextInputPanel} from "eterna/ui"; -import {SubmitPoseDetails} from "."; +import SubmitPoseDetails from "./SubmitPoseDetails"; /** Prompts the player for a title and comment */ export default class SubmitPoseDialog extends Dialog { diff --git a/src/eterna/mode/PuzzleEdit/PuzzleEditMode.ts b/src/eterna/mode/PuzzleEdit/PuzzleEditMode.ts index 02f00a77d..9d4228695 100644 --- a/src/eterna/mode/PuzzleEdit/PuzzleEditMode.ts +++ b/src/eterna/mode/PuzzleEdit/PuzzleEditMode.ts @@ -15,16 +15,14 @@ import {Bitmaps} from "eterna/resources"; import { AsyncProcessDialog, ConstraintBox, DialogCanceledError, EternaViewOptionsDialog, EternaViewOptionsMode, GameButton, GetPaletteTargetBaseType, PaletteTargetType, PasteSequenceDialog, PoseThumbnail, PoseThumbnailType, - URLButton + URLButton, Toolbar, ToolbarType } from "eterna/ui"; -import {default as Toolbar, ToolbarType} from "eterna/ui/Toolbar"; import {default as UndoBlock, UndoBlockParam} from "eterna/UndoBlock"; import {ExternalInterfaceCtx, Fonts} from "eterna/util"; import {Background, BaseGlow} from "eterna/vfx"; import {CopyTextDialogMode, GameMode} from "eterna/mode"; -import { - StructureInput, SubmitPuzzleDialog, SubmitPuzzleDetails -} from "."; +import StructureInput from "./StructureInput"; +import SubmitPuzzleDialog, {SubmitPuzzleDetails} from "./SubmitPuzzleDialog"; type InteractionEvent = PIXI.interaction.InteractionEvent; diff --git a/src/eterna/pose2D/Base.ts b/src/eterna/pose2D/Base.ts index 07c38fa76..5822d2680 100644 --- a/src/eterna/pose2D/Base.ts +++ b/src/eterna/pose2D/Base.ts @@ -6,7 +6,9 @@ import Constants from "eterna/Constants"; import EPars from "eterna/EPars"; import Eterna from "eterna/Eterna"; import {ROPWait} from "eterna/rscript"; -import {BaseAssets, BaseDrawFlags, Pose2D, RNAHighlightState} from "."; +import BaseAssets from "./BaseAssets"; +import BaseDrawFlags from "./BaseDrawFlags"; +import Pose2D, {RNAHighlightState} from "./Pose2D"; type ColorMatrixFilter = PIXI.filters.ColorMatrixFilter; diff --git a/src/eterna/pose2D/BaseAssets.ts b/src/eterna/pose2D/BaseAssets.ts index d8a5afaa1..0e28ec44d 100644 --- a/src/eterna/pose2D/BaseAssets.ts +++ b/src/eterna/pose2D/BaseAssets.ts @@ -4,7 +4,9 @@ import EPars from "eterna/EPars"; import ExpPainter from "eterna/ExpPainter"; import {BitmapManager, Bitmaps, Sounds} from "eterna/resources"; import {EternaTextureUtil} from "eterna/util"; -import {Base, BaseDrawFlags, BaseTextures} from "."; +import Base from "./Base"; +import BaseDrawFlags from "./BaseDrawFlags"; +import BaseTextures from "./BaseTextures"; /** Handles initialization and management of Base-related assets */ export default class BaseAssets { diff --git a/src/eterna/pose2D/BaseTextures.ts b/src/eterna/pose2D/BaseTextures.ts index 4244fb504..4a31f0f56 100644 --- a/src/eterna/pose2D/BaseTextures.ts +++ b/src/eterna/pose2D/BaseTextures.ts @@ -3,7 +3,8 @@ import {TextureUtil} from "flashbang/util"; import EPars from "eterna/EPars"; import {BitmapManager} from "eterna/resources"; import {EternaTextureUtil, Fonts} from "eterna/util"; -import {Base, BaseDrawFlags} from "."; +import Base from "./Base"; +import BaseDrawFlags from "./BaseDrawFlags"; /** Encapsulates textures for a Base type */ export default class BaseTextures { diff --git a/src/eterna/pose2D/ExplosionFactorPanel.ts b/src/eterna/pose2D/ExplosionFactorPanel.ts index 4cb38e71e..fddff58d6 100644 --- a/src/eterna/pose2D/ExplosionFactorPanel.ts +++ b/src/eterna/pose2D/ExplosionFactorPanel.ts @@ -1,7 +1,7 @@ import {Point, Text} from "pixi.js"; import {Signal} from "signals"; import {KeyCode} from "flashbang/input"; -import {GamePanel, GameButton, TextInputObject} from "eterna/ui"; +import {GameButton, GamePanel, TextInputObject} from "eterna/ui"; import {Fonts} from "eterna/util"; export default class ExplosionFactorPanel extends GamePanel { diff --git a/src/eterna/pose2D/HighlightBox.ts b/src/eterna/pose2D/HighlightBox.ts index 2f906e63b..72371a45b 100644 --- a/src/eterna/pose2D/HighlightBox.ts +++ b/src/eterna/pose2D/HighlightBox.ts @@ -2,7 +2,7 @@ import {DisplayObject, Graphics, Point} from "pixi.js"; import {GameObject, LateUpdatable, ObjectTask} from "flashbang/core"; import {Vector2} from "flashbang/geom"; import {AlphaTask, RepeatingTask, SerialTask} from "flashbang/tasks"; -import {Pose2D} from "."; +import Pose2D from "./Pose2D"; export enum HighlightType { STACK = 0, diff --git a/src/eterna/pose2D/Pose2D.ts b/src/eterna/pose2D/Pose2D.ts index 5bd75a137..bc54ebda4 100644 --- a/src/eterna/pose2D/Pose2D.ts +++ b/src/eterna/pose2D/Pose2D.ts @@ -3,11 +3,11 @@ import {Container, Graphics, Point, Sprite, Texture, Rectangle} from "pixi.js"; import {Flashbang, Updatable} from "flashbang/core"; import {Vector2} from "flashbang/geom"; import {InputUtil} from "flashbang/input"; -import {ContainerObject, SceneObject} from "flashbang/objects"; +import {ContainerObject, SceneObject, Dragger} from "flashbang/objects"; import { AlphaTask, DelayTask, LocationTask, ParallelTask, RepeatingTask, SelfDestructTask, SerialTask } from "flashbang/tasks"; -import {Arrays, DisplayUtil, Dragger, Easing} from "flashbang/util"; +import {Arrays, DisplayUtil, Easing} from "flashbang/util"; import {Registration} from "signals"; import EPars from "eterna/EPars"; import Eterna from "eterna/Eterna"; @@ -20,11 +20,19 @@ import {ROPWait} from "eterna/rscript"; import {TextBalloon} from "eterna/ui"; import {Fonts, Utility} from "eterna/util"; import {BaseGlow, LightRay} from "eterna/vfx"; -import { - Base, BaseDrawFlags, EnergyScoreDisplay, HighlightBox, HighlightType, Molecule, PaintCursor, - PoseField, PoseUtil, PuzzleEditOp, RNAAnchorObject, RNALayout, RNATreeNode, - ScoreDisplayNode, ScoreDisplayNodeType, ExplosionFactorPanel -} from "."; +import Base from "./Base"; +import BaseDrawFlags from "./BaseDrawFlags"; +import EnergyScoreDisplay from "./EnergyScoreDisplay"; +import HighlightBox, {HighlightType} from "./HighlightBox"; +import Molecule from "./Molecule"; +import PaintCursor from "./PaintCursor"; +import PoseField from "./PoseField"; +import PoseUtil from "./PoseUtil"; +import PuzzleEditOp from "./PuzzleEditOp"; +import RNAAnchorObject from "./RNAAnchorObject"; +import RNALayout, {RNATreeNode} from "./RNALayout"; +import ScoreDisplayNode, {ScoreDisplayNodeType} from "./ScoreDisplayNode"; +import ExplosionFactorPanel from "./ExplosionFactorPanel"; type InteractionEvent = PIXI.interaction.InteractionEvent; diff --git a/src/eterna/pose2D/PoseField.ts b/src/eterna/pose2D/PoseField.ts index 71f8ff283..0a7e3701b 100644 --- a/src/eterna/pose2D/PoseField.ts +++ b/src/eterna/pose2D/PoseField.ts @@ -1,10 +1,9 @@ import {Graphics, Point} from "pixi.js"; import {Flashbang, GameObjectRef} from "flashbang/core"; import {InputUtil, KeyboardEventType, KeyboardListener, KeyCode, MouseWheelListener} from "flashbang/input"; -import {ContainerObject} from "flashbang/objects"; -import {Dragger} from "flashbang/util"; +import {ContainerObject, Dragger} from "flashbang/objects"; import {ROPWait} from "eterna/rscript"; -import {Pose2D} from "."; +import Pose2D from "./Pose2D"; type InteractionEvent = PIXI.interaction.InteractionEvent; diff --git a/src/eterna/pose2D/PoseUtil.ts b/src/eterna/pose2D/PoseUtil.ts index d2a5de853..46fa31526 100644 --- a/src/eterna/pose2D/PoseUtil.ts +++ b/src/eterna/pose2D/PoseUtil.ts @@ -1,5 +1,5 @@ import EPars from "eterna/EPars"; -import {PuzzleEditOp} from "."; +import PuzzleEditOp from "./PuzzleEditOp"; /** Utility functions for pose data */ export default class PoseUtil { diff --git a/src/eterna/puzzle/Puzzle.ts b/src/eterna/puzzle/Puzzle.ts index 6854b20a8..a58bd7312 100644 --- a/src/eterna/puzzle/Puzzle.ts +++ b/src/eterna/puzzle/Puzzle.ts @@ -3,7 +3,7 @@ import EPars from "eterna/EPars"; import {Folder, FolderManager, Vienna} from "eterna/folding"; import {EternaURL} from "eterna/net"; import {Pose2D} from "eterna/pose2D"; -import {ConstraintType} from "."; +import {ConstraintType} from "./Constraints"; export interface BoostersData { mission?: any; diff --git a/src/eterna/puzzle/PuzzleManager.ts b/src/eterna/puzzle/PuzzleManager.ts index 05edfe21b..3c6a23a8a 100644 --- a/src/eterna/puzzle/PuzzleManager.ts +++ b/src/eterna/puzzle/PuzzleManager.ts @@ -2,7 +2,8 @@ import * as log from "loglevel"; import Eterna from "eterna/Eterna"; import {CSVParser} from "eterna/util"; import {Folder, FolderManager} from "../folding"; -import {Puzzle, SolutionManager} from "."; +import Puzzle from "./Puzzle"; +import SolutionManager from "./SolutionManager"; export default class PuzzleManager { public static get instance(): PuzzleManager { diff --git a/src/eterna/puzzle/SolutionManager.ts b/src/eterna/puzzle/SolutionManager.ts index c7f28b9c1..f4ed244eb 100644 --- a/src/eterna/puzzle/SolutionManager.ts +++ b/src/eterna/puzzle/SolutionManager.ts @@ -3,7 +3,7 @@ import EPars from "eterna/EPars"; import Eterna from "eterna/Eterna"; import Feedback from "eterna/Feedback"; import {CSVParser} from "eterna/util"; -import {Solution} from "."; +import Solution from "./Solution"; export default class SolutionManager { public static get instance(): SolutionManager { diff --git a/src/eterna/rank/RankBoard.ts b/src/eterna/rank/RankBoard.ts index 646704837..54f92dee7 100644 --- a/src/eterna/rank/RankBoard.ts +++ b/src/eterna/rank/RankBoard.ts @@ -1,7 +1,8 @@ import {Point} from "pixi.js"; import {Updatable} from "flashbang/core"; import {ContainerObject} from "flashbang/objects"; -import {PlayerRank, RankRowLayout} from "."; +import PlayerRank from "./PlayerRank"; +import RankRowLayout from "./RankRowLayout"; export default class RankBoard extends ContainerObject implements Updatable { public static readonly ROW_WIDTH = 400; diff --git a/src/eterna/rank/RankRowLayout.ts b/src/eterna/rank/RankRowLayout.ts index a908cd0d6..8d530f23f 100644 --- a/src/eterna/rank/RankRowLayout.ts +++ b/src/eterna/rank/RankRowLayout.ts @@ -2,7 +2,7 @@ import {Point, Text} from "pixi.js"; import {ContainerObject} from "flashbang/objects"; import {TextUtil} from "flashbang/util"; import {Fonts} from "eterna/util"; -import {PlayerRank} from "."; +import PlayerRank from "./PlayerRank"; export default class RankRowLayout extends ContainerObject { public constructor(rank: number, data: PlayerRank, rankScoreOffset: number, diff --git a/src/eterna/rank/RankScroll.ts b/src/eterna/rank/RankScroll.ts index 9d93fd0a7..e31b1afff 100644 --- a/src/eterna/rank/RankScroll.ts +++ b/src/eterna/rank/RankScroll.ts @@ -8,7 +8,9 @@ import Eterna from "eterna/Eterna"; import {GamePanel} from "eterna/ui"; import {Fonts} from "eterna/util"; import {VibrateTask} from "eterna/vfx"; -import {PlayerRank, RankBoard, RankRowLayout} from "."; +import PlayerRank from "./PlayerRank"; +import RankBoard from "./RankBoard"; +import RankRowLayout from "./RankRowLayout"; export default class RankScroll extends ContainerObject { public static hasRankScrollData(submissionRsp: any): boolean { diff --git a/src/eterna/resources/BitmapManager.ts b/src/eterna/resources/BitmapManager.ts index 672d9a3e4..55409673e 100644 --- a/src/eterna/resources/BitmapManager.ts +++ b/src/eterna/resources/BitmapManager.ts @@ -1,7 +1,7 @@ import {Texture} from "pixi.js"; import {Assert, TextBuilder, TextureUtil} from "flashbang/util"; import {Fonts} from "eterna/util"; -import {Bitmaps} from "."; +import Bitmaps from "./Bitmaps"; export default class BitmapManager { public static getBitmap(url: string): Texture { diff --git a/src/eterna/rscript/RNAScript.ts b/src/eterna/rscript/RNAScript.ts index 685799c9e..ce2a3a1d8 100644 --- a/src/eterna/rscript/RNAScript.ts +++ b/src/eterna/rscript/RNAScript.ts @@ -1,9 +1,15 @@ import {PoseEditMode} from "eterna/mode"; import {Puzzle} from "eterna/puzzle"; -import { - ROPHighlight, ROPHighlightMode, ROPHint, ROPPre, ROPRNA, ROPRNAType, ROPTextbox, ROPTextboxMode, - ROPUI, ROPWait, ROPWaitType, RScriptEnv, RScriptOp, RScriptOpTree -} from "."; +import ROPHighlight, {ROPHighlightMode} from "./ROPHighlight"; +import ROPHint from "./ROPHint"; +import ROPPre from "./ROPPre"; +import ROPRNA, {ROPRNAType} from "./ROPRNA"; +import ROPTextbox, {ROPTextboxMode} from "./ROPTextbox"; +import ROPUI from "./ROPUI"; +import ROPWait, {ROPWaitType} from "./ROPWait"; +import RScriptEnv from "./RScriptEnv"; +import RScriptOp from "./RScriptOp"; +import RScriptOpTree from "./RScriptOpTree"; export default class RNAScript { public constructor(puz: Puzzle, ui: PoseEditMode) { diff --git a/src/eterna/rscript/ROPHighlight.ts b/src/eterna/rscript/ROPHighlight.ts index 1f60dc97d..279e0dc2a 100644 --- a/src/eterna/rscript/ROPHighlight.ts +++ b/src/eterna/rscript/ROPHighlight.ts @@ -6,9 +6,9 @@ import {AlphaTask, RepeatingTask, SerialTask} from "flashbang/tasks"; import {ColorUtil, Easing} from "flashbang/util"; import {RNAHighlightState} from "eterna/pose2D"; import {ConstraintBox, EternaMenu} from "eterna/ui"; -import { - RScriptEnv, RScriptOp, GetRScriptUIElementBounds, RScriptUIElement, RScriptUIElementID -} from "."; +import RScriptEnv from "./RScriptEnv"; +import RScriptOp from "./RScriptOp"; +import {RScriptUIElement, GetRScriptUIElementBounds, RScriptUIElementID} from "./RScriptUIElement" export enum ROPHighlightMode { RNA = "RNA", diff --git a/src/eterna/rscript/ROPHint.ts b/src/eterna/rscript/ROPHint.ts index ab4ee79a3..4d92a1bca 100644 --- a/src/eterna/rscript/ROPHint.ts +++ b/src/eterna/rscript/ROPHint.ts @@ -1,5 +1,7 @@ import {Point} from "pixi.js"; -import {NovaPaintHint, RScriptEnv, RScriptOp} from "."; +import NovaPaintHint from "./NovaPaintHint"; +import RScriptEnv from "./RScriptEnv"; +import RScriptOp from "./RScriptOp"; export default class ROPHint extends RScriptOp { public constructor(isVisible: boolean, env: RScriptEnv) { diff --git a/src/eterna/rscript/ROPPre.ts b/src/eterna/rscript/ROPPre.ts index fca2a81cf..f76f71167 100644 --- a/src/eterna/rscript/ROPPre.ts +++ b/src/eterna/rscript/ROPPre.ts @@ -1,5 +1,6 @@ import {PoseState} from "eterna/puzzle"; -import {RScriptEnv, RScriptOp} from "."; +import RScriptEnv from "./RScriptEnv"; +import RScriptOp from "./RScriptOp"; export default class ROPPre extends RScriptOp { constructor(command: string, env: RScriptEnv) { diff --git a/src/eterna/rscript/ROPRNA.ts b/src/eterna/rscript/ROPRNA.ts index b4169aabd..45ca5f793 100644 --- a/src/eterna/rscript/ROPRNA.ts +++ b/src/eterna/rscript/ROPRNA.ts @@ -1,6 +1,7 @@ import {MathUtil} from "flashbang/util"; import {StringToPaletteTargetType} from "eterna/ui"; -import {RScriptEnv, RScriptOp} from "."; +import RScriptEnv from "./RScriptEnv"; +import RScriptOp from "./RScriptOp"; export enum ROPRNAType { SETBASE = "SETBASE", diff --git a/src/eterna/rscript/ROPTextbox.ts b/src/eterna/rscript/ROPTextbox.ts index 9293bbb32..165262166 100644 --- a/src/eterna/rscript/ROPTextbox.ts +++ b/src/eterna/rscript/ROPTextbox.ts @@ -7,9 +7,10 @@ import {ColorUtil, StyledTextBuilder} from "flashbang/util"; import {RNAAnchorObject} from "eterna/pose2D"; import {FancyTextBalloon} from "eterna/ui"; import {Fonts} from "eterna/util"; -import { - ROPWait, RScriptArrow, RScriptEnv, RScriptOp -} from "."; +import ROPWait from "./ROPWait"; +import RScriptArrow from "./RScriptArrow"; +import RScriptEnv from "./RScriptEnv"; +import RScriptOp from "./RScriptOp"; export enum ROPTextboxMode { TEXTBOX_LOCATION = "TEXTBOX_LOCATION", diff --git a/src/eterna/rscript/ROPUI.ts b/src/eterna/rscript/ROPUI.ts index 80c9c4abc..48275a3f9 100644 --- a/src/eterna/rscript/ROPUI.ts +++ b/src/eterna/rscript/ROPUI.ts @@ -1,4 +1,5 @@ -import {RScriptOp, RScriptEnv} from "."; +import RScriptEnv from "./RScriptEnv"; +import RScriptOp from "./RScriptOp"; export default class ROPUI extends RScriptOp { constructor(env: RScriptEnv, isVisible: boolean, isDisabled: boolean) { diff --git a/src/eterna/rscript/ROPWait.ts b/src/eterna/rscript/ROPWait.ts index e465945d8..ab79c99d1 100644 --- a/src/eterna/rscript/ROPWait.ts +++ b/src/eterna/rscript/ROPWait.ts @@ -1,6 +1,7 @@ -import { - ROPTextbox, RScriptEnv, RScriptOp, RScriptUIElementID -} from "."; +import ROPTextbox from "./ROPTextbox"; +import RScriptEnv from "./RScriptEnv"; +import RScriptOp from "./RScriptOp"; +import {RScriptUIElementID} from "./RScriptUIElement"; export enum ROPWaitType { MOVECAMERA = "MOVECAMERA", diff --git a/src/eterna/rscript/RScriptEnv.ts b/src/eterna/rscript/RScriptEnv.ts index 925ec0002..ddb1e561b 100644 --- a/src/eterna/rscript/RScriptEnv.ts +++ b/src/eterna/rscript/RScriptEnv.ts @@ -7,7 +7,7 @@ import {PoseEditMode} from "eterna/mode"; import {Pose2D, RNAHighlightState} from "eterna/pose2D"; import {Puzzle} from "eterna/puzzle"; import {PaletteTargetType, TextBalloon, ToggleBar} from "eterna/ui"; -import {RScriptUIElement, RScriptUIElementID} from "."; +import {RScriptUIElement, RScriptUIElementID} from "./RScriptUIElement"; /** * RScript Environment. diff --git a/src/eterna/rscript/RScriptOp.ts b/src/eterna/rscript/RScriptOp.ts index 263d461ed..7e5178bc9 100644 --- a/src/eterna/rscript/RScriptOp.ts +++ b/src/eterna/rscript/RScriptOp.ts @@ -1,4 +1,4 @@ -import {RScriptEnv} from "."; +import RScriptEnv from "./RScriptEnv"; /** * RScript Operation. diff --git a/src/eterna/rscript/RScriptOpTree.ts b/src/eterna/rscript/RScriptOpTree.ts index 7e8c8b38a..b5c3af0ec 100644 --- a/src/eterna/rscript/RScriptOpTree.ts +++ b/src/eterna/rscript/RScriptOpTree.ts @@ -1,4 +1,5 @@ -import {ROPWait, RScriptOp} from "."; +import ROPWait from "./ROPWait"; +import RScriptOp from "./RScriptOp"; /* * RScript Operation Tree. diff --git a/src/eterna/ui/AsyncProcessDialog.ts b/src/eterna/ui/AsyncProcessDialog.ts index 469067c80..331391bd1 100644 --- a/src/eterna/ui/AsyncProcessDialog.ts +++ b/src/eterna/ui/AsyncProcessDialog.ts @@ -3,7 +3,7 @@ import {Flashbang} from "flashbang/core"; import {AlphaTask, RepeatingTask, SerialTask} from "flashbang/tasks"; import {Easing} from "flashbang/util"; import {Fonts} from "eterna/util"; -import {Dialog} from "."; +import Dialog from "./Dialog"; /** Dims the screen and shows a notification text that fades in and out */ export default class AsyncProcessDialog extends Dialog { diff --git a/src/eterna/ui/ConfirmDialog.ts b/src/eterna/ui/ConfirmDialog.ts index 7218a0fae..f291d0d0b 100644 --- a/src/eterna/ui/ConfirmDialog.ts +++ b/src/eterna/ui/ConfirmDialog.ts @@ -3,9 +3,10 @@ import {Flashbang, HAlign} from "flashbang/core"; import {HLayoutContainer, VLayoutContainer} from "flashbang/layout"; import {AlphaTask} from "flashbang/tasks"; import {Fonts} from "eterna/util"; -import { - Dialog, DialogCanceledError, GameButton, GamePanel, GamePanelType, HTMLTextObject -} from "."; +import Dialog, {DialogCanceledError} from "./Dialog"; +import GameButton from "./GameButton"; +import GamePanel, {GamePanelType} from "./GamePanel"; +import HTMLTextObject from "./HTMLTextObject"; export default class ConfirmDialog extends Dialog { public constructor(prompt: string, promptIsHTML: boolean = false) { diff --git a/src/eterna/ui/ConstraintBox.ts b/src/eterna/ui/ConstraintBox.ts index 7480f3da6..cb53f15e4 100644 --- a/src/eterna/ui/ConstraintBox.ts +++ b/src/eterna/ui/ConstraintBox.ts @@ -15,9 +15,9 @@ import EPars from "eterna/EPars"; import {ConstraintType} from "eterna/puzzle"; import {BitmapManager, Bitmaps} from "eterna/resources"; import {Fonts} from "eterna/util"; -import { - Band, PoseThumbnail, PoseThumbnailType, TextBalloon -} from "."; +import Band from "./Band"; +import PoseThumbnail, {PoseThumbnailType} from "./PoseThumbnail"; +import TextBalloon from "./TextBalloon"; export enum ConstraintBoxType { DEFAULT = "DEFAULT", diff --git a/src/eterna/ui/ContextMenu.ts b/src/eterna/ui/ContextMenu.ts index b361466bd..f96194fe7 100644 --- a/src/eterna/ui/ContextMenu.ts +++ b/src/eterna/ui/ContextMenu.ts @@ -2,7 +2,8 @@ import {HAlign} from "flashbang/core"; import {VLayoutContainer} from "flashbang/layout"; import {ContainerObject} from "flashbang/objects"; import {UnitSignal} from "signals"; -import {GameButton, GamePanel, GamePanelType} from "."; +import GameButton from "./GameButton"; +import GamePanel, {GamePanelType} from "./GamePanel"; export default class ContextMenu extends ContainerObject { /** Emitted when the user interacts with the menu. */ diff --git a/src/eterna/ui/EternaMenu.ts b/src/eterna/ui/EternaMenu.ts index 39d2cdfa5..d9bbdb627 100644 --- a/src/eterna/ui/EternaMenu.ts +++ b/src/eterna/ui/EternaMenu.ts @@ -2,7 +2,8 @@ import {Point} from "pixi.js"; import {PointerCapture} from "flashbang/input"; import {Enableable} from "flashbang/objects"; import {DisplayUtil} from "flashbang/util"; -import {GameButton, GamePanel, GamePanelType} from "."; +import GameButton from "./GameButton"; +import GamePanel, {GamePanelType} from "./GamePanel"; export enum EternaMenuStyle { DEFAULT = 0, PULLUP diff --git a/src/eterna/ui/EternaViewOptionsDialog.ts b/src/eterna/ui/EternaViewOptionsDialog.ts index 191d5e345..b45abeadf 100644 --- a/src/eterna/ui/EternaViewOptionsDialog.ts +++ b/src/eterna/ui/EternaViewOptionsDialog.ts @@ -5,9 +5,10 @@ import {Setting} from "flashbang/settings"; import {DisplayUtil} from "flashbang/util"; import Eterna from "eterna/Eterna"; import {Bitmaps} from "eterna/resources"; -import { - Dialog, GameButton, GameCheckbox, GamePanel, GamePanelType -} from "."; +import Dialog from "./Dialog"; +import GameButton from "./GameButton"; +import GameCheckbox from "./GameCheckbox"; +import GamePanel, {GamePanelType} from "./GamePanel"; export enum EternaViewOptionsMode { PUZZLE = 0, PUZZLEMAKER, LAB diff --git a/src/eterna/ui/FancyGamePanel.ts b/src/eterna/ui/FancyGamePanel.ts index fea54c1a8..1ad60d004 100644 --- a/src/eterna/ui/FancyGamePanel.ts +++ b/src/eterna/ui/FancyGamePanel.ts @@ -1,6 +1,6 @@ import {Graphics, Point, Text} from "pixi.js"; import {Fonts} from "eterna/util"; -import {BaseGamePanel} from "."; +import BaseGamePanel from "./BaseGamePanel"; export enum FancyGamePanelType { NORMAL, INVISIBLE, NEW_NOVA diff --git a/src/eterna/ui/FancyTextBalloon.ts b/src/eterna/ui/FancyTextBalloon.ts index ecb86eaa4..2b216dc35 100644 --- a/src/eterna/ui/FancyTextBalloon.ts +++ b/src/eterna/ui/FancyTextBalloon.ts @@ -4,7 +4,9 @@ import {Vector2} from "flashbang/geom"; import {DisplayUtil} from "flashbang/util"; import {Bitmaps} from "eterna/resources"; import {RScriptArrow} from "eterna/rscript"; -import {FancyGamePanel, GameButton, TextBalloon} from "."; +import FancyGamePanel from "./FancyGamePanel"; +import GameButton from "./GameButton"; +import TextBalloon from "./TextBalloon"; export default class FancyTextBalloon extends TextBalloon implements Updatable { public constructor(balloonColor: number = 0xFFFFFF, balloonAlpha: number = 0.07, diff --git a/src/eterna/ui/GameButton.ts b/src/eterna/ui/GameButton.ts index a2606722f..7c7ae3c91 100644 --- a/src/eterna/ui/GameButton.ts +++ b/src/eterna/ui/GameButton.ts @@ -8,10 +8,10 @@ import {DisplayUtil, TextBuilder} from "flashbang/util"; import {Registration, Registrations, Value} from "signals"; import {ROPWait, RScriptUIElementID} from "eterna/rscript"; import {Fonts} from "eterna/util"; -import {Tooltips} from "."; +import Tooltips from "./Tooltips"; export default class GameButton extends Button implements KeyboardListener { - public readonly toggled: Value = new Value(false); + public readonly toggled: Value = new Value(false); public constructor() { super(); diff --git a/src/eterna/ui/GamePanel.ts b/src/eterna/ui/GamePanel.ts index dc6b67cdd..4ffa6f785 100644 --- a/src/eterna/ui/GamePanel.ts +++ b/src/eterna/ui/GamePanel.ts @@ -2,7 +2,7 @@ import { Graphics, Point, Text, Rectangle } from "pixi.js"; import {Fonts} from "eterna/util"; -import {BaseGamePanel} from "."; +import BaseGamePanel from "./BaseGamePanel"; export enum GamePanelType { NORMAL, INVISIBLE diff --git a/src/eterna/ui/NotificationDialog.ts b/src/eterna/ui/NotificationDialog.ts index dd70e6f72..99a7ba3d8 100644 --- a/src/eterna/ui/NotificationDialog.ts +++ b/src/eterna/ui/NotificationDialog.ts @@ -1,7 +1,9 @@ import {Point} from "pixi.js"; import {Flashbang} from "flashbang/core"; import {HLayoutContainer} from "flashbang/layout"; -import {Dialog, GameButton, TextBalloon} from "."; +import Dialog from "./Dialog"; +import GameButton from "./GameButton"; +import TextBalloon from "./TextBalloon"; export default class NotificationDialog extends Dialog { /** Non-null if extraButtonTitle is specified */ diff --git a/src/eterna/ui/NucleotidePalette.ts b/src/eterna/ui/NucleotidePalette.ts index 8d2af7fea..66b5f7d0a 100644 --- a/src/eterna/ui/NucleotidePalette.ts +++ b/src/eterna/ui/NucleotidePalette.ts @@ -11,7 +11,7 @@ import EPars from "eterna/EPars"; import {BitmapManager, Bitmaps} from "eterna/resources"; import {ROPWait, RScriptUIElementID} from "eterna/rscript"; import {Fonts} from "eterna/util"; -import {Tooltips} from "."; +import Tooltips from "./Tooltips"; type InteractionEvent = PIXI.interaction.InteractionEvent; diff --git a/src/eterna/ui/PasteSequenceDialog.ts b/src/eterna/ui/PasteSequenceDialog.ts index e5e710a8a..af1e39606 100644 --- a/src/eterna/ui/PasteSequenceDialog.ts +++ b/src/eterna/ui/PasteSequenceDialog.ts @@ -1,7 +1,8 @@ import {Flashbang} from "flashbang/core"; import {KeyCode} from "flashbang/input"; import {GameMode} from "eterna/mode"; -import {Dialog, TextInputPanel} from "."; +import Dialog from "./Dialog"; +import TextInputPanel from "./TextInputPanel"; /** * Prompts the user to paste a sequence. diff --git a/src/eterna/ui/SliderBar.ts b/src/eterna/ui/SliderBar.ts index 7e3d04432..b0aca7304 100644 --- a/src/eterna/ui/SliderBar.ts +++ b/src/eterna/ui/SliderBar.ts @@ -1,8 +1,7 @@ import {Graphics, Point} from "pixi.js"; import {Flashbang, GameObjectRef} from "flashbang/core"; import {DisplayObjectPointerTarget} from "flashbang/input"; -import {ContainerObject} from "flashbang/objects"; -import {Dragger} from "flashbang/util"; +import {ContainerObject, Dragger} from "flashbang/objects"; import {Signal} from "signals"; export default class SliderBar extends ContainerObject { diff --git a/src/eterna/ui/SpecBox.ts b/src/eterna/ui/SpecBox.ts index de8fb4d77..164aa9612 100644 --- a/src/eterna/ui/SpecBox.ts +++ b/src/eterna/ui/SpecBox.ts @@ -14,9 +14,10 @@ import {EternaURL} from "eterna/net"; import {Bitmaps} from "eterna/resources"; import {default as UndoBlock, UndoBlockParam} from "eterna/UndoBlock"; import {Fonts} from "eterna/util"; -import { - GameButton, GamePanel, HTMLTextObject, TextBalloon -} from "."; +import GameButton from "./GameButton"; +import GamePanel from "./GamePanel"; +import HTMLTextObject from "./HTMLTextObject"; +import TextBalloon from "./TextBalloon"; type InteractionEvent = PIXI.interaction.InteractionEvent; diff --git a/src/eterna/ui/SpecBoxDialog.ts b/src/eterna/ui/SpecBoxDialog.ts index 4e83c5310..b65eb47b5 100644 --- a/src/eterna/ui/SpecBoxDialog.ts +++ b/src/eterna/ui/SpecBoxDialog.ts @@ -3,7 +3,9 @@ import {Flashbang, HAlign, VAlign} from "flashbang/core"; import {KeyCode} from "flashbang/input"; import {DisplayUtil} from "flashbang/util"; import UndoBlock from "eterna/UndoBlock"; -import {Dialog, GameButton, SpecBox} from "."; +import Dialog from "./Dialog"; +import GameButton from "./GameButton"; +import SpecBox from "./SpecBox"; /** * Displays a SpecBox in a modal dialog. diff --git a/src/eterna/ui/TextBalloon.ts b/src/eterna/ui/TextBalloon.ts index edf88aabf..ba9727adb 100644 --- a/src/eterna/ui/TextBalloon.ts +++ b/src/eterna/ui/TextBalloon.ts @@ -3,9 +3,9 @@ import {Point, Text} from "pixi.js"; import {ContainerObject} from "flashbang/objects"; import {DisplayUtil, StyledTextBuilder} from "flashbang/util"; import {Fonts} from "eterna/util"; -import { - BaseGamePanel, GameButton, GamePanel, GamePanelType -} from "."; +import BaseGamePanel from "./BaseGamePanel"; +import GameButton from "./GameButton"; +import GamePanel, {GamePanelType} from "./GamePanel"; export default class TextBalloon extends ContainerObject { public constructor(text: string = "", balloonColor: number = 0xFFFFFF, balloonAlpha: number = 0.07, borderColor: number = 0, borderAlpha: number = 0) { diff --git a/src/eterna/ui/TextInputPanel.ts b/src/eterna/ui/TextInputPanel.ts index cfb358bbb..958850ca3 100644 --- a/src/eterna/ui/TextInputPanel.ts +++ b/src/eterna/ui/TextInputPanel.ts @@ -2,7 +2,9 @@ import {Point, Text} from "pixi.js"; import {Signal, UnitSignal} from "signals"; import {Fonts} from "eterna/util"; -import {GameButton, GamePanel, TextInputObject} from "."; +import GameButton from "./GameButton"; +import GamePanel from "./GamePanel"; +import TextInputObject from "./TextInputObject" export default class TextInputPanel extends GamePanel { public readonly cancelClicked: UnitSignal = new UnitSignal(); diff --git a/src/eterna/ui/Toolbar.ts b/src/eterna/ui/Toolbar.ts index b3cc70730..e1e4d976e 100644 --- a/src/eterna/ui/Toolbar.ts +++ b/src/eterna/ui/Toolbar.ts @@ -7,13 +7,16 @@ import {ContainerObject} from "flashbang/objects"; import {LocationTask} from "flashbang/tasks"; import {Easing, DisplayUtil} from "flashbang/util"; import Eterna from "eterna/Eterna"; -import {Booster, PoseEditMode} from "eterna/mode/PoseEdit"; +// Stupid cyclic dependancy - TODO: Fix later once this can get refactored +import Booster from "eterna/mode/PoseEdit/Booster"; +import PoseEditMode from "eterna/mode/PoseEdit/PoseEditMode"; import {Bitmaps} from "eterna/resources"; import {RScriptUIElementID} from "eterna/rscript"; import {BoostersData} from "eterna/puzzle"; -import { - NucleotidePalette, GameButton, ToggleBar, EternaMenu, EternaMenuStyle -} from "."; +import NucleotidePalette from "./NucleotidePalette"; +import GameButton from "./GameButton"; +import ToggleBar from "./ToggleBar"; +import EternaMenu, {EternaMenuStyle} from "./EternaMenu"; export enum ToolbarType { PUZZLE, diff --git a/src/eterna/ui/UILockDialog.ts b/src/eterna/ui/UILockDialog.ts index 0693d7ad9..2882423bb 100644 --- a/src/eterna/ui/UILockDialog.ts +++ b/src/eterna/ui/UILockDialog.ts @@ -1,6 +1,6 @@ import * as log from "loglevel"; import {AlphaTask} from "flashbang/tasks"; -import {Dialog} from "."; +import Dialog from "./Dialog"; /** A "dialog" that simply dims the screen and eats UI events */ export default class UILockDialog extends Dialog { diff --git a/src/eterna/ui/URLButton.ts b/src/eterna/ui/URLButton.ts index b0de23ea3..31e4cc1b7 100644 --- a/src/eterna/ui/URLButton.ts +++ b/src/eterna/ui/URLButton.ts @@ -1,5 +1,5 @@ import {Graphics} from "pixi.js"; -import {HTMLTextObject} from "."; +import HTMLTextObject from "./HTMLTextObject"; /** A DOM-based underlined text link with some background styling. */ export default class URLButton extends HTMLTextObject { diff --git a/src/eterna/ui/VScrollBox.ts b/src/eterna/ui/VScrollBox.ts index d336bfb74..db4772b9a 100644 --- a/src/eterna/ui/VScrollBox.ts +++ b/src/eterna/ui/VScrollBox.ts @@ -1,7 +1,8 @@ import {Container} from "pixi.js"; import {SceneObject} from "flashbang/objects"; import {MathUtil} from "flashbang/util"; -import {ScrollContainer, SliderBar} from "."; +import ScrollContainer from "./ScrollContainer"; +import SliderBar from "./SliderBar"; /** Contains scrollable content and a vertical sliderbar */ export default class VScrollBox extends SceneObject { diff --git a/src/eterna/ui/index.ts b/src/eterna/ui/index.ts index 7f69b192f..0db2c5dde 100644 --- a/src/eterna/ui/index.ts +++ b/src/eterna/ui/index.ts @@ -1,8 +1,8 @@ +export {default as BaseGamePanel} from "./BaseGamePanel"; +export {default as GamePanel, GamePanelType} from "./GamePanel"; export {default as ActionBar} from "./ActionBar"; export {default as Dialog, DialogCanceledError} from "./Dialog"; export {default as TextBalloon} from "./TextBalloon"; -export {default as BaseGamePanel} from "./BaseGamePanel"; -export {default as GamePanel, GamePanelType} from "./GamePanel"; export {default as AsyncProcessDialog} from "./AsyncProcessDialog"; export {default as Band} from "./Band"; export {default as ConfirmDialog} from "./ConfirmDialog"; @@ -28,10 +28,9 @@ export {default as SpecBox} from "./SpecBox"; export {default as SpecBoxDialog} from "./SpecBoxDialog"; export {default as TextInputObject} from "./TextInputObject"; export {default as TextInputPanel} from "./TextInputPanel"; -// TODO: Weird circular dependancy issue. Once importing from eterna/mode/PoseEdit is gone, we can bring this back -// export {default as Toolbar} from "./Toolbar"; export {default as ToggleBar} from "./ToggleBar"; export {default as Tooltips, Tooltip} from "./Tooltips"; export {default as UILockDialog} from "./UILockDialog"; export {default as URLButton} from "./URLButton"; export {default as VScrollBox} from "./VScrollBox"; +export {default as Toolbar, ToolbarType} from "./Toolbar"; diff --git a/src/eterna/vfx/Background.ts b/src/eterna/vfx/Background.ts index 8aa7a9fcb..dafc1ac3c 100644 --- a/src/eterna/vfx/Background.ts +++ b/src/eterna/vfx/Background.ts @@ -1,6 +1,6 @@ import {ContainerObject} from "flashbang/objects"; import Eterna from "eterna/Eterna"; -import {Bubble} from "."; +import Bubble from "./Bubble"; export default class Background extends ContainerObject { constructor(bubbleCount: number = 20, foreground: boolean = false) { diff --git a/src/eterna/vfx/BubbleSweep.ts b/src/eterna/vfx/BubbleSweep.ts index 7c442157c..e0e35c29d 100644 --- a/src/eterna/vfx/BubbleSweep.ts +++ b/src/eterna/vfx/BubbleSweep.ts @@ -1,5 +1,5 @@ import {ContainerObject} from "flashbang/objects"; -import {Bubble} from "."; +import Bubble from "./Bubble"; export default class BubbleSweep extends ContainerObject { public constructor(numBubbles: number) { diff --git a/src/flashbang/core/AppMode.ts b/src/flashbang/core/AppMode.ts index e337723af..60486c4f5 100644 --- a/src/flashbang/core/AppMode.ts +++ b/src/flashbang/core/AppMode.ts @@ -4,9 +4,12 @@ import { } from "signals"; import {KeyboardInput, MouseWheelInput} from "../input"; import {Assert} from "../util"; -import { - GameObject, GameObjectBase, GameObjectRef, LateUpdatable, ModeStack, Updatable -} from "."; +import GameObject from "./GameObject"; +import GameObjectBase from "./GameObjectBase"; +import GameObjectRef from "./GameObjectRef"; +import LateUpdatable from "./LateUpdatable"; +import ModeStack from "./ModeStack"; +import Updatable from "./Updatable"; export default class AppMode { /** Default keyboard input processor */ diff --git a/src/flashbang/core/Flashbang.ts b/src/flashbang/core/Flashbang.ts index eedc9e9c2..d55c476a9 100644 --- a/src/flashbang/core/Flashbang.ts +++ b/src/flashbang/core/Flashbang.ts @@ -1,7 +1,8 @@ import * as PIXI from "pixi.js"; import {Point} from "pixi.js"; import {Assert} from "../util"; -import {FlashbangApp, AppMode} from "."; +import FlashbangApp from "./FlashbangApp"; +import AppMode from "./AppMode"; type InteractionManager = PIXI.interaction.InteractionManager; diff --git a/src/flashbang/core/FlashbangApp.ts b/src/flashbang/core/FlashbangApp.ts index d94efd1f2..21b0c1025 100644 --- a/src/flashbang/core/FlashbangApp.ts +++ b/src/flashbang/core/FlashbangApp.ts @@ -1,14 +1,16 @@ import * as log from "loglevel"; import {RegistrationGroup, Value} from "signals"; import {KeyboardEventType, KeyCode} from "../input"; -import {Flashbang, ModeStack, Updatable} from "."; +import Flashbang from "./Flashbang"; +import ModeStack from "./ModeStack"; +import Updatable from "./Updatable"; // Adds KeyboardEvent.code support to Edge import "js-polyfills/keyboard"; export default class FlashbangApp { /** True if the app is foregrounded */ - public readonly isActive: Value = new Value(true); + public readonly isActive: Value = new Value(true); public get pixi(): PIXI.Application { return this._pixi; diff --git a/src/flashbang/core/GameObject.ts b/src/flashbang/core/GameObject.ts index 8fc14d9f3..319c0309e 100644 --- a/src/flashbang/core/GameObject.ts +++ b/src/flashbang/core/GameObject.ts @@ -1,8 +1,8 @@ import * as log from "loglevel"; import {Container, DisplayObject} from "pixi.js"; -// Full path, not module path, has to be used here to prevent cyclic dependency/module load order issue import Assert from "../util/Assert"; -import {GameObjectBase, GameObjectRef} from "."; +import GameObjectBase from "./GameObjectBase"; +import GameObjectRef from "./GameObjectRef"; export default class GameObject extends GameObjectBase { /** The DisplayObject that this GameObject manages, if any */ diff --git a/src/flashbang/core/GameObjectBase.ts b/src/flashbang/core/GameObjectBase.ts index 98a8b805c..ef53b7268 100644 --- a/src/flashbang/core/GameObjectBase.ts +++ b/src/flashbang/core/GameObjectBase.ts @@ -1,8 +1,9 @@ import {Container} from "pixi.js"; import {RegistrationGroup, UnitSignal} from "signals"; -import { - AppMode, ModeStack, GameObject, GameObjectRef -} from "."; +import AppMode from "./AppMode"; +import ModeStack from "./ModeStack"; +import GameObject from "./GameObject"; +import GameObjectRef from "./GameObjectRef"; export default class GameObjectBase { public get destroyed(): UnitSignal { diff --git a/src/flashbang/core/GameObjectRef.ts b/src/flashbang/core/GameObjectRef.ts index 806158d18..78e215872 100644 --- a/src/flashbang/core/GameObjectRef.ts +++ b/src/flashbang/core/GameObjectRef.ts @@ -1,4 +1,5 @@ -import {GameObject, GameObjectBase} from "."; +import GameObject from "./GameObject"; +import GameObjectBase from "./GameObjectBase"; export default class GameObjectRef { public static readonly NULL: GameObjectRef = new GameObjectRef(); diff --git a/src/flashbang/core/ModeStack.ts b/src/flashbang/core/ModeStack.ts index be38a962d..0945d2c4d 100644 --- a/src/flashbang/core/ModeStack.ts +++ b/src/flashbang/core/ModeStack.ts @@ -1,7 +1,7 @@ import {Container} from "pixi.js"; import {UnitSignal} from "signals"; import {Assert, MathUtil} from "../util"; -import {AppMode} from "."; +import AppMode from "./AppMode"; /** * A stack of AppModes. Only the top-most mode in the stack gets updates diff --git a/src/flashbang/core/ObjectTask.ts b/src/flashbang/core/ObjectTask.ts index ac146f9c6..6a45e819a 100644 --- a/src/flashbang/core/ObjectTask.ts +++ b/src/flashbang/core/ObjectTask.ts @@ -1,5 +1,5 @@ import {Container} from "pixi.js"; -import {GameObjectBase} from "."; +import GameObjectBase from "./GameObjectBase"; export default class ObjectTask extends GameObjectBase { /* internal */ diff --git a/src/flashbang/core/index.ts b/src/flashbang/core/index.ts index 6266d4ead..6a8290e4a 100644 --- a/src/flashbang/core/index.ts +++ b/src/flashbang/core/index.ts @@ -8,4 +8,4 @@ export {default as GameObjectRef} from "./GameObjectRef"; export {default as LateUpdatable} from "./LateUpdatable"; export {default as ModeStack} from "./ModeStack"; export {default as ObjectTask} from "./ObjectTask"; -export {default as Updatable} from "./Updatable"; +export {default as Updatable} from "./Updatable"; \ No newline at end of file diff --git a/src/flashbang/input/DisplayObjectPointerTarget.ts b/src/flashbang/input/DisplayObjectPointerTarget.ts index 5c1cdb268..70f7c3e24 100644 --- a/src/flashbang/input/DisplayObjectPointerTarget.ts +++ b/src/flashbang/input/DisplayObjectPointerTarget.ts @@ -1,7 +1,7 @@ import {DisplayObject} from "pixi.js"; import {SignalView} from "signals"; import {EventSignal} from "../util"; -import {PointerTarget} from "."; +import PointerTarget from "./PointerTarget"; type InteractionEvent = PIXI.interaction.InteractionEvent; diff --git a/src/flashbang/layout/HLayoutContainer.ts b/src/flashbang/layout/HLayoutContainer.ts index 01ce42004..d2b239650 100644 --- a/src/flashbang/layout/HLayoutContainer.ts +++ b/src/flashbang/layout/HLayoutContainer.ts @@ -1,7 +1,7 @@ import {Rectangle} from "pixi.js"; import {VAlign} from "../core"; import {DisplayUtil} from "../util"; -import {LayoutContainer} from "."; +import LayoutContainer from "./LayoutContainer"; /** * A Container that arranges its children horizontally. diff --git a/src/flashbang/layout/VLayoutContainer.ts b/src/flashbang/layout/VLayoutContainer.ts index 238c70e6b..2e2645264 100644 --- a/src/flashbang/layout/VLayoutContainer.ts +++ b/src/flashbang/layout/VLayoutContainer.ts @@ -1,7 +1,7 @@ import {Rectangle} from "pixi.js"; import {HAlign} from "../core"; import {DisplayUtil} from "../util"; -import {LayoutContainer} from "."; +import LayoutContainer from "./LayoutContainer"; /** * A Container that arranges its children vertically. diff --git a/src/flashbang/objects/Button.ts b/src/flashbang/objects/Button.ts index c002e6eef..c8191ef8f 100644 --- a/src/flashbang/objects/Button.ts +++ b/src/flashbang/objects/Button.ts @@ -5,7 +5,8 @@ import {UnitSignal} from "signals"; import {InputUtil, PointerCapture} from "../input"; import {CallbackTask, DelayTask, SerialTask} from "../tasks"; import {DisplayUtil} from "../util"; -import {ContainerObject, Enableable} from "."; +import ContainerObject from "./ContainerObject"; +import Enableable from "./Enableable"; type InteractionEvent = PIXI.interaction.InteractionEvent; diff --git a/src/flashbang/objects/ContainerObject.ts b/src/flashbang/objects/ContainerObject.ts index 9a2dfbf86..4bf919ce9 100644 --- a/src/flashbang/objects/ContainerObject.ts +++ b/src/flashbang/objects/ContainerObject.ts @@ -1,5 +1,5 @@ import {Container} from "pixi.js"; -import {SceneObject} from "."; +import SceneObject from "./SceneObject"; /** A GameObject that manages a PIXI Container */ export default class ContainerObject extends SceneObject { diff --git a/src/flashbang/util/Dragger.ts b/src/flashbang/objects/Dragger.ts similarity index 100% rename from src/flashbang/util/Dragger.ts rename to src/flashbang/objects/Dragger.ts diff --git a/src/flashbang/objects/ImageButton.ts b/src/flashbang/objects/ImageButton.ts index 652458bd1..023069034 100644 --- a/src/flashbang/objects/ImageButton.ts +++ b/src/flashbang/objects/ImageButton.ts @@ -1,5 +1,5 @@ import {Texture, Sprite} from "pixi.js"; -import {Button, ButtonState} from "."; +import Button, {ButtonState} from "./Button"; export default class ImageButton extends Button { public constructor(textures: Texture[]) { diff --git a/src/flashbang/objects/SimpleTextButton.ts b/src/flashbang/objects/SimpleTextButton.ts index a4f4df00b..5f4946e4a 100644 --- a/src/flashbang/objects/SimpleTextButton.ts +++ b/src/flashbang/objects/SimpleTextButton.ts @@ -1,6 +1,6 @@ import {Graphics, Text} from "pixi.js"; import {TextBuilder} from "../util"; -import {Button, ButtonState} from "."; +import Button, {ButtonState} from "./Button"; /** A deliberately unstylish button that displays text on a rectangle. (For debugging.) */ export default class SimpleTextButton extends Button { diff --git a/src/flashbang/objects/SpriteObject.ts b/src/flashbang/objects/SpriteObject.ts index 463f49c5d..bb507bdb3 100644 --- a/src/flashbang/objects/SpriteObject.ts +++ b/src/flashbang/objects/SpriteObject.ts @@ -1,5 +1,5 @@ import {Sprite} from "pixi.js"; -import {SceneObject} from "."; +import SceneObject from "./SceneObject"; /** A GameObject that manages a PIXI Sprite */ export default class SpriteObject extends SceneObject { diff --git a/src/flashbang/objects/ToggleButton.ts b/src/flashbang/objects/ToggleButton.ts index 52bd0626e..b155075f2 100644 --- a/src/flashbang/objects/ToggleButton.ts +++ b/src/flashbang/objects/ToggleButton.ts @@ -1,5 +1,5 @@ import {Value} from "signals"; -import {Button} from "."; +import Button from "./Button"; /** A two-state Button whose value is toggled on click (e.g. a checkbox). */ export default abstract class ToggleButton extends Button { diff --git a/src/flashbang/objects/index.ts b/src/flashbang/objects/index.ts index 674653941..4674efe61 100644 --- a/src/flashbang/objects/index.ts +++ b/src/flashbang/objects/index.ts @@ -7,3 +7,4 @@ export {default as ImageButton} from "./ImageButton"; export {default as SimpleTextButton} from "./SimpleTextButton"; export {default as SpriteObject} from "./SpriteObject"; export {default as ToggleButton} from "./ToggleButton"; +export {default as Dragger} from "./Dragger"; \ No newline at end of file diff --git a/src/flashbang/settings/Settings.ts b/src/flashbang/settings/Settings.ts index 140ed7775..05f808450 100644 --- a/src/flashbang/settings/Settings.ts +++ b/src/flashbang/settings/Settings.ts @@ -1,5 +1,5 @@ import * as storejs from "store"; -import {Setting} from "."; +import Setting from "./Setting"; export default abstract class Settings { protected constructor(namespace: string) { diff --git a/src/flashbang/tasks/AlphaTask.ts b/src/flashbang/tasks/AlphaTask.ts index 7c9e4f40c..f9dc5e756 100644 --- a/src/flashbang/tasks/AlphaTask.ts +++ b/src/flashbang/tasks/AlphaTask.ts @@ -1,6 +1,6 @@ import {DisplayObject} from "pixi.js"; import {EasingFunc} from "../util"; -import {DisplayObjectTask} from "."; +import DisplayObjectTask from "./DisplayObjectTask"; export default class AlphaTask extends DisplayObjectTask { constructor(alpha: number, time: number = 0, easingFn: EasingFunc = null, target: DisplayObject = null) { diff --git a/src/flashbang/tasks/DisplayObjectTask.ts b/src/flashbang/tasks/DisplayObjectTask.ts index 880794dcf..b3e1b4a17 100644 --- a/src/flashbang/tasks/DisplayObjectTask.ts +++ b/src/flashbang/tasks/DisplayObjectTask.ts @@ -1,6 +1,6 @@ import {DisplayObject} from "pixi.js"; import {Assert, EasingFunc} from "../util"; -import {InterpolatingTask} from "."; +import InterpolatingTask from "./InterpolatingTask"; export default class DisplayObjectTask extends InterpolatingTask { constructor(time: number, easing: EasingFunc, target: DisplayObject) { diff --git a/src/flashbang/tasks/LocationTask.ts b/src/flashbang/tasks/LocationTask.ts index eca0a6ef6..549d3a87c 100644 --- a/src/flashbang/tasks/LocationTask.ts +++ b/src/flashbang/tasks/LocationTask.ts @@ -1,6 +1,6 @@ import {DisplayObject} from "pixi.js"; import {EasingFunc} from "../util"; -import {DisplayObjectTask} from "."; +import DisplayObjectTask from "./DisplayObjectTask"; export default class LocationTask extends DisplayObjectTask { constructor(x: number, y: number, time: number = 0, easingFn: EasingFunc = null, target: DisplayObject = null) { diff --git a/src/flashbang/tasks/RotationTask.ts b/src/flashbang/tasks/RotationTask.ts index daa7258e7..6b41a0753 100644 --- a/src/flashbang/tasks/RotationTask.ts +++ b/src/flashbang/tasks/RotationTask.ts @@ -1,6 +1,6 @@ import {DisplayObject} from "pixi.js"; import {EasingFunc} from "../util"; -import {DisplayObjectTask} from "."; +import DisplayObjectTask from "./DisplayObjectTask"; export default class RotationTask extends DisplayObjectTask { constructor(radians: number, time: number = 0, easingFn: EasingFunc = null, target: DisplayObject = null) { diff --git a/src/flashbang/tasks/ScaleTask.ts b/src/flashbang/tasks/ScaleTask.ts index 642f9d0e6..4db27de60 100644 --- a/src/flashbang/tasks/ScaleTask.ts +++ b/src/flashbang/tasks/ScaleTask.ts @@ -1,6 +1,6 @@ import {DisplayObject} from "pixi.js"; import {EasingFunc} from "../util"; -import {DisplayObjectTask} from "."; +import DisplayObjectTask from "./DisplayObjectTask"; export default class ScaleTask extends DisplayObjectTask { constructor(x: number, y: number, time: number = 0, easingFn: EasingFunc = null, target: DisplayObject = null) { diff --git a/src/flashbang/util/Base64.ts b/src/flashbang/util/Base64.ts index 4a2d2a9fa..151efb10f 100644 --- a/src/flashbang/util/Base64.ts +++ b/src/flashbang/util/Base64.ts @@ -1,6 +1,6 @@ import * as base64js from "base64-js"; import {DisplayObject, Sprite, Texture} from "pixi.js"; -import {DisplayUtil} from "."; +import DisplayUtil from "./DisplayUtil"; export default class Base64 { /** Renders a DisplayObject or Texture to a PNG and base64-encodes it */ diff --git a/src/flashbang/util/ColorUtil.ts b/src/flashbang/util/ColorUtil.ts index cb6d1e802..290612d7f 100644 --- a/src/flashbang/util/ColorUtil.ts +++ b/src/flashbang/util/ColorUtil.ts @@ -1,4 +1,5 @@ -import {MathUtil, StringUtil} from "."; +import MathUtil from "./MathUtil"; +import StringUtil from "./StringUtil"; export default class ColorUtil { public static fromString(str: string): number { diff --git a/src/flashbang/util/DisplayUtil.ts b/src/flashbang/util/DisplayUtil.ts index 11c778d91..2ff3e100d 100644 --- a/src/flashbang/util/DisplayUtil.ts +++ b/src/flashbang/util/DisplayUtil.ts @@ -2,7 +2,7 @@ import { DisplayObject, Graphics, Matrix, Point, Rectangle } from "pixi.js"; import {Flashbang, HAlign, VAlign} from "../core"; -import {RectangleUtil} from "."; +import RectangleUtil from "./RectangleUtil"; // the @types file for upng-js is broken, so we just require it directly const UPNG = require("upng-js"); diff --git a/src/flashbang/util/Easing.ts b/src/flashbang/util/Easing.ts index 3a3ff7731..51a2398cd 100644 --- a/src/flashbang/util/Easing.ts +++ b/src/flashbang/util/Easing.ts @@ -1,4 +1,4 @@ -import {PowerEaser} from "."; +import PowerEaser from "./PowerEaser"; export type EasingFunc = (from: number, to: number, dt: number, t: number) => number; diff --git a/src/flashbang/util/RectangleUtil.ts b/src/flashbang/util/RectangleUtil.ts index 82bc8348f..25581f0be 100644 --- a/src/flashbang/util/RectangleUtil.ts +++ b/src/flashbang/util/RectangleUtil.ts @@ -9,7 +9,7 @@ // ================================================================================================= import {Point, Rectangle, Matrix} from "pixi.js"; -import {MatrixUtil} from "."; +import MatrixUtil from "./MatrixUtil"; /** A utility class containing methods related to the Rectangle class. */ export default class RectangleUtil { diff --git a/src/flashbang/util/StyledTextBuilder.ts b/src/flashbang/util/StyledTextBuilder.ts index 61857d836..eb524dbf5 100644 --- a/src/flashbang/util/StyledTextBuilder.ts +++ b/src/flashbang/util/StyledTextBuilder.ts @@ -1,6 +1,6 @@ import * as log from "loglevel"; import {default as MultiStyleText, ExtendedTextStyle, TextStyleSet} from "pixi-multistyle-text"; -import {ColorUtil} from "."; +import ColorUtil from "./ColorUtil"; export default class StyledTextBuilder { public constructor(defaultStyle?: ExtendedTextStyle) { diff --git a/src/flashbang/util/TextureUtil.ts b/src/flashbang/util/TextureUtil.ts index 31fdc88a0..be85e69d7 100644 --- a/src/flashbang/util/TextureUtil.ts +++ b/src/flashbang/util/TextureUtil.ts @@ -2,7 +2,7 @@ import { BaseRenderTexture, BaseTexture, Container, DisplayObject, Rectangle, RenderTexture, Texture } from "pixi.js"; import {Flashbang} from "../core"; -import {Assert} from "."; +import Assert from "./Assert"; export default class TextureUtil { public static fromBase64PNG(base64PNG: string): Promise { diff --git a/src/flashbang/util/index.ts b/src/flashbang/util/index.ts index 76c8d51ab..f8451aec4 100644 --- a/src/flashbang/util/index.ts +++ b/src/flashbang/util/index.ts @@ -1,5 +1,4 @@ export {default as Assert} from "./Assert"; -export {default as Dragger} from "./Dragger"; export {default as Arrays} from "./Arrays"; export {default as Base64} from "./Base64"; export {default as ColorUtil} from "./ColorUtil"; @@ -18,4 +17,4 @@ export {default as StringUtil} from "./StringUtil"; export {default as StyledTextBuilder} from "./StyledTextBuilder"; export {default as TextBuilder} from "./TextBuilder"; export {default as TextureUtil} from "./TextureUtil"; -export {default as TextUtil} from "./TextUtil"; +export {default as TextUtil} from "./TextUtil"; \ No newline at end of file diff --git a/src/signals/AbstractSignal.ts b/src/signals/AbstractSignal.ts index 40a109806..649593fa4 100644 --- a/src/signals/AbstractSignal.ts +++ b/src/signals/AbstractSignal.ts @@ -1,7 +1,6 @@ -/* import Reactor from "./Reactor"; +import Reactor from "./Reactor"; import SignalView from "./SignalView"; -import Connection from "./Connection"; */ -import {Reactor, SignalView, Connection} from "."; +import Connection from "./Connection"; /** * Handles the machinery of connecting slots to a signal and emitting events to them, without diff --git a/src/signals/AbstractValue.ts b/src/signals/AbstractValue.ts index d5465f87b..3a2427a28 100644 --- a/src/signals/AbstractValue.ts +++ b/src/signals/AbstractValue.ts @@ -1,10 +1,7 @@ -/* import Connection from "./Connection"; +import Connection from "./Connection"; import Cons from "./Cons"; import Reactor from "./Reactor"; -import ValueView from "./ValueView"; */ -import { - Connection, Cons, Reactor, ValueView -} from "."; +import ValueView from "./ValueView"; /** * Handles the machinery of connecting listeners to a value and notifying them, without exposing a diff --git a/src/signals/Connection.ts b/src/signals/Connection.ts index 0ee66135e..4e99428c4 100644 --- a/src/signals/Connection.ts +++ b/src/signals/Connection.ts @@ -1,5 +1,4 @@ -// import Registration from "./Registration"; -import {Registration} from "."; +import Registration from "./Registration"; /** * Provides a mechanism to cancel a slot or listener registration, or to perform post-registration diff --git a/src/signals/Cons.ts b/src/signals/Cons.ts index ae3f791d2..2dff45510 100644 --- a/src/signals/Cons.ts +++ b/src/signals/Cons.ts @@ -1,7 +1,6 @@ -/* import Reactor from "./Reactor"; +import Reactor from "./Reactor"; import {RListener} from "./Reactor"; -import Connection from "./Connection"; */ -import {Reactor, RListener, Connection} from "."; +import Connection from "./Connection"; /** * Implements {@link Connection} and a linked-list style listener list for {@link Reactor}s. diff --git a/src/signals/FilteredSignal.ts b/src/signals/FilteredSignal.ts index ff23d9a36..cceb465af 100644 --- a/src/signals/FilteredSignal.ts +++ b/src/signals/FilteredSignal.ts @@ -1,7 +1,6 @@ -/* import MappedSignal from "./MappedSignal"; +import MappedSignal from "./MappedSignal"; import SignalView from "./SignalView"; -import Connection from "./Connection"; */ -import {MappedSignal, SignalView, Connection} from "."; +import Connection from "./Connection"; export default class FilteredSignal extends MappedSignal { constructor(source: SignalView, pred: (value: T) => boolean) { diff --git a/src/signals/MappedSignal.ts b/src/signals/MappedSignal.ts index 458f87a73..2c28e1144 100644 --- a/src/signals/MappedSignal.ts +++ b/src/signals/MappedSignal.ts @@ -1,10 +1,7 @@ -/* import AbstractSignal from "./AbstractSignal"; -import FilteredSignal from "./FilteredSignal"; +import AbstractSignal from "./AbstractSignal"; import SignalView from "./SignalView"; -import Connection from "./Connection"; */ -import { - AbstractSignal, FilteredSignal, SignalView, Connection -} from "."; +import Connection from "./Connection"; +import FilteredSignal from "./FilteredSignal"; /** * Plumbing to implement mapped signals in such a way that they automatically manage a connection diff --git a/src/signals/MappedValue.ts b/src/signals/MappedValue.ts index a9d41c5da..94211c752 100644 --- a/src/signals/MappedValue.ts +++ b/src/signals/MappedValue.ts @@ -1,7 +1,6 @@ -/* import AbstractValue from "./AbstractValue"; +import AbstractValue from "./AbstractValue"; import ValueView from "./ValueView"; -import Connection from "./Connection"; */ -import {AbstractValue, ValueView, Connection} from "."; +import Connection from "./Connection"; /** * Plumbing to implement mapped values in such a way that they automatically manage a connection to diff --git a/src/signals/Reactor.ts b/src/signals/Reactor.ts index a25080b12..43211489e 100644 --- a/src/signals/Reactor.ts +++ b/src/signals/Reactor.ts @@ -1,5 +1,4 @@ -// import Cons from "./Cons"; -import {Cons} from "."; +import Cons from "./Cons"; export type RListener = (arg1?: any, arg2?: any, arg3?: any) => void; diff --git a/src/signals/RegistrationGroup.ts b/src/signals/RegistrationGroup.ts index 35244e462..bc7ebc2bb 100644 --- a/src/signals/RegistrationGroup.ts +++ b/src/signals/RegistrationGroup.ts @@ -1,6 +1,5 @@ -/* import MultiFailureError from "./MultiFailureError"; -import Registration from "./Registration"; */ -import {MultiFailureError, Registration} from "."; +import MultiFailureError from "./MultiFailureError"; +import Registration from "./Registration"; /** Collects Registrations to allow mass operations on them. */ export default class RegistrationGroup implements Registration { diff --git a/src/signals/Registrations.ts b/src/signals/Registrations.ts index 0c8918c30..cf2eb012d 100644 --- a/src/signals/Registrations.ts +++ b/src/signals/Registrations.ts @@ -1,5 +1,4 @@ -// import Registration from "./Registration"; -import {Registration} from "."; +import Registration from "./Registration"; export default class Registrations { /** Returns a Registration that will call the given function when disconnected */ diff --git a/src/signals/Signal.ts b/src/signals/Signal.ts index fa6273891..80be80ab4 100644 --- a/src/signals/Signal.ts +++ b/src/signals/Signal.ts @@ -1,10 +1,7 @@ -/* import AbstractSignal from "./AbstractSignal"; +import AbstractSignal from "./AbstractSignal"; import FilteredSignal from "./FilteredSignal"; import MappedSignal from "./MappedSignal"; -import SignalView from "./SignalView"; */ -import { - AbstractSignal, FilteredSignal, MappedSignal, SignalView -} from "."; +import SignalView from "./SignalView"; /** A signal that emits events of type {@code T}. */ export default class Signal extends AbstractSignal { diff --git a/src/signals/SignalView.ts b/src/signals/SignalView.ts index ccb865dec..13e54cb4e 100644 --- a/src/signals/SignalView.ts +++ b/src/signals/SignalView.ts @@ -1,5 +1,4 @@ -// import Connection from "./Connection"; -import {Connection} from "."; +import Connection from "./Connection"; /** * A view of a {@link Signal}, on which slots may listen, but to which one cannot emit events. This diff --git a/src/signals/UnitSignal.ts b/src/signals/UnitSignal.ts index ffe079091..538f3de1c 100644 --- a/src/signals/UnitSignal.ts +++ b/src/signals/UnitSignal.ts @@ -1,10 +1,7 @@ -/* import AbstractSignal from "./AbstractSignal"; +import AbstractSignal from "./AbstractSignal"; import FilteredSignal from "./FilteredSignal"; import MappedSignal from "./MappedSignal"; -import SignalView from "./SignalView"; */ -import { - AbstractSignal, FilteredSignal, MappedSignal, SignalView -} from "."; +import SignalView from "./SignalView"; /** A signal that emits an event with no associated data. */ export default class UnitSignal extends AbstractSignal { diff --git a/src/signals/Value.ts b/src/signals/Value.ts index ecbdea297..bb188515d 100644 --- a/src/signals/Value.ts +++ b/src/signals/Value.ts @@ -1,7 +1,6 @@ -/* import AbstractValue from "./AbstractValue"; +import AbstractValue from "./AbstractValue"; import MappedValue from "./MappedValue"; -import ValueView from "./ValueView"; */ -import {AbstractValue, MappedValue, ValueView} from "."; +import ValueView from "./ValueView"; export default class Value extends AbstractValue implements ValueView { /** Creates an instance with the supplied starting value. */ diff --git a/src/signals/ValueView.ts b/src/signals/ValueView.ts index 2dcdf133f..6b64ecb28 100644 --- a/src/signals/ValueView.ts +++ b/src/signals/ValueView.ts @@ -1,5 +1,4 @@ -// import Connection from "./Connection"; -import {Connection} from "."; +import Connection from "./Connection"; /** * A view of a {@link AbstractValue} subclass, to which listeners may be added, but which one diff --git a/src/signals/__tests__/Counter.ts b/src/signals/__tests__/Counter.ts index 06d0edee5..1f9c95658 100644 --- a/src/signals/__tests__/Counter.ts +++ b/src/signals/__tests__/Counter.ts @@ -1,4 +1,4 @@ -export class Counter { +export default class Counter { public get slot(): (value: any) => void { return this.onEmit; } diff --git a/src/signals/__tests__/RegistrationGroup.test.ts b/src/signals/__tests__/RegistrationGroup.test.ts index 8730748ce..479d76abc 100644 --- a/src/signals/__tests__/RegistrationGroup.test.ts +++ b/src/signals/__tests__/RegistrationGroup.test.ts @@ -1,6 +1,6 @@ -import {RegistrationGroup} from "../RegistrationGroup"; -import {UnitSignal} from "../UnitSignal"; -import {Counter} from "./Counter"; +import RegistrationGroup from "../RegistrationGroup"; +import UnitSignal from "../UnitSignal"; +import Counter from "./Counter"; test("registrationGroup", () => { let group: RegistrationGroup = new RegistrationGroup(); diff --git a/src/signals/__tests__/Signal.test.ts b/src/signals/__tests__/Signal.test.ts index 07de9cc81..ea5f7f9fe 100644 --- a/src/signals/__tests__/Signal.test.ts +++ b/src/signals/__tests__/Signal.test.ts @@ -1,8 +1,5 @@ -import {Connection} from "../Connection"; -import {Signal} from "../Signal"; -import {SignalView} from "../SignalView"; -import {UnitSignal} from "../UnitSignal"; -import {Counter} from "./Counter"; +import {Connection, Signal, SignalView, UnitSignal} from "signals"; +import Counter from "./Counter"; test("signalToSlot", () => { let signal: Signal = new Signal(); diff --git a/src/signals/__tests__/Value.test.ts b/src/signals/__tests__/Value.test.ts index 4d35591bd..508681bab 100644 --- a/src/signals/__tests__/Value.test.ts +++ b/src/signals/__tests__/Value.test.ts @@ -1,8 +1,6 @@ import * as assert from "assert"; -import {Connection} from "../Connection"; -import {Value} from "../Value"; -import {ValueView} from "../ValueView"; -import {Counter} from "./Counter"; +import {Connection, Value, ValueView} from "signals"; +import Counter from "./Counter"; test("simpleListener", () => { let value: Value = new Value(42); diff --git a/src/signals/index.ts b/src/signals/index.ts index c1da78afb..702a22285 100644 --- a/src/signals/index.ts +++ b/src/signals/index.ts @@ -3,8 +3,8 @@ export {default as Reactor, RListener} from "./Reactor"; export {default as AbstractSignal} from "./AbstractSignal"; export {default as AbstractValue} from "./AbstractValue"; export {default as Connection} from "./Connection"; -export {default as MappedSignal} from "./MappedSignal"; export {default as FilteredSignal} from "./FilteredSignal"; +export {default as MappedSignal} from "./MappedSignal"; export {default as MappedValue} from "./MappedValue"; export {default as MultiFailureError} from "./MultiFailureError"; export {default as Registration} from "./Registration"; From 81aa1f8ffa56d74505f7aef311dd5dcae21d3036 Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Tue, 2 Jul 2019 15:49:22 -0400 Subject: [PATCH 09/39] Fix typing issues --- src/eterna/settings/EternaSettings.ts | 30 +++++++++++++-------------- src/flashbang/objects/ToggleButton.ts | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/eterna/settings/EternaSettings.ts b/src/eterna/settings/EternaSettings.ts index c798fec67..f00f241b3 100644 --- a/src/eterna/settings/EternaSettings.ts +++ b/src/eterna/settings/EternaSettings.ts @@ -29,22 +29,22 @@ export default class EternaSettings extends Settings { public constructor() { super("EternaSettings"); - this.showChat = this.setting("showChat", true); - this.showNumbers = this.setting("showNumbers", true); - this.showLetters = this.setting("showLetters", false); - this.displayFreeEnergies = this.setting("displayFreeEnergies", false); - this.highlightRestricted = this.setting("highlightRestricted", true); - this.autohideToolbar = this.setting("autohideToolbar", false); - this.freezeButtonAlwaysVisible = this.setting("freezeButtonAlwaysVisible", false); - this.multipleFoldingEngines = this.setting("multipleFoldingEngines", false); - this.useContinuousColors = this.setting("useContinuousColors", false); - this.useExtendedColors = this.setting("useExtendedColors", false); - this.displayAuxInfo = this.setting("displayAuxInfo", false); - this.soundMute = this.setting("soundMute", false); + this.showChat = this.setting("showChat", true); + this.showNumbers = this.setting("showNumbers", true); + this.showLetters = this.setting("showLetters", false); + this.displayFreeEnergies = this.setting("displayFreeEnergies", false); + this.highlightRestricted = this.setting("highlightRestricted", true); + this.autohideToolbar = this.setting("autohideToolbar", false); + this.freezeButtonAlwaysVisible = this.setting("freezeButtonAlwaysVisible", false); + this.multipleFoldingEngines = this.setting("multipleFoldingEngines", false); + this.useContinuousColors = this.setting("useContinuousColors", false); + this.useExtendedColors = this.setting("useExtendedColors", false); + this.displayAuxInfo = this.setting("displayAuxInfo", false); + this.soundMute = this.setting("soundMute", false); this.soundVolume = this.setting("soundVolume", 0.6); this.lastUsedFolder = this.setting("lastUsedFolder", null); - this.pipEnabled = this.setting("pipEnabled", false); - this.simpleGraphics = this.setting("simpleGraphics", false); + this.pipEnabled = this.setting("pipEnabled", false); + this.simpleGraphics = this.setting("simpleGraphics", false); this.designBrowserColumnNames = this.setting("designBrowserColumnNames", null); this.designBrowserSelectedSolutionIDs = this.setting("designBrowserSelectedSolutionIDs", null); @@ -53,7 +53,7 @@ export default class EternaSettings extends Settings { // indexedDB/localforage/SaveGameManager - eventually this might be able to be dropped, // but anyone who hasn't run Eterna between the EternaJS launch and the time it was // introduced will loose any autosaves - this.saveGamesTransfered = this.setting("saveGamesTransfered", false); + this.saveGamesTransfered = this.setting("saveGamesTransfered", false); if (this.saveGamesTransfered.value == false) { this._namespace.each((val, key) => { diff --git a/src/flashbang/objects/ToggleButton.ts b/src/flashbang/objects/ToggleButton.ts index b155075f2..e7b3ad0db 100644 --- a/src/flashbang/objects/ToggleButton.ts +++ b/src/flashbang/objects/ToggleButton.ts @@ -3,7 +3,7 @@ import Button from "./Button"; /** A two-state Button whose value is toggled on click (e.g. a checkbox). */ export default abstract class ToggleButton extends Button { - public readonly toggled: Value = new Value(false); + public readonly toggled: Value = new Value(false); protected constructor() { super(); From 4c28d3e8312a4393191e2888253e9a8c8557fe29 Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Tue, 2 Jul 2019 15:53:39 -0400 Subject: [PATCH 10/39] Lint autofix --- src/eterna/UndoBlock.ts | 6 +++--- src/eterna/mode/DesignBrowser/DesignBrowserMode.ts | 2 +- src/eterna/rscript/ROPHighlight.ts | 2 +- src/eterna/ui/TextInputPanel.ts | 2 +- src/flashbang/core/index.ts | 2 +- src/flashbang/objects/index.ts | 2 +- src/flashbang/util/index.ts | 2 +- src/signals/Cons.ts | 4 ++-- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/eterna/UndoBlock.ts b/src/eterna/UndoBlock.ts index 8be070227..dc9ebc1dc 100644 --- a/src/eterna/UndoBlock.ts +++ b/src/eterna/UndoBlock.ts @@ -3,7 +3,7 @@ import EPars from "eterna/EPars"; import {Folder} from "eterna/folding"; import {default as Plot, PlotType} from "eterna/Plot"; import {Oligo, Pose2D} from "eterna/pose2D"; -import { Utility } from "./util"; +import {Utility} from "./util"; export enum UndoBlockParam { GU = 0, @@ -331,10 +331,10 @@ export default class UndoBlock { let originalIndices: number[][] = []; let oligoFirstBaseIndex = this._sequence.length; - + for (let oligo of this._targetOligos) { // The + 1 is used to account for the "cut" base denoting split points between strands - originalIndices.push(Utility.range(oligoFirstBaseIndex, oligoFirstBaseIndex + oligo.sequence.length + 1)) + originalIndices.push(Utility.range(oligoFirstBaseIndex, oligoFirstBaseIndex + oligo.sequence.length + 1)); oligoFirstBaseIndex += oligo.sequence.length; } diff --git a/src/eterna/mode/DesignBrowser/DesignBrowserMode.ts b/src/eterna/mode/DesignBrowser/DesignBrowserMode.ts index 8f993ac2a..fe02330d1 100644 --- a/src/eterna/mode/DesignBrowser/DesignBrowserMode.ts +++ b/src/eterna/mode/DesignBrowser/DesignBrowserMode.ts @@ -22,7 +22,7 @@ import {Fonts, int} from "eterna/util"; import {GameMode} from "eterna/mode"; import CustomizeColumnOrderDialog from "./CustomizeColumnOrderDialog"; import DataCol from "./DataCol"; -import DotLine from "./DotLine" +import DotLine from "./DotLine"; import GridLines from "./GridLines"; import MarkerBoxView from "./MarkerBoxView"; import SelectionBox from "./SelectionBox"; diff --git a/src/eterna/rscript/ROPHighlight.ts b/src/eterna/rscript/ROPHighlight.ts index 279e0dc2a..e834f9b9b 100644 --- a/src/eterna/rscript/ROPHighlight.ts +++ b/src/eterna/rscript/ROPHighlight.ts @@ -8,7 +8,7 @@ import {RNAHighlightState} from "eterna/pose2D"; import {ConstraintBox, EternaMenu} from "eterna/ui"; import RScriptEnv from "./RScriptEnv"; import RScriptOp from "./RScriptOp"; -import {RScriptUIElement, GetRScriptUIElementBounds, RScriptUIElementID} from "./RScriptUIElement" +import {RScriptUIElement, GetRScriptUIElementBounds, RScriptUIElementID} from "./RScriptUIElement"; export enum ROPHighlightMode { RNA = "RNA", diff --git a/src/eterna/ui/TextInputPanel.ts b/src/eterna/ui/TextInputPanel.ts index 958850ca3..bc59d8807 100644 --- a/src/eterna/ui/TextInputPanel.ts +++ b/src/eterna/ui/TextInputPanel.ts @@ -4,7 +4,7 @@ import {Signal, UnitSignal} from "signals"; import {Fonts} from "eterna/util"; import GameButton from "./GameButton"; import GamePanel from "./GamePanel"; -import TextInputObject from "./TextInputObject" +import TextInputObject from "./TextInputObject"; export default class TextInputPanel extends GamePanel { public readonly cancelClicked: UnitSignal = new UnitSignal(); diff --git a/src/flashbang/core/index.ts b/src/flashbang/core/index.ts index 6a8290e4a..6266d4ead 100644 --- a/src/flashbang/core/index.ts +++ b/src/flashbang/core/index.ts @@ -8,4 +8,4 @@ export {default as GameObjectRef} from "./GameObjectRef"; export {default as LateUpdatable} from "./LateUpdatable"; export {default as ModeStack} from "./ModeStack"; export {default as ObjectTask} from "./ObjectTask"; -export {default as Updatable} from "./Updatable"; \ No newline at end of file +export {default as Updatable} from "./Updatable"; diff --git a/src/flashbang/objects/index.ts b/src/flashbang/objects/index.ts index 4674efe61..68b69beb1 100644 --- a/src/flashbang/objects/index.ts +++ b/src/flashbang/objects/index.ts @@ -7,4 +7,4 @@ export {default as ImageButton} from "./ImageButton"; export {default as SimpleTextButton} from "./SimpleTextButton"; export {default as SpriteObject} from "./SpriteObject"; export {default as ToggleButton} from "./ToggleButton"; -export {default as Dragger} from "./Dragger"; \ No newline at end of file +export {default as Dragger} from "./Dragger"; diff --git a/src/flashbang/util/index.ts b/src/flashbang/util/index.ts index f8451aec4..502a48123 100644 --- a/src/flashbang/util/index.ts +++ b/src/flashbang/util/index.ts @@ -17,4 +17,4 @@ export {default as StringUtil} from "./StringUtil"; export {default as StyledTextBuilder} from "./StyledTextBuilder"; export {default as TextBuilder} from "./TextBuilder"; export {default as TextureUtil} from "./TextureUtil"; -export {default as TextUtil} from "./TextUtil"; \ No newline at end of file +export {default as TextUtil} from "./TextUtil"; diff --git a/src/signals/Cons.ts b/src/signals/Cons.ts index 2dff45510..6f3b5c5f6 100644 --- a/src/signals/Cons.ts +++ b/src/signals/Cons.ts @@ -1,5 +1,5 @@ -import Reactor from "./Reactor"; -import {RListener} from "./Reactor"; +import {RListener} from Reactor from "./Reactor"; + import Connection from "./Connection"; /** From 946b70cc7ba7b0c9aa30ca7866f72ed0fafd46ea Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Tue, 2 Jul 2019 15:57:23 -0400 Subject: [PATCH 11/39] Syntax typo fix --- src/signals/Cons.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/signals/Cons.ts b/src/signals/Cons.ts index 6f3b5c5f6..852b1a9ed 100644 --- a/src/signals/Cons.ts +++ b/src/signals/Cons.ts @@ -1,4 +1,4 @@ -import {RListener} from Reactor from "./Reactor"; +import Reactor, {RListener} from "./Reactor"; import Connection from "./Connection"; From 3e61f8b6c6cbc341830d33ebd2aba01dd5bc3da0 Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Tue, 2 Jul 2019 16:14:35 -0400 Subject: [PATCH 12/39] Package bump --- package-lock.json | 3487 +++++++++++++++------------------------------ package.json | 34 +- 2 files changed, 1191 insertions(+), 2330 deletions(-) diff --git a/package-lock.json b/package-lock.json index bd3be9738..61daa038a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -62,25 +62,10 @@ "ms": "^2.1.1" } }, - "json5": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.0.tgz", - "integrity": "sha512-8Mh9h6xViijj36g7Dxi+Y4S6hNGV96vcJZr/SrlHh1LR/pEn/8j/+qIBbs44YKl69Lrfctp4QD+AdWLTMqEZAQ==", - "dev": true, - "requires": { - "minimist": "^1.2.0" - } - }, - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true - }, "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true } } @@ -743,9 +728,9 @@ } }, "@babel/plugin-transform-typescript": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.4.0.tgz", - "integrity": "sha512-U7/+zKnRZg04ggM/Bm+xmu2B/PrwyDQTT/V89FXWYWNMxBDwSx56u6jtk9SEbfLFbZaEI72L+5LPvQjeZgFCrQ==", + "version": "7.4.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.4.5.tgz", + "integrity": "sha512-RPB/YeGr4ZrFKNwfuQRlMf2lxoCUaU01MTw39/OFE/RiL8HDjtn68BwEPft1P7JN4akyEmjGWAMNldOV7o9V2g==", "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.0.0", @@ -867,9 +852,9 @@ } }, "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true } } @@ -955,12 +940,6 @@ "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", "dev": true }, - "graceful-fs": { - "version": "4.1.15", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", - "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==", - "dev": true - }, "strip-ansi": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", @@ -1043,12 +1022,6 @@ "source-map": "^0.6.0" }, "dependencies": { - "graceful-fs": { - "version": "4.1.15", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", - "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==", - "dev": true - }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -1103,12 +1076,6 @@ "write-file-atomic": "2.4.1" }, "dependencies": { - "graceful-fs": { - "version": "4.1.15", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", - "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==", - "dev": true - }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -1140,9 +1107,9 @@ } }, "@koa/cors": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/@koa/cors/-/cors-2.2.3.tgz", - "integrity": "sha512-tCVVXa39ETsit5kGBtEWWimjLn1sDaeu8+0phgb8kT3GmBDZOykkI3ZO8nMjV2p3MGkJI4K5P+bxR8Ztq0bwsA==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@koa/cors/-/cors-3.0.0.tgz", + "integrity": "sha512-hDp+cXj6vTYSwHRJfiSpnf5dTMv3FmqNKh1or9BPJk4SHOviHnK9GoL9dT0ypt/E+hlkRkZ9edHylcosW3Ghrw==", "dev": true, "requires": { "vary": "^1.1.2" @@ -1342,9 +1309,9 @@ } }, "@types/babel__traverse": { - "version": "7.0.6", - "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.0.6.tgz", - "integrity": "sha512-XYVgHF2sQ0YblLRMLNPB3CkFMewzFmlDsH/TneZFHUXDlABQgh88uOxuez7ZcXxayLFrqLwtDH1t+FmlFwNZxw==", + "version": "7.0.7", + "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.0.7.tgz", + "integrity": "sha512-CeBpmX1J8kWLcDEnI3Cl2Eo6RfbGvzUctA+CjZUhOKDFbLfcr7fc4usEqLNWetrlJd7RhAkyYe2czXop4fICpw==", "dev": true, "requires": { "@babel/types": "^7.3.0" @@ -1356,6 +1323,12 @@ "integrity": "sha1-WCskdhaabLpGCiFNR2x0REHYc9U=", "dev": true }, + "@types/eslint-visitor-keys": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", + "integrity": "sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag==", + "dev": true + }, "@types/istanbul-lib-coverage": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.1.tgz", @@ -1382,9 +1355,9 @@ } }, "@types/jest": { - "version": "24.0.13", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-24.0.13.tgz", - "integrity": "sha512-3m6RPnO35r7Dg+uMLj1+xfZaOgIHHHut61djNjzwExXN4/Pm9has9C6I1KMYSfz7mahDhWUOVg4HW/nZdv5Pww==", + "version": "24.0.15", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-24.0.15.tgz", + "integrity": "sha512-MU1HIvWUme74stAoc3mgAi+aMlgKOudgEvQDIm1v4RkrDudBh1T+NFp5sftpBAdXdx1J0PbdpJ+M2EsSOi1djA==", "dev": true, "requires": { "@types/jest-diff": "*" @@ -1397,21 +1370,24 @@ "dev": true }, "@types/loglevel": { - "version": "1.5.4", - "resolved": "https://registry.npmjs.org/@types/loglevel/-/loglevel-1.5.4.tgz", - "integrity": "sha512-8dx4ckP0vndJeN+iKZwdGiapLqFjVQ3JLOt92uqK0C63acs5NcPLbUOpfXCJkKVRjZLBQjw8NIGNBSsnatFnFQ==", - "dev": true + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/@types/loglevel/-/loglevel-1.6.3.tgz", + "integrity": "sha512-v2YWQQgqtNXAzybOT9qV3CIJqSeoaMUwmBfIMTQdvhsWUybYic/zNGccKH494naWKJ7zUm+VTgFepJfTrbCCJQ==", + "dev": true, + "requires": { + "loglevel": "*" + } }, "@types/node": { - "version": "12.0.4", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.0.4.tgz", - "integrity": "sha512-j8YL2C0fXq7IONwl/Ud5Kt0PeXw22zGERt+HSSnwbKOJVsAGkEz3sFCYwaF9IOuoG1HOtE0vKCj6sXF7Q0+Vaw==", + "version": "12.0.10", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.0.10.tgz", + "integrity": "sha512-LcsGbPomWsad6wmMNv7nBLw7YYYyfdYcz6xryKYQhx89c3XXan+8Q6AJ43G5XDIaklaVkK3mE4fCb0SBvMiPSQ==", "dev": true }, "@types/pixi.js": { - "version": "4.8.6", - "resolved": "https://registry.npmjs.org/@types/pixi.js/-/pixi.js-4.8.6.tgz", - "integrity": "sha512-70PcmzoHG723nMLx7OzMM7xoH8EnJfVVQmh1WQgXGaXdU9ygq3VlsXLRt/g6Z124abKDvmzg3hfRpA8CvBp2eA==", + "version": "4.8.8", + "resolved": "https://registry.npmjs.org/@types/pixi.js/-/pixi.js-4.8.8.tgz", + "integrity": "sha512-5wmLnmL3foK/rqYMrrEM/3DxEwvwxJaP73RyqY8aMqq8zUm6CBlmc+12RIBH6iR/RHqU76XL238vWWJV1IN/zw==", "dev": true }, "@types/stack-utils": { @@ -1439,49 +1415,56 @@ "dev": true }, "@typescript-eslint/eslint-plugin": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-1.9.0.tgz", - "integrity": "sha512-FOgfBorxjlBGpDIw+0LaZIXRX6GEEUfzj8LXwaQIUCp+gDOvkI+1WgugJ7SmWiISqK9Vj5r8S7NDKO/LB+6X9A==", + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-1.11.0.tgz", + "integrity": "sha512-mXv9ccCou89C8/4avKHuPB2WkSZyY/XcTQUXd5LFZAcLw1I3mWYVjUu6eS9Ja0QkP/ClolbcW9tb3Ov/pMdcqw==", "dev": true, "requires": { - "@typescript-eslint/experimental-utils": "1.9.0", - "@typescript-eslint/parser": "1.9.0", + "@typescript-eslint/experimental-utils": "1.11.0", "eslint-utils": "^1.3.1", "functional-red-black-tree": "^1.0.1", "regexpp": "^2.0.1", - "requireindex": "^1.2.0", "tsutils": "^3.7.0" } }, "@typescript-eslint/experimental-utils": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-1.9.0.tgz", - "integrity": "sha512-1s2dY9XxBwtS9IlSnRIlzqILPyeMly5tz1bfAmQ84Ul687xBBve5YsH5A5EKeIcGurYYqY2w6RkHETXIwnwV0A==", + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-1.11.0.tgz", + "integrity": "sha512-7LbfaqF6B8oa8cp/315zxKk8FFzosRzzhF8Kn/ZRsRsnpm7Qcu25cR/9RnAQo5utZ2KIWVgaALr+ZmcbG47ruw==", "dev": true, "requires": { - "@typescript-eslint/typescript-estree": "1.9.0" + "@typescript-eslint/typescript-estree": "1.11.0", + "eslint-scope": "^4.0.0" } }, "@typescript-eslint/parser": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-1.9.0.tgz", - "integrity": "sha512-CWgC1XrQ34H/+LwAU7vY5xteZDkNqeAkeidEpJnJgkKu0yqQ3ZhQ7S+dI6MX4vmmM1TKRbOrKuXc6W0fIHhdbA==", + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-1.11.0.tgz", + "integrity": "sha512-5xBExyXaxVyczrZvbRKEXvaTUFFq7gIM9BynXukXZE0zF3IQP/FxF4mPmmh3gJ9egafZFqByCpPTFm3dk4SY7Q==", "dev": true, "requires": { - "@typescript-eslint/experimental-utils": "1.9.0", - "@typescript-eslint/typescript-estree": "1.9.0", - "eslint-scope": "^4.0.0", + "@types/eslint-visitor-keys": "^1.0.0", + "@typescript-eslint/experimental-utils": "1.11.0", + "@typescript-eslint/typescript-estree": "1.11.0", "eslint-visitor-keys": "^1.0.0" } }, "@typescript-eslint/typescript-estree": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-1.9.0.tgz", - "integrity": "sha512-7Eg0TEQpCkTsEwsl1lIzd6i7L3pJLQFWesV08dS87bNz0NeSjbL78gNAP1xCKaCejkds4PhpLnZkaAjx9SU8OA==", + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-1.11.0.tgz", + "integrity": "sha512-fquUHF5tAx1sM2OeRCC7wVxFd1iMELWMGCzOSmJ3pLzArj9+kRixdlC4d5MncuzXpjEqc6045p3KwM0o/3FuUA==", "dev": true, "requires": { "lodash.unescape": "4.0.1", "semver": "5.5.0" + }, + "dependencies": { + "semver": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", + "dev": true + } } }, "@webassemblyjs/ast": { @@ -1696,23 +1679,6 @@ "requires": { "mime-types": "~2.1.24", "negotiator": "0.6.2" - }, - "dependencies": { - "mime-db": { - "version": "1.40.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", - "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==", - "dev": true - }, - "mime-types": { - "version": "2.1.24", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", - "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", - "dev": true, - "requires": { - "mime-db": "1.40.0" - } - } } }, "acorn": { @@ -1762,15 +1728,15 @@ } }, "ajv-errors": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/ajv-errors/-/ajv-errors-1.0.0.tgz", - "integrity": "sha1-7PAh+hCP0X37Xms4Py3SM+Mf/Fk=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ajv-errors/-/ajv-errors-1.0.1.tgz", + "integrity": "sha512-DCRfO/4nQ+89p/RK43i8Ezd41EqdGIU4ld7nGF8OQ14oc/we5rEntLCUa7+jrn3nn83BosfwZA0wb4pon2o8iQ==", "dev": true }, "ajv-keywords": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.2.0.tgz", - "integrity": "sha1-6GuBnGAs+IIa1jdBNpjx3sAhhHo=", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.4.0.tgz", + "integrity": "sha512-aUjdRFISbuFOl0EIZc+9e4FfZp0bDZgAdOOf30bJmw8VM9v84SHyVyxDfbWxpGYbdZD/9XoKxfHVNmxPkhwyGw==", "dev": true }, "ansi-escape-sequences": { @@ -1789,9 +1755,9 @@ "dev": true }, "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", "dev": true }, "ansi-styles": { @@ -1963,12 +1929,12 @@ "dev": true }, "async": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.1.tgz", - "integrity": "sha512-fNEiL2+AZt6AlAw/29Cr0UDe4sRAHCpEHh54WMz+Bb7QfNcFw4h3loofyJpLeQs4Yx7yuqu/2dLgM5hKOs6HlQ==", + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.2.tgz", + "integrity": "sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg==", "dev": true, "requires": { - "lodash": "^4.17.10" + "lodash": "^4.17.11" } }, "async-each": { @@ -2062,19 +2028,6 @@ "babel-preset-jest": "^24.6.0", "chalk": "^2.4.2", "slash": "^2.0.0" - }, - "dependencies": { - "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" - } - } } }, "babel-loader": { @@ -2087,14 +2040,6 @@ "loader-utils": "^1.0.2", "mkdirp": "^0.5.1", "pify": "^4.0.1" - }, - "dependencies": { - "pify": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", - "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", - "dev": true - } } }, "babel-plugin-istanbul": { @@ -2106,51 +2051,6 @@ "find-up": "^3.0.0", "istanbul-lib-instrument": "^3.3.0", "test-exclude": "^5.2.3" - }, - "dependencies": { - "find-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", - "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", - "dev": true, - "requires": { - "locate-path": "^3.0.0" - } - }, - "locate-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", - "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", - "dev": true, - "requires": { - "p-locate": "^3.0.0", - "path-exists": "^3.0.0" - } - }, - "p-limit": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.0.tgz", - "integrity": "sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ==", - "dev": true, - "requires": { - "p-try": "^2.0.0" - } - }, - "p-locate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", - "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", - "dev": true, - "requires": { - "p-limit": "^2.0.0" - } - }, - "p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true - } } }, "babel-plugin-jest-hoist": { @@ -2463,10 +2363,13 @@ "integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==" }, "basic-auth": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-1.1.0.tgz", - "integrity": "sha1-RSIe5Cn37h5QNb4/UVM/HN/SmIQ=", - "dev": true + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", + "integrity": "sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==", + "dev": true, + "requires": { + "safe-buffer": "5.1.2" + } }, "batch": { "version": "0.6.1", @@ -2484,9 +2387,9 @@ } }, "big.js": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/big.js/-/big.js-3.2.0.tgz", - "integrity": "sha512-+hN/Zh2D08Mx65pZ/4g5bsmNiZUuChDiQfTUQ7qJr4/kuopCr88xZsAXv6mBoZEsUI4OuGHlX59qE94K2mMW8Q==", + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", + "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==", "dev": true }, "binary-extensions": { @@ -2658,14 +2561,14 @@ } }, "browserslist": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.6.1.tgz", - "integrity": "sha512-1MC18ooMPRG2UuVFJTHFIAkk6mpByJfxCrnUyvSlu/hyQSFHMrlhM02SzNuCV+quTP4CKmqtOMAIjrifrpBJXQ==", + "version": "4.6.3", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.6.3.tgz", + "integrity": "sha512-CNBqTCq22RKM8wKJNowcqihHJ4SkI8CGeK7KOR9tPboXUuS5Zk5lQgzzTbs4oxD8x+6HUshZUa2OyNI9lR93bQ==", "dev": true, "requires": { - "caniuse-lite": "^1.0.30000971", - "electron-to-chromium": "^1.3.137", - "node-releases": "^1.1.21" + "caniuse-lite": "^1.0.30000975", + "electron-to-chromium": "^1.3.164", + "node-releases": "^1.1.23" } }, "bs-logger": { @@ -2678,9 +2581,9 @@ } }, "bser": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/bser/-/bser-2.0.0.tgz", - "integrity": "sha1-mseNPtXZFYBP2HrLFYvHlxR6Fxk=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/bser/-/bser-2.1.0.tgz", + "integrity": "sha512-8zsjWrQkkBoLK6uxASk1nJ2SKv97ltiGDo6A3wA0/yRPz+CwmEyDo0hUrhIuukG2JHpAl3bvFIixw2/3Hi0DOg==", "dev": true, "requires": { "node-int64": "^0.4.0" @@ -2709,12 +2612,6 @@ "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=", "dev": true }, - "builtin-modules": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", - "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", - "dev": true - }, "builtin-status-codes": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", @@ -2734,47 +2631,25 @@ "dev": true }, "cacache": { - "version": "11.3.2", - "resolved": "https://registry.npmjs.org/cacache/-/cacache-11.3.2.tgz", - "integrity": "sha512-E0zP4EPGDOaT2chM08Als91eYnf8Z+eH1awwwVsngUmgppfM5jjJ8l3z5vO5p5w/I3LsiXawb1sW0VY65pQABg==", + "version": "11.3.3", + "resolved": "https://registry.npmjs.org/cacache/-/cacache-11.3.3.tgz", + "integrity": "sha512-p8WcneCytvzPxhDvYp31PD039vi77I12W+/KfR9S8AZbaiARFBCpsPJS+9uhWfeBfeAtW7o/4vt3MUqLkbY6nA==", "dev": true, "requires": { - "bluebird": "^3.5.3", + "bluebird": "^3.5.5", "chownr": "^1.1.1", "figgy-pudding": "^3.5.1", - "glob": "^7.1.3", + "glob": "^7.1.4", "graceful-fs": "^4.1.15", "lru-cache": "^5.1.1", "mississippi": "^3.0.0", "mkdirp": "^0.5.1", "move-concurrently": "^1.0.1", "promise-inflight": "^1.0.1", - "rimraf": "^2.6.2", + "rimraf": "^2.6.3", "ssri": "^6.0.1", "unique-filename": "^1.1.1", "y18n": "^4.0.0" - }, - "dependencies": { - "glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "graceful-fs": { - "version": "4.1.15", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", - "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==", - "dev": true - } } }, "cache-base": { @@ -2821,15 +2696,15 @@ } }, "camelcase": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.2.0.tgz", - "integrity": "sha512-IXFsBS2pC+X0j0N/GE7Dm7j3bsEBp+oTpb7F50dwEVX7rf3IgwO9XatnegTsDtniKCUtEJH4fSU6Asw7uoVLfQ==", + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", "dev": true }, "caniuse-lite": { - "version": "1.0.30000973", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000973.tgz", - "integrity": "sha512-/F3t/Yo8LEdRSEPCmI15fLu5vepVh9UCg/9inJXF5AAfW7xRRJkbaM2ut52iRMQMnGCLQouLbFdbOA+VEFOIsg==", + "version": "1.0.30000979", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000979.tgz", + "integrity": "sha512-gcu45yfq3B7Y+WB05fOMfr0EiSlq+1u+m6rPHyJli/Wy3PVQNGaU7VA4bZE5qw+AU2UVOBR/N5g1bzADUqdvFw==", "dev": true }, "capture-exit": { @@ -2848,9 +2723,9 @@ "dev": true }, "chalk": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", - "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", + "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", @@ -2955,16 +2830,6 @@ } } }, - "cli-commands": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/cli-commands/-/cli-commands-0.4.0.tgz", - "integrity": "sha512-zAvJlR7roeMgpUIhMDYATYL90vz+9ffuyPr0+qq4LzcZ0Jq+gM+H1KdYKxerc6U2nhitiDEx79YiJlXdrooEOA==", - "dev": true, - "requires": { - "command-line-args": "^5.0.2", - "command-line-commands": "^2.0.1" - } - }, "cli-cursor": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", @@ -2989,23 +2854,6 @@ "string-width": "^2.1.1", "strip-ansi": "^4.0.0", "wrap-ansi": "^2.0.0" - }, - "dependencies": { - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "dev": true, - "requires": { - "ansi-regex": "^3.0.0" - } - } } }, "co": { @@ -3049,18 +2897,18 @@ } }, "color-convert": { - "version": "1.9.2", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.2.tgz", - "integrity": "sha512-3NUJZdhMhcdPn8vJ9v2UQJoH0qqoGUkYTgFEPZaPjEtwmmKUfNV46zZmgB2M5M4DCEQHMaCfWHCxiBflLm04Tg==", + "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.1" + "color-name": "1.1.3" } }, "color-name": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.1.tgz", - "integrity": "sha1-SxQVMEz1ACjqgWQ2Q72C6gWANok=", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", "dev": true }, "combined-stream": { @@ -3092,71 +2940,28 @@ } } }, - "command-line-commands": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/command-line-commands/-/command-line-commands-2.0.1.tgz", - "integrity": "sha512-m8c2p1DrNd2ruIAggxd/y6DgygQayf6r8RHwchhXryaLF8I6koYjoYroVP+emeROE9DXN5b9sP1Gh+WtvTTdtQ==", - "dev": true, - "requires": { - "array-back": "^2.0.0" - }, - "dependencies": { - "array-back": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/array-back/-/array-back-2.0.0.tgz", - "integrity": "sha512-eJv4pLLufP3g5kcZry0j6WXpIbzYw9GUB4mVJZno9wfwiBxbizTnHCw3VJb07cBihbFX48Y7oSrW9y+gt4glyw==", - "dev": true, - "requires": { - "typical": "^2.6.1" - } - }, - "typical": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/typical/-/typical-2.6.1.tgz", - "integrity": "sha1-XAgOXWYcu+OCWdLnCjxyU+hziB0=", - "dev": true - } - } - }, "command-line-usage": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/command-line-usage/-/command-line-usage-5.0.5.tgz", - "integrity": "sha512-d8NrGylA5oCXSbGoKz05FkehDAzSmIm4K03S5VDh4d5lZAtTWfc3D1RuETtuQCn8129nYfJfDdF7P/lwcz1BlA==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/command-line-usage/-/command-line-usage-6.0.1.tgz", + "integrity": "sha512-jrKZUGLSwHoVDHjcLf3O5silOEo21yy0ju2whGw67f0KWp2s8mRdSlMJsVm/8dfR5a8cAOo2SUuXwAzMLBCyJw==", "dev": true, "requires": { - "array-back": "^2.0.0", - "chalk": "^2.4.1", - "table-layout": "^0.4.3", - "typical": "^2.6.1" - }, - "dependencies": { - "array-back": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/array-back/-/array-back-2.0.0.tgz", - "integrity": "sha512-eJv4pLLufP3g5kcZry0j6WXpIbzYw9GUB4mVJZno9wfwiBxbizTnHCw3VJb07cBihbFX48Y7oSrW9y+gt4glyw==", - "dev": true, - "requires": { - "typical": "^2.6.1" - } - }, - "typical": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/typical/-/typical-2.6.1.tgz", - "integrity": "sha1-XAgOXWYcu+OCWdLnCjxyU+hziB0=", - "dev": true - } + "array-back": "^3.1.0", + "chalk": "^2.4.2", + "table-layout": "^1.0.0", + "typical": "^5.1.0" } }, "commander": { - "version": "2.17.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.17.1.tgz", - "integrity": "sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==", + "version": "2.20.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", + "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==", "dev": true }, "common-log-format": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/common-log-format/-/common-log-format-0.1.4.tgz", - "integrity": "sha512-BXcgq+wzr2htmBmnT7cL7YHzPAWketWbr4kozjoM9kWe4sk3+zMgjcH0HO+EddjDlEw2LZysqLpVRwbF318tDw==", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/common-log-format/-/common-log-format-1.0.0.tgz", + "integrity": "sha512-fFn/WPNbsTCGTTwdCpZfVZSa5mgqMEkA0gMTRApFSlEsYN+9B2FPfiqch5FT+jsv5IV1RHV3GeZvCa7Qg+jssw==", "dev": true }, "commondir": { @@ -3178,14 +2983,6 @@ "dev": true, "requires": { "mime-db": ">= 1.40.0 < 2" - }, - "dependencies": { - "mime-db": { - "version": "1.40.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", - "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==", - "dev": true - } } }, "concat-map": { @@ -3207,9 +3004,9 @@ } }, "concurrently": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-4.1.0.tgz", - "integrity": "sha512-pwzXCE7qtOB346LyO9eFWpkFJVO3JQZ/qU/feGeaAHiX1M3Rw3zgXKc5cZ8vSH5DGygkjzLFDzA/pwoQDkRNGg==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-4.1.1.tgz", + "integrity": "sha512-48+FE5RJ0qc8azwKv4keVQWlni1hZeSjcWr8shBelOBtBHcKj1aJFM9lHRiSc1x7lq416pkvsqfBMhSRja+Lhw==", "dev": true, "requires": { "chalk": "^2.4.1", @@ -3223,197 +3020,29 @@ "yargs": "^12.0.1" }, "dependencies": { - "camelcase": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.0.0.tgz", - "integrity": "sha512-faqwZqnWxbxn+F1d399ygeamQNy3lPp/H9H6rNrqYh4FSVCtcY+3cub1MxA8o9mDd55mM8Aghuu/kuyYA6VTsA==", - "dev": true - }, - "cross-spawn": { - "version": "6.0.5", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", - "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", - "dev": true, - "requires": { - "nice-try": "^1.0.4", - "path-key": "^2.0.1", - "semver": "^5.5.0", - "shebang-command": "^1.2.0", - "which": "^1.2.9" - } - }, - "execa": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz", - "integrity": "sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==", - "dev": true, - "requires": { - "cross-spawn": "^6.0.0", - "get-stream": "^4.0.0", - "is-stream": "^1.1.0", - "npm-run-path": "^2.0.0", - "p-finally": "^1.0.0", - "signal-exit": "^3.0.0", - "strip-eof": "^1.0.0" - } - }, - "find-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", - "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", - "dev": true, - "requires": { - "locate-path": "^3.0.0" - } - }, - "get-stream": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", - "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", - "dev": true, - "requires": { - "pump": "^3.0.0" - } - }, "has-flag": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", "dev": true }, - "invert-kv": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-2.0.0.tgz", - "integrity": "sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA==", - "dev": true - }, - "lcid": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/lcid/-/lcid-2.0.0.tgz", - "integrity": "sha512-avPEb8P8EGnwXKClwsNUgryVjllcRqtMYa49NTsbQagYuT1DcXnl1915oxWjoyGrXR6zH/Y0Zc96xWsPcoDKeA==", - "dev": true, - "requires": { - "invert-kv": "^2.0.0" - } - }, - "locate-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", - "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", - "dev": true, - "requires": { - "p-locate": "^3.0.0", - "path-exists": "^3.0.0" - } - }, - "mem": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/mem/-/mem-4.0.0.tgz", - "integrity": "sha512-WQxG/5xYc3tMbYLXoXPm81ET2WDULiU5FxbuIoNbJqLOOI8zehXFdZuiUEgfdrU2mVB1pxBZUGlYORSrpuJreA==", - "dev": true, - "requires": { - "map-age-cleaner": "^0.1.1", - "mimic-fn": "^1.0.0", - "p-is-promise": "^1.1.0" - } - }, - "os-locale": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-3.1.0.tgz", - "integrity": "sha512-Z8l3R4wYWM40/52Z+S265okfFj8Kt2cC2MKY+xNi3kFs+XGI7WXu/I309QQQYbRW4ijiZ+yxs9pqEhJh0DqW3Q==", + "supports-color": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", "dev": true, "requires": { - "execa": "^1.0.0", - "lcid": "^2.0.0", - "mem": "^4.0.0" - } - }, - "p-limit": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.1.0.tgz", - "integrity": "sha512-NhURkNcrVB+8hNfLuysU8enY5xn2KXphsHBaC2YmRNTZRc7RWusw6apSpdEj3jo4CMb6W9nrF6tTnsJsJeyu6g==", - "dev": true, - "requires": { - "p-try": "^2.0.0" - } - }, - "p-locate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", - "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", - "dev": true, - "requires": { - "p-limit": "^2.0.0" - } - }, - "p-try": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.0.0.tgz", - "integrity": "sha512-hMp0onDKIajHfIkdRk3P4CdCmErkYAxxDtP3Wx/4nZ3aGlau2VKh3mZpcuFkH27WQkL/3WBCPOktzA9ZOAnMQQ==", - "dev": true - }, - "parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", - "dev": true, - "requires": { - "error-ex": "^1.3.1", - "json-parse-better-errors": "^1.0.1" - } - }, - "read-pkg": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-4.0.1.tgz", - "integrity": "sha1-ljYlN48+HE1IyFhytabsfV0JMjc=", - "dev": true, - "requires": { - "normalize-package-data": "^2.3.2", - "parse-json": "^4.0.0", - "pify": "^3.0.0" - } - }, - "supports-color": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", - "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", - "dev": true, - "requires": { - "has-flag": "^2.0.0" - } - }, - "yargs": { - "version": "12.0.5", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-12.0.5.tgz", - "integrity": "sha512-Lhz8TLaYnxq/2ObqHDql8dX8CJi97oHxrjUcYtzKbbykPtVW9WB+poxI+NM2UIzsMgNCZTIf0AQwsjK5yMAqZw==", - "dev": true, - "requires": { - "cliui": "^4.0.0", - "decamelize": "^1.2.0", - "find-up": "^3.0.0", - "get-caller-file": "^1.0.1", - "os-locale": "^3.0.0", - "require-directory": "^2.1.1", - "require-main-filename": "^1.0.1", - "set-blocking": "^2.0.0", - "string-width": "^2.0.0", - "which-module": "^2.0.0", - "y18n": "^3.2.1 || ^4.0.0", - "yargs-parser": "^11.1.1" - } - }, - "yargs-parser": { - "version": "11.1.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-11.1.1.tgz", - "integrity": "sha512-C6kB/WJDiaxONLJQnF8ccx9SEeoTTLek8RVbaOIsrAUS8VrBEXfmeSnCZxygc+XC2sNMBIwOOnfcxiynjHsVSQ==", - "dev": true, - "requires": { - "camelcase": "^5.0.0", - "decamelize": "^1.2.0" + "has-flag": "^2.0.0" } } } }, + "confusing-browser-globals": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/confusing-browser-globals/-/confusing-browser-globals-1.0.7.tgz", + "integrity": "sha512-cgHI1azax5ATrZ8rJ+ODDML9Fvu67PimB6aNxBrc/QwSaDaM9eTfIEUHx3bBLJJ82ioSb+/5zfsMCCEJax3ByQ==", + "dev": true + }, "console-browserify": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz", @@ -3496,34 +3125,34 @@ "dev": true }, "core-js": { - "version": "2.5.7", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.7.tgz", - "integrity": "sha512-RszJCAxg/PP6uzXVXL6BsxSXx/B05oJAQ2vkJRjyjrEcNVycaqOmNb5OTxZPE3xa5gwZduqza6L9JOCenh/Ecw==", + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.9.tgz", + "integrity": "sha512-HOpZf6eXmnl7la+cUdMnLvUxKNqLUzJvgIziQ0DiF3JwSImNphIqdGqzj6hIKyX04MmV0poclQ7+wjWvxQyR2A==", "dev": true }, "core-js-compat": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.1.3.tgz", - "integrity": "sha512-EP018pVhgwsKHz3YoN1hTq49aRe+h017Kjz0NQz3nXV0cCRMvH3fLQl+vEPGr4r4J5sk4sU3tUC7U1aqTCeJeA==", + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.1.4.tgz", + "integrity": "sha512-Z5zbO9f1d0YrJdoaQhphVAnKPimX92D6z8lCGphH89MNRxlL1prI9ExJPqVwP0/kgkQCv8c4GJGT8X16yUncOg==", "dev": true, "requires": { - "browserslist": "^4.6.0", - "core-js-pure": "3.1.3", - "semver": "^6.1.0" + "browserslist": "^4.6.2", + "core-js-pure": "3.1.4", + "semver": "^6.1.1" }, "dependencies": { "semver": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.1.1.tgz", - "integrity": "sha512-rWYq2e5iYW+fFe/oPPtYJxYgjBm8sC4rmoGdUOgBB7VnwKt6HrL793l2voH1UlsyYZpJ4g0wfjnTEO1s1NP2eQ==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.2.0.tgz", + "integrity": "sha512-jdFC1VdUGT/2Scgbimf7FSx9iJLXoqfglSF+gJeuNWVpiE37OIbc1jywR/GJyFdz3mnkz2/id0L0J/cr0izR5A==", "dev": true } } }, "core-js-pure": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.1.3.tgz", - "integrity": "sha512-k3JWTrcQBKqjkjI0bkfXS0lbpWPxYuHWfMMjC1VDmzU4Q58IwSbuXSo99YO/hUHlw/EB4AlfA2PVxOGkrIq6dA==", + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.1.4.tgz", + "integrity": "sha512-uJ4Z7iPNwiu1foygbcZYJsJs1jiXrTTCvxfLDXNhI/I+NHbSIEyr548y4fcsCEyWY0XgfAG/qqaunJ1SThHenA==", "dev": true }, "core-util-is": { @@ -3569,6 +3198,12 @@ "sha.js": "^2.4.8" } }, + "create-mixin": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/create-mixin/-/create-mixin-2.0.1.tgz", + "integrity": "sha512-r11aTk2z5x2C9ZI85oxuZ0EzgjBH0BdGacnXeuA+9d59xV2Hsy+ZpRmU+LUjJT9KdnLgzaxZoCbqrJ5qjl0bAA==", + "dev": true + }, "cross-spawn": { "version": "6.0.5", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", @@ -3602,62 +3237,23 @@ } }, "css-loader": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/css-loader/-/css-loader-2.1.1.tgz", - "integrity": "sha512-OcKJU/lt232vl1P9EEDamhoO9iKY3tIjY5GU+XDLblAykTdgs6Ux9P1hTHve8nFKy5KPpOXOsVI/hIwi3841+w==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/css-loader/-/css-loader-3.0.0.tgz", + "integrity": "sha512-WR6KZuCkFbnMhRrGPlkwAA7SSCtwqPwpyXJAPhotYkYsc0mKU9n/fu5wufy4jl2WhBw9Ia8gUQMIp/1w98DuPw==", "dev": true, "requires": { - "camelcase": "^5.2.0", - "icss-utils": "^4.1.0", + "camelcase": "^5.3.1", + "cssesc": "^3.0.0", + "icss-utils": "^4.1.1", "loader-utils": "^1.2.3", "normalize-path": "^3.0.0", - "postcss": "^7.0.14", + "postcss": "^7.0.17", "postcss-modules-extract-imports": "^2.0.0", - "postcss-modules-local-by-default": "^2.0.6", + "postcss-modules-local-by-default": "^3.0.2", "postcss-modules-scope": "^2.1.0", - "postcss-modules-values": "^2.0.0", - "postcss-value-parser": "^3.3.0", + "postcss-modules-values": "^3.0.0", + "postcss-value-parser": "^4.0.0", "schema-utils": "^1.0.0" - }, - "dependencies": { - "big.js": { - "version": "5.2.2", - "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", - "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==", - "dev": true - }, - "json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", - "dev": true, - "requires": { - "minimist": "^1.2.0" - } - }, - "loader-utils": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.2.3.tgz", - "integrity": "sha512-fkpz8ejdnEMG3s37wGL07iSBDg99O9D5yflE9RGNH3hRdx9SOwYfnGYdZOUIZitN8E+E2vkq3MUMYMvPYl5ZZA==", - "dev": true, - "requires": { - "big.js": "^5.2.2", - "emojis-list": "^2.0.0", - "json5": "^1.0.1" - } - }, - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true - }, - "normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "dev": true - } } }, "css-select": { @@ -3673,9 +3269,9 @@ } }, "css-what": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/css-what/-/css-what-2.1.0.tgz", - "integrity": "sha1-lGfQMsOM+u+58teVASUwYvh/ob0=", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/css-what/-/css-what-2.1.3.tgz", + "integrity": "sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg==", "dev": true }, "cssesc": { @@ -3691,12 +3287,12 @@ "dev": true }, "cssstyle": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-1.2.2.tgz", - "integrity": "sha512-43wY3kl1CVQSvL7wUY1qXkxVGkStjpkDmVjiIKX8R97uhajy8Bybay78uOtqvh7Q5GK75dNPfW0geWjE6qQQow==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-1.3.0.tgz", + "integrity": "sha512-wXsoRfsRfsLVNaVzoKdqvEmK/5PFaEXNspVT22Ots6K/cnJdpoDKuQFw+qlMiXnmaif1OgeC466X1zISgAOcGg==", "dev": true, "requires": { - "cssom": "0.3.x" + "cssom": "~0.3.6" } }, "cyclist": { @@ -3789,20 +3385,13 @@ "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", "dev": true }, - "defer-promise": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/defer-promise/-/defer-promise-1.0.2.tgz", - "integrity": "sha512-5a0iWJvnon50nLLqHPW83pX45BLb4MmlSa1sIg05NBhZoK5EZGz1s8qoZ3888dVGGOT0Ni01NdETuAgdJUZknA==", - "dev": true - }, "define-properties": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.2.tgz", - "integrity": "sha1-g6c/L+pWmJj7c3GTyPhzyvbUXJQ=", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", + "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", "dev": true, "requires": { - "foreach": "^2.0.5", - "object-keys": "^1.0.8" + "object-keys": "^1.0.12" } }, "define-property": { @@ -3925,38 +3514,22 @@ } }, "dom-converter": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/dom-converter/-/dom-converter-0.1.4.tgz", - "integrity": "sha1-pF71cnuJDJv/5tfIduexnLDhfzs=", + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/dom-converter/-/dom-converter-0.2.0.tgz", + "integrity": "sha512-gd3ypIPfOMr9h5jIKq8E3sHOTCjeirnl0WK5ZdS1AW0Odt0b1PaWaHdJ4Qk4klv+YB9aJBS7mESXjFoDQPu6DA==", "dev": true, "requires": { - "utila": "~0.3" - }, - "dependencies": { - "utila": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/utila/-/utila-0.3.3.tgz", - "integrity": "sha1-1+jn1+MJEHCSsF+NloiCTWM6QiY=", - "dev": true - } + "utila": "~0.4" } }, "dom-serializer": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.0.tgz", - "integrity": "sha1-BzxpdUbOB4DOI75KKOKT5AvDDII=", + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-0.1.1.tgz", + "integrity": "sha512-l0IU0pPzLWSHBcieZbpOKgkIn3ts3vAh7ZuFyXNwJxJXk/c4Gwj9xaTJwIDVQCXawWD0qb3IzMGH5rglQaO0XA==", "dev": true, "requires": { - "domelementtype": "~1.1.1", - "entities": "~1.1.1" - }, - "dependencies": { - "domelementtype": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.1.3.tgz", - "integrity": "sha1-vSh3PiZCiBrsUVRJJCmcXNgiGFs=", - "dev": true - } + "domelementtype": "^1.3.0", + "entities": "^1.1.1" } }, "domain-browser": { @@ -3966,9 +3539,9 @@ "dev": true }, "domelementtype": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.0.tgz", - "integrity": "sha1-sXrtguirWeUt2cGbF1bg/BhyBMI=", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.1.tgz", + "integrity": "sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w==", "dev": true }, "domexception": { @@ -3981,9 +3554,9 @@ } }, "domhandler": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.1.0.tgz", - "integrity": "sha1-0mRvXlf2w7qxHPbLBdPArPdBJZQ=", + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-2.4.2.tgz", + "integrity": "sha512-JiK04h0Ht5u/80fdLMCEmV4zkNh2BcoMFBmZ/91WtYZ8qVXSKjiw7fXMgFPnHcSZgOo3XdinHvmnDUeMf5R4wA==", "dev": true, "requires": { "domelementtype": "1" @@ -4057,15 +3630,15 @@ "dev": true }, "electron-to-chromium": { - "version": "1.3.146", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.146.tgz", - "integrity": "sha512-BrUq08sx7eR4PCwLbjFxXmjcbDro6DSoc1pN8VCxq76U+o9JQzJlWH/NVtcpAqcktwpE5CVvMyqHqTQfCETNoQ==", + "version": "1.3.183", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.183.tgz", + "integrity": "sha512-WbKCYs7yAFOfpuoa2pK5kbOngriUtlPC+8mcQW5L/686wv04w7hYXfw5ScDrsl9kixFw1SPsALEob5V/gtlDxw==", "dev": true }, "elliptic": { - "version": "6.4.1", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.1.tgz", - "integrity": "sha512-BsXLz5sqX8OHcsh7CqBMztyXARmGQ3LWPtGjJi6DiJHq5C/qvi9P3OqgswKSDftbu8+IoI/QDTAm2fFnQ9SZSQ==", + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.0.tgz", + "integrity": "sha512-eFOJTMyCYb7xtE/caJ6JJu+bhi67WCYNbkGSknu20pmM8Ke/bqOfdnZWxyoGN26JgfxTbXrsCkEw4KheCT/KGg==", "dev": true, "requires": { "bn.js": "^4.4.0", @@ -4110,9 +3683,9 @@ } }, "entities": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.1.tgz", - "integrity": "sha1-blwtClYhtdra7O+AuQ7ftc13cvA=", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz", + "integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==", "dev": true }, "errno": { @@ -4140,27 +3713,28 @@ "dev": true }, "es-abstract": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.12.0.tgz", - "integrity": "sha512-C8Fx/0jFmV5IPoMOFPA9P9G5NtqW+4cOPit3MIuvR2t7Ag2K15EJTpxnHAYTzL+aYQJIESYeXZmDBfOBE1HcpA==", + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.13.0.tgz", + "integrity": "sha512-vDZfg/ykNxQVwup/8E1BZhVzFfBxs9NqMzGcvIJrqg5k2/5Za2bWo40dK2J1pgLngZ7c+Shh8lwYtLGyrwPutg==", "dev": true, "requires": { - "es-to-primitive": "^1.1.1", + "es-to-primitive": "^1.2.0", "function-bind": "^1.1.1", - "has": "^1.0.1", - "is-callable": "^1.1.3", - "is-regex": "^1.0.4" + "has": "^1.0.3", + "is-callable": "^1.1.4", + "is-regex": "^1.0.4", + "object-keys": "^1.0.12" } }, "es-to-primitive": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.1.1.tgz", - "integrity": "sha1-RTVSSKiJeQNLZ5Lhm7gfK3l13Q0=", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.0.tgz", + "integrity": "sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg==", "dev": true, "requires": { - "is-callable": "^1.1.1", + "is-callable": "^1.1.4", "is-date-object": "^1.0.1", - "is-symbol": "^1.0.1" + "is-symbol": "^1.0.2" } }, "escape-html": { @@ -4204,13 +3778,13 @@ } }, "eslint": { - "version": "5.16.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.16.0.tgz", - "integrity": "sha512-S3Rz11i7c8AA5JPv7xAH+dOyq/Cu/VXHiHXBPOU1k/JAM5dXqQPt3qcrhpHSorXmrpu2g0gkIBVXAqCpzfoZIg==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.0.1.tgz", + "integrity": "sha512-DyQRaMmORQ+JsWShYsSg4OPTjY56u1nCjAmICrE8vLWqyLKxhFXOthwMj1SA8xwfrv0CofLNVnqbfyhwCkaO0w==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", - "ajv": "^6.9.1", + "ajv": "^6.10.0", "chalk": "^2.1.0", "cross-spawn": "^6.0.5", "debug": "^4.0.1", @@ -4218,18 +3792,19 @@ "eslint-scope": "^4.0.3", "eslint-utils": "^1.3.1", "eslint-visitor-keys": "^1.0.0", - "espree": "^5.0.1", + "espree": "^6.0.0", "esquery": "^1.0.1", "esutils": "^2.0.2", "file-entry-cache": "^5.0.1", "functional-red-black-tree": "^1.0.1", - "glob": "^7.1.2", + "glob-parent": "^3.1.0", "globals": "^11.7.0", "ignore": "^4.0.6", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", "inquirer": "^6.2.2", - "js-yaml": "^3.13.0", + "is-glob": "^4.0.0", + "js-yaml": "^3.13.1", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.3.0", "lodash": "^4.17.11", @@ -4237,7 +3812,6 @@ "mkdirp": "^0.5.1", "natural-compare": "^1.4.0", "optionator": "^0.8.2", - "path-is-inside": "^1.0.2", "progress": "^2.0.0", "regexpp": "^2.0.1", "semver": "^5.5.1", @@ -4247,12 +3821,6 @@ "text-table": "^0.2.0" }, "dependencies": { - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true - }, "debug": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", @@ -4263,37 +3831,22 @@ } }, "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", - "dev": true - }, - "semver": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", - "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "dev": true, - "requires": { - "ansi-regex": "^3.0.0" - } } } }, "eslint-config-airbnb-base": { - "version": "13.1.0", - "resolved": "https://registry.npmjs.org/eslint-config-airbnb-base/-/eslint-config-airbnb-base-13.1.0.tgz", - "integrity": "sha512-XWwQtf3U3zIoKO1BbHh6aUhJZQweOwSt4c2JrPDg9FP3Ltv3+YfEv7jIDB8275tVnO/qOHbfuYg3kzw6Je7uWw==", + "version": "13.2.0", + "resolved": "https://registry.npmjs.org/eslint-config-airbnb-base/-/eslint-config-airbnb-base-13.2.0.tgz", + "integrity": "sha512-1mg/7eoB4AUeB0X1c/ho4vb2gYkNH8Trr/EgCT/aGmKhhG+F6vF5s8+iRBlWAzFIAphxIdp3YfEKgEl0f9Xg+w==", "dev": true, "requires": { - "eslint-restricted-globals": "^0.1.1", + "confusing-browser-globals": "^1.0.5", "object.assign": "^4.1.0", - "object.entries": "^1.0.4" + "object.entries": "^1.1.0" } }, "eslint-import-resolver-node": { @@ -4332,12 +3885,66 @@ "requires": { "debug": "^2.6.8", "pkg-dir": "^2.0.0" + }, + "dependencies": { + "find-up": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", + "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "dev": true, + "requires": { + "locate-path": "^2.0.0" + } + }, + "locate-path": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", + "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", + "dev": true, + "requires": { + "p-locate": "^2.0.0", + "path-exists": "^3.0.0" + } + }, + "p-limit": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", + "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", + "dev": true, + "requires": { + "p-try": "^1.0.0" + } + }, + "p-locate": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", + "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", + "dev": true, + "requires": { + "p-limit": "^1.1.0" + } + }, + "p-try": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", + "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", + "dev": true + }, + "pkg-dir": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-2.0.0.tgz", + "integrity": "sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s=", + "dev": true, + "requires": { + "find-up": "^2.1.0" + } + } } }, "eslint-plugin-import": { - "version": "2.17.3", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.17.3.tgz", - "integrity": "sha512-qeVf/UwXFJbeyLbxuY8RgqDyEKCkqV7YC+E5S5uOjAp4tOc8zj01JP3ucoBM8JcEqd1qRasJSg6LLlisirfy0Q==", + "version": "2.18.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.18.0.tgz", + "integrity": "sha512-PZpAEC4gj/6DEMMoU2Df01C5c50r7zdGIN52Yfi7CvvWaYssG7Jt5R9nFG5gmqodxNOz9vQS87xk6Izdtpdrig==", "dev": true, "requires": { "array-includes": "^3.0.3", @@ -4365,12 +3972,6 @@ } } }, - "eslint-restricted-globals": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/eslint-restricted-globals/-/eslint-restricted-globals-0.1.1.tgz", - "integrity": "sha1-NfDVy8ZMLj7WLpO0saevBbp+1Nc=", - "dev": true - }, "eslint-scope": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.3.tgz", @@ -4394,9 +3995,9 @@ "dev": true }, "espree": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-5.0.1.tgz", - "integrity": "sha512-qWAZcWh4XE/RwzLJejfcofscgMc9CamR6Tn1+XRXNzrvUSSbiAjGOI/fggztjIi7y9VLPqnICMIPiGyr8JaZ0A==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-6.0.0.tgz", + "integrity": "sha512-lJvCS6YbCn3ImT3yKkPe0+tJ+mH6ljhGNjHQH9mRtiO6gjhVAOhVXW1yjnwqGwTkK3bGbye+hb00nFNmu0l/1Q==", "dev": true, "requires": { "acorn": "^6.0.7", @@ -4720,40 +4321,6 @@ "requires": { "loader-utils": "^1.2.2", "schema-utils": "^1.0.0" - }, - "dependencies": { - "big.js": { - "version": "5.2.2", - "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", - "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==", - "dev": true - }, - "json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", - "dev": true, - "requires": { - "minimist": "^1.2.0" - } - }, - "loader-utils": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.2.3.tgz", - "integrity": "sha512-fkpz8ejdnEMG3s37wGL07iSBDg99O9D5yflE9RGNH3hRdx9SOwYfnGYdZOUIZitN8E+E2vkq3MUMYMvPYl5ZZA==", - "dev": true, - "requires": { - "big.js": "^5.2.2", - "emojis-list": "^2.0.0", - "json5": "^1.0.1" - } - }, - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true - } } }, "fill-range": { @@ -4780,68 +4347,14 @@ } }, "find-cache-dir": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-2.0.0.tgz", - "integrity": "sha512-LDUY6V1Xs5eFskUVYtIwatojt6+9xC9Chnlk/jYOOvn3FAFfSaWddxahDGyNHh0b2dMXa6YW2m0tk8TdVaXHlA==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-2.1.0.tgz", + "integrity": "sha512-Tq6PixE0w/VMFfCgbONnkiQIVol/JJL7nRMi20fqzA4NRs9AfeqMGeRdPi3wIhYkxjeBaWh2rxwapn5Tu3IqOQ==", "dev": true, "requires": { "commondir": "^1.0.1", - "make-dir": "^1.0.0", + "make-dir": "^2.0.0", "pkg-dir": "^3.0.0" - }, - "dependencies": { - "find-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", - "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", - "dev": true, - "requires": { - "locate-path": "^3.0.0" - } - }, - "locate-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", - "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", - "dev": true, - "requires": { - "p-locate": "^3.0.0", - "path-exists": "^3.0.0" - } - }, - "p-limit": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.1.0.tgz", - "integrity": "sha512-NhURkNcrVB+8hNfLuysU8enY5xn2KXphsHBaC2YmRNTZRc7RWusw6apSpdEj3jo4CMb6W9nrF6tTnsJsJeyu6g==", - "dev": true, - "requires": { - "p-try": "^2.0.0" - } - }, - "p-locate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", - "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", - "dev": true, - "requires": { - "p-limit": "^2.0.0" - } - }, - "p-try": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.0.0.tgz", - "integrity": "sha512-hMp0onDKIajHfIkdRk3P4CdCmErkYAxxDtP3Wx/4nZ3aGlau2VKh3mZpcuFkH27WQkL/3WBCPOktzA9ZOAnMQQ==", - "dev": true - }, - "pkg-dir": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-3.0.0.tgz", - "integrity": "sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw==", - "dev": true, - "requires": { - "find-up": "^3.0.0" - } - } } }, "find-replace": { @@ -4860,35 +4373,24 @@ "dev": true }, "find-up": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", - "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", "dev": true, "requires": { - "locate-path": "^2.0.0" + "locate-path": "^3.0.0" } }, "findup-sync": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-2.0.0.tgz", - "integrity": "sha1-kyaxSIwi0aYIhlCoaQGy2akKLLw=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-3.0.0.tgz", + "integrity": "sha512-YbffarhcicEhOrm4CtrwdKBdCuz576RLdhJDsIfvNtxUuhdRet1qZcsMjqbePtAseKdAnDyM/IyXbu7PRPRLYg==", "dev": true, "requires": { "detect-file": "^1.0.0", - "is-glob": "^3.1.0", + "is-glob": "^4.0.0", "micromatch": "^3.0.4", "resolve-dir": "^1.0.1" - }, - "dependencies": { - "is-glob": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", - "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", - "dev": true, - "requires": { - "is-extglob": "^2.1.0" - } - } } }, "flat-cache": { @@ -4900,37 +4402,12 @@ "flatted": "^2.0.0", "rimraf": "2.6.3", "write": "1.0.3" - }, - "dependencies": { - "glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "rimraf": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", - "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", - "dev": true, - "requires": { - "glob": "^7.1.3" - } - } } }, "flatted": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.0.tgz", - "integrity": "sha512-R+H8IZclI8AAkSBRQJLVOsxwAoHd6WC40b4QTNWIjzAa6BXOBfQcM587MXDTVPeYaopFNWHUFLx7eNmHDSxMWg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.1.tgz", + "integrity": "sha512-a1hQMktqW9Nmqr5aktAux3JMNqaucxGcjtjWnZLHX7yyPCmlSV3M54nGYbqT8K+0GhF3NBgmJCc3ma+WOgX8Jg==", "dev": true }, "flush-write-stream": { @@ -4949,12 +4426,6 @@ "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", "dev": true }, - "foreach": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz", - "integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=", - "dev": true - }, "forever-agent": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", @@ -4997,6 +4468,17 @@ "readable-stream": "^2.0.0" } }, + "fs-extra": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", + "integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, "fs-readdir-recursive": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/fs-readdir-recursive/-/fs-readdir-recursive-1.1.0.tgz", @@ -5612,9 +5094,9 @@ } }, "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", + "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", "dev": true, "requires": { "fs.realpath": "^1.0.0", @@ -5647,14 +5129,25 @@ } }, "global-modules": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz", - "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-2.0.0.tgz", + "integrity": "sha512-NGbfmJBp9x8IxyJSd1P+otYK8vonoJactOogrVfFRIAEY1ukil8RSKDz2Yo7wh1oihl51l/r6W4epkeKJHqL8A==", "dev": true, "requires": { - "global-prefix": "^1.0.1", - "is-windows": "^1.0.1", - "resolve-dir": "^1.0.0" + "global-prefix": "^3.0.0" + }, + "dependencies": { + "global-prefix": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-3.0.0.tgz", + "integrity": "sha512-awConJSVCHVGND6x3tmMaKcQvwXLhjdkmomy2W+Goaui8YPgYgXJZewhg3fWC+DlfqqQuWg8AwqjGTD2nAPVWg==", + "dev": true, + "requires": { + "ini": "^1.3.5", + "kind-of": "^6.0.2", + "which": "^1.3.1" + } + } } }, "global-prefix": { @@ -5677,9 +5170,9 @@ "dev": true }, "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.0.tgz", + "integrity": "sha512-jpSvDPV4Cq/bgtpndIWbI5hmYxhQGHPC4d4cqBPb4DLniCfhJokdXhwhaDuLBGLQdvvRum/UiX6ECVIPvDXqdg==", "dev": true }, "growly": { @@ -5745,78 +5238,10 @@ "write-json-file": "^2.3.0" }, "dependencies": { - "find-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", - "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", - "dev": true, - "requires": { - "locate-path": "^3.0.0" - } - }, - "locate-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", - "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", - "dev": true, - "requires": { - "p-locate": "^3.0.0", - "path-exists": "^3.0.0" - } - }, - "p-limit": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.1.0.tgz", - "integrity": "sha512-NhURkNcrVB+8hNfLuysU8enY5xn2KXphsHBaC2YmRNTZRc7RWusw6apSpdEj3jo4CMb6W9nrF6tTnsJsJeyu6g==", - "dev": true, - "requires": { - "p-try": "^2.0.0" - } - }, - "p-locate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", - "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", - "dev": true, - "requires": { - "p-limit": "^2.0.0" - } - }, - "p-try": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.0.0.tgz", - "integrity": "sha512-hMp0onDKIajHfIkdRk3P4CdCmErkYAxxDtP3Wx/4nZ3aGlau2VKh3mZpcuFkH27WQkL/3WBCPOktzA9ZOAnMQQ==", - "dev": true - }, - "parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", - "dev": true, - "requires": { - "error-ex": "^1.3.1", - "json-parse-better-errors": "^1.0.1" - } - }, - "pkg-dir": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-3.0.0.tgz", - "integrity": "sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw==", - "dev": true, - "requires": { - "find-up": "^3.0.0" - } - }, - "semver": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", - "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", - "dev": true - }, "tapable": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/tapable/-/tapable-1.1.1.tgz", - "integrity": "sha512-9I2ydhj8Z9veORCw5PRm4u9uebCn0mcCa6scWoNcbZ6dAtoo2618u9UUzxgmsCOreJpqDDuv61LvwofW7hLcBA==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-1.1.3.tgz", + "integrity": "sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA==", "dev": true } } @@ -5895,9 +5320,9 @@ } }, "he": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", - "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", "dev": true }, "hmac-drbg": { @@ -5936,41 +5361,31 @@ } }, "html-minifier": { - "version": "3.5.20", - "resolved": "https://registry.npmjs.org/html-minifier/-/html-minifier-3.5.20.tgz", - "integrity": "sha512-ZmgNLaTp54+HFKkONyLFEfs5dd/ZOtlquKaTnqIWFmx3Av5zG6ZPcV2d0o9XM2fXOTxxIf6eDcwzFFotke/5zA==", + "version": "3.5.21", + "resolved": "https://registry.npmjs.org/html-minifier/-/html-minifier-3.5.21.tgz", + "integrity": "sha512-LKUKwuJDhxNa3uf/LPR/KVjm/l3rBqtYeCOAekvG8F1vItxMUpueGd94i/asDDr8/1u7InxzFA5EeGjhhG5mMA==", "dev": true, "requires": { "camel-case": "3.0.x", "clean-css": "4.2.x", "commander": "2.17.x", - "he": "1.1.x", + "he": "1.2.x", "param-case": "2.1.x", "relateurl": "0.2.x", "uglify-js": "3.4.x" }, "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "commander": { + "version": "2.17.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.17.1.tgz", + "integrity": "sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==", "dev": true - }, - "uglify-js": { - "version": "3.4.9", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.9.tgz", - "integrity": "sha512-8CJsbKOtEbnJsTyv6LE6m6ZKniqMiFWmm9sRbopbkGs3gMPPfd3Fh8iIA4Ykv5MgaTbqHr4BaoGLJLZNhsrW1Q==", - "dev": true, - "requires": { - "commander": "~2.17.1", - "source-map": "~0.6.1" - } } } }, "html-webpack-plugin": { "version": "3.2.0", - "resolved": "http://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-3.2.0.tgz", + "resolved": "https://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-3.2.0.tgz", "integrity": "sha1-sBq71yOsqqeze2r0SS69oD2d03s=", "dev": true, "requires": { @@ -5983,6 +5398,18 @@ "util.promisify": "1.0.0" }, "dependencies": { + "big.js": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/big.js/-/big.js-3.2.0.tgz", + "integrity": "sha512-+hN/Zh2D08Mx65pZ/4g5bsmNiZUuChDiQfTUQ7qJr4/kuopCr88xZsAXv6mBoZEsUI4OuGHlX59qE94K2mMW8Q==", + "dev": true + }, + "json5": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", + "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=", + "dev": true + }, "loader-utils": { "version": "0.2.17", "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-0.2.17.tgz", @@ -5996,57 +5423,37 @@ } }, "tapable": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/tapable/-/tapable-1.0.0.tgz", - "integrity": "sha512-dQRhbNQkRnaqauC7WqSJ21EEksgT0fYZX2lqXzGkpo8JNig9zGZTYoMGvyI2nWmXlE2VSVXVDu7wLVGu/mQEsg==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-1.1.3.tgz", + "integrity": "sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA==", "dev": true } } }, "htmlparser2": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.3.0.tgz", - "integrity": "sha1-zHDQWln2VC5D8OaFyYLhTJJKnv4=", + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.10.1.tgz", + "integrity": "sha512-IgieNijUMbkDovyoKObU1DUhm1iwNYE/fuifEoEHfd1oZKZDaONBSkal7Y01shxsM49R4XaMdGez3WnF9UfiCQ==", "dev": true, "requires": { - "domelementtype": "1", - "domhandler": "2.1", - "domutils": "1.1", - "readable-stream": "1.0" + "domelementtype": "^1.3.1", + "domhandler": "^2.3.0", + "domutils": "^1.5.1", + "entities": "^1.1.1", + "inherits": "^2.0.1", + "readable-stream": "^3.1.1" }, "dependencies": { - "domutils": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.1.6.tgz", - "integrity": "sha1-vdw94Jm5ou+sxRxiPyj0FuzFdIU=", - "dev": true, - "requires": { - "domelementtype": "1" - } - }, - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, "readable-stream": { - "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.4.0.tgz", + "integrity": "sha512-jItXPLmrSR8jmTRmRWJXCnGJsfy85mB3Wd/uINMXA65yrnFo0cPClFIUWzo2najVNSl+mx7/4W8ttlLWJe99pQ==", "dev": true, "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true } } }, @@ -6061,13 +5468,13 @@ } }, "http-errors": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", - "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.3.tgz", + "integrity": "sha512-ZTTX0MWrsQ2ZAhA1cejAwDLycFsd7I7nVtnkT3Ol0aqodaKW+0CTZDQ1uBv5whptCnc8e8HeRRJxRs0kmm/Qfw==", "dev": true, "requires": { "depd": "~1.1.2", - "inherits": "2.0.3", + "inherits": "2.0.4", "setprototypeof": "1.1.1", "statuses": ">= 1.5.0 < 2", "toidentifier": "1.0.0" @@ -6099,16 +5506,10 @@ "safer-buffer": ">= 2.1.2 < 3" } }, - "icss-replace-symbols": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/icss-replace-symbols/-/icss-replace-symbols-1.1.0.tgz", - "integrity": "sha1-Bupvg2ead0njhs/h/oEq5dsiPe0=", - "dev": true - }, "icss-utils": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/icss-utils/-/icss-utils-4.1.0.tgz", - "integrity": "sha512-3DEun4VOeMvSczifM3F2cKQrDQ5Pj6WKhkOq6HD4QTnDUAq8MQRxy5TX6Sy1iY6WPBe4gQ3p5vTECjbIkglkkQ==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/icss-utils/-/icss-utils-4.1.1.tgz", + "integrity": "sha512-4aFq7wvWyMHKgxsH8QQtGpvbASCf+eM3wPRLI6R+MgAnTCZ6STYsRvttLvRWK0Nfif5piF394St3HeJDaljGPA==", "dev": true, "requires": { "postcss": "^7.0.14" @@ -6138,9 +5539,9 @@ "integrity": "sha1-nbHb0Pr43m++D13V5Wu2BigN5ps=" }, "import-fresh": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.0.0.tgz", - "integrity": "sha512-pOnA9tfM3Uwics+SaBLCNyZZZbK+4PTu0OPZtLlMIrv17EdBoC15S9Kn8ckJ9TZTyKb3ywNE5y1yeDxxGA7nTQ==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.1.0.tgz", + "integrity": "sha512-PpuksHKGt8rXfWEr9m9EHIpgyyaltBy8+eF6GJM0QCAxMgxCfucMF3mjecK2QsJr0amJW7gTqh5/wht0z2UhEQ==", "dev": true, "requires": { "parent-module": "^1.0.0", @@ -6155,60 +5556,6 @@ "requires": { "pkg-dir": "^3.0.0", "resolve-cwd": "^2.0.0" - }, - "dependencies": { - "find-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", - "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", - "dev": true, - "requires": { - "locate-path": "^3.0.0" - } - }, - "locate-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", - "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", - "dev": true, - "requires": { - "p-locate": "^3.0.0", - "path-exists": "^3.0.0" - } - }, - "p-limit": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.0.tgz", - "integrity": "sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ==", - "dev": true, - "requires": { - "p-try": "^2.0.0" - } - }, - "p-locate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", - "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", - "dev": true, - "requires": { - "p-limit": "^2.0.0" - } - }, - "p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true - }, - "pkg-dir": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-3.0.0.tgz", - "integrity": "sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw==", - "dev": true, - "requires": { - "find-up": "^3.0.0" - } - } } }, "imurmurhash": { @@ -6223,12 +5570,6 @@ "integrity": "sha1-8w9xbI4r00bHtn0985FVZqfAVgc=", "dev": true }, - "indexof": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz", - "integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=", - "dev": true - }, "inflation": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/inflation/-/inflation-2.0.0.tgz", @@ -6246,9 +5587,9 @@ } }, "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, "ini": { @@ -6258,9 +5599,9 @@ "dev": true }, "inquirer": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.3.1.tgz", - "integrity": "sha512-MmL624rfkFt4TG9y/Jvmt8vdmOo836U7Y0Hxr2aFk3RelZEGX4Igk0KabWrcaaZaTv9uzglOqWh1Vly+FAWAXA==", + "version": "6.4.1", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.4.1.tgz", + "integrity": "sha512-/Jw+qPZx4EDYsaT6uz7F4GJRNFMRdKNeUZw3ZnKV8lyuUgz/YWRCSUAJMZSVhSq4Ec0R2oYnyi6b3d4JXcL5Nw==", "dev": true, "requires": { "ansi-escapes": "^3.2.0", @@ -6284,26 +5625,6 @@ "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", "dev": true }, - "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" - } - }, - "rxjs": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.2.tgz", - "integrity": "sha512-HUb7j3kvb7p7eCUHE3FqjoDsC1xfZQ4AHFWfTKSpZ+sAhhz5X1WX0ZuUqWbzB2QhSLp3DoLUG+hMdEDKqWo2Zg==", - "dev": true, - "requires": { - "tslib": "^1.9.0" - } - }, "strip-ansi": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", @@ -6377,15 +5698,6 @@ "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, - "is-builtin-module": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", - "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", - "dev": true, - "requires": { - "builtin-modules": "^1.0.0" - } - }, "is-callable": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz", @@ -6542,10 +5854,13 @@ "dev": true }, "is-symbol": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.1.tgz", - "integrity": "sha1-PMWfAAJRlLarLjjbrmaJJWtmBXI=", - "dev": true + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.2.tgz", + "integrity": "sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw==", + "dev": true, + "requires": { + "has-symbols": "^1.0.0" + } }, "is-typedarray": { "version": "1.0.0", @@ -6578,9 +5893,9 @@ "dev": true }, "ismobilejs": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/ismobilejs/-/ismobilejs-0.5.1.tgz", - "integrity": "sha512-QX4STsOcBYqlTjVGuAdP1MiRVxtiUbRHOKH0v7Gn1EvfUVIQnrSdgCM4zB4VCZuIejnb2NUMUx0Bwd3EIG6yyA==" + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/ismobilejs/-/ismobilejs-0.5.2.tgz", + "integrity": "sha512-ta9UdV60xVZk/ZafFtSFslQaE76SvNkcs1r73d2PVR21zVzx9xuYv9tNe4MxA1NN7WoeCc2RjGot3Bz1eHDx3Q==" }, "isobject": { "version": "3.0.1", @@ -6616,9 +5931,9 @@ }, "dependencies": { "semver": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.1.1.tgz", - "integrity": "sha512-rWYq2e5iYW+fFe/oPPtYJxYgjBm8sC4rmoGdUOgBB7VnwKt6HrL793l2voH1UlsyYZpJ4g0wfjnTEO1s1NP2eQ==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.2.0.tgz", + "integrity": "sha512-jdFC1VdUGT/2Scgbimf7FSx9iJLXoqfglSF+gJeuNWVpiE37OIbc1jywR/GJyFdz3mnkz2/id0L0J/cr0izR5A==", "dev": true } } @@ -6634,28 +5949,6 @@ "supports-color": "^6.1.0" }, "dependencies": { - "make-dir": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz", - "integrity": "sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==", - "dev": true, - "requires": { - "pify": "^4.0.1", - "semver": "^5.6.0" - } - }, - "pify": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", - "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", - "dev": true - }, - "semver": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", - "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==", - "dev": true - }, "supports-color": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.1.0.tgz", @@ -6689,61 +5982,16 @@ "ms": "^2.1.1" } }, - "glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "make-dir": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz", - "integrity": "sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==", - "dev": true, - "requires": { - "pify": "^4.0.1", - "semver": "^5.6.0" - } - }, "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, - "pify": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", - "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", - "dev": true - }, - "rimraf": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", - "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", - "dev": true, - "requires": { - "glob": "^7.1.3" - } - }, - "semver": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", - "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==", - "dev": true - }, - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true } } @@ -6894,9 +6142,9 @@ "dev": true }, "jest-haste-map": { - "version": "24.8.0", - "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-24.8.0.tgz", - "integrity": "sha512-ZBPRGHdPt1rHajWelXdqygIDpJx8u3xOoLyUBWRW28r3tagrgoepPrzAozW7kW9HrQfhvmiv1tncsxqHJO1onQ==", + "version": "24.8.1", + "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-24.8.1.tgz", + "integrity": "sha512-SwaxMGVdAZk3ernAx2Uv2sorA7jm3Kx+lR0grp6rMmnY06Kn/urtKx1LPN2mGTea4fCT38impYT28FfcLUhX0g==", "dev": true, "requires": { "@jest/types": "^24.8.0", @@ -6911,14 +6159,6 @@ "micromatch": "^3.1.10", "sane": "^4.0.3", "walker": "^1.0.7" - }, - "dependencies": { - "graceful-fs": { - "version": "4.1.15", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", - "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==", - "dev": true - } } }, "jest-jasmine2": { @@ -7052,25 +6292,6 @@ "jest-worker": "^24.6.0", "source-map-support": "^0.5.6", "throat": "^4.0.0" - }, - "dependencies": { - "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" - } - }, - "graceful-fs": { - "version": "4.1.15", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", - "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==", - "dev": true - } } }, "jest-runtime": { @@ -7102,28 +6323,6 @@ "slash": "^2.0.0", "strip-bom": "^3.0.0", "yargs": "^12.0.2" - }, - "dependencies": { - "glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "graceful-fs": { - "version": "4.1.15", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", - "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==", - "dev": true - } } }, "jest-serializer": { @@ -7172,12 +6371,6 @@ "source-map": "^0.6.0" }, "dependencies": { - "graceful-fs": { - "version": "4.1.15", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", - "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==", - "dev": true - }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -7348,10 +6541,21 @@ "dev": true }, "json5": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", - "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=", - "dev": true + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.0.tgz", + "integrity": "sha512-8Mh9h6xViijj36g7Dxi+Y4S6hNGV96vcJZr/SrlHh1LR/pEn/8j/+qIBbs44YKl69Lrfctp4QD+AdWLTMqEZAQ==", + "dev": true, + "requires": { + "minimist": "^1.2.0" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true + } + } }, "jsonfile": { "version": "4.0.0", @@ -7458,23 +6662,15 @@ "dev": true }, "koa-compress": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/koa-compress/-/koa-compress-2.0.0.tgz", - "integrity": "sha1-e36ykhuEd0a14SK6n1zYpnHo6jo=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/koa-compress/-/koa-compress-3.0.0.tgz", + "integrity": "sha512-xol+LkNB1mozKJkB5Kj6nYXbJXhkLkZlXl9BsGBPjujVfZ8MsIXwU4GHRTT7TlSfUcl2DU3JtC+j6wOWcovfuQ==", "dev": true, "requires": { - "bytes": "^2.3.0", + "bytes": "^3.0.0", "compressible": "^2.0.0", "koa-is-json": "^1.0.0", "statuses": "^1.0.0" - }, - "dependencies": { - "bytes": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-2.5.0.tgz", - "integrity": "sha1-TJQj6i0lLCcMQbK97+/5u2tiwGo=", - "dev": true - } } }, "koa-conditional-get": { @@ -7530,49 +6726,6 @@ "streaming-json-stringify": "3" } }, - "koa-mock-response": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/koa-mock-response/-/koa-mock-response-0.2.0.tgz", - "integrity": "sha512-HmybRN1a3WqcSFvf7tycu2YhBIEHeqzm8bwcsShNWGsTgP86coZOpdI8aqYm/1DFsAQMctnpdWrva4rDr1Pibg==", - "dev": true, - "requires": { - "array-back": "^2.0.0", - "path-to-regexp": "^1.7.0", - "typical": "^2.6.1" - }, - "dependencies": { - "array-back": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/array-back/-/array-back-2.0.0.tgz", - "integrity": "sha512-eJv4pLLufP3g5kcZry0j6WXpIbzYw9GUB4mVJZno9wfwiBxbizTnHCw3VJb07cBihbFX48Y7oSrW9y+gt4glyw==", - "dev": true, - "requires": { - "typical": "^2.6.1" - } - }, - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "path-to-regexp": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.7.0.tgz", - "integrity": "sha1-Wf3g9DW62suhA6hOnTvGTpa5k30=", - "dev": true, - "requires": { - "isarray": "0.0.1" - } - }, - "typical": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/typical/-/typical-2.6.1.tgz", - "integrity": "sha1-XAgOXWYcu+OCWdLnCjxyU+hziB0=", - "dev": true - } - } - }, "koa-morgan": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/koa-morgan/-/koa-morgan-1.0.1.tgz", @@ -7592,28 +6745,19 @@ } }, "koa-rewrite-75lb": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/koa-rewrite-75lb/-/koa-rewrite-75lb-2.1.1.tgz", - "integrity": "sha512-i9ofDKLs0xNCb2PW7wKGFzBFX6+Ce3aKoZzNKPh0fkejeUOTWkkDqnjXrgqrJEP2ifX6WWsHp6VtGuXzSYLSWQ==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/koa-rewrite-75lb/-/koa-rewrite-75lb-3.0.1.tgz", + "integrity": "sha512-4sTmiYbUheh4X0xSPEcxSiNYkDbHiR62zCcibmISfMhtyjoLaqjvN99KnIA825Tw7HgN47Yta7dQA5h6Koom6A==", "dev": true, "requires": { - "path-to-regexp": "1.7.0" + "path-to-regexp": "^2.1.0" }, "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, "path-to-regexp": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.7.0.tgz", - "integrity": "sha1-Wf3g9DW62suhA6hOnTvGTpa5k30=", - "dev": true, - "requires": { - "isarray": "0.0.1" - } + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-2.4.0.tgz", + "integrity": "sha512-G6zHoVqC6GGTQkZwF4lkuEyMbVOjoBKAEybQUypI1WTkqinCOrq2x6U2+phkJ1XsEMTy4LjtwPI7HW+NVrRR2w==", + "dev": true } } }, @@ -7646,25 +6790,42 @@ } }, "koa-send": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/koa-send/-/koa-send-4.1.3.tgz", - "integrity": "sha512-3UetMBdaXSiw24qM2Mx5mKmxLKw5ZTPRjACjfhK6Haca55RKm9hr/uHDrkrxhSl5/S1CKI/RivZVIopiatZuTA==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/koa-send/-/koa-send-5.0.0.tgz", + "integrity": "sha512-90ZotV7t0p3uN9sRwW2D484rAaKIsD8tAVtypw/aBU+ryfV+fR2xrcAwhI8Wl6WRkojLUs/cB9SBSCuIb+IanQ==", "dev": true, "requires": { - "debug": "^2.6.3", - "http-errors": "^1.6.1", - "mz": "^2.6.0", + "debug": "^3.1.0", + "http-errors": "^1.6.3", + "mz": "^2.7.0", "resolve-path": "^1.4.0" + }, + "dependencies": { + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + } } }, "koa-static": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/koa-static/-/koa-static-4.0.3.tgz", - "integrity": "sha512-JGmxTuPWy4bH7bt6gD/OMWkhprawvRmzJSr8TWKmTL4N7+IMv3s0SedeQi5S4ilxM9Bo6ptkCyXj/7wf+VS5tg==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/koa-static/-/koa-static-5.0.0.tgz", + "integrity": "sha512-UqyYyH5YEXaJrf9S8E23GoJFQZXkBVJ9zYYMPGz919MSX1KuvAcycIuS0ci150HCoPf4XQVhQ84Qf8xRPWxFaQ==", "dev": true, "requires": { "debug": "^3.1.0", - "koa-send": "^4.1.3" + "koa-send": "^5.0.0" }, "dependencies": { "debug": { @@ -7677,9 +6838,9 @@ } }, "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true } } @@ -7735,6 +6896,15 @@ "strip-bom": "^3.0.0" }, "dependencies": { + "parse-json": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", + "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "dev": true, + "requires": { + "error-ex": "^1.2.0" + } + }, "pify": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", @@ -7744,29 +6914,12 @@ } }, "load-module": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/load-module/-/load-module-1.0.0.tgz", - "integrity": "sha512-FmoAJI/RM4vmvIRk65g/SFCnGQC9BbALY3zy38Z0cMllNnra1+iCdxAf051LVymzE60/FweOo9or9XJiGgFshg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/load-module/-/load-module-2.0.1.tgz", + "integrity": "sha512-uPi6sDp/7rcX5hP8jRncyBa63++qOJxczYAoq58DpoAnQmLJ+e7zz8qmRS+zfkOGEhqj10SFwuZrZuen8Ep5zQ==", "dev": true, "requires": { - "array-back": "^2.0.0" - }, - "dependencies": { - "array-back": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/array-back/-/array-back-2.0.0.tgz", - "integrity": "sha512-eJv4pLLufP3g5kcZry0j6WXpIbzYw9GUB4mVJZno9wfwiBxbizTnHCw3VJb07cBihbFX48Y7oSrW9y+gt4glyw==", - "dev": true, - "requires": { - "typical": "^2.6.1" - } - }, - "typical": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/typical/-/typical-2.6.1.tgz", - "integrity": "sha1-XAgOXWYcu+OCWdLnCjxyU+hziB0=", - "dev": true - } + "array-back": "^3.1.0" } }, "loader-runner": { @@ -7776,40 +6929,56 @@ "dev": true }, "loader-utils": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.1.0.tgz", - "integrity": "sha1-yYrvSIvM7aL/teLeZG1qdUQp9c0=", + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.2.3.tgz", + "integrity": "sha512-fkpz8ejdnEMG3s37wGL07iSBDg99O9D5yflE9RGNH3hRdx9SOwYfnGYdZOUIZitN8E+E2vkq3MUMYMvPYl5ZZA==", "dev": true, "requires": { - "big.js": "^3.1.3", + "big.js": "^5.2.2", "emojis-list": "^2.0.0", - "json5": "^0.5.0" + "json5": "^1.0.1" + }, + "dependencies": { + "json5": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", + "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "dev": true, + "requires": { + "minimist": "^1.2.0" + } + }, + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true + } } }, "local-web-server": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/local-web-server/-/local-web-server-2.6.1.tgz", - "integrity": "sha512-KglUDD5jy3CMJ88E04aDjY6mRm387G2MX1XZI1bM6+dzrjLWKHURbef896tw7w7KI997r5UT0Y6NUm8To11/tQ==", - "dev": true, - "requires": { - "lws": "^1.3.0", - "lws-basic-auth": "^0.1.1", - "lws-blacklist": "^0.3.0", - "lws-body-parser": "^0.2.4", - "lws-compress": "^0.2.1", - "lws-conditional-get": "^0.3.4", - "lws-cors": "^1.0.0", - "lws-index": "^0.4.0", - "lws-json": "^0.3.2", - "lws-log": "^0.3.2", - "lws-mime": "^0.2.2", - "lws-mock-response": "^0.5.1", - "lws-range": "^1.1.0", - "lws-request-monitor": "^0.1.5", - "lws-rewrite": "^0.4.1", - "lws-spa": "^0.3.0", - "lws-static": "^0.5.0", - "node-version-matches": "^1.0.0" + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/local-web-server/-/local-web-server-3.0.4.tgz", + "integrity": "sha512-Rddg07XLKI2tyzxtSwAq7WZnsLNpbCYOn/KC38n0idhKEBzsAJKTbwfItplqUWK409jiGG4l8fbdZm8NaxmYBA==", + "dev": true, + "requires": { + "lws": "^2.0.3", + "lws-basic-auth": "^1.0.3", + "lws-blacklist": "^2.0.2", + "lws-body-parser": "^1.0.2", + "lws-compress": "^1.0.2", + "lws-conditional-get": "^1.0.1", + "lws-cors": "^2.0.1", + "lws-index": "^1.0.4", + "lws-json": "^1.0.1", + "lws-log": "^1.0.3", + "lws-mime": "^1.0.1", + "lws-range": "^2.0.1", + "lws-request-monitor": "^1.0.4", + "lws-rewrite": "^2.0.5", + "lws-spa": "^2.0.2", + "lws-static": "^1.1.3", + "node-version-matches": "^1.0.1" } }, "localforage": { @@ -7821,12 +6990,12 @@ } }, "locate-path": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", - "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", "dev": true, "requires": { - "p-locate": "^2.0.0", + "p-locate": "^3.0.0", "path-exists": "^3.0.0" } }, @@ -7860,12 +7029,6 @@ "integrity": "sha1-U8y6BH0G4VjTEfRdpiX05J5vFm4=", "dev": true }, - "lodash.pick": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/lodash.pick/-/lodash.pick-4.4.0.tgz", - "integrity": "sha1-UvBWEP/53tQiYRRB7R/BI6AwAbM=", - "dev": true - }, "lodash.some": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/lodash.some/-/lodash.some-4.6.0.tgz", @@ -7891,9 +7054,9 @@ "dev": true }, "loglevel": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.6.2.tgz", - "integrity": "sha512-Jt2MHrCNdtIe1W6co3tF5KXGRkzF+TYffiQstfXa04mrss9IKXzAAXYWak8LbZseAQY03sH2GzMCMU0ZOUc9bg==" + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.6.3.tgz", + "integrity": "sha512-LoEDv5pgpvWgPF4kNYuIp0qqSJVWak/dML0RY74xlzMZiT9w77teNAwKYKWBTYjlokMirg+o3jBwp+vlLrcfAA==" }, "loose-envify": { "version": "1.4.0", @@ -7920,86 +7083,68 @@ } }, "lws": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/lws/-/lws-1.3.2.tgz", - "integrity": "sha512-0JF2zD01FXVI19rpyEBKlmKuaJJ0dPhrudbbY4oEPh9+X835MLm0C/thAJCyDhJJ87aZ42trv9G+s/JErvojaQ==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/lws/-/lws-2.0.3.tgz", + "integrity": "sha512-a5Civu1FmHsWKzJ89lIa69I/tzDkRyonYvu/QECIyMJOxXIWgzfM8Ed14zkBWocVNjdWq8+D0C65qYPLjw/0MA==", "dev": true, "requires": { - "ansi-escape-sequences": "^4.0.1", - "array-back": "^3.0.1", + "ansi-escape-sequences": "^4.1.0", + "array-back": "^3.1.0", "byte-size": "^5.0.1", - "cli-commands": "^0.4.0", - "command-line-args": "^5.0.2", - "command-line-usage": "^5.0.5", - "koa": "^2.6.2", - "load-module": "^1.0.0", + "command-line-args": "^5.1.1", + "command-line-usage": "^6.0.1", + "create-mixin": "^2.0.1", + "koa": "^2.7.0", + "load-module": "^2.0.1", "lodash.assignwith": "^4.2.0", "node-version-matches": "^1.0.1", - "opn": "^5.4.0", + "open": "^6.4.0", "reduce-flatten": "^2.0.0", - "typical": "^3.0.0", - "walk-back": "^3.0.1", - "ws": "^5.2.1" + "typical": "^5.1.0", + "walk-back": "^3.0.1" } }, "lws-basic-auth": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/lws-basic-auth/-/lws-basic-auth-0.1.1.tgz", - "integrity": "sha512-npPpqkOFzJzB9yJ2pGXmiYOswH+0n86ro75WhromeGuNo0GfE18ZLI/VCOVWmBbeXp2pcnPIMUAdkNSgukpAww==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/lws-basic-auth/-/lws-basic-auth-1.0.3.tgz", + "integrity": "sha512-YMVsYyIcmEgAyjuQuU+rVtrs1vmrc6U5Nqrj0G/A++h96bJVfgxu0p9Qj1ZmeZplya3Jx8TefzppAfuzxebZxw==", "dev": true, "requires": { - "basic-auth": "^1.1.0" + "basic-auth": "^2.0.1" } }, "lws-blacklist": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/lws-blacklist/-/lws-blacklist-0.3.0.tgz", - "integrity": "sha512-ZA8dujYaZwRNMBhgP+oGsZi9tum44Ba6VHsA3JrV1JVrjZ8c65kLaO/41rLBqQDKP3SDPu7dLity4YLwe1FuNQ==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/lws-blacklist/-/lws-blacklist-2.0.2.tgz", + "integrity": "sha512-7W2z6epqC+V5FSLN9Cblezgqem8jdGvIyIlhrbNfV+Sq818xHU9h5+Bh2rfQmNUKYp59TX+7K3Gp73kGLo37bA==", "dev": true, "requires": { - "array-back": "^2.0.0", - "path-to-regexp": "^2.2.0" - }, - "dependencies": { - "array-back": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/array-back/-/array-back-2.0.0.tgz", - "integrity": "sha512-eJv4pLLufP3g5kcZry0j6WXpIbzYw9GUB4mVJZno9wfwiBxbizTnHCw3VJb07cBihbFX48Y7oSrW9y+gt4glyw==", - "dev": true, - "requires": { - "typical": "^2.6.1" - } - }, - "typical": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/typical/-/typical-2.6.1.tgz", - "integrity": "sha1-XAgOXWYcu+OCWdLnCjxyU+hziB0=", - "dev": true - } + "array-back": "^3.1.0", + "path-to-regexp": "^3.0.0" } }, "lws-body-parser": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/lws-body-parser/-/lws-body-parser-0.2.4.tgz", - "integrity": "sha512-XKJzbzK97TUsewIPA5J2RpEk7kRoJcL+/Du6JlwzqIq84tWuXMfiT2a4Ncj12+tRWrdY2avV6d8uLhqlHLz1yg==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/lws-body-parser/-/lws-body-parser-1.0.2.tgz", + "integrity": "sha512-Tm/gtNgQQdi6nr1FgD0PLDWohBdEXqXAPI62j/7JbGsQTcR7NBbSYmk1hrCdMKMcZ8BNZEPEDUjOA6v19YceWA==", "dev": true, "requires": { - "koa-bodyparser": "^4.2.0" + "koa-bodyparser": "^4.2.1" } }, "lws-compress": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/lws-compress/-/lws-compress-0.2.1.tgz", - "integrity": "sha512-14++1o6U8upi3DLx9J2O2sFELsijEJF9utoFxSH4Stoo9SdU2Cxw6BtqQTrb9SEA6O6IsApzstdMYnq8floLSg==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/lws-compress/-/lws-compress-1.0.2.tgz", + "integrity": "sha512-bQWfg6RopS4UEu9pXU8yCHxJa40do1NM3399oeAz9klMv94h+SAbjqpf1i5ZgEou5p5psiE6LYaGokHdJy/yew==", "dev": true, "requires": { - "koa-compress": "^2.0.0" + "koa-compress": "^3.0.0" } }, "lws-conditional-get": { - "version": "0.3.4", - "resolved": "https://registry.npmjs.org/lws-conditional-get/-/lws-conditional-get-0.3.4.tgz", - "integrity": "sha512-6asZSfM747snhdz4xexRllm09pebz8pjYeg2d5khLR53D/OJznZWHsIqW0JGiScJObri2D7+H4z7yRLBjokT7g==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/lws-conditional-get/-/lws-conditional-get-1.0.1.tgz", + "integrity": "sha512-PK6JOnrkGTlyqaq8mdxKfBVb8begapwk1i9jNvtWqs1FZj0ElLfDhF+57YR1r0aD/CX64RoaD5UHsGb84rQqTw==", "dev": true, "requires": { "koa-conditional-get": "^2.0.0", @@ -8007,176 +7152,105 @@ } }, "lws-cors": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/lws-cors/-/lws-cors-1.0.0.tgz", - "integrity": "sha512-4C0m4lvYdAnpAa03tr9AqziB4d8SRPh4beQBuzPiefv7N9/tpVdrl9kgXrUe1hLHhISnVJ5MoOZuZ6wFeMiU4g==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/lws-cors/-/lws-cors-2.0.1.tgz", + "integrity": "sha512-FkGoqQrFETdyDYqPhuJufR7131J014QsyHVtDbBs17kMtspzcIrS2BOtO/NIShgs5ybGZ7S/CjuBNuy/0+kV1w==", "dev": true, "requires": { - "@koa/cors": "^2.2.1" + "@koa/cors": "^3.0.0" } }, "lws-index": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/lws-index/-/lws-index-0.4.0.tgz", - "integrity": "sha512-k+mkqgMSzx1ipzVpaxsAJU4Qe7R1kp1B/u+qC+d1Y3l+auBz+bLcIxL4dYKfaxLqiz0IFwg1dZwGzVm/dd7FFw==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/lws-index/-/lws-index-1.0.4.tgz", + "integrity": "sha512-DmfnyesC4M43bdO3Jr5fjye7qYaq6kGoOBfWJu64llHxHnOpvowShEtoJeUEEzUf4Myjzzl+xO2IzYqFmpqa4w==", "dev": true, "requires": { - "serve-index-75lb": "^2.0.0" + "serve-index": "^1.9.1" } }, "lws-json": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/lws-json/-/lws-json-0.3.2.tgz", - "integrity": "sha512-ElmCA8hi3GPMfxbtiI015PDHuJovhhcbXX/qTTTifXhopedAzIBzn/rF5dHZHE4k7HQDYfbiaPgPMbmpv9dMvQ==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/lws-json/-/lws-json-1.0.1.tgz", + "integrity": "sha512-uP2YTPymDT2aJW7GBWjXKdfIqkQuUWz3T4lNw8U8AEbyR6sIg8J5nSO9PneT/zqq9KSp3/+nQoFkO31LMeSq5w==", "dev": true, "requires": { "koa-json": "^2.0.2" } }, "lws-log": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/lws-log/-/lws-log-0.3.2.tgz", - "integrity": "sha512-DRp4bFl4a7hjwR/RjARjhFLEXs8pIeqKbUvojaAl1hhfRBuW2JsDxRSKC+ViQN06CW4Qypg3ZsztMMR8dRO8dA==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/lws-log/-/lws-log-1.0.3.tgz", + "integrity": "sha512-lxOsQgXbWd7Xwny5dVZnYUu7b6nSoT3o5A+OEuktxomEAG7Eirb6o8eOkeTMbfhE9/qfviXb5W2rFDcWk+UAlA==", "dev": true, "requires": { "koa-morgan": "^1.0.1", - "stream-log-stats": "^2.0.2" + "stream-log-stats": "^3.0.1" } }, "lws-mime": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/lws-mime/-/lws-mime-0.2.2.tgz", - "integrity": "sha512-cWBj9CuuSvvaqdYMPiXRid0QhzJmr+5gWAA96pEDOiW8tMCMoxl7CIgTpHXZwhJzCqdI84RZDVm+FswByATS5w==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/lws-mime/-/lws-mime-1.0.1.tgz", + "integrity": "sha512-+4lRjaJmexwmScZAb50A0J4F8vhSyTBOsva8xFgX9yC/AMR7t56asZpgAAw7WUI8rlSbpJQCfh0nkuAhEWgMEA==", "dev": true }, - "lws-mock-response": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/lws-mock-response/-/lws-mock-response-0.5.1.tgz", - "integrity": "sha512-4R5Q1RmRglC0pqEwywrS5g62aKaLQsteMnShGmWU9aQ/737Bq0/3qbQ3mb8VbMk3lLzo3ZaNZ1DUsPgVvZaXNQ==", - "dev": true, - "requires": { - "array-back": "^2.0.0", - "koa-mock-response": "0.2.0", - "load-module": "^1.0.0", - "reduce-flatten": "^2.0.0" - }, - "dependencies": { - "array-back": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/array-back/-/array-back-2.0.0.tgz", - "integrity": "sha512-eJv4pLLufP3g5kcZry0j6WXpIbzYw9GUB4mVJZno9wfwiBxbizTnHCw3VJb07cBihbFX48Y7oSrW9y+gt4glyw==", - "dev": true, - "requires": { - "typical": "^2.6.1" - } - }, - "typical": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/typical/-/typical-2.6.1.tgz", - "integrity": "sha1-XAgOXWYcu+OCWdLnCjxyU+hziB0=", - "dev": true - } - } - }, "lws-range": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/lws-range/-/lws-range-1.1.1.tgz", - "integrity": "sha512-pg+UI3/Y5niQA4+HjBrHRtxWm9oExICC9GX5IhrmDnDSrwR1rNw3wukWlgIX0ZFmAqZt1Gs0Td1qI2hkFMcutg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/lws-range/-/lws-range-2.0.1.tgz", + "integrity": "sha512-W4phkrh4lGtwe4M4Q5xsKBhme69s0wyrYTxoe8K9ZRDQdCFrP5wUGa5+wz/dsOvlPSaBKWxnGluCYhspGid3Gw==", "dev": true, "requires": { "koa-range": "^0.3.0" } }, "lws-request-monitor": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/lws-request-monitor/-/lws-request-monitor-0.1.5.tgz", - "integrity": "sha512-u9eczHPowH17ftUjQ8ysutGDADNZdDD6k8wgFMzOB7/rRq1Is12lTYA4u8pfKZ8C2oyoy+HYsDSrOzTwespTlA==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/lws-request-monitor/-/lws-request-monitor-1.0.4.tgz", + "integrity": "sha512-i3rpVmBnd/QIZe20lupZk+jcI7Qxr3zAddU7BR4FHniyY2ygGL3WobeZqKE0hT25p2N7roGbk/ywZn8EIXXBDQ==", "dev": true, "requires": { - "byte-size": "^4.0.2" - }, - "dependencies": { - "byte-size": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/byte-size/-/byte-size-4.0.4.tgz", - "integrity": "sha512-82RPeneC6nqCdSwCX2hZUz3JPOvN5at/nTEw/CMf05Smu3Hrpo9Psb7LjN+k+XndNArG1EY8L4+BM3aTM4BCvw==", - "dev": true - } + "byte-size": "^5.0.1" } }, "lws-rewrite": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/lws-rewrite/-/lws-rewrite-0.4.1.tgz", - "integrity": "sha512-EHUdbqfdwc4Baa7iXOdG2y815WC040Cing1GwhM9VsBL7lHtZ7zl3EHzjWFv3styoO3qNqZ4W0xCey4hoo/aYg==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/lws-rewrite/-/lws-rewrite-2.0.5.tgz", + "integrity": "sha512-VbD86rd4reocdMBWV6mrRkwR7BRG2Xi4sDyFbehH7p1aIopG4o8WwDk9dtICc9is6FIWBw3ChYZ3Hz8vZjCoog==", "dev": true, "requires": { - "array-back": "^2.0.0", - "koa-rewrite-75lb": "^2.1.1", + "array-back": "^3.1.0", + "koa-rewrite-75lb": "^3.0.1", "koa-route": "^3.2.0", - "path-to-regexp": "^1.7.0", - "req-then": "^0.6.4", - "stream-read-all": "^0.1.2", - "typical": "^2.6.1" - }, - "dependencies": { - "array-back": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/array-back/-/array-back-2.0.0.tgz", - "integrity": "sha512-eJv4pLLufP3g5kcZry0j6WXpIbzYw9GUB4mVJZno9wfwiBxbizTnHCw3VJb07cBihbFX48Y7oSrW9y+gt4glyw==", - "dev": true, - "requires": { - "typical": "^2.6.1" - } - }, - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "path-to-regexp": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.7.0.tgz", - "integrity": "sha1-Wf3g9DW62suhA6hOnTvGTpa5k30=", - "dev": true, - "requires": { - "isarray": "0.0.1" - } - }, - "typical": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/typical/-/typical-2.6.1.tgz", - "integrity": "sha1-XAgOXWYcu+OCWdLnCjxyU+hziB0=", - "dev": true - } + "path-to-regexp": "^3.0.0", + "request": "^2.88.0" } }, "lws-spa": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/lws-spa/-/lws-spa-0.3.0.tgz", - "integrity": "sha512-8wxZl5dOI/CQsJ6oOG8Y7B4khjlQXfB7GlVkjYFPuOYM+JIw/QzMvezKjKweG0qGePmHJVHWa38+CyololV4aw==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/lws-spa/-/lws-spa-2.0.2.tgz", + "integrity": "sha512-rCFzp/wC3r9CXBsFfVgURu7cc2oM/YCmPFSdRF21ws5UiYLdrgSwOV+vRfVuoXHUvfmLOuhx1sste9cFayDZEw==", "dev": true, "requires": { - "koa-route": "^3.2.0", - "koa-send": "^4.1.3" + "koa-send": "^5.0.0" } }, "lws-static": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/lws-static/-/lws-static-0.5.0.tgz", - "integrity": "sha512-r3QIeJfBox/hSJLSL7TPhNSZsTKE0r4mWYHbGZ+DwrBcKbLt1ljsh5NAtmJpsqCcjYpyOuD/DlsZ0yQY9VI8bA==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/lws-static/-/lws-static-1.1.3.tgz", + "integrity": "sha512-0f9kiddam/QZ05y9X+HwNtvdaOppub3vkZ+9lq2Vkt4tZ9IaXydsjBjOkjIQf70dsgFPlVqkC+NysYTXEuO19g==", "dev": true, "requires": { - "koa-static": "^4.0.2" + "koa-static": "^5.0.0" } }, "make-dir": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.3.0.tgz", - "integrity": "sha512-2w31R7SJtieJJnQtGc7RVL2StM2vGYVfqUOvUDxH6bC6aJTxPxTF0GnIgCyu7tjockiUWAYQRbxa7vKn34s5sQ==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz", + "integrity": "sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==", "dev": true, "requires": { - "pify": "^3.0.0" + "pify": "^4.0.1", + "semver": "^5.6.0" } }, "make-error": { @@ -8250,20 +7324,6 @@ "map-age-cleaner": "^0.1.1", "mimic-fn": "^2.0.0", "p-is-promise": "^2.0.0" - }, - "dependencies": { - "mimic-fn": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", - "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", - "dev": true - }, - "p-is-promise": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-2.1.0.tgz", - "integrity": "sha512-Y3W0wlRPK8ZMRbNq97l4M5otioeA5lm1z7bkNkxCka8HSPjR0xRWmpCmc9utiaLP9Jb1eD8BgeIxTW4AIF45Pg==", - "dev": true - } } }, "memory-fs": { @@ -8319,24 +7379,24 @@ } }, "mime-db": { - "version": "1.38.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.38.0.tgz", - "integrity": "sha512-bqVioMFFzc2awcdJZIzR3HjZFX20QhilVS7hytkKrv7xFAn8bM1gzc/FOX2awLISvWe0PV8ptFKcon+wZ5qYkg==", + "version": "1.40.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==", "dev": true }, "mime-types": { - "version": "2.1.22", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.22.tgz", - "integrity": "sha512-aGl6TZGnhm/li6F7yx82bJiBZwgiEa4Hf6CNr8YO+r5UHr53tSTYZb102zyU50DOWWKeOv0uQLRL0/9EiKWCog==", + "version": "2.1.24", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", "dev": true, "requires": { - "mime-db": "~1.38.0" + "mime-db": "1.40.0" } }, "mimic-fn": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", - "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", "dev": true }, "mini-signals": { @@ -8390,9 +7450,9 @@ } }, "mixin-deep": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", - "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", + "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", "dev": true, "requires": { "for-in": "^1.0.2", @@ -8430,17 +7490,6 @@ "depd": "~1.1.2", "on-finished": "~2.3.0", "on-headers": "~1.0.1" - }, - "dependencies": { - "basic-auth": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", - "integrity": "sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==", - "dev": true, - "requires": { - "safe-buffer": "5.1.2" - } - } } }, "move-concurrently": { @@ -8546,9 +7595,9 @@ "dev": true }, "node-libs-browser": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/node-libs-browser/-/node-libs-browser-2.2.0.tgz", - "integrity": "sha512-5MQunG/oyOaBdttrL40dA7bUfPORLRWMUJLQtMg7nluxUvk5XwnLdL9twQHFAjRx/y7mIMkLKT9++qPbbk6BZA==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/node-libs-browser/-/node-libs-browser-2.2.1.tgz", + "integrity": "sha512-h/zcD8H9kaDZ9ALUWwlBUDo6TKF8a7qBSCSEGfjTVIYeqsioSKaAX+BN7NgiMGp6iSIXZ3PxgCu8KS3b71YK5Q==", "dev": true, "requires": { "assert": "^1.1.1", @@ -8561,7 +7610,7 @@ "events": "^3.0.0", "https-browserify": "^1.0.0", "os-browserify": "^0.3.0", - "path-browserify": "0.0.0", + "path-browserify": "0.0.1", "process": "^0.11.10", "punycode": "^1.2.4", "querystring-es3": "^0.2.0", @@ -8573,7 +7622,15 @@ "tty-browserify": "0.0.0", "url": "^0.11.0", "util": "^0.11.0", - "vm-browserify": "0.0.4" + "vm-browserify": "^1.0.1" + }, + "dependencies": { + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", + "dev": true + } } }, "node-modules-regexp": { @@ -8596,15 +7653,15 @@ } }, "node-object-hash": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/node-object-hash/-/node-object-hash-1.4.1.tgz", - "integrity": "sha512-JQVqSM5/mOaUoUhCYR0t1vgm8RFo7qpJtPvnoFCLeqQh1xrfmr3BCD3nGBnACzpIEF7F7EVgqGD3O4lao/BY/A==", + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/node-object-hash/-/node-object-hash-1.4.2.tgz", + "integrity": "sha512-UdS4swXs85fCGWWf6t6DMGgpN/vnlKeSGEQ7hJcrs7PBFoxoKLmibc3QRb7fwiYsjdL7PX8iI/TMSlZ90dgHhQ==", "dev": true }, "node-releases": { - "version": "1.1.23", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.23.tgz", - "integrity": "sha512-uq1iL79YjfYC0WXoHbC/z28q/9pOl8kSHaXdWmAAc8No+bDwqkZbzIJz55g/MUsPgSGm9LZ7QSUbzTcH5tz47w==", + "version": "1.1.24", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.24.tgz", + "integrity": "sha512-wym2jptfuKowMmkZsfCSTsn8qAVo8zm+UiQA6l5dNqUcpfChZSnS/vbbpOeXczf+VdPhutxh+99lWHhdd6xKzg==", "dev": true, "requires": { "semver": "^5.3.0" @@ -8617,24 +7674,16 @@ "dev": true, "requires": { "semver": "^5.6.0" - }, - "dependencies": { - "semver": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", - "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==", - "dev": true - } } }, "normalize-package-data": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", "dev": true, "requires": { "hosted-git-info": "^2.1.4", - "is-builtin-module": "^1.0.0", + "resolve": "^1.10.0", "semver": "2 || 3 || 4 || 5", "validate-npm-package-license": "^3.0.1" } @@ -8655,9 +7704,9 @@ } }, "nth-check": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.1.tgz", - "integrity": "sha1-mSms32KPwsQQmN6rgqxYDPFJquQ=", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.2.tgz", + "integrity": "sha512-WeBOdju8SnzPN5vTUJYxYUxLeXpCaVP5i5e0LF8fg7WORF2Wd7wFX/pk0tYZk7s8T+J7VLy0Da6J1+wCT0AtHg==", "dev": true, "requires": { "boolbase": "~1.0.0" @@ -8718,9 +7767,9 @@ } }, "object-keys": { - "version": "1.0.12", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.0.12.tgz", - "integrity": "sha512-FTMyFUm2wBcGHnH2eXmz7tC6IwlqQZ6mVZ+6dm6vZ4IQIHjs6FdNsQBuKGPuUUUY6NfJw2PshC08Tn6LzLDOag==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", "dev": true }, "object-visit": { @@ -8745,15 +7794,15 @@ } }, "object.entries": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.0.4.tgz", - "integrity": "sha1-G/mk3SKI9bM/Opk9JXZh8F0WGl8=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.1.0.tgz", + "integrity": "sha512-l+H6EQ8qzGRxbkHOd5I/aHRhHDKoQXQ8g0BYt4uSweQU1/J6dZUOyWh9a2Vky35YCKjzmgxOzta2hH6kf9HuXA==", "dev": true, "requires": { - "define-properties": "^1.1.2", - "es-abstract": "^1.6.1", - "function-bind": "^1.1.0", - "has": "^1.0.1" + "define-properties": "^1.1.3", + "es-abstract": "^1.12.0", + "function-bind": "^1.1.1", + "has": "^1.0.3" } }, "object.getownpropertydescriptors": { @@ -8806,6 +7855,14 @@ "dev": true, "requires": { "mimic-fn": "^1.0.0" + }, + "dependencies": { + "mimic-fn": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", + "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", + "dev": true + } } }, "only": { @@ -8814,10 +7871,10 @@ "integrity": "sha1-Kv3oTQPlC5qO3EROMGEKcCle37Q=", "dev": true }, - "opn": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/opn/-/opn-5.5.0.tgz", - "integrity": "sha512-PqHpggC9bLV0VeWcdKhkpxY+3JTzetLSqTCWL/z/tFIbI6G8JCjondXklT1JinczLz2Xib62sSp0T/gKT4KksA==", + "open": { + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/open/-/open-6.4.0.tgz", + "integrity": "sha512-IFenVPgF70fSm1keSd2iDBIDIBZkroLeuffXq+wKTzTJlBpesFWojV9lb8mzOfaAzM1sr7HQHuO0vtV0zYekGg==", "dev": true, "requires": { "is-wsl": "^1.1.0" @@ -8911,27 +7968,27 @@ "dev": true }, "p-is-promise": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-1.1.0.tgz", - "integrity": "sha1-nJRWmJ6fZYgBewQ01WCXZ1w9oF4=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-2.1.0.tgz", + "integrity": "sha512-Y3W0wlRPK8ZMRbNq97l4M5otioeA5lm1z7bkNkxCka8HSPjR0xRWmpCmc9utiaLP9Jb1eD8BgeIxTW4AIF45Pg==", "dev": true }, "p-limit": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", - "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.0.tgz", + "integrity": "sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ==", "dev": true, "requires": { - "p-try": "^1.0.0" + "p-try": "^2.0.0" } }, "p-locate": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", - "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", "dev": true, "requires": { - "p-limit": "^1.1.0" + "p-limit": "^2.0.0" } }, "p-reduce": { @@ -8941,15 +7998,15 @@ "dev": true }, "p-try": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", - "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "dev": true }, "pako": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.6.tgz", - "integrity": "sha512-lQe48YPsMJAig+yngZ87Lus+NF+3mtu7DVOBu6b/gHO1YpKwIj5AWjZ/TOS7i46HD/UixzWb1zeWDZfGZ3iYcg==" + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.10.tgz", + "integrity": "sha512-0DTvPVU3ed8+HNXOu5Bs+o//Mbdj9VNQMUOe9oKCwh8l0GNwpTDMKCWbRjgtD291AWnkAgkqA/LOnQS8AmS1tw==" }, "parallel-transform": { "version": "1.1.0", @@ -8995,12 +8052,13 @@ } }, "parse-json": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", - "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", + "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", "dev": true, "requires": { - "error-ex": "^1.2.0" + "error-ex": "^1.3.1", + "json-parse-better-errors": "^1.0.1" } }, "parse-passwd": { @@ -9033,9 +8091,9 @@ "dev": true }, "path-browserify": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.0.tgz", - "integrity": "sha1-oLhwcpquIUAFt9UDLsLLuw+0RRo=", + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz", + "integrity": "sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ==", "dev": true }, "path-dirname": { @@ -9056,12 +8114,6 @@ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, - "path-is-inside": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", - "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", - "dev": true - }, "path-key": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", @@ -9075,9 +8127,9 @@ "dev": true }, "path-to-regexp": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-2.4.0.tgz", - "integrity": "sha512-G6zHoVqC6GGTQkZwF4lkuEyMbVOjoBKAEybQUypI1WTkqinCOrq2x6U2+phkJ1XsEMTy4LjtwPI7HW+NVrRR2w==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-3.0.0.tgz", + "integrity": "sha512-ZOtfhPttCrqp2M1PBBH4X13XlvnfhIwD7yCLx+GoGoXRPQyxGOTdQMpIzPSPKXAJT/JQrdfFrgdJOyAzvgpQ9A==", "dev": true }, "path-type": { @@ -9117,9 +8169,9 @@ "dev": true }, "pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", + "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", "dev": true }, "pirates": { @@ -9180,14 +8232,14 @@ "integrity": "sha512-lHVH8iy+7wFeRVy6MhnMegXX4F2jVMfrl2yjUpk1A0gaj6Oyb1s4G4VyxL45b9nML4iePFoJCi4kxgIHbhwtAA==" }, "pixi-sound": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/pixi-sound/-/pixi-sound-2.1.0.tgz", - "integrity": "sha512-J3VtaOaWOnxdE3ynWjFpyecyN+fuxw16yiK/Oy1ZtdBoUDh3gM8oOPjMCXjSYyDIhEOUF+uJD8tZ/kopsZ/wvw==" + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/pixi-sound/-/pixi-sound-2.1.4.tgz", + "integrity": "sha512-MdBcJskddL1z2zTQwXbpAXCUHqcq5SxG1lSoVN2xSAqa4z6Xp5sAOasfk16YEESRfsUIUIqBtGyujaLO0Yc0/g==" }, "pixi.js": { - "version": "4.8.6", - "resolved": "https://registry.npmjs.org/pixi.js/-/pixi.js-4.8.6.tgz", - "integrity": "sha512-+p6njU8rPfCN+e/KVYYQlbA8smKSauWfoBeqCskZmax9FqYYLyQwMsXnF8f6h/++xSbrIe5LxgxX7Wl8jHVvkQ==", + "version": "4.8.8", + "resolved": "https://registry.npmjs.org/pixi.js/-/pixi.js-4.8.8.tgz", + "integrity": "sha512-wQzuLAWSMfV+x2guL5jZBp37pwCmYXHiTXG7ZWXu4E/5IsC9xozwmOfLeCNEyPzlyucOgxAx/HS+tLqxWPYX7Q==", "requires": { "bit-twiddle": "^1.0.2", "earcut": "^2.1.4", @@ -9200,12 +8252,12 @@ } }, "pkg-dir": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-2.0.0.tgz", - "integrity": "sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-3.0.0.tgz", + "integrity": "sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw==", "dev": true, "requires": { - "find-up": "^2.1.0" + "find-up": "^3.0.0" } }, "pn": { @@ -9221,9 +8273,9 @@ "dev": true }, "postcss": { - "version": "7.0.14", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.14.tgz", - "integrity": "sha512-NsbD6XUUMZvBxtQAJuWDJeeC4QFsmWsfozWxCJPWf3M55K9iu2iMDaKqyoOdTJ1R4usBXuxlVFAIo8rZPQD4Bg==", + "version": "7.0.17", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.17.tgz", + "integrity": "sha512-546ZowA+KZ3OasvQZHsbuEpysvwTZNGJv9EfyCQdsIDltPSWHAeTQ5fQy/Npi2ZDtLI3zs7Ps/p6wThErhm9fQ==", "dev": true, "requires": { "chalk": "^2.4.2", @@ -9231,28 +8283,6 @@ "supports-color": "^6.1.0" }, "dependencies": { - "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" - }, - "dependencies": { - "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" - } - } - } - }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -9280,14 +8310,15 @@ } }, "postcss-modules-local-by-default": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/postcss-modules-local-by-default/-/postcss-modules-local-by-default-2.0.6.tgz", - "integrity": "sha512-oLUV5YNkeIBa0yQl7EYnxMgy4N6noxmiwZStaEJUSe2xPMcdNc8WmBQuQCx18H5psYbVxz8zoHk0RAAYZXP9gA==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/postcss-modules-local-by-default/-/postcss-modules-local-by-default-3.0.2.tgz", + "integrity": "sha512-jM/V8eqM4oJ/22j0gx4jrp63GSvDH6v86OqyTHHUvk4/k1vceipZsaymiZ5PvocqZOl5SFHiFJqjs3la0wnfIQ==", "dev": true, "requires": { - "postcss": "^7.0.6", - "postcss-selector-parser": "^6.0.0", - "postcss-value-parser": "^3.3.1" + "icss-utils": "^4.1.1", + "postcss": "^7.0.16", + "postcss-selector-parser": "^6.0.2", + "postcss-value-parser": "^4.0.0" } }, "postcss-modules-scope": { @@ -9301,12 +8332,12 @@ } }, "postcss-modules-values": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/postcss-modules-values/-/postcss-modules-values-2.0.0.tgz", - "integrity": "sha512-Ki7JZa7ff1N3EIMlPnGTZfUMe69FFwiQPnVSXC9mnn3jozCRBYIxiZd44yJOV2AmabOo4qFf8s0dC/+lweG7+w==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/postcss-modules-values/-/postcss-modules-values-3.0.0.tgz", + "integrity": "sha512-1//E5jCBrZ9DmRX+zCtmQtRSV6PV42Ix7Bzj9GbwJceduuf7IqP8MgeTXuRDHOWj2m0VzZD5+roFWDuU8RQjcg==", "dev": true, "requires": { - "icss-replace-symbols": "^1.1.0", + "icss-utils": "^4.0.0", "postcss": "^7.0.6" } }, @@ -9322,9 +8353,9 @@ } }, "postcss-value-parser": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-3.3.1.tgz", - "integrity": "sha512-pISE66AbVkp4fDQ7VHBwRNXzAAKJjw4Vw7nWI/+Q3vuly7SNfgYXvm6i5IgFylHGK5sP/xHAbB7N49OS4gWNyQ==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.0.0.tgz", + "integrity": "sha512-ESPktioptiSUchCKgggAkzdmkgzKfmp0EU8jXH+5kbIUB+unr0Y4CY9SRMvibuvYUBjNh1ACLbxqYNpdTQOteQ==", "dev": true }, "prelude-ls": { @@ -9376,9 +8407,9 @@ "dev": true }, "process-nextick-args": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", "dev": true }, "progress": { @@ -9410,9 +8441,9 @@ "dev": true }, "psl": { - "version": "1.1.32", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.32.tgz", - "integrity": "sha512-MHACAkHpihU/REGGPLj4sEfc/XKW2bheigvHO1dUqjaKigMp1C8+WLQYRGgeKFMsw5PMfegZcaN8IDXK/cD0+g==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.2.0.tgz", + "integrity": "sha512-GEn74ZffufCmkDDLNcl3uuyF/aSD6exEyh1v/ZSdAomB82t6G9hzJVRx0jBmLDW+VfZqks3aScmMw9DszwUalA==", "dev": true }, "public-encrypt": { @@ -9463,9 +8494,9 @@ } }, "punycode": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", "dev": true }, "qs": { @@ -9506,13 +8537,13 @@ } }, "raw-body": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", - "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.1.tgz", + "integrity": "sha512-9WmIKF6mkvA0SLmA2Knm9+qj89e+j1zqgyn8aXGd7+nAduPoqgI9lO57SAZNn/Byzo5P7JhXTyg9PzaJbH73bA==", "dev": true, "requires": { "bytes": "3.1.0", - "http-errors": "1.7.2", + "http-errors": "1.7.3", "iconv-lite": "0.4.24", "unpipe": "1.0.0" } @@ -9524,14 +8555,22 @@ "dev": true }, "read-pkg": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", - "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-4.0.1.tgz", + "integrity": "sha1-ljYlN48+HE1IyFhytabsfV0JMjc=", "dev": true, "requires": { - "load-json-file": "^2.0.0", "normalize-package-data": "^2.3.2", - "path-type": "^2.0.0" + "parse-json": "^4.0.0", + "pify": "^3.0.0" + }, + "dependencies": { + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "dev": true + } } }, "read-pkg-up": { @@ -9542,6 +8581,62 @@ "requires": { "find-up": "^2.0.0", "read-pkg": "^2.0.0" + }, + "dependencies": { + "find-up": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", + "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "dev": true, + "requires": { + "locate-path": "^2.0.0" + } + }, + "locate-path": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", + "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", + "dev": true, + "requires": { + "p-locate": "^2.0.0", + "path-exists": "^3.0.0" + } + }, + "p-limit": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", + "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", + "dev": true, + "requires": { + "p-try": "^1.0.0" + } + }, + "p-locate": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", + "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", + "dev": true, + "requires": { + "p-limit": "^1.1.0" + } + }, + "p-try": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", + "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", + "dev": true + }, + "read-pkg": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", + "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=", + "dev": true, + "requires": { + "load-json-file": "^2.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^2.0.0" + } + } } }, "readable-stream": { @@ -9692,23 +8787,32 @@ "dev": true }, "renderkid": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/renderkid/-/renderkid-2.0.1.tgz", - "integrity": "sha1-iYyr/Ivt5Le5ETWj/9Mj5YwNsxk=", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/renderkid/-/renderkid-2.0.3.tgz", + "integrity": "sha512-z8CLQp7EZBPCwCnncgf9C4XAi3WR0dv+uWu/PjIyhhAb5d6IJ/QZqlHFprHeKT+59//V6BNUsLbvN8+2LarxGA==", "dev": true, "requires": { "css-select": "^1.1.0", - "dom-converter": "~0.1", - "htmlparser2": "~3.3.0", + "dom-converter": "^0.2", + "htmlparser2": "^3.3.0", "strip-ansi": "^3.0.0", - "utila": "~0.3" + "utila": "^0.4.0" }, "dependencies": { - "utila": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/utila/-/utila-0.3.3.tgz", - "integrity": "sha1-1+jn1+MJEHCSsF+NloiCTWM6QiY=", + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", "dev": true + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } } } }, @@ -9724,36 +8828,6 @@ "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", "dev": true }, - "req-then": { - "version": "0.6.4", - "resolved": "https://registry.npmjs.org/req-then/-/req-then-0.6.4.tgz", - "integrity": "sha512-Uf7xsK1qPqPUetESHemNQ7nGtgOxngSFtlcAOOkx0lDAo+XRZpEA9QDrGBdyOfGq4b+a0z/D5gR2VJ+pp/dzBA==", - "dev": true, - "requires": { - "array-back": "^2.0.0", - "defer-promise": "^1.0.1", - "lodash.pick": "^4.4.0", - "stream-read-all": "^0.1.0", - "typical": "^2.6.1" - }, - "dependencies": { - "array-back": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/array-back/-/array-back-2.0.0.tgz", - "integrity": "sha512-eJv4pLLufP3g5kcZry0j6WXpIbzYw9GUB4mVJZno9wfwiBxbizTnHCw3VJb07cBihbFX48Y7oSrW9y+gt4glyw==", - "dev": true, - "requires": { - "typical": "^2.6.1" - } - }, - "typical": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/typical/-/typical-2.6.1.tgz", - "integrity": "sha1-XAgOXWYcu+OCWdLnCjxyU+hziB0=", - "dev": true - } - } - }, "request": { "version": "2.88.0", "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", @@ -9782,6 +8856,12 @@ "uuid": "^3.3.2" }, "dependencies": { + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", + "dev": true + }, "tough-cookie": { "version": "2.4.3", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", @@ -9826,12 +8906,6 @@ "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", "dev": true }, - "requireindex": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/requireindex/-/requireindex-1.2.0.tgz", - "integrity": "sha512-L9jEkOi3ASd9PYit2cwRfyppc9NoABujTP8/5gFcbERmo5jUoAKovIC3fsF17pkTnGsrByysqX+Kxd2OTNI1ww==", - "dev": true - }, "resolve": { "version": "1.11.1", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.11.1.tgz", @@ -9866,6 +8940,19 @@ "requires": { "expand-tilde": "^2.0.0", "global-modules": "^1.0.0" + }, + "dependencies": { + "global-modules": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz", + "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==", + "dev": true, + "requires": { + "global-prefix": "^1.0.1", + "is-windows": "^1.0.1", + "resolve-dir": "^1.0.0" + } + } } }, "resolve-from": { @@ -9896,6 +8983,12 @@ "statuses": ">= 1.4.0 < 2" } }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, "setprototypeof": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", @@ -9911,9 +9004,9 @@ "dev": true }, "resource-loader": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/resource-loader/-/resource-loader-2.2.3.tgz", - "integrity": "sha512-SsxilncV7gxwr12clSq0E2HZh8QjcosVVSEAnZ3VF9VtBNNtO3UFxxXT9pJgkVEJUHAlXg26MkkTOMjyz1kDdw==", + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/resource-loader/-/resource-loader-2.2.4.tgz", + "integrity": "sha512-MrY0bEJN26us3h4bzJUSP0n4tFEb79lCpYBavtLjSezWCcXZMgxhSgvC9LxueuqpcxG+qPjhwFu5SQAcUNacdA==", "requires": { "mini-signals": "^1.1.1", "parse-uri": "^1.0.0" @@ -9936,12 +9029,12 @@ "dev": true }, "rimraf": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", + "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", "dev": true, "requires": { - "glob": "^7.0.5" + "glob": "^7.1.3" } }, "ripemd160": { @@ -9955,9 +9048,9 @@ } }, "rsvp": { - "version": "4.8.4", - "resolved": "https://registry.npmjs.org/rsvp/-/rsvp-4.8.4.tgz", - "integrity": "sha512-6FomvYPfs+Jy9TfXmBpBuMWNH94SgCsZmJKcanySzgNNP6LjWxBvyLTa9KaMfDDM5oxRfrKDB0r/qeRsLwnBfA==", + "version": "4.8.5", + "resolved": "https://registry.npmjs.org/rsvp/-/rsvp-4.8.5.tgz", + "integrity": "sha512-nfMOlASu9OnRJo1mbEk2cz0D56a1MBNrJ7orjRZQG10XDyuvwksKbuXNp6qa+kbn839HwjwhBzhFmdsaEAfauA==", "dev": true }, "run-async": { @@ -9979,9 +9072,9 @@ } }, "rxjs": { - "version": "6.3.3", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.3.3.tgz", - "integrity": "sha512-JTWmoY9tWCs7zvIk/CvRjhjGaOd+OVBM987mxFo+OW66cGpdKjZcpmc74ES1sB//7Kl/PAe8+wEakuhG4pcgOw==", + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.2.tgz", + "integrity": "sha512-HUb7j3kvb7p7eCUHE3FqjoDsC1xfZQ4AHFWfTKSpZ+sAhhz5X1WX0ZuUqWbzB2QhSLp3DoLUG+hMdEDKqWo2Zg==", "dev": true, "requires": { "tslib": "^1.9.0" @@ -10048,38 +9141,12 @@ "ajv": "^6.1.0", "ajv-errors": "^1.0.0", "ajv-keywords": "^3.1.0" - }, - "dependencies": { - "ajv": { - "version": "6.6.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.6.2.tgz", - "integrity": "sha512-FBHEW6Jf5TB9MGBgUUA9XHkTbjXYfAUjY43ACMfmdMRHniyoMHjHjzD50OK8LGDWQwp4rWEsIq5kEqq7rvIM1g==", - "dev": true, - "requires": { - "fast-deep-equal": "^2.0.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - } - }, - "fast-deep-equal": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", - "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", - "dev": true - }, - "json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "dev": true - } } }, "semver": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", + "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==", "dev": true }, "serialize-javascript": { @@ -10088,10 +9155,10 @@ "integrity": "sha512-ke8UG8ulpFOxO8f8gRYabHQe/ZntKlcig2Mp+8+URDP1D8vJZ0KUt7LYo07q25Z/+JVSgpr/cui9PIp5H6/+nA==", "dev": true }, - "serve-index-75lb": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/serve-index-75lb/-/serve-index-75lb-2.0.1.tgz", - "integrity": "sha512-/d9r8bqJlFQcwy0a0nb1KnWAA+Mno+V+VaoKocdkbW5aXKRQd/+4bfnRhQRQr6uEoYwTRJ4xgztOyCJvWcpBpQ==", + "serve-index": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/serve-index/-/serve-index-1.9.1.tgz", + "integrity": "sha1-03aNabHn2C5c4FD/9bRTvqEqkjk=", "dev": true, "requires": { "accepts": "~1.3.4", @@ -10099,7 +9166,7 @@ "debug": "2.6.9", "escape-html": "~1.0.3", "http-errors": "~1.6.2", - "mime-types": "~2.1.18", + "mime-types": "~2.1.17", "parseurl": "~1.3.2" }, "dependencies": { @@ -10115,6 +9182,12 @@ "statuses": ">= 1.4.0 < 2" } }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, "setprototypeof": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", @@ -10130,9 +9203,9 @@ "dev": true }, "set-value": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", - "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", + "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==", "dev": true, "requires": { "extend-shallow": "^2.0.1", @@ -10406,9 +9479,9 @@ "dev": true }, "spdx-correct": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", - "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.0.tgz", + "integrity": "sha512-lr2EZCctC2BNR7j7WzJ2FpDznxky1sjfxvvYEyzxNyb6lZXHODmEoJeFu4JupYlkfha1KZpJyoqiJ7pgA1qq8Q==", "dev": true, "requires": { "spdx-expression-parse": "^3.0.0", @@ -10416,9 +9489,9 @@ } }, "spdx-exceptions": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.2.0.tgz", + "integrity": "sha512-2XQACfElKi9SlVb1CYadKDXvoajPgBVPn/gOQLrTvHdElaVhr7ZEbqJaRnJLVNeaI4cMEAgVCeBMKF6MWRDCRA==", "dev": true }, "spdx-expression-parse": { @@ -10432,9 +9505,9 @@ } }, "spdx-license-ids": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.4.tgz", + "integrity": "sha512-7j8LYJLeY/Yb6ACbQ7F76qy5jHkp0U6jgBfJsk97bwWlVUnUWsAgpyaCvo17h0/RQGnQ036tVDomiwoI4pDkQA==", "dev": true }, "split-string": { @@ -10556,58 +9629,66 @@ } }, "stream-log-stats": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/stream-log-stats/-/stream-log-stats-2.0.2.tgz", - "integrity": "sha512-b1LccxXhMlOQQrzSqapQHyZ3UI00QTAv+8VecFgsJz//sGB5LFl/+mkFeWBVVI2/E4DlCT4sGgvLExB/VTVFfA==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/stream-log-stats/-/stream-log-stats-3.0.1.tgz", + "integrity": "sha512-FmaeaSGmhuYkYfD9HAnTJxmqH2nASpUvYl4/KiWF5mOUW3i0EEfqWJOka20M/rLKotsl8HEQM3OtNqd2xZnZfQ==", "dev": true, "requires": { - "JSONStream": "^1.3.1", - "ansi-escape-sequences": "^3.0.0", - "byte-size": "^3.0.0", - "common-log-format": "~0.1.3", + "JSONStream": "^1.3.5", + "ansi-escape-sequences": "^4.1.0", + "byte-size": "^5.0.1", + "common-log-format": "^1.0.0", "lodash.throttle": "^4.1.1", - "stream-via": "^1.0.3", - "table-layout": "~0.4.0" + "stream-via": "^1.0.4", + "table-layout": "~0.4.4" }, "dependencies": { - "ansi-escape-sequences": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-escape-sequences/-/ansi-escape-sequences-3.0.0.tgz", - "integrity": "sha1-HBg5S2r5t2/5pjUJ+kl2af0s5T4=", + "array-back": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/array-back/-/array-back-2.0.0.tgz", + "integrity": "sha512-eJv4pLLufP3g5kcZry0j6WXpIbzYw9GUB4mVJZno9wfwiBxbizTnHCw3VJb07cBihbFX48Y7oSrW9y+gt4glyw==", "dev": true, "requires": { - "array-back": "^1.0.3" + "typical": "^2.6.1" } }, - "array-back": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/array-back/-/array-back-1.0.4.tgz", - "integrity": "sha1-ZEun8JX3/898Q7Xw3DnTwfA8Bjs=", + "reduce-flatten": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/reduce-flatten/-/reduce-flatten-1.0.1.tgz", + "integrity": "sha1-JYx479FT3fk8tWEjf2EYTzaW4yc=", + "dev": true + }, + "table-layout": { + "version": "0.4.5", + "resolved": "https://registry.npmjs.org/table-layout/-/table-layout-0.4.5.tgz", + "integrity": "sha512-zTvf0mcggrGeTe/2jJ6ECkJHAQPIYEwDoqsiqBjI24mvRmQbInK5jq33fyypaCBxX08hMkfmdOqj6haT33EqWw==", "dev": true, "requires": { - "typical": "^2.6.0" + "array-back": "^2.0.0", + "deep-extend": "~0.6.0", + "lodash.padend": "^4.6.1", + "typical": "^2.6.1", + "wordwrapjs": "^3.0.0" } }, - "byte-size": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/byte-size/-/byte-size-3.0.0.tgz", - "integrity": "sha1-QG+eI2aqXav2NnLrKR17sJSV2nU=", - "dev": true - }, "typical": { "version": "2.6.1", "resolved": "https://registry.npmjs.org/typical/-/typical-2.6.1.tgz", "integrity": "sha1-XAgOXWYcu+OCWdLnCjxyU+hziB0=", "dev": true + }, + "wordwrapjs": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/wordwrapjs/-/wordwrapjs-3.0.0.tgz", + "integrity": "sha512-mO8XtqyPvykVCsrwj5MlOVWvSnCdT+C+QVbm6blradR7JExAhbkZ7hZ9A+9NUtwzSqrlUo9a67ws0EiILrvRpw==", + "dev": true, + "requires": { + "reduce-flatten": "^1.0.1", + "typical": "^2.6.1" + } } } }, - "stream-read-all": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/stream-read-all/-/stream-read-all-0.1.2.tgz", - "integrity": "sha512-KX42xBg853m+KnwRtwCKT95ShopAbY/MNKs2dBQ0WkNeuJdqgQYRtGRbTlxdx0L6t979h3z/wMq2eMSAu7Tygw==", - "dev": true - }, "stream-shift": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.0.tgz", @@ -10644,23 +9725,6 @@ "requires": { "astral-regex": "^1.0.0", "strip-ansi": "^4.0.0" - }, - "dependencies": { - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "dev": true, - "requires": { - "ansi-regex": "^3.0.0" - } - } } }, "string-width": { @@ -10671,23 +9735,6 @@ "requires": { "is-fullwidth-code-point": "^2.0.0", "strip-ansi": "^4.0.0" - }, - "dependencies": { - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "dev": true, - "requires": { - "ansi-regex": "^3.0.0" - } - } } }, "string_decoder": { @@ -10700,12 +9747,12 @@ } }, "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "dev": true, "requires": { - "ansi-regex": "^2.0.0" + "ansi-regex": "^3.0.0" } }, "strip-bom": { @@ -10734,70 +9781,27 @@ "requires": { "loader-utils": "^1.1.0", "schema-utils": "^1.0.0" - }, - "dependencies": { - "ajv": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.5.4.tgz", - "integrity": "sha512-4Wyjt8+t6YszqaXnLDfMmG/8AlO5Zbcsy3ATHncCzjW/NoPzAId8AK6749Ybjmdt+kUY1gP60fCu46oDxPv/mg==", - "dev": true, - "requires": { - "fast-deep-equal": "^2.0.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - } - }, - "ajv-keywords": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.2.0.tgz", - "integrity": "sha1-6GuBnGAs+IIa1jdBNpjx3sAhhHo=", - "dev": true - }, - "fast-deep-equal": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", - "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", - "dev": true - }, - "json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "dev": true - }, - "schema-utils": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-1.0.0.tgz", - "integrity": "sha512-i27Mic4KovM/lnGsy8whRCHhc7VicJajAjTrYg11K9zfZXnYIt4k5F+kZkwjnrhKzLic/HLU4j11mjsz2G/75g==", - "dev": true, - "requires": { - "ajv": "^6.1.0", - "ajv-errors": "^1.0.0", - "ajv-keywords": "^3.1.0" - } - } } }, "supports-color": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", - "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", + "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" } }, "symbol-tree": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.2.tgz", - "integrity": "sha1-rifbOPZgp64uHDt9G8KQgZuFGeY=", + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", + "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==", "dev": true }, "table": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/table/-/table-5.4.0.tgz", - "integrity": "sha512-nHFDrxmbrkU7JAFKqKbDJXfzrX2UBsWmrieXFTGxiI5e4ncg3VqsZeI4EzNmX0ncp4XNGVeoxIWJXfCIXwrsvw==", + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/table/-/table-5.4.1.tgz", + "integrity": "sha512-E6CK1/pZe2N75rGZQotFOdmzWQ1AILtgYbMAbAjvms0S1l5IDB47zG3nCnFGB/w+7nB3vKofbLXCH7HPBo864w==", "dev": true, "requires": { "ajv": "^6.9.1", @@ -10835,33 +9839,15 @@ } }, "table-layout": { - "version": "0.4.4", - "resolved": "https://registry.npmjs.org/table-layout/-/table-layout-0.4.4.tgz", - "integrity": "sha512-uNaR3SRMJwfdp9OUr36eyEi6LLsbcTqTO/hfTsNviKsNeyMBPICJCC7QXRF3+07bAP6FRwA8rczJPBqXDc0CkQ==", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/table-layout/-/table-layout-1.0.0.tgz", + "integrity": "sha512-o8V8u943KXX9gLNK/Ss1n6Nn4YhpyY/RRnp3hKv/zTA+SXYiQnzJQlR8CZQf1RqYqgkiWMJ54Mv+Vq9Kfzxz1A==", "dev": true, "requires": { - "array-back": "^2.0.0", + "array-back": "^3.1.0", "deep-extend": "~0.6.0", - "lodash.padend": "^4.6.1", - "typical": "^2.6.1", - "wordwrapjs": "^3.0.0" - }, - "dependencies": { - "array-back": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/array-back/-/array-back-2.0.0.tgz", - "integrity": "sha512-eJv4pLLufP3g5kcZry0j6WXpIbzYw9GUB4mVJZno9wfwiBxbizTnHCw3VJb07cBihbFX48Y7oSrW9y+gt4glyw==", - "dev": true, - "requires": { - "typical": "^2.6.1" - } - }, - "typical": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/typical/-/typical-2.6.1.tgz", - "integrity": "sha1-XAgOXWYcu+OCWdLnCjxyU+hziB0=", - "dev": true - } + "typical": "^5.0.0", + "wordwrapjs": "^4.0.0" } }, "tapable": { @@ -10871,9 +9857,9 @@ "dev": true }, "terser": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/terser/-/terser-4.0.0.tgz", - "integrity": "sha512-dOapGTU0hETFl1tCo4t56FN+2jffoKyER9qBGoUFyZ6y7WLoKT0bF+lAYi6B6YsILcGF3q1C2FBh8QcKSCgkgA==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/terser/-/terser-4.0.2.tgz", + "integrity": "sha512-IWLuJqTvx97KP3uTYkFVn93cXO+EtlzJu8TdJylq+H0VBDlPMIfQA9MBS5Vc5t3xTEUG1q0hIfHMpAP2R+gWTw==", "dev": true, "requires": { "commander": "^2.19.0", @@ -10881,12 +9867,6 @@ "source-map-support": "~0.5.10" }, "dependencies": { - "commander": { - "version": "2.20.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", - "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==", - "dev": true - }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -10913,38 +9893,6 @@ "worker-farm": "^1.7.0" }, "dependencies": { - "big.js": { - "version": "5.2.2", - "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", - "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==", - "dev": true - }, - "json5": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", - "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", - "dev": true, - "requires": { - "minimist": "^1.2.0" - } - }, - "loader-utils": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.2.3.tgz", - "integrity": "sha512-fkpz8ejdnEMG3s37wGL07iSBDg99O9D5yflE9RGNH3hRdx9SOwYfnGYdZOUIZitN8E+E2vkq3MUMYMvPYl5ZZA==", - "dev": true, - "requires": { - "big.js": "^5.2.2", - "emojis-list": "^2.0.0", - "json5": "^1.0.1" - } - }, - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true - }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -10965,29 +9913,6 @@ "require-main-filename": "^2.0.0" }, "dependencies": { - "find-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", - "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", - "dev": true, - "requires": { - "locate-path": "^3.0.0" - } - }, - "glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, "load-json-file": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", @@ -11000,50 +9925,6 @@ "strip-bom": "^3.0.0" } }, - "locate-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", - "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", - "dev": true, - "requires": { - "p-locate": "^3.0.0", - "path-exists": "^3.0.0" - } - }, - "p-limit": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.0.tgz", - "integrity": "sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ==", - "dev": true, - "requires": { - "p-try": "^2.0.0" - } - }, - "p-locate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", - "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", - "dev": true, - "requires": { - "p-limit": "^2.0.0" - } - }, - "p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true - }, - "parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", - "dev": true, - "requires": { - "error-ex": "^1.3.1", - "json-parse-better-errors": "^1.0.1" - } - }, "path-type": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", @@ -11053,6 +9934,12 @@ "pify": "^3.0.0" } }, + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "dev": true + }, "read-pkg": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", @@ -11226,14 +10113,6 @@ "requires": { "psl": "^1.1.28", "punycode": "^2.1.1" - }, - "dependencies": { - "punycode": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", - "dev": true - } } }, "tr46": { @@ -11243,14 +10122,6 @@ "dev": true, "requires": { "punycode": "^2.1.0" - }, - "dependencies": { - "punycode": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", - "dev": true - } } }, "tree-kill": { @@ -11288,21 +10159,6 @@ "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=", "dev": true }, - "json5": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.0.tgz", - "integrity": "sha512-8Mh9h6xViijj36g7Dxi+Y4S6hNGV96vcJZr/SrlHh1LR/pEn/8j/+qIBbs44YKl69Lrfctp4QD+AdWLTMqEZAQ==", - "dev": true, - "requires": { - "minimist": "^1.2.0" - } - }, - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true - }, "yargs-parser": { "version": "10.1.0", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-10.1.0.tgz", @@ -11315,15 +10171,15 @@ } }, "tslib": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", - "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==", + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==", "dev": true }, "tsutils": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.12.0.tgz", - "integrity": "sha512-64KxDOb3+5ZVbz6NDZlCtOHstLk9+W96Y7d5Z/s5ge92gLaunxDeXYahvB7Rhl1dbaa3ifyq/W53o4mshIV1Tw==", + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.14.0.tgz", + "integrity": "sha512-SmzGbB0l+8I0QwsPgjooFRaRvHLBLNYM8SeQ0k6rtNDru5sCGeLJcZdwilNndN+GysuFjF5EIYgN8GfFG6UeUw==", "dev": true, "requires": { "tslib": "^1.8.1" @@ -11367,23 +10223,6 @@ "requires": { "media-typer": "0.3.0", "mime-types": "~2.1.24" - }, - "dependencies": { - "mime-db": { - "version": "1.40.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", - "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==", - "dev": true - }, - "mime-types": { - "version": "2.1.24", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", - "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", - "dev": true, - "requires": { - "mime-db": "1.40.0" - } - } } }, "typedarray": { @@ -11393,41 +10232,38 @@ "dev": true }, "typescript": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.1.tgz", - "integrity": "sha512-64HkdiRv1yYZsSe4xC1WVgamNigVYjlssIoaH2HcZF0+ijsk5YK2g0G34w9wJkze8+5ow4STd22AynfO6ZYYLw==", + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.2.tgz", + "integrity": "sha512-7KxJovlYhTX5RaRbUdkAXN1KUZ8PwWlTzQdHV6xNqvuFOs7+WBo10TQUqT19Q/Jz2hk5v9TQDIhyLhhJY4p5AA==", "dev": true }, "typical": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/typical/-/typical-3.0.2.tgz", - "integrity": "sha512-uvJvOMwAheCYrxDUsqkMPpYk7t1/R+4VQnBZ3wzkaA6QRQzXxG6+/yA6VGDtK+bgzCxh6Vk5arJ7TG0Gf8GN1w==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/typical/-/typical-5.1.0.tgz", + "integrity": "sha512-t5Ik8UAwBal1P1XzuVE4dc+RYQZicLUGJdvqr/vdqsED7SQECgsGBylldSsfWZL7RQjxT3xhQcKHWhLaVSR6YQ==", "dev": true }, "uglify-js": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.0.tgz", - "integrity": "sha512-W+jrUHJr3DXKhrsS7NUVxn3zqMOFn0hL/Ei6v0anCIMoKC93TjcflTagwIHLW7SfMFfiQuktQyFVCFHGUE0+yg==", + "version": "3.4.10", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.10.tgz", + "integrity": "sha512-Y2VsbPVs0FIshJztycsO2SfPk7/KAF/T72qzv9u5EpQ4kB2hQoHlhNQTsNyy6ul7lQtqJN/AoWeS23OzEiEFxw==", "dev": true, - "optional": true, "requires": { - "commander": "~2.20.0", + "commander": "~2.19.0", "source-map": "~0.6.1" }, "dependencies": { "commander": { - "version": "2.20.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", - "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==", - "dev": true, - "optional": true + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz", + "integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==", + "dev": true }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, - "optional": true + "dev": true } } }, @@ -11460,38 +10296,15 @@ "dev": true }, "union-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", - "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", + "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==", "dev": true, "requires": { "arr-union": "^3.1.0", "get-value": "^2.0.6", "is-extendable": "^0.1.1", - "set-value": "^0.4.3" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - }, - "set-value": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz", - "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=", - "dev": true, - "requires": { - "extend-shallow": "^2.0.1", - "is-extendable": "^0.1.1", - "is-plain-object": "^2.0.1", - "to-object-path": "^0.3.0" - } - } + "set-value": "^2.0.1" } }, "uniq": { @@ -11510,9 +10323,9 @@ } }, "unique-slug": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/unique-slug/-/unique-slug-2.0.1.tgz", - "integrity": "sha512-n9cU6+gITaVu7VGj1Z8feKMmfAjEAQGhwD9fE3zvpRRa0wEIx8ODYkVGfSc94M2OX00tUFV8wH3zYbm1I8mxFg==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/unique-slug/-/unique-slug-2.0.2.tgz", + "integrity": "sha512-zoWr9ObaxALD3DOPfjPSqxt4fnZiWblxHIgeWqW8x7UqDzEtHEQLzji2cuJYQFCU6KmoJikOYAZlrTHHebjx2w==", "dev": true, "requires": { "imurmurhash": "^0.1.4" @@ -11597,14 +10410,6 @@ "dev": true, "requires": { "punycode": "^2.1.0" - }, - "dependencies": { - "punycode": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", - "dev": true - } } }, "urix": { @@ -11644,6 +10449,14 @@ "dev": true, "requires": { "inherits": "2.0.3" + }, + "dependencies": { + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + } } }, "util-deprecate": { @@ -11708,13 +10521,10 @@ } }, "vm-browserify": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz", - "integrity": "sha1-XX6kW7755Kb/ZflUOOCofDV9WnM=", - "dev": true, - "requires": { - "indexof": "0.0.1" - } + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.0.tgz", + "integrity": "sha512-iq+S7vZJE60yejDYM0ek6zg308+UZsdtPExWP9VZoCFCz1zkJoXFnAX7aZfd/ZwrkidzdUZL0C/ryW+JwAiIGw==", + "dev": true }, "w3c-hr-time": { "version": "1.0.1", @@ -11763,9 +10573,9 @@ "dev": true }, "webpack": { - "version": "4.33.0", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.33.0.tgz", - "integrity": "sha512-ggWMb0B2QUuYso6FPZKUohOgfm+Z0sVFs8WwWuSH1IAvkWs428VDNmOlAxvHGTB9Dm/qOB/qtE5cRx5y01clxw==", + "version": "4.35.2", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.35.2.tgz", + "integrity": "sha512-TZAmorNymV4q66gAM/h90cEjG+N3627Q2MnkSgKlX/z3DlNVKUtqy57lz1WmZU2+FUZwzM+qm7cGaO95PyrX5A==", "dev": true, "requires": { "@webassemblyjs/ast": "1.8.5", @@ -11824,24 +10634,41 @@ } }, "webpack-cli": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-3.3.2.tgz", - "integrity": "sha512-FLkobnaJJ+03j5eplxlI0TUxhGCOdfewspIGuvDVtpOlrAuKMFC57K42Ukxqs1tn8947/PM6tP95gQc0DCzRYA==", + "version": "3.3.5", + "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-3.3.5.tgz", + "integrity": "sha512-w0j/s42c5UhchwTmV/45MLQnTVwRoaUTu9fM5LuyOd/8lFoCNCELDogFoecx5NzRUndO0yD/gF2b02XKMnmAWQ==", "dev": true, "requires": { - "chalk": "^2.4.1", - "cross-spawn": "^6.0.5", - "enhanced-resolve": "^4.1.0", - "findup-sync": "^2.0.0", - "global-modules": "^1.0.0", - "import-local": "^2.0.0", - "interpret": "^1.1.0", - "loader-utils": "^1.1.0", - "supports-color": "^5.5.0", - "v8-compile-cache": "^2.0.2", - "yargs": "^12.0.5" + "chalk": "2.4.2", + "cross-spawn": "6.0.5", + "enhanced-resolve": "4.1.0", + "findup-sync": "3.0.0", + "global-modules": "2.0.0", + "import-local": "2.0.0", + "interpret": "1.2.0", + "loader-utils": "1.2.3", + "supports-color": "6.1.0", + "v8-compile-cache": "2.0.3", + "yargs": "13.2.4" }, "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "cliui": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", + "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==", + "dev": true, + "requires": { + "string-width": "^3.1.0", + "strip-ansi": "^5.2.0", + "wrap-ansi": "^5.1.0" + } + }, "enhanced-resolve": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-4.1.0.tgz", @@ -11853,6 +10680,12 @@ "tapable": "^1.0.0" } }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true + }, "memory-fs": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.4.1.tgz", @@ -11863,10 +10696,36 @@ "readable-stream": "^2.0.1" } }, + "require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + }, "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.1.0.tgz", + "integrity": "sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ==", "dev": true, "requires": { "has-flag": "^3.0.0" @@ -11877,6 +10736,46 @@ "resolved": "https://registry.npmjs.org/tapable/-/tapable-1.1.3.tgz", "integrity": "sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA==", "dev": true + }, + "wrap-ansi": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz", + "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.0", + "string-width": "^3.0.0", + "strip-ansi": "^5.0.0" + } + }, + "yargs": { + "version": "13.2.4", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.2.4.tgz", + "integrity": "sha512-HG/DWAJa1PAnHT9JAhNa8AbAv3FPaiLzioSjCcmuXXhP8MlpHO5vwls4g4j6n30Z74GVQj8Xa62dWVx1QCGklg==", + "dev": true, + "requires": { + "cliui": "^5.0.0", + "find-up": "^3.0.0", + "get-caller-file": "^2.0.1", + "os-locale": "^3.1.0", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^3.0.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^13.1.0" + } + }, + "yargs-parser": { + "version": "13.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.1.tgz", + "integrity": "sha512-oVAVsHz6uFrg3XQheFII8ESO2ssAf9luWuAd6Wexsu4F3OtIW0o8IribPXYrD4WC24LWtPrJlGy87y5udK+dxQ==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } } } }, @@ -11891,21 +10790,10 @@ "tapable": "^1.0.0" }, "dependencies": { - "fs-extra": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.0.tgz", - "integrity": "sha512-EglNDLRpmaTWiD/qraZn6HREAEAHJcJOmxNEYwq6xeMKnVMAy3GUcFB+wXt2C6k4CNvB/mP1y/U3dzvKKj5OtQ==", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - } - }, "tapable": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/tapable/-/tapable-1.1.0.tgz", - "integrity": "sha512-IlqtmLVaZA2qab8epUXbVWRn3aB1imbDMJtjB3nu4X0NqPkcY/JH9ZtCBWKHWPxs8Svi9tyo8w2dBoi07qZbBA==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-1.1.3.tgz", + "integrity": "sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA==", "dev": true } } @@ -11985,27 +10873,13 @@ "dev": true }, "wordwrapjs": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/wordwrapjs/-/wordwrapjs-3.0.0.tgz", - "integrity": "sha512-mO8XtqyPvykVCsrwj5MlOVWvSnCdT+C+QVbm6blradR7JExAhbkZ7hZ9A+9NUtwzSqrlUo9a67ws0EiILrvRpw==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/wordwrapjs/-/wordwrapjs-4.0.0.tgz", + "integrity": "sha512-Svqw723a3R34KvsMgpjFBYCgNOSdcW3mQFK4wIfhGQhtaFVOJmdYoXgi63ne3dTlWgatVcUc7t4HtQ/+bUVIzQ==", "dev": true, "requires": { - "reduce-flatten": "^1.0.1", - "typical": "^2.6.1" - }, - "dependencies": { - "reduce-flatten": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/reduce-flatten/-/reduce-flatten-1.0.1.tgz", - "integrity": "sha1-JYx479FT3fk8tWEjf2EYTzaW4yc=", - "dev": true - }, - "typical": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/typical/-/typical-2.6.1.tgz", - "integrity": "sha1-XAgOXWYcu+OCWdLnCjxyU+hziB0=", - "dev": true - } + "reduce-flatten": "^2.0.0", + "typical": "^5.0.0" } }, "worker-farm": { @@ -12027,6 +10901,12 @@ "strip-ansi": "^3.0.1" }, "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, "is-fullwidth-code-point": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", @@ -12046,6 +10926,15 @@ "is-fullwidth-code-point": "^1.0.0", "strip-ansi": "^3.0.0" } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } } } }, @@ -12065,9 +10954,9 @@ } }, "write-file-atomic": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.3.0.tgz", - "integrity": "sha512-xuPeK4OdjWqtfi59ylvVL0Yn35SF3zgcAcv7rBPFHVaEapaDr4GdGgm3j7ckTwH9wHL7fGmgfAnb0+THrHb8tA==", + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.4.3.tgz", + "integrity": "sha512-GaETH5wwsX+GcnzhPgKcKjJ6M2Cq3/iZp1WyY/X1CSqrW+jVNM9Y7D8EC2sM4ZG/V8wZlSniJnCKWPmBYAucRQ==", "dev": true, "requires": { "graceful-fs": "^4.1.11", @@ -12087,6 +10976,23 @@ "pify": "^3.0.0", "sort-keys": "^2.0.0", "write-file-atomic": "^2.0.0" + }, + "dependencies": { + "make-dir": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.3.0.tgz", + "integrity": "sha512-2w31R7SJtieJJnQtGc7RVL2StM2vGYVfqUOvUDxH6bC6aJTxPxTF0GnIgCyu7tjockiUWAYQRbxa7vKn34s5sQ==", + "dev": true, + "requires": { + "pify": "^3.0.0" + } + }, + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "dev": true + } } }, "ws": { @@ -12140,51 +11046,6 @@ "which-module": "^2.0.0", "y18n": "^3.2.1 || ^4.0.0", "yargs-parser": "^11.1.1" - }, - "dependencies": { - "find-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", - "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", - "dev": true, - "requires": { - "locate-path": "^3.0.0" - } - }, - "locate-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", - "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", - "dev": true, - "requires": { - "p-locate": "^3.0.0", - "path-exists": "^3.0.0" - } - }, - "p-limit": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.0.tgz", - "integrity": "sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ==", - "dev": true, - "requires": { - "p-try": "^2.0.0" - } - }, - "p-locate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", - "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", - "dev": true, - "requires": { - "p-limit": "^2.0.0" - } - }, - "p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true - } } }, "yargs-parser": { diff --git a/package.json b/package.json index 91ef63c93..f8fc61020 100644 --- a/package.json +++ b/package.json @@ -48,36 +48,36 @@ "@babel/preset-env": "^7.4.5", "@babel/preset-typescript": "^7.3.3", "@types/base64-js": "^1.2.5", - "@types/jest": "^24.0.13", - "@types/loglevel": "^1.5.4", - "@types/node": "^12.0.4", - "@types/pixi.js": "^4.8.6", + "@types/jest": "^24.0.15", + "@types/loglevel": "^1.6.3", + "@types/node": "^12.0.10", + "@types/pixi.js": "^4.8.8", "@types/storejs": "^2.0.3", "@types/webfontloader": "^1.6.29", - "@typescript-eslint/eslint-plugin": "^1.9.0", - "@typescript-eslint/parser": "^1.9.0", + "@typescript-eslint/eslint-plugin": "^1.11.0", + "@typescript-eslint/parser": "^1.11.0", "babel-loader": "^8.0.6", "babel-polyfill": "^6.26.0", "babel-preset-minify": "^0.5.0", "coffeescript": "^1.12.7", - "concurrently": "^4.1.0", - "css-loader": "^2.1.1", + "concurrently": "^4.1.1", + "css-loader": "^3.0.0", "dotenv-webpack": "^1.7.0", - "eslint": "^5.16.0", - "eslint-config-airbnb-base": "^13.1.0", + "eslint": "^6.0.1", + "eslint-config-airbnb-base": "^13.2.0", "eslint-import-resolver-webpack": "^0.11.1", - "eslint-plugin-import": "^2.17.3", + "eslint-plugin-import": "^2.18.0", "file-loader": "^4.0.0", "hard-source-webpack-plugin": "0.13.1", "html-webpack-plugin": "^3.2.0", "jest": "^24.8.0", - "local-web-server": "^2.6.1", + "local-web-server": "^3.0.4", "source-map-loader": "^0.2.4", "style-loader": "^0.23.1", "ts-jest": "^24.0.2", - "typescript": "^3.5.1", - "webpack": "^4.33.0", - "webpack-cli": "^3.3.2", + "typescript": "^3.5.2", + "webpack": "^4.35.2", + "webpack-cli": "^3.3.5", "webpack-manifest-plugin": "^2.0.4", "webpack-merge": "^4.2.1" }, @@ -85,11 +85,11 @@ "base64-js": "^1.3.0", "js-polyfills": "^0.1.42", "localforage": "^1.7.3", - "loglevel": "^1.6.2", + "loglevel": "^1.6.3", "pixi-filters": "^2.7.1", "pixi-multistyle-text": "^0.7.0", "pixi-sound": "^2.1.0", - "pixi.js": "^4.8.6", + "pixi.js": "^4.8.8", "store": "^2.0.12", "upng-js": "^2.1.0", "webfontloader": "^1.6.28" From cf6ba0100a615c26511044fefe4fc16b1d42c038 Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Tue, 2 Jul 2019 17:29:43 -0400 Subject: [PATCH 13/39] Improved/safer regex --- src/flashbang/util/StringUtil.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/flashbang/util/StringUtil.ts b/src/flashbang/util/StringUtil.ts index 6880973d8..4db1398aa 100644 --- a/src/flashbang/util/StringUtil.ts +++ b/src/flashbang/util/StringUtil.ts @@ -429,8 +429,10 @@ export default class StringUtil { private static DECIMAL_REGEXP: RegExp = /^-?[0-9]*\.?[0-9]+(e-?[0-9]+)?$/; - /** A regular expression that finds URLs. */ - private static URL_REGEXP: RegExp = // new RegExp("(http|https|ftp)://\\S+", "i"); - // from John Gruber: http://daringfireball.net/2009/11/liberal_regex_for_matching_urls - new RegExp("\\b(([\\w-]+://?|www[.])[^\\s()<>]+(?:\\([\\w\\d]+\\)|([^!\\\"#$%&'()*+,\\-./:;<=>?@\\[\\\\\\]\\^_`{|}~\\s]|/)))", "i"); + /** + * A regular expression that finds URLs. + * From John Gruber: https://gist.github.com/gruber/8891611#file-liberal-regex-pattern-for-web-urls-L7 + */ + private static URL_REGEXP: RegExp = + /\b((?:(?:http|ftp)s?:(?:\/{1,3}|[a-z0-9%])|[a-z0-9.\-]+[.](?:com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|Ja|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)\/)(?:[^\s()<>{}\[\]]+|\([^\s()]*?\([^\s()]+\)[^\s()]*?\)|\([^\s]+?\))+(?:\([^\s()]*?\([^\s()]+\)[^\s()]*?\)|\([^\s]+?\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’])|(?:(? Date: Wed, 3 Jul 2019 10:54:09 -0400 Subject: [PATCH 14/39] We're using JS regex, not PCRE, and negative lookbehinds aren't well supported (or transformed by Babel), so use an alternate method for that instead --- src/flashbang/util/StringUtil.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/flashbang/util/StringUtil.ts b/src/flashbang/util/StringUtil.ts index 4db1398aa..d41148861 100644 --- a/src/flashbang/util/StringUtil.ts +++ b/src/flashbang/util/StringUtil.ts @@ -434,5 +434,5 @@ export default class StringUtil { * From John Gruber: https://gist.github.com/gruber/8891611#file-liberal-regex-pattern-for-web-urls-L7 */ private static URL_REGEXP: RegExp = - /\b((?:(?:http|ftp)s?:(?:\/{1,3}|[a-z0-9%])|[a-z0-9.\-]+[.](?:com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|Ja|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)\/)(?:[^\s()<>{}\[\]]+|\([^\s()]*?\([^\s()]+\)[^\s()]*?\)|\([^\s]+?\))+(?:\([^\s()]*?\([^\s()]+\)[^\s()]*?\)|\([^\s]+?\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’])|(?:(?{}[\]]+|\([^\s()]*?\([^\s()]+\)[^\s()]*?\)|\([^\s]+?\))+(?:\([^\s()]*?\([^\s()]+\)[^\s()]*?\)|\([^\s]+?\)|[^\s`!()[\]{};:'".,<>?«»“”‘’])|(?:(?:(?!@).|^)[a-z0-9]+(?:[.-][a-z0-9]+)*[.](?:com|net|org|edu|gov|mil|aero|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|post|pro|tel|travel|xxx|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|dd|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|Ja|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)\b\/?(?!@)))/im; } From 3f0245c4015bc887cbb506fba301164468298828 Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Fri, 5 Jul 2019 13:20:34 -0400 Subject: [PATCH 15/39] Lint fixes and general style improvements --- .eslintignore | 2 - .eslintrc.js | 104 +- .gitignore | 2 +- package-lock.json | 6 + package.json | 1 + src/eterna/ChatManager.ts | 16 +- src/eterna/EPars.ts | 410 ++-- src/eterna/Eterna.ts | 53 +- src/eterna/EternaApp.ts | 148 +- src/eterna/ExpPainter.ts | 38 +- src/eterna/Feedback.ts | 47 +- src/eterna/Plot.ts | 109 +- src/eterna/UndoBlock.ts | 190 +- src/eterna/achievements/AchievementBox.ts | 22 +- src/eterna/achievements/AchievementManager.ts | 20 +- src/eterna/achievements/index.ts | 4 +- src/eterna/debug/TestMode.ts | 6 +- src/eterna/debug/index.ts | 3 +- src/eterna/emscripten/EmscriptenUtil.ts | 9 +- src/eterna/emscripten/index.ts | 3 +- src/eterna/folding/Folder.ts | 50 +- src/eterna/folding/FolderManager.ts | 18 +- src/eterna/folding/LinearFoldBase.ts | 81 +- src/eterna/folding/LinearFoldC.ts | 8 +- src/eterna/folding/LinearFoldV.ts | 8 +- src/eterna/folding/NuPACK.ts | 352 +-- src/eterna/folding/RNAFoldBasic.ts | 127 +- src/eterna/folding/Vienna.ts | 486 ++-- src/eterna/folding/Vienna2.ts | 494 ++-- .../index.d.ts | 10 +- .../{nupack_lib => NupackLib}/index.d.ts | 22 +- .../{vienna_lib => Viena2Lib}/index.d.ts | 22 +- .../{vrna2_lib => ViennaLib}/index.d.ts | 22 +- src/eterna/folding/index.ts | 20 +- src/eterna/index.ts | 8 +- src/eterna/mode/CopyTextDialogMode.ts | 16 +- .../CustomizeColumnOrderDialog.ts | 32 +- src/eterna/mode/DesignBrowser/DataCol.ts | 274 +-- .../mode/DesignBrowser/DesignBrowserMode.ts | 323 +-- src/eterna/mode/DesignBrowser/DotLine.ts | 26 +- src/eterna/mode/DesignBrowser/GridLines.ts | 2 +- src/eterna/mode/DesignBrowser/LabComments.ts | 30 +- .../mode/DesignBrowser/MarkerBoxView.ts | 8 +- src/eterna/mode/DesignBrowser/SelectionBox.ts | 4 +- .../DesignBrowser/SequenceStringListView.ts | 132 +- .../mode/DesignBrowser/SolutionDescBox.ts | 120 +- src/eterna/mode/DesignBrowser/SortOptions.ts | 48 +- .../mode/DesignBrowser/SortOptionsDialog.ts | 46 +- .../mode/DesignBrowser/ViewSolutionDialog.ts | 105 +- .../mode/DesignBrowser/VoteProcessor.ts | 36 +- src/eterna/mode/DesignBrowser/index.ts | 28 +- src/eterna/mode/ErrorDialogMode.ts | 20 +- src/eterna/mode/FeedbackViewMode.ts | 180 +- src/eterna/mode/GameMode.ts | 72 +- src/eterna/mode/LoadingMode.ts | 18 +- src/eterna/mode/PoseEdit/Booster.ts | 104 +- .../mode/PoseEdit/MissionClearedPanel.ts | 38 +- src/eterna/mode/PoseEdit/MissionIntroMode.ts | 33 +- src/eterna/mode/PoseEdit/PoseEditMode.ts | 2041 +++++++++-------- src/eterna/mode/PoseEdit/SubmitPoseDialog.ts | 14 +- src/eterna/mode/PoseEdit/SubmittingDialog.ts | 14 +- src/eterna/mode/PoseEdit/index.ts | 14 +- src/eterna/mode/PuzzleEdit/PuzzleEditMode.ts | 422 ++-- src/eterna/mode/PuzzleEdit/StructureInput.ts | 164 +- .../mode/PuzzleEdit/SubmitPuzzleDialog.ts | 72 +- src/eterna/mode/PuzzleEdit/index.ts | 6 +- src/eterna/mode/index.ts | 16 +- src/eterna/net/EternaURL.ts | 123 +- src/eterna/net/GameClient.ts | 106 +- src/eterna/net/index.ts | 4 +- src/eterna/pose2D/Base.ts | 377 +-- src/eterna/pose2D/BaseAssets.ts | 221 +- src/eterna/pose2D/BaseTextures.ts | 101 +- src/eterna/pose2D/EnergyScoreDisplay.ts | 44 +- src/eterna/pose2D/ExplosionFactorPanel.ts | 36 +- src/eterna/pose2D/HighlightBox.ts | 289 +-- src/eterna/pose2D/Molecule.ts | 26 +- src/eterna/pose2D/PaintCursor.ts | 103 +- src/eterna/pose2D/Pose2D.ts | 1655 +++++++------ src/eterna/pose2D/PoseField.ts | 32 +- src/eterna/pose2D/PoseOp.ts | 2 +- src/eterna/pose2D/PoseUtil.ts | 118 +- src/eterna/pose2D/PuzzleEditOp.ts | 10 +- src/eterna/pose2D/RNAAnchorObject.ts | 8 +- src/eterna/pose2D/RNALayout.ts | 405 ++-- src/eterna/pose2D/ScoreDisplayNode.ts | 22 +- src/eterna/pose2D/index.ts | 36 +- src/eterna/puzzle/Constraints.ts | 76 +- src/eterna/puzzle/Puzzle.ts | 199 +- src/eterna/puzzle/PuzzleManager.ts | 185 +- src/eterna/puzzle/Solution.ts | 70 +- src/eterna/puzzle/SolutionManager.ts | 124 +- src/eterna/puzzle/index.ts | 10 +- src/eterna/rank/PlayerRank.ts | 2 +- src/eterna/rank/RankBoard.ts | 37 +- src/eterna/rank/RankRowLayout.ts | 24 +- src/eterna/rank/RankScroll.ts | 199 +- src/eterna/rank/index.ts | 8 +- src/eterna/resources/BitmapManager.ts | 12 +- src/eterna/resources/Bitmaps.ts | 568 ++--- src/eterna/resources/PlaySoundTask.ts | 6 +- src/eterna/resources/SoundManager.ts | 14 +- src/eterna/resources/Sounds.ts | 46 +- src/eterna/resources/index.ts | 10 +- src/eterna/rscript/NovaPaintHint.ts | 35 +- src/eterna/rscript/RNAScript.ts | 58 +- src/eterna/rscript/ROPHighlight.ts | 346 +-- src/eterna/rscript/ROPHint.ts | 52 +- src/eterna/rscript/ROPPre.ts | 120 +- src/eterna/rscript/ROPRNA.ts | 92 +- src/eterna/rscript/ROPTextbox.ts | 360 +-- src/eterna/rscript/ROPUI.ts | 4 +- src/eterna/rscript/ROPWait.ts | 166 +- src/eterna/rscript/RScriptArrow.ts | 29 +- src/eterna/rscript/RScriptEnv.ts | 170 +- src/eterna/rscript/RScriptOp.ts | 32 +- src/eterna/rscript/RScriptOpTree.ts | 16 +- src/eterna/rscript/RScriptUIElement.ts | 90 +- src/eterna/rscript/index.ts | 28 +- src/eterna/settings/EternaSettings.ts | 50 +- src/eterna/settings/index.ts | 3 +- src/eterna/ui/ActionBar.ts | 62 +- src/eterna/ui/AsyncProcessDialog.ts | 14 +- src/eterna/ui/Band.ts | 24 +- src/eterna/ui/BaseGamePanel.ts | 4 +- src/eterna/ui/ConfirmDialog.ts | 26 +- src/eterna/ui/ConstraintBox.ts | 322 +-- src/eterna/ui/ContextMenu.ts | 14 +- src/eterna/ui/Dialog.ts | 12 +- src/eterna/ui/EternaMenu.ts | 52 +- src/eterna/ui/EternaViewOptionsDialog.ts | 52 +- src/eterna/ui/FancyGamePanel.ts | 14 +- src/eterna/ui/FancyTextBalloon.ts | 24 +- src/eterna/ui/FixedWidthTextField.ts | 29 +- src/eterna/ui/GameButton.ts | 32 +- src/eterna/ui/GameCheckbox.ts | 10 +- src/eterna/ui/GamePanel.ts | 14 +- src/eterna/ui/HTMLTextObject.ts | 44 +- src/eterna/ui/NotificationDialog.ts | 18 +- src/eterna/ui/NucleotidePalette.ts | 136 +- src/eterna/ui/PasteSequenceDialog.ts | 18 +- src/eterna/ui/PoseThumbnail.ts | 248 +- src/eterna/ui/ScrollContainer.ts | 6 +- src/eterna/ui/SliderBar.ts | 68 +- src/eterna/ui/SpecBox.ts | 114 +- src/eterna/ui/SpecBoxDialog.ts | 24 +- src/eterna/ui/TextBalloon.ts | 62 +- src/eterna/ui/TextInputObject.ts | 49 +- src/eterna/ui/TextInputPanel.ts | 30 +- src/eterna/ui/ToggleBar.ts | 47 +- src/eterna/ui/Toolbar.ts | 153 +- src/eterna/ui/Tooltips.ts | 28 +- src/eterna/ui/UILockDialog.ts | 6 +- src/eterna/ui/URLButton.ts | 6 +- src/eterna/ui/VScrollBox.ts | 18 +- src/eterna/ui/index.ts | 68 +- src/eterna/util/CSVParser.ts | 41 - src/eterna/util/EternaTextureUtil.ts | 54 +- src/eterna/util/ExternalInterface.ts | 52 +- src/eterna/util/Fonts.ts | 36 +- src/eterna/util/GraphicsUtil.ts | 20 +- src/eterna/util/Utility.ts | 79 +- src/eterna/util/index.ts | 13 +- src/eterna/vfx/Background.ts | 14 +- src/eterna/vfx/BaseGlow.ts | 48 +- src/eterna/vfx/Bubble.ts | 50 +- src/eterna/vfx/BubbleSweep.ts | 6 +- src/eterna/vfx/LightRay.ts | 12 +- src/eterna/vfx/VibrateTask.ts | 8 +- src/eterna/vfx/index.ts | 12 +- src/flashbang/core/AppMode.ts | 53 +- src/flashbang/core/Flashbang.ts | 15 +- src/flashbang/core/FlashbangApp.ts | 26 +- src/flashbang/core/GameObject.ts | 39 +- src/flashbang/core/GameObjectBase.ts | 30 +- src/flashbang/core/GameObjectRef.ts | 10 +- src/flashbang/core/ModeStack.ts | 39 +- src/flashbang/core/ObjectTask.ts | 8 +- src/flashbang/core/index.ts | 22 +- src/flashbang/geom/Vector2.ts | 2 +- src/flashbang/geom/index.ts | 3 +- .../input/DisplayObjectPointerTarget.ts | 22 +- src/flashbang/input/KeyCode.ts | 310 +-- src/flashbang/input/KeyboardEventType.ts | 4 +- src/flashbang/input/KeyboardInput.ts | 10 +- src/flashbang/input/MouseWheelInput.ts | 10 +- src/flashbang/input/PointerCapture.ts | 12 +- src/flashbang/input/PointerTarget.ts | 4 +- src/flashbang/input/index.ts | 16 +- src/flashbang/layout/HLayoutContainer.ts | 10 +- src/flashbang/layout/LayoutContainer.ts | 4 +- src/flashbang/layout/VLayoutContainer.ts | 10 +- src/flashbang/layout/index.ts | 6 +- src/flashbang/objects/Button.ts | 34 +- src/flashbang/objects/ContainerObject.ts | 6 +- src/flashbang/objects/DOMObject.ts | 33 +- src/flashbang/objects/Dragger.ts | 16 +- src/flashbang/objects/ImageButton.ts | 6 +- src/flashbang/objects/SceneObject.ts | 8 +- src/flashbang/objects/SimpleTextButton.ts | 8 +- src/flashbang/objects/SpriteObject.ts | 6 +- src/flashbang/objects/ToggleButton.ts | 4 +- src/flashbang/objects/index.ts | 20 +- src/flashbang/resources/FontLoader.ts | 6 +- src/flashbang/resources/index.ts | 3 +- src/flashbang/settings/SaveGameManager.ts | 10 +- src/flashbang/settings/Setting.ts | 4 +- src/flashbang/settings/Settings.ts | 4 +- src/flashbang/settings/index.ts | 6 +- src/flashbang/tasks/AlphaTask.ts | 6 +- src/flashbang/tasks/CallbackTask.ts | 2 +- src/flashbang/tasks/DelayTask.ts | 2 +- src/flashbang/tasks/DisplayObjectTask.ts | 8 +- src/flashbang/tasks/FrameDelayTask.ts | 2 +- src/flashbang/tasks/FunctionTask.ts | 2 +- src/flashbang/tasks/InterpolatingTask.ts | 4 +- src/flashbang/tasks/LocationTask.ts | 6 +- src/flashbang/tasks/ParallelTask.ts | 4 +- src/flashbang/tasks/RepeatingTask.ts | 2 +- src/flashbang/tasks/RotationTask.ts | 6 +- src/flashbang/tasks/ScaleTask.ts | 6 +- src/flashbang/tasks/SelfDestructTask.ts | 2 +- src/flashbang/tasks/SerialTask.ts | 4 +- src/flashbang/tasks/VisibleTask.ts | 8 +- src/flashbang/tasks/index.ts | 30 +- src/flashbang/util/Assert.ts | 13 +- src/flashbang/util/Base64.ts | 6 +- src/flashbang/util/ColorUtil.ts | 6 +- src/flashbang/util/Deferred.ts | 2 +- src/flashbang/util/DisplayUtil.ts | 102 +- src/flashbang/util/Easing.ts | 2 +- src/flashbang/util/ErrorUtil.ts | 4 +- src/flashbang/util/EventSignal.ts | 4 +- src/flashbang/util/JSONUtil.ts | 2 +- src/flashbang/util/LinkedList.ts | 8 +- src/flashbang/util/MathUtil.ts | 4 +- src/flashbang/util/MatrixUtil.ts | 6 +- src/flashbang/util/PowerEaser.ts | 4 +- src/flashbang/util/RectangleUtil.ts | 4 +- src/flashbang/util/StringUtil.ts | 83 +- src/flashbang/util/StyledTextBuilder.ts | 40 +- src/flashbang/util/TextBuilder.ts | 18 +- src/flashbang/util/TextUtil.ts | 4 +- src/flashbang/util/TextureUtil.ts | 29 +- src/flashbang/util/index.ts | 40 +- src/signals/AbstractSignal.ts | 6 +- src/signals/AbstractValue.ts | 10 +- src/signals/Connection.ts | 2 +- src/signals/Cons.ts | 12 +- src/signals/FilteredSignal.ts | 6 +- src/signals/MappedSignal.ts | 8 +- src/signals/MappedValue.ts | 6 +- src/signals/MultiFailureError.ts | 10 +- src/signals/Reactor.ts | 10 +- src/signals/RegistrationGroup.ts | 4 +- src/signals/Registrations.ts | 2 +- src/signals/Signal.ts | 8 +- src/signals/SignalView.ts | 2 +- src/signals/UnitSignal.ts | 8 +- src/signals/Value.ts | 6 +- src/signals/ValueView.ts | 2 +- src/signals/index.ts | 34 +- 262 files changed, 9355 insertions(+), 8726 deletions(-) rename src/eterna/folding/engines/{LinearFold_lib => LinearFoldLib}/index.d.ts (87%) rename src/eterna/folding/engines/{nupack_lib => NupackLib}/index.d.ts (78%) rename src/eterna/folding/engines/{vienna_lib => Viena2Lib}/index.d.ts (77%) rename src/eterna/folding/engines/{vrna2_lib => ViennaLib}/index.d.ts (77%) delete mode 100644 src/eterna/util/CSVParser.ts diff --git a/.eslintignore b/.eslintignore index 5cf2c4ba5..cb5c9b674 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,2 @@ __tests__/ *.d.ts -/src/eterna/mode/PoseEdit/PoseEditMode.ts -/src/eterna/pose2D \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js index 948584a52..c3dac0e69 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,12 +1,12 @@ module.exports = { 'extends': ['airbnb-base', 'plugin:@typescript-eslint/recommended'], - 'parser': '@typescript-eslint/parser', + //'parser': '@typescript-eslint/parser', 'parserOptions': { 'project': './tsconfig.json' }, - 'plugins': [ + /*'plugins': [ '@typescript-eslint' - ], + ],*/ // Some imports may be resolved via webpack aliases 'settings': { 'import/resolver': { @@ -16,60 +16,80 @@ module.exports = { } }, 'rules': { + // Broken // This rule frequently throws up false positives with subclasses https://github.com/typescript-eslint/typescript-eslint/issues/52 'class-methods-use-this': 'off', // Same with this one https://github.com/typescript-eslint/typescript-eslint/issues/586 '@typescript-eslint/no-unused-vars': 'off', - // Don't bug out due to TypeScript + + // Prefer typescript-eslint version + 'semi': 'off', + '@typescript-eslint/semi': 'error', + + // Handled by typescript + 'no-dupe-class-members': 'off', 'no-undef': 'off', - // typescript-eslint handles this one - 'no-use-before-define': 'off', + // These aren't really a big issue and used well keep our code cleaner 'no-bitwise': 'off', 'no-continue': 'off', 'no-plusplus': 'off', 'no-underscore-dangle': 'off', + 'no-fallthrough': ['error', { "commentPattern": "break[\\s\\w]*omitted" }], '@typescript-eslint/no-use-before-define': ['error', {'classes': false}], - // Additionally, only use warn since internal members are marked without modifiers, since internal doesn't exist yet https://github.com/Microsoft/TypeScript/issues/5228 + // NOTE: Some are public but marked `/* internal */`, awaiting https://github.com/Microsoft/TypeScript/issues/5228 '@typescript-eslint/explicit-member-accessibility': ['warn', { - "accessibility": "explicit", 'overrides': {'constructors': 'no-public'} }], '@typescript-eslint/no-angle-bracket-type-assertion': 'off', + '@typescript-eslint/explicit-function-return-type': ['off', { + 'allowTypedFunctionExpressions': true + }], + 'no-constant-condition': ['error', { 'checkLoops': false }], // We like using for..of statements, so we have to redefine with everything else via the airbnb config (https://github.com/airbnb/javascript/blob/a510095acf20e3d96a94e6d0d0b26cfac71d2c7f/packages/eslint-config-airbnb-base/rules/style.js#L334) 'no-restricted-syntax': ['error', - { - 'selector': 'ForInStatement', - 'message': 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.', - }, - { - 'selector': 'LabeledStatement', - 'message': 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.', - }, - { - 'selector': 'WithStatement', - 'message': '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.', - }, - ], - // For everything here on out, keep at least for now, so as not to cause issues/slow down while porting. - // Discuss/review these later for final determinations - 'indent': ['error', 4], - 'camelcase': 'off', - 'quotes': ['error', 'double'], - 'object-curly-spacing': ['error', 'never'], - 'prefer-const': 'off', - 'lines-between-class-members': ['error', 'always', {'exceptAfterSingleLine': true}], - 'comma-dangle': ['error', 'never'], - 'max-len': ['warn', {'code': 120}], - 'no-else-return': 'off', - // At least until the dynamic content changes to interfaces - 'dot-notation': 'off', - // Outparams are used in some places to reduce allocations, however it'd be nice to have in general... - // Should probably reconfigure with ignorePropertyModificationsFor - 'no-param-reassign': 'off', - // This is currently broken https://github.com/benmosher/eslint-plugin-import/issues/1152 - 'import/order': 'off', - // prefer-default-export hurts refactorability, and leads to style inconsistencies (enums can't be default-exported) - 'import/prefer-default-export': 'off', + { + 'selector': 'ForInStatement', + 'message': 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.', + }, + { + 'selector': 'LabeledStatement', + 'message': 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.', + }, + { + 'selector': 'WithStatement', + 'message': '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.', + }, + ], + + // Stylistic preference + 'comma-dangle': ['error', 'never'], + //'quotes': ['error', 'single'], + 'max-len': ['error', { + 'code': 120, + 'ignoreTemplateLiterals': true, + 'ignoreRegExpLiterals': true, + 'ignoreUrls': true + }], + 'lines-between-class-members': ['error', 'always', {'exceptAfterSingleLine': true}], + 'object-curly-spacing': ['error', 'never'], + // This can be more readable depending on the situation + 'no-else-return': 'off', + // const should really be used to indicate that something *shouldn't* change, not just that it doesn't + 'prefer-const': 'off', + // This would be great if it could pick up when we reassign multiple properties, but it's all sorts of + // painful/less readable in a large number of of cases + 'prefer-destructuring': 'off', + + // Stuff to review, likely due to impending code changes + // This isn't generally great practice, but a couple portions of our code benefit from this. + 'no-cond-assign': ['error', 'except-parens'], + // At least until the dynamic content changes to interfaces + 'dot-notation': 'off', + '@typescript-eslint/no-explicit-any': 'off', + // Outparams are used in some places to reduce allocations, however it'd be nice to have in general... + // Should probably reconfigure with ignorePropertyModificationsFor + 'no-param-reassign': 'off' } -}; + }; + \ No newline at end of file diff --git a/.gitignore b/.gitignore index c9a45ff45..a545cfde4 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,7 @@ CTestTestfile.cmake # JetBrains CLion vienna.cbp nupack.cbp -vrna2.cbp +vienna2.cbp LinearFold.cbp cmake-build-debug/ cmake-build-release/ diff --git a/package-lock.json b/package-lock.json index 61daa038a..0b7c1ad5a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1402,6 +1402,12 @@ "integrity": "sha512-VF/KPGUEKxi7j3//HaPCKaKbMtKOnWYf+aLzZcBQrhQAcHevA4OA2HwFpeJ6S6JD7xpS06G3K7oZkyIfp9lfeQ==", "dev": true }, + "@types/upng-js": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@types/upng-js/-/upng-js-2.1.1.tgz", + "integrity": "sha512-jzQGgtmEqWJgyL5I/z3Gw7p6RjOYzF7sXQ1r/2bPa1YQ6Zvn+hTqdRm+XE3Yi6Q4f6NFmk5Xlk7hhTB0eaXaUg==", + "dev": true + }, "@types/webfontloader": { "version": "1.6.29", "resolved": "https://registry.npmjs.org/@types/webfontloader/-/webfontloader-1.6.29.tgz", diff --git a/package.json b/package.json index f8fc61020..3664a6452 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,7 @@ "@types/node": "^12.0.10", "@types/pixi.js": "^4.8.8", "@types/storejs": "^2.0.3", + "@types/upng-js": "^2.1.1", "@types/webfontloader": "^1.6.29", "@typescript-eslint/eslint-plugin": "^1.11.0", "@typescript-eslint/parser": "^1.11.0", diff --git a/src/eterna/ChatManager.ts b/src/eterna/ChatManager.ts index 09e5467b1..1f2688516 100644 --- a/src/eterna/ChatManager.ts +++ b/src/eterna/ChatManager.ts @@ -1,13 +1,13 @@ -import {EternaSettings} from "eterna/settings"; -import * as log from "loglevel"; +import {EternaSettings} from 'eterna/settings'; +import * as log from 'loglevel'; export default class ChatManager { - public constructor(chatboxID: string, settings: EternaSettings) { + constructor(chatboxID: string, settings: EternaSettings) { this._chatbox = document.getElementById(chatboxID); if (this._chatbox == null) { log.warn(`Missing chatbox (id=${chatboxID})`); } else { - let iframe: HTMLIFrameElement = this._chatbox.getElementsByTagName("iframe")[0]; + let iframe: HTMLIFrameElement = this._chatbox.getElementsByTagName('iframe')[0]; if (iframe == null) { log.warn(`No iframe in chatbox (id=${chatboxID}`); } else { @@ -22,7 +22,7 @@ export default class ChatManager { /** Posts a message to the chat */ public postText(text: string): void { if (this._chatIFrame != null) { - this._chatIFrame.postMessage({type: "chat-message", content: text}, "*"); + this._chatIFrame.postMessage({type: 'chat-message', content: text}, '*'); } } @@ -35,7 +35,7 @@ export default class ChatManager { /** Decreases the hideChat counter. Chat is visible if the counter is 0. */ public popHideChat(): void { if (this._hideChat <= 0) { - log.warn("popHideChat, but no matching pushHideChat"); + log.warn('popHideChat, but no matching pushHideChat'); } else { this._hideChat--; this.updateChatVisibility(); @@ -48,8 +48,8 @@ export default class ChatManager { } let show = this._settings.showChat.value && this._hideChat <= 0; - this._chatbox.style.display = show ? null : "none"; - if (show) this._chatIFrame.postMessage({type: "chat-scroll"}, "*"); + this._chatbox.style.display = show ? null : 'none'; + if (show) this._chatIFrame.postMessage({type: 'chat-scroll'}, '*'); } private readonly _chatbox: HTMLElement; diff --git a/src/eterna/EPars.ts b/src/eterna/EPars.ts index 285d77314..87d187a26 100644 --- a/src/eterna/EPars.ts +++ b/src/eterna/EPars.ts @@ -1,5 +1,5 @@ -import {StyledTextBuilder} from "flashbang/util"; -import IntLoopPars from "eterna/IntLoopPars"; +import {StyledTextBuilder} from 'flashbang/util'; +import IntLoopPars from 'eterna/IntLoopPars'; export default class EPars { public static readonly INF: number = 1000000; @@ -56,10 +56,12 @@ export default class EPars { /* only F[2] used */ public static readonly RNABASE_LAST20: number[] = [ - EPars.RNABASE_ADENINE, EPars.RNABASE_ADENINE, EPars.RNABASE_ADENINE, EPars.RNABASE_GUANINE, EPars.RNABASE_ADENINE, - EPars.RNABASE_ADENINE, EPars.RNABASE_ADENINE, EPars.RNABASE_CYTOSINE, EPars.RNABASE_ADENINE, EPars.RNABASE_ADENINE, - EPars.RNABASE_CYTOSINE, EPars.RNABASE_ADENINE, EPars.RNABASE_ADENINE, EPars.RNABASE_CYTOSINE, EPars.RNABASE_ADENINE, - EPars.RNABASE_ADENINE, EPars.RNABASE_CYTOSINE, EPars.RNABASE_ADENINE, EPars.RNABASE_ADENINE, EPars.RNABASE_CYTOSINE]; + EPars.RNABASE_ADENINE, EPars.RNABASE_ADENINE, EPars.RNABASE_ADENINE, EPars.RNABASE_GUANINE, + EPars.RNABASE_ADENINE, EPars.RNABASE_ADENINE, EPars.RNABASE_ADENINE, EPars.RNABASE_CYTOSINE, + EPars.RNABASE_ADENINE, EPars.RNABASE_ADENINE, EPars.RNABASE_CYTOSINE, EPars.RNABASE_ADENINE, + EPars.RNABASE_ADENINE, EPars.RNABASE_CYTOSINE, EPars.RNABASE_ADENINE, EPars.RNABASE_ADENINE, + EPars.RNABASE_CYTOSINE, EPars.RNABASE_ADENINE, EPars.RNABASE_ADENINE, EPars.RNABASE_CYTOSINE + ]; public static readonly HAIRPIN_37: number[] = [ EPars.INF, EPars.INF, EPars.INF, 570, 560, 560, 540, 590, 560, 640, 650, @@ -85,49 +87,49 @@ export default class EPars { } public static getBarcodeHairpin(seq: string): string { - let hairpin_match: string[] = (/[AGUC]{7}UUCG([AGUC]{7})AAAAGAAACAACAACAACAAC$/i).exec(seq); - if (hairpin_match == null) { + let hairpinMatch: string[] = (/[AGUC]{7}UUCG([AGUC]{7})AAAAGAAACAACAACAACAAC$/i).exec(seq); + if (hairpinMatch == null) { return null; } - return hairpin_match[1]; + return hairpinMatch[1]; } public static getLongestStackLength(pairs: number[]): number { let longlen = 0; - let stack_start = -1; - let last_stack_other = -1; + let stackStart = -1; + let lastStackOther = -1; for (let ii = 0; ii < pairs.length; ii++) { if (pairs[ii] > ii) { - if (stack_start < 0) { - stack_start = ii; + if (stackStart < 0) { + stackStart = ii; } - let is_continued = false; - if (last_stack_other < 0) { - is_continued = true; - } else if (pairs[ii] === last_stack_other - 1) { - is_continued = true; + let isContinued = false; + if (lastStackOther < 0) { + isContinued = true; + } else if (pairs[ii] === lastStackOther - 1) { + isContinued = true; } - if (is_continued) { - last_stack_other = pairs[ii]; + if (isContinued) { + lastStackOther = pairs[ii]; } else { - if (stack_start >= 0 && ii - stack_start > longlen) { - longlen = ii - stack_start; + if (stackStart >= 0 && ii - stackStart > longlen) { + longlen = ii - stackStart; } - last_stack_other = -1; - stack_start = -1; + lastStackOther = -1; + stackStart = -1; } } else { - if (stack_start >= 0 && ii - stack_start > longlen) { - longlen = ii - stack_start; + if (stackStart >= 0 && ii - stackStart > longlen) { + longlen = ii - stackStart; } - stack_start = -1; - last_stack_other = -1; + stackStart = -1; + lastStackOther = -1; } } @@ -135,13 +137,13 @@ export default class EPars { } public static getLetterColor(letter: string): number { - if (letter === "G") { + if (letter === 'G') { return 0xFF3333; - } else if (letter === "A") { + } else if (letter === 'A') { return 0xFFFF33; - } else if (letter === "U") { + } else if (letter === 'U') { return 0x7777FF; - } else if (letter === "C") { + } else if (letter === 'C') { return 0x33FF33; } @@ -149,59 +151,59 @@ export default class EPars { } public static addLetterStyles(builder: StyledTextBuilder): void { - builder.addStyle("G", {fill: this.getLetterColor("G")}); - builder.addStyle("A", {fill: this.getLetterColor("A")}); - builder.addStyle("U", {fill: this.getLetterColor("U")}); - builder.addStyle("C", {fill: this.getLetterColor("C")}); + builder.addStyle('G', {fill: this.getLetterColor('G')}); + builder.addStyle('A', {fill: this.getLetterColor('A')}); + builder.addStyle('U', {fill: this.getLetterColor('U')}); + builder.addStyle('C', {fill: this.getLetterColor('C')}); } public static getColoredLetter(letter: string): string { - if (letter === "G") { - return "G"; - } else if (letter === "A") { - return "A"; - } else if (letter === "U") { - return "U"; - } else if (letter === "C") { - return "C"; + if (letter === 'G') { + return 'G'; + } else if (letter === 'A') { + return 'A'; + } else if (letter === 'U') { + return 'U'; + } else if (letter === 'C') { + return 'C'; } - return ""; + return ''; } public static getColoredSequence(seq: string): string { - let res = ""; + let res = ''; for (let ii = 0; ii < seq.length; ii++) { res += EPars.getColoredLetter(seq.charAt(ii)); } return res; } - public static getExpColoredSequence(seq: string, exp_data: number[]): string { - if (exp_data == null) { + public static getExpColoredSequence(seq: string, expData: number[]): string { + if (expData == null) { return seq; } - let offset: number = exp_data[0]; - let maxmax: number = exp_data[1]; - let minmin: number = exp_data[1]; - for (let ii = 1; ii < exp_data.length; ii++) { - if (exp_data[ii] > maxmax) { - maxmax = exp_data[ii]; + let offset: number = expData[0]; + let maxmax: number = expData[1]; + let minmin: number = expData[1]; + for (let ii = 1; ii < expData.length; ii++) { + if (expData[ii] > maxmax) { + maxmax = expData[ii]; } - if (exp_data[ii] < minmin) { - minmin = exp_data[ii]; + if (expData[ii] < minmin) { + minmin = expData[ii]; } } let avg: number = (maxmax + minmin) / 2.0; - let res = ""; + let res = ''; for (let ii = 0; ii < seq.length; ii++) { - if (ii < offset - 1 || ii >= exp_data.length) { + if (ii < offset - 1 || ii >= expData.length) { res += seq.charAt(ii); - } else if (exp_data[ii] < avg) { + } else if (expData[ii] < avg) { res += `${seq.charAt(ii)}`; } else { res += `${seq.charAt(ii)}`; @@ -212,83 +214,85 @@ export default class EPars { } public static countConsecutive(sequence: number[], letter: number, locks: boolean[] | null = null): number { - let max_consecutive = 0; + let maxConsecutive = 0; let ii = 0; - let start_index = -1; + let startIndex = -1; for (ii = 0; ii < sequence.length; ii++) { if (sequence[ii] === letter) { - if (start_index < 0) { - start_index = ii; + if (startIndex < 0) { + startIndex = ii; } - } else if (start_index >= 0) { - if (max_consecutive < ii - start_index) { + } else if (startIndex >= 0) { + if (maxConsecutive < ii - startIndex) { if (locks == null) { - max_consecutive = ii - start_index; + maxConsecutive = ii - startIndex; } else { - let all_locked = true; + let allLocked = true; let jj: number; - for (jj = start_index; jj < ii; jj++) { - all_locked = all_locked && locks[jj]; + for (jj = startIndex; jj < ii; jj++) { + allLocked = allLocked && locks[jj]; } - if (all_locked === false) { - max_consecutive = ii - start_index; + if (allLocked === false) { + maxConsecutive = ii - startIndex; } } } - start_index = -1; + startIndex = -1; } } - if (start_index >= 0) { - if (max_consecutive < ii - start_index) { - max_consecutive = ii - start_index; + if (startIndex >= 0) { + if (maxConsecutive < ii - startIndex) { + maxConsecutive = ii - startIndex; } } - return max_consecutive; + return maxConsecutive; } - public static getRestrictedConsecutive(sequence: number[], letter: number, max_allowed: number, locks: boolean[] | null = null): number[] { + public static getRestrictedConsecutive( + sequence: number[], letter: number, maxAllowed: number, locks: boolean[] | null = null + ): number[] { let restricted: number[] = []; let ii = 0; - let start_index = -1; + let startIndex = -1; - if (max_allowed <= 0) { + if (maxAllowed <= 0) { return restricted; } for (ii = 0; ii < sequence.length; ii++) { if (sequence[ii] === letter) { - if (start_index < 0) { - start_index = ii; + if (startIndex < 0) { + startIndex = ii; } - } else if (start_index >= 0) { - if (max_allowed < ii - start_index) { + } else if (startIndex >= 0) { + if (maxAllowed < ii - startIndex) { if (locks == null) { - restricted.push(start_index); + restricted.push(startIndex); restricted.push(ii - 1); } else { - let all_locked = true; + let allLocked = true; let jj: number; - for (jj = start_index; jj < ii; jj++) { - all_locked = all_locked && locks[jj]; + for (jj = startIndex; jj < ii; jj++) { + allLocked = allLocked && locks[jj]; } - if (all_locked === false) { - restricted.push(start_index); + if (allLocked === false) { + restricted.push(startIndex); restricted.push(ii - 1); } } } - start_index = -1; + startIndex = -1; } } - // gotta check if we found a start_index without an end... - if (start_index >= 0) { - if (max_allowed < ii - start_index) { - restricted.push(start_index); + // gotta check if we found a startIndex without an end... + if (startIndex >= 0) { + if (maxAllowed < ii - startIndex) { + restricted.push(startIndex); restricted.push(ii - 1); } } @@ -296,54 +300,54 @@ export default class EPars { return restricted; } - public static getSequenceRepetition(seq_str: string, n: number): number { + public static getSequenceRepetition(seqStr: string, n: number): number { let dict: Set = new Set(); - let num_repeats = 0; + let numRepeats = 0; - for (let ii = 0; ii < seq_str.length - n; ii++) { - let substr: string = seq_str.substr(ii, n); + for (let ii = 0; ii < seqStr.length - n; ii++) { + let substr: string = seqStr.substr(ii, n); if (dict.has(substr)) { - num_repeats++; + numRepeats++; } else { dict.add(substr); } } - return num_repeats++; + return numRepeats++; } public static nucleotideToString(value: number, allowCut: boolean, allowUnknown: boolean): string { if (value === EPars.RNABASE_ADENINE) { - return "A"; + return 'A'; } else if (value === EPars.RNABASE_URACIL) { - return "U"; + return 'U'; } else if (value === EPars.RNABASE_GUANINE) { - return "G"; + return 'G'; } else if (value === EPars.RNABASE_CYTOSINE) { - return "C"; + return 'C'; } else if (value === EPars.RNABASE_CUT) { if (allowCut) { - return "&"; + return '&'; } else { throw new Error(`Bad nucleotide '${value}`); } } else if (allowUnknown) { - return "?"; + return '?'; } else { throw new Error(`Bad nucleotide '${value}`); } } public static stringToNucleotide(value: string, allowCut: boolean, allowUnknown: boolean): number { - if (value === "A" || value === "a") { + if (value === 'A' || value === 'a') { return EPars.RNABASE_ADENINE; - } else if (value === "G" || value === "g") { + } else if (value === 'G' || value === 'g') { return EPars.RNABASE_GUANINE; - } else if (value === "U" || value === "u") { + } else if (value === 'U' || value === 'u') { return EPars.RNABASE_URACIL; - } else if (value === "C" || value === "c") { + } else if (value === 'C' || value === 'c') { return EPars.RNABASE_CYTOSINE; - } else if (value === "&" || value === "-" || value === "+") { + } else if (value === '&' || value === '-' || value === '+') { if (allowCut) { return EPars.RNABASE_CUT; } else { @@ -366,7 +370,7 @@ export default class EPars { } public static sequenceToString(sequence: number[], allowCut: boolean = true, allowUnknown: boolean = true): string { - let str = ""; + let str = ''; for (let value of sequence) { str += EPars.nucleotideToString(value, allowCut, allowUnknown); } @@ -374,10 +378,10 @@ export default class EPars { } public static isInternal(index: number, pairs: number[]): number[] | null { - let pair_start_here = -1; - let pair_end_here = -1; - let pair_start_there = -1; - let pair_end_there = -1; + let pairStartHere = -1; + let pairEndHere = -1; + let pairStartThere = -1; + let pairEndThere = -1; if (pairs[index] >= 0) { return null; @@ -386,8 +390,8 @@ export default class EPars { let walker: number = index; while (walker >= 0) { if (pairs[walker] >= 0) { - pair_start_here = walker; - pair_start_there = pairs[walker]; + pairStartHere = walker; + pairStartThere = pairs[walker]; break; } walker--; @@ -396,25 +400,25 @@ export default class EPars { walker = index; while (walker < pairs.length) { if (pairs[walker] >= 0) { - pair_end_here = walker; - pair_end_there = pairs[walker]; + pairEndHere = walker; + pairEndThere = pairs[walker]; break; } walker++; } - if (pair_start_here < 0 || pair_end_here < 0) { + if (pairStartHere < 0 || pairEndHere < 0) { return null; } - let there_start: number = Math.min(pair_start_there, pair_end_there); - let there_end: number = Math.max(pair_start_there, pair_end_there); + let thereStart: number = Math.min(pairStartThere, pairEndThere); + let thereEnd: number = Math.max(pairStartThere, pairEndThere); - if (pair_start_here === there_start) { + if (pairStartHere === thereStart) { return null; } - for (let ii: number = there_start + 1; ii < there_end; ii++) { + for (let ii: number = thereStart + 1; ii < thereEnd; ii++) { if (pairs[ii] >= 0) { return null; } @@ -422,54 +426,54 @@ export default class EPars { let bases: number[] = []; - for (let ii = pair_start_here; ii <= pair_end_here; ii++) { + for (let ii = pairStartHere; ii <= pairEndHere; ii++) { bases.push(ii); } - for (let ii = there_start; ii <= there_end; ii++) { + for (let ii = thereStart; ii <= thereEnd; ii++) { bases.push(ii); } return bases; } - public static validateParenthesis(parenthesis: string, letteronly: boolean = true, length_limit: number = -1): string | null { - let pair_stack: number[] = []; + public static validateParenthesis( + parenthesis: string, letteronly: boolean = true, lengthLimit: number = -1 + ): string | null { + let pairStack: number[] = []; - if (length_limit >= 0 && parenthesis.length > length_limit) { - return `Structure length limit is ${length_limit}`; + if (lengthLimit >= 0 && parenthesis.length > lengthLimit) { + return `Structure length limit is ${lengthLimit}`; } for (let jj = 0; jj < parenthesis.length; jj++) { - if (parenthesis.charAt(jj) === "(") { - pair_stack.push(jj); - } else if (parenthesis.charAt(jj) === ")") { - if (pair_stack.length === 0) { - return "Unbalanced parenthesis notation"; + if (parenthesis.charAt(jj) === '(') { + pairStack.push(jj); + } else if (parenthesis.charAt(jj) === ')') { + if (pairStack.length === 0) { + return 'Unbalanced parenthesis notation'; } - pair_stack.pop(); - } else if (parenthesis.charAt(jj) === ".") { - - } else { + pairStack.pop(); + } else if (parenthesis.charAt(jj) !== '.') { return `Unrecognized character ${parenthesis.charAt(jj)}`; } } - if (pair_stack.length !== 0) { - return "Unbalanced parenthesis notation"; + if (pairStack.length !== 0) { + return 'Unbalanced parenthesis notation'; } if (letteronly) { return null; } - let index: number = parenthesis.indexOf("(.)"); + let index: number = parenthesis.indexOf('(.)'); if (index >= 0) { return `There is a length 1 hairpin loop which is impossible at base ${index + 2}`; } - index = parenthesis.indexOf("(..)"); + index = parenthesis.indexOf('(..)'); if (index >= 0) { return `There is a length 2 hairpin loop which is impossible at base ${index + 2}`; @@ -480,22 +484,22 @@ export default class EPars { public static parenthesisToPairs(parenthesis: string): number[] { let pairs: number[] = []; - let pair_stack: number[] = []; + let pairStack: number[] = []; for (let jj = 0; jj < parenthesis.length; jj++) { pairs.push(-1); } for (let jj = 0; jj < parenthesis.length; jj++) { - if (parenthesis.charAt(jj) === "(") { - pair_stack.push(jj); - } else if (parenthesis.charAt(jj) === ")") { - if (pair_stack.length === 0) { - throw new Error("Invalid parenthesis notation"); + if (parenthesis.charAt(jj) === '(') { + pairStack.push(jj); + } else if (parenthesis.charAt(jj) === ')') { + if (pairStack.length === 0) { + throw new Error('Invalid parenthesis notation'); } - pairs[pair_stack[pair_stack.length - 1]] = jj; - pair_stack.pop(); + pairs[pairStack[pairStack.length - 1]] = jj; + pairStack.pop(); } } @@ -507,50 +511,50 @@ export default class EPars { } public static getSatisfiedPairs(pairs: number[], seq: number[]): number[] { - let ret_pairs: number[] = new Array(pairs.length); + let retPairs: number[] = new Array(pairs.length); for (let ii = 0; ii < pairs.length; ii++) { if (pairs[ii] < 0) { - ret_pairs[ii] = -1; + retPairs[ii] = -1; } else if (pairs[ii] > ii) { if (EPars.pairType(seq[ii], seq[pairs[ii]]) !== 0) { - ret_pairs[ii] = pairs[ii]; - ret_pairs[pairs[ii]] = ii; + retPairs[ii] = pairs[ii]; + retPairs[pairs[ii]] = ii; } else { - ret_pairs[ii] = -1; - ret_pairs[pairs[ii]] = -1; + retPairs[ii] = -1; + retPairs[pairs[ii]] = -1; } } } - return ret_pairs; + return retPairs; } public static pairsToParenthesis(pairs: number[], seq: number[] | null = null): string { - let bi_pairs: number[] = new Array(pairs.length); + let biPairs: number[] = new Array(pairs.length); for (let ii = 0; ii < pairs.length; ii++) { - bi_pairs[ii] = -1; + biPairs[ii] = -1; } for (let ii = 0; ii < pairs.length; ii++) { if (pairs[ii] > ii) { - bi_pairs[ii] = pairs[ii]; - bi_pairs[pairs[ii]] = ii; + biPairs[ii] = pairs[ii]; + biPairs[pairs[ii]] = ii; } } - let str = ""; + let str = ''; - for (let ii = 0; ii < bi_pairs.length; ii++) { - if (bi_pairs[ii] > ii) { - str += "("; - } else if (bi_pairs[ii] >= 0) { - str += ")"; + for (let ii = 0; ii < biPairs.length; ii++) { + if (biPairs[ii] > ii) { + str += '('; + } else if (biPairs[ii] >= 0) { + str += ')'; } else if (seq != null && seq[ii] === EPars.RNABASE_CUT) { - str += "&"; + str += '&'; } else { - str += "."; + str += '.'; } } @@ -559,32 +563,32 @@ export default class EPars { public static parenthesisToForcedArray(parenthesis: string): number[] { let forced: number[] = []; - let pair_stack: number[] = []; + let pairStack: number[] = []; for (let jj = 0; jj < parenthesis.length; jj++) { forced.push(EPars.FORCE_IGNORE); } for (let jj = 0; jj < parenthesis.length; jj++) { - if (parenthesis.charAt(jj) === ".") { + if (parenthesis.charAt(jj) === '.') { continue; - } else if (parenthesis.charAt(jj) === "|") { + } else if (parenthesis.charAt(jj) === '|') { forced[jj] = EPars.FORCE_PAIRED; - } else if (parenthesis.charAt(jj) === "<") { + } else if (parenthesis.charAt(jj) === '<') { forced[jj] = EPars.FORCE_PAIRED3P; - } else if (parenthesis.charAt(jj) === ">") { + } else if (parenthesis.charAt(jj) === '>') { forced[jj] = EPars.FORCE_PAIRED5P; - } else if (parenthesis.charAt(jj) === "x") { + } else if (parenthesis.charAt(jj) === 'x') { forced[jj] = EPars.FORCE_UNPAIRED; - } else if (parenthesis.charAt(jj) === "(") { - pair_stack.push(jj); - } else if (parenthesis.charAt(jj) === ")") { - if (pair_stack.length === 0) { - throw new Error("Invalid parenthesis notation"); + } else if (parenthesis.charAt(jj) === '(') { + pairStack.push(jj); + } else if (parenthesis.charAt(jj) === ')') { + if (pairStack.length === 0) { + throw new Error('Invalid parenthesis notation'); } - forced[pair_stack[pair_stack.length - 1]] = jj; - pair_stack.pop(); + forced[pairStack[pairStack.length - 1]] = jj; + pairStack.pop(); } } @@ -596,23 +600,23 @@ export default class EPars { } public static forcedArrayToParenthesis(forced: number[]): string { - let str = ""; + let str = ''; for (let ii = 0; ii < forced.length; ii++) { if (forced[ii] > ii) { - str = str.concat("("); + str = str.concat('('); } else if (forced[ii] >= 0) { - str = str.concat(")"); + str = str.concat(')'); } else if (forced[ii] === EPars.FORCE_PAIRED) { - str = str.concat("|"); + str = str.concat('|'); } else if (forced[ii] === EPars.FORCE_PAIRED3P) { - str = str.concat("<"); + str = str.concat('<'); } else if (forced[ii] === EPars.FORCE_PAIRED5P) { - str = str.concat(">"); + str = str.concat('>'); } else if (forced[ii] === EPars.FORCE_UNPAIRED) { - str = str.concat("x"); + str = str.concat('x'); } else { - str = str.concat("."); + str = str.concat('.'); } } @@ -691,22 +695,22 @@ export default class EPars { return diff; } - public static arePairsSame(a_pairs: number[], b_pairs: number[], constraints: any[] | null = null): boolean { - if (a_pairs.length !== b_pairs.length) { + public static arePairsSame(aPairs: number[], bPairs: number[], constraints: any[] | null = null): boolean { + if (aPairs.length !== bPairs.length) { return false; } - for (let ii = 0; ii < a_pairs.length; ii++) { - if (b_pairs[ii] >= 0) { - if (b_pairs[ii] !== a_pairs[ii]) { + for (let ii = 0; ii < aPairs.length; ii++) { + if (bPairs[ii] >= 0) { + if (bPairs[ii] !== aPairs[ii]) { if (constraints == null || constraints[ii]) { return false; } } } - if (a_pairs[ii] >= 0) { - if (b_pairs[ii] !== a_pairs[ii]) { + if (aPairs[ii] >= 0) { + if (bPairs[ii] !== aPairs[ii]) { if (constraints == null || constraints[ii]) { return false; } @@ -729,7 +733,7 @@ export default class EPars { return EPars.PAIR_TYPE_MAT[a * (EPars.NBPAIRS + 1) + b]; } - public static get_bulge(i: number): number { + public static getBulge(i: number): number { return EPars.BULGE_37[30] + (Number)(EPars.LXC * Math.log((Number)(i) / 30.0)); } @@ -965,7 +969,7 @@ export default class EPars { -150, -150, -150, -150, -150, -150]; private static readonly TETRA_LOOPS: string[] = [ - "GGGGAC", "GGUGAC", "CGAAAG", "GGAGAC", "CGCAAG", "GGAAAC", "CGGAAG", "CUUCGG", "CGUGAG", "CGAAGG", - "CUACGG", "GGCAAC", "CGCGAG", "UGAGAG", "CGAGAG", "AGAAAU", "CGUAAG", "CUAACG", "UGAAAG", "GGAAGC", - "GGGAAC", "UGAAAA", "AGCAAU", "AGUAAU", "CGGGAG", "AGUGAU", "GGCGAC", "GGGAGC", "GUGAAC", "UGGAAA"]; + 'GGGGAC', 'GGUGAC', 'CGAAAG', 'GGAGAC', 'CGCAAG', 'GGAAAC', 'CGGAAG', 'CUUCGG', 'CGUGAG', 'CGAAGG', + 'CUACGG', 'GGCAAC', 'CGCGAG', 'UGAGAG', 'CGAGAG', 'AGAAAU', 'CGUAAG', 'CUAACG', 'UGAAAG', 'GGAAGC', + 'GGGAAC', 'UGAAAA', 'AGCAAU', 'AGUAAU', 'CGGGAG', 'AGUGAU', 'GGCGAC', 'GGGAGC', 'GUGAAC', 'UGGAAA']; } diff --git a/src/eterna/Eterna.ts b/src/eterna/Eterna.ts index 5401ee8fd..91c6ced98 100644 --- a/src/eterna/Eterna.ts +++ b/src/eterna/Eterna.ts @@ -1,21 +1,31 @@ -import * as log from "loglevel"; -import {Flashbang} from "flashbang/core"; -import {SaveGameManager} from "../flashbang/settings"; -import {ErrorUtil} from "flashbang/util"; -import ChatManager from "eterna/ChatManager"; -import EternaApp from "eterna/EternaApp"; -import {ErrorDialogMode} from "eterna/mode"; -import {GameClient} from "eterna/net"; -import {EternaSettings} from "eterna/settings"; -import {SoundManager} from "eterna/resources"; +import * as log from 'loglevel'; +import {Flashbang} from 'flashbang/core'; +import {SaveGameManager} from 'flashbang/settings'; +import {ErrorUtil} from 'flashbang/util'; +import ChatManager from 'eterna/ChatManager'; +import EternaApp from 'eterna/EternaApp'; +import {ErrorDialogMode} from 'eterna/mode'; +import {GameClient} from 'eterna/net'; +import {EternaSettings} from 'eterna/settings'; +import {SoundManager} from 'eterna/resources'; + +/** Return env.APP_SERVER_URL; if unspecified, default to window.location.origin */ +function GetServerURL(): string { + const url = process.env['APP_SERVER_URL']; + return (url != null && url !== '' ? url : window.location.origin); +} + +function ParseBool(value: string): boolean { + return value.toLowerCase() === 'true'; +} /** Constants and global managers */ export default class Eterna { - public static readonly OVERLAY_DIV_ID = "overlay"; - public static readonly PIXI_CONTAINER_ID = "pixi-container"; + public static readonly OVERLAY_DIV_ID = 'overlay'; + public static readonly PIXI_CONTAINER_ID = 'pixi-container'; public static readonly MAX_PUZZLE_EDIT_LENGTH = 400; // max length of PuzzleEditMode input - public static readonly DEV_MODE: boolean = ParseBool(process.env["DEBUG"]); + public static readonly DEV_MODE: boolean = ParseBool(process.env['DEBUG']); public static readonly SERVER_URL: string = GetServerURL(); public static gameDiv: HTMLElement; @@ -36,27 +46,18 @@ export default class Eterna { } public static onFatalError(err: any): void { - log.error("Fatal error error", ErrorUtil.getErrorObj(err) || ErrorUtil.getErrString(err)); + log.error('Fatal error error', ErrorUtil.getErrorObj(err) || ErrorUtil.getErrString(err)); if (Flashbang.app != null && Flashbang.app.modeStack != null && !(Flashbang.app.modeStack.topMode instanceof ErrorDialogMode)) { Flashbang.app.modeStack.pushMode(new ErrorDialogMode(err)); - } else if (process.env.NODE_ENV !== "production") { + } else if (process.env.NODE_ENV !== 'production') { try { + // eslint-disable-next-line no-alert alert(ErrorUtil.getErrorObj(err) || ErrorUtil.getErrString(err)); } catch (alertError) { - log.error("An error occurred while trying to display an error", alertError); + log.error('An error occurred while trying to display an error', alertError); } } } } - -/** Return env.APP_SERVER_URL; if unspecified, default to window.location.origin */ -function GetServerURL(): string { - const url = process.env["APP_SERVER_URL"]; - return (url != null && url != "" ? url : window.location.origin); -} - -function ParseBool(value: string): boolean { - return value.toLowerCase() === "true"; -} diff --git a/src/eterna/EternaApp.ts b/src/eterna/EternaApp.ts index a9d48175d..3d613d7a3 100644 --- a/src/eterna/EternaApp.ts +++ b/src/eterna/EternaApp.ts @@ -1,25 +1,25 @@ -import "assets/styles.css"; // css-loader will pick up on this and embed our stylesheet -import * as log from "loglevel"; -import {FlashbangApp} from "flashbang/core"; -import {SaveGameManager} from "flashbang/settings"; -import {ErrorUtil, TextureUtil} from "flashbang/util"; -import ChatManager from "eterna/ChatManager"; -import {TestMode} from "eterna/debug"; -import Eterna from "eterna/Eterna"; +import 'assets/styles.css'; // css-loader will pick up on this and embed our stylesheet +import * as log from 'loglevel'; +import {FlashbangApp} from 'flashbang/core'; +import {SaveGameManager} from 'flashbang/settings'; +import {ErrorUtil, TextureUtil} from 'flashbang/util'; +import ChatManager from 'eterna/ChatManager'; +import {TestMode} from 'eterna/debug'; +import Eterna from 'eterna/Eterna'; import { Folder, FolderManager, LinearFoldC, LinearFoldV, NuPACK, RNAFoldBasic, Vienna, Vienna2 -} from "eterna/folding"; +} from 'eterna/folding'; import { LoadingMode, FeedbackViewMode, DesignBrowserFilter, DesignBrowserMode, PoseEditMode, PoseEditParams, PuzzleEditMode, PuzzleEditPoseData -} from "eterna/mode"; -import {GameClient} from "eterna/net"; +} from 'eterna/mode'; +import {GameClient} from 'eterna/net'; import { Puzzle, PuzzleManager, Solution, SolutionManager -} from "eterna/puzzle"; -import {Bitmaps, SoundManager} from "eterna/resources"; -import {EternaSettings} from "eterna/settings"; -import {ExternalInterface, ExternalInterfaceCtx, Fonts} from "eterna/util"; +} from 'eterna/puzzle'; +import {Bitmaps, SoundManager} from 'eterna/resources'; +import {EternaSettings} from 'eterna/settings'; +import {ExternalInterface, ExternalInterfaceCtx, Fonts} from 'eterna/util'; enum PuzzleID { FunAndEasy = 4350940, @@ -30,17 +30,17 @@ enum PuzzleID { AAMismatchPilotRun = 3263276, // locks, tails TheophyllineRibozymeSwitch = 2390140, // aux info MicrofluidicChip = 6502997, // level 4/7 - MissionCleared info - AandB_RO = 6892307, // Oligos + AandBRO = 6892307, // Oligos Tutorial1 = 6502927, // rscript Tutorial4 = 6502944, Tutorial6 = 6502945, Tutorial8 = 6502947, - LiquidRobotics10_of_11 = 6503036, // Script constraints + LiquidRobotics10of11 = 6503036, // Script constraints EternaCon2018 = 8952159, - SameState_TryptophanB = 7656242, // Booster paint tool + SameStateTryptophanB = 7656242, // Booster paint tool TemporalAnomaly = 7796345, // Really big! - Switch2pt5_left_Right = 8984178, // molecule - JieuxAppetit_2 = 8980331, // unbound molecule + Switch2pt5leftRight = 8984178, // molecule + JieuxAppetit2 = 8980331, // unbound molecule } interface SolutionAndPuzzleID { @@ -54,12 +54,12 @@ let CloudLab19Solution: SolutionAndPuzzleID = { }; export enum InitialAppMode { - PUZZLE = "puzzle", // load a puzzle - PUZZLEMAKER = "puzzlemaker", // load the puzzlemaker - SOLUTION_SEE_RESULT = "solution_see_result", // load a solution into FeedbackViewMode - SOLUTION_COPY_AND_VIEW = "solution_copy_and_view", // load a solution into PoseEditMode - DESIGN_BROWSER = "design_browser", // load a puzzle into DesignBrowserMode - TEST = "test", // load the debugging test mode + PUZZLE = 'puzzle', // load a puzzle + PUZZLEMAKER = 'puzzlemaker', // load the puzzlemaker + SOLUTION_SEE_RESULT = 'solution_see_result', // load a solution into FeedbackViewMode + SOLUTION_COPY_AND_VIEW = 'solution_copy_and_view', // load a solution into PoseEditMode + DESIGN_BROWSER = 'design_browser', // load a puzzle into DesignBrowserMode + TEST = 'test', // load the debugging test mode } export interface EternaAppParams { @@ -80,13 +80,13 @@ export interface EternaAppParams { /** Entry point for the game */ export default class EternaApp extends FlashbangApp { - public constructor(params: EternaAppParams) { + constructor(params: EternaAppParams) { super(); // Default param values params.mode = params.mode || InitialAppMode.PUZZLE; - params.containerID = params.containerID || "maingame"; - params.chatboxID = params.chatboxID || "chat-container"; + params.containerID = params.containerID || 'maingame'; + params.chatboxID = params.chatboxID || 'chat-container'; params.width = params.width || 1280; params.height = params.height || 1024; params.puzzleID = params.puzzleID || PuzzleID.Tutorial1; @@ -96,13 +96,13 @@ export default class EternaApp extends FlashbangApp { this._params = params; let eternaContainer: HTMLElement = document.getElementById(params.containerID); - eternaContainer.style.position = "relative"; + eternaContainer.style.position = 'relative'; - let pixiContainer: HTMLElement = document.createElement("div"); + let pixiContainer: HTMLElement = document.createElement('div'); pixiContainer.id = Eterna.PIXI_CONTAINER_ID; eternaContainer.appendChild(pixiContainer); - let overlay: HTMLElement = document.createElement("div"); + let overlay: HTMLElement = document.createElement('div'); overlay.id = Eterna.OVERLAY_DIV_ID; eternaContainer.appendChild(overlay); @@ -112,41 +112,41 @@ export default class EternaApp extends FlashbangApp { /* override */ protected setup(): void { Eterna.app = this; - Eterna.saveManager = new SaveGameManager("EternaSaveGame"); + Eterna.saveManager = new SaveGameManager('EternaSaveGame'); Eterna.settings = new EternaSettings(); Eterna.client = new GameClient(Eterna.SERVER_URL); Eterna.sound = new SoundManager(Eterna.settings); Eterna.chat = new ChatManager(this._params.chatboxID, Eterna.settings); Eterna.gameDiv = document.getElementById(this._params.containerID); - this.setLoadingText("Authenticating..."); + this.setLoadingText('Authenticating...'); this.authenticate() .then(() => { - this.setLoadingText("Loading assets..."); + this.setLoadingText('Loading assets...'); return Promise.all([this.initFoldingEngines(), TextureUtil.load(Bitmaps.all), Fonts.loadFonts()]); }) .then(() => this.initScriptInterface()) .then(async () => { switch (this._params.mode) { - case InitialAppMode.TEST: - this._modeStack.unwindToMode(new TestMode()); - return Promise.resolve(); - case InitialAppMode.PUZZLEMAKER: - return this.loadPuzzleEditor(this._params.puzzleEditNumTargets); - case InitialAppMode.PUZZLE: - return this.loadPoseEdit(this._params.puzzleID, { - initialFolder: this._params.folderName, - initSequence: this._params.sequence - }); - case InitialAppMode.SOLUTION_SEE_RESULT: - case InitialAppMode.SOLUTION_COPY_AND_VIEW: - return this.loadSolutionViewer(this._params.puzzleID, this._params.solutionID, - this._params.mode === InitialAppMode.SOLUTION_COPY_AND_VIEW); - case InitialAppMode.DESIGN_BROWSER: - return this.loadDesignBrowser(this._params.puzzleID, this._params.designBrowserFilters); - default: - return Promise.reject(`Unrecognized mode '${this._params.mode}'`); + case InitialAppMode.TEST: + this._modeStack.unwindToMode(new TestMode()); + return Promise.resolve(); + case InitialAppMode.PUZZLEMAKER: + return this.loadPuzzleEditor(this._params.puzzleEditNumTargets); + case InitialAppMode.PUZZLE: + return this.loadPoseEdit(this._params.puzzleID, { + initialFolder: this._params.folderName, + initSequence: this._params.sequence + }); + case InitialAppMode.SOLUTION_SEE_RESULT: + case InitialAppMode.SOLUTION_COPY_AND_VIEW: + return this.loadSolutionViewer(this._params.puzzleID, this._params.solutionID, + this._params.mode === InitialAppMode.SOLUTION_COPY_AND_VIEW); + case InitialAppMode.DESIGN_BROWSER: + return this.loadDesignBrowser(this._params.puzzleID, this._params.designBrowserFilters); + default: + return Promise.reject(new Error(`Unrecognized mode '${this._params.mode}'`)); } }) .catch((err) => { @@ -168,12 +168,16 @@ export default class EternaApp extends FlashbangApp { /** Creates a PuzzleEditMode and removes all other modes from the stack */ public async loadPuzzleEditor(numTargets?: number, initialPoseData?: PuzzleEditPoseData[]): Promise { const initPoseData = initialPoseData - || await Eterna.saveManager.load(PuzzleEditMode.savedDataTokenName(this._params.puzzleEditNumTargets)) || null; + || await Eterna.saveManager.load(PuzzleEditMode.savedDataTokenName(this._params.puzzleEditNumTargets)) + || null; this._modeStack.unwindToMode(new PuzzleEditMode(false, numTargets, initPoseData)); return Promise.resolve(); } - /** Creates a FeedbackViewMode (or a PoseEditMode, if loadInPoseEdit is true), and removes all other modes from the stack */ + /** + * Creates a FeedbackViewMode (or a PoseEditMode, if loadInPoseEdit is true), + * and removes all other modes from the stack + */ public loadSolutionViewer(puzzleID: number, solutionID: number, loadInPoseEdit: boolean = false): Promise { return this.loadSolution(puzzleID, solutionID) .then(([puzzle, solution]) => { @@ -197,8 +201,10 @@ export default class EternaApp extends FlashbangApp { */ public switchToDesignBrowser(puzzleOrID: number | Puzzle): Promise { const puzzleID = (puzzleOrID instanceof Puzzle ? puzzleOrID.nodeID : puzzleOrID); - const existingBrowser = this.modeStack.modes.find(mode => mode instanceof DesignBrowserMode) as DesignBrowserMode; - if (existingBrowser != null && existingBrowser.puzzleID == puzzleID) { + const existingBrowser = this.modeStack.modes.find( + mode => mode instanceof DesignBrowserMode + ) as DesignBrowserMode; + if (existingBrowser != null && existingBrowser.puzzleID === puzzleID) { this.modeStack.setModeIndex(existingBrowser, -1); return Promise.resolve(); } else { @@ -217,10 +223,12 @@ export default class EternaApp extends FlashbangApp { * move the existing PoseEditMode to the top of the stack. Otherwise, push a new PoseEditMode to the stack, * retaining any existing modes. */ - public switchToPoseEdit(puzzleOrID: number | Puzzle, canSwitchToExisting: boolean, params: PoseEditParams = {}): Promise { + public switchToPoseEdit( + puzzleOrID: number | Puzzle, canSwitchToExisting: boolean, params: PoseEditParams = {} + ): Promise { const puzzleID = (puzzleOrID instanceof Puzzle ? puzzleOrID.nodeID : puzzleOrID); const existingPoseEdit = this.existingPoseEditMode; - if (existingPoseEdit != null && canSwitchToExisting && existingPoseEdit.puzzleID == puzzleID) { + if (existingPoseEdit != null && canSwitchToExisting && existingPoseEdit.puzzleID === puzzleID) { this.modeStack.setModeIndex(existingPoseEdit, -1); return Promise.resolve(); } else { @@ -239,7 +247,7 @@ export default class EternaApp extends FlashbangApp { const solutionID = (solutionOrID instanceof Solution ? solutionOrID.nodeID : solutionOrID); const existingMode = this.modeStack.modes.find(mode => mode instanceof FeedbackViewMode) as FeedbackViewMode; - if (existingMode != null && existingMode.puzzleID == puzzleID && existingMode.solutionID == solutionID) { + if (existingMode != null && existingMode.puzzleID === puzzleID && existingMode.solutionID === solutionID) { this.modeStack.setModeIndex(existingMode, -1); return Promise.resolve(); } else { @@ -277,7 +285,7 @@ export default class EternaApp extends FlashbangApp { } return Promise.reject( - `No such solution for given puzzle [puzzleID=${puzzleID}, solutionID=${solutionID}` + new Error(`No such solution for given puzzle [puzzleID=${puzzleID}, solutionID=${solutionID}`) ); }); @@ -304,8 +312,8 @@ export default class EternaApp extends FlashbangApp { protected onKeyboardEvent(e: KeyboardEvent): void { // if a form element is focused, don't trigger hotkeys - let selected = document.body.querySelectorAll(":focus")[0]; - if (selected && (["INPUT", "TEXTAREA", "OPTION", "SELECT", "BUTTON"].includes(selected.tagName))) return; + let selected = document.body.querySelectorAll(':focus')[0]; + if (selected && (['INPUT', 'TEXTAREA', 'OPTION', 'SELECT', 'BUTTON'].includes(selected.tagName))) return; super.onKeyboardEvent(e); } @@ -313,7 +321,7 @@ export default class EternaApp extends FlashbangApp { protected onUncaughtError(err: any): void { let errstring = ErrorUtil.getErrString(err); if (errstring.startsWith("Error: Failed to set the 'buffer' property on 'AudioBufferSourceNode'")) { - log.debug("pixi-sound is misbehaving again"); + log.debug('pixi-sound is misbehaving again'); } else { Eterna.onFatalError(err); } @@ -361,7 +369,7 @@ export default class EternaApp extends FlashbangApp { Eterna.setPlayer(username, uid); }); } else { - let playerID = process.env["DEBUG_PLAYER_ID"]; + let playerID = process.env['DEBUG_PLAYER_ID']; // If no player is specified, ensure that no user is authenticated, // allowing for testing as a nonauthenticated user if (playerID.length === 0) { @@ -373,7 +381,7 @@ export default class EternaApp extends FlashbangApp { }); } - let playerPassword = process.env["DEBUG_PLAYER_PASSWORD"]; + let playerPassword = process.env['DEBUG_PLAYER_PASSWORD']; log.debug(`Logging in ${playerID}...`); return Eterna.client.login(playerID, playerPassword).then((uid) => { log.debug(`Logged in [name=${playerID}, uid=${uid}]`); @@ -383,7 +391,7 @@ export default class EternaApp extends FlashbangApp { } private initFoldingEngines(): Promise { - log.info("Initializing folding engines..."); + log.info('Initializing folding engines...'); return Promise.all([ Vienna.create(), Vienna2.create(), @@ -392,7 +400,7 @@ export default class EternaApp extends FlashbangApp { LinearFoldV.create(), RNAFoldBasic.create()]) .then((folders: Folder[]) => { - log.info("Folding engines intialized"); + log.info('Folding engines intialized'); for (let folder of folders) { FolderManager.instance.addFolder(folder); } @@ -400,12 +408,12 @@ export default class EternaApp extends FlashbangApp { } private initScriptInterface(): void { - this._scriptInterface.addCallback("test_tutorial", (puzzleID: number, rscript: string): void => { + this._scriptInterface.addCallback('test_tutorial', (puzzleID: number, rscript: string): void => { this.loadPoseEdit(puzzleID, {rscript, isReset: true}) .catch(e => Eterna.onFatalError(e)); }); - this._scriptInterface.addCallback("load_puzzle", (puzzleID: number, doneCallback: string): void => { + this._scriptInterface.addCallback('load_puzzle', (puzzleID: number, doneCallback: string): void => { this.loadPoseEdit(puzzleID, {isReset: true}) .then(() => { ExternalInterface.call(doneCallback); diff --git a/src/eterna/ExpPainter.ts b/src/eterna/ExpPainter.ts index 9fe68b814..3172ae27d 100644 --- a/src/eterna/ExpPainter.ts +++ b/src/eterna/ExpPainter.ts @@ -1,18 +1,18 @@ -import Constants from "eterna/Constants"; -import {ColorUtil, MathUtil} from "flashbang/util"; +import Constants from 'eterna/Constants'; +import {ColorUtil, MathUtil} from 'flashbang/util'; export default class ExpPainter { public static readonly NUM_COLORS = 5; - public static transformData(data: number[], data_max: number, data_min: number): number[] { - let data_ret: number[] = data.slice(); - let abs_max: number = 2 * data_max - data_min; + public static transformData(data: number[], dataMax: number, dataMin: number): number[] { + let dataRet: number[] = data.slice(); + let absMax: number = 2 * dataMax - dataMin; - for (let ii = 0; ii < data_ret.length; ii++) { - data_ret[ii] = MathUtil.clamp(data_ret[ii], data_min, abs_max); + for (let ii = 0; ii < dataRet.length; ii++) { + dataRet[ii] = MathUtil.clamp(dataRet[ii], dataMin, absMax); } - return data_ret; + return dataRet; } public static getColorByLevel(lev: number): number { @@ -31,9 +31,9 @@ export default class ExpPainter { } } - constructor(data: number[], start_index: number) { + constructor(data: number[], startIndex: number) { if (data == null || data.length === 0) { - throw new Error("ExpPainter got empty array"); + throw new Error('ExpPainter got empty array'); } this._data = data.slice(); @@ -42,7 +42,7 @@ export default class ExpPainter { this._dataMax = this._data[0]; this._dataAvg = this._data[0]; - this._startIdx = start_index; + this._startIdx = startIndex; this._continuous = false; this._extended = false; @@ -204,17 +204,15 @@ export default class ExpPainter { diff = MathUtil.clamp(diff, 0, 1); return Math.round(ExpPainter.NUM_COLORS * diff) + ExpPainter.NUM_COLORS; } - } else { + } else if (!this._continuous) { // / SUPER HACK - binary coloring - if (!this._continuous) { - return 0; - } else { - diff *= -1; - diff /= (this._dataAvg - this._dataMin); - diff = MathUtil.clamp(diff, 0, 1); + return 0; + } else { + diff *= -1; + diff /= (this._dataAvg - this._dataMin); + diff = MathUtil.clamp(diff, 0, 1); - return Math.round(ExpPainter.NUM_COLORS * diff) * -1 + ExpPainter.NUM_COLORS; - } + return Math.round(ExpPainter.NUM_COLORS * diff) * -1 + ExpPainter.NUM_COLORS; } } } diff --git a/src/eterna/Feedback.ts b/src/eterna/Feedback.ts index ebd750048..fb15d12f4 100644 --- a/src/eterna/Feedback.ts +++ b/src/eterna/Feedback.ts @@ -1,31 +1,36 @@ export default class Feedback { public static readonly EXPCODES: number[] = [1, -100, -200]; - public static readonly EXPSTRINGS: string[] = ["NOT SYNTHESIZED", "FAILED", "NOT INTERPRETABLE"]; - public static readonly EXPDISPLAYS: string[] = ["-", "Failed", "Unreadable"]; - public static readonly EXPDISPLAYS_LONG: string[] = ["Not synthesized", + public static readonly EXPSTRINGS: string[] = ['NOT SYNTHESIZED', 'FAILED', 'NOT INTERPRETABLE']; + public static readonly EXPDISPLAYS: string[] = [ + '-', "Failed", "Unreadable" + ]; + + public static readonly EXPDISPLAYS_LONG: string[] = ['Not synthesized', "[FAILED..] This design failed to synthesize in test tubes.", "[Unreadable..] The synthesis result of this was not interpretable."]; public static readonly EXPSCORES: number[] = [0, 10, 15]; - public static scoreFeedback(shapedata: number[], secstruct: string, start_index: number, min: number, threshold: number, max: number): number { + public static scoreFeedback( + shapedata: number[], secstruct: string, startIndex: number, min: number, threshold: number, max: number + ): number { let score = 0; for (let ii = 0; ii < secstruct.length; ii++) { - if (ii < start_index) { + if (ii < startIndex) { continue; } - if (ii - start_index >= shapedata.length) { + if (ii - startIndex >= shapedata.length) { continue; } let char: string = secstruct.charAt(ii); - if (char === ".") { - if (shapedata[ii - start_index] > (threshold / 4 + min / 4 * 3)) { + if (char === '.') { + if (shapedata[ii - startIndex] > (threshold / 4 + min / 4 * 3)) { score++; } - } else if (shapedata[ii - start_index] < threshold) { + } else if (shapedata[ii - startIndex] < threshold) { score++; } } @@ -47,26 +52,26 @@ export default class Feedback { this._shapeStarts[index] = dat[0] - 1; dat.splice(0, 1); this._shapeData[index] = dat.slice(); - let shape_data: number[] = this._shapeData[index]; + let shapeData: number[] = this._shapeData[index]; - let smax: number = shape_data[0]; - let smin: number = shape_data[0]; - let savg: number = shape_data[0]; + let smax: number = shapeData[0]; + let smin: number = shapeData[0]; + let savg: number = shapeData[0]; - for (let ii = 0; ii < shape_data.length; ii++) { - if (shape_data[ii] > smax) { - smax = shape_data[ii]; + for (let ii = 0; ii < shapeData.length; ii++) { + if (shapeData[ii] > smax) { + smax = shapeData[ii]; } - if (shape_data[ii] < smin) { - smin = shape_data[ii]; + if (shapeData[ii] < smin) { + smin = shapeData[ii]; } - savg += shape_data[ii]; + savg += shapeData[ii]; } - if (shape_data.length > 0) { - savg /= shape_data.length; + if (shapeData.length > 0) { + savg /= shapeData.length; } if (threshold != null) { diff --git a/src/eterna/Plot.ts b/src/eterna/Plot.ts index 07d14115e..a2e4af8c1 100644 --- a/src/eterna/Plot.ts +++ b/src/eterna/Plot.ts @@ -1,6 +1,6 @@ -import {Graphics, Text, Container} from "pixi.js"; -import {ColorUtil} from "flashbang/util"; -import {Fonts} from "eterna/util"; +import {Graphics, Text, Container} from 'pixi.js'; +import {ColorUtil} from 'flashbang/util'; +import {Fonts} from 'eterna/util'; export enum PlotType { LINE, BAR, SCATTER @@ -9,7 +9,7 @@ export enum PlotType { export default class Plot extends Container { public type: PlotType = PlotType.BAR; - public constructor(type: PlotType = PlotType.BAR) { + constructor(type: PlotType = PlotType.BAR) { super(); this.type = type; this._graphics = new Graphics(); @@ -21,27 +21,27 @@ export default class Plot extends Container { this._height = height; } - public setData(data: number[], maxvals: number[], labels: string[] = null, ghost_data: number[] = null): void { + public setData(data: number[], maxvals: number[], labels: string[] = null, ghostData: number[] = null): void { this._data = (data != null ? data.slice() : null); this._labels = (labels != null ? labels.slice() : null); this._upperBounds = (maxvals != null ? maxvals.slice() : null); - if (ghost_data != null) { - if (ghost_data.length !== data.length) { + if (ghostData != null) { + if (ghostData.length !== data.length) { throw new Error("Data lengths don't match"); } - this._ghostData = ghost_data.slice(); + this._ghostData = ghostData.slice(); } else { this._ghostData = null; } } - public set2DData(data_2d: number[], num_bases: number): void { - if (data_2d) { - this._data2D = data_2d; + public set2DData(data2D: number[], numBases: number): void { + if (data2D) { + this._data2D = data2D; } - this._numBases = num_bases; + this._numBases = numBases; } public replot(): void { @@ -62,8 +62,8 @@ export default class Plot extends Container { this._numBases = this._data.length; } - const horizontal_space: number = this._width / this._numBases; - const vertical_space: number = this._height / this._numBases; + const horizontalSpace: number = this._width / this._numBases; + const verticalSpace: number = this._height / this._numBases; this._graphics.clear(); this._graphics.lineStyle(1, 0); @@ -78,36 +78,51 @@ export default class Plot extends Container { if (this._ghostData == null) { this._graphics.beginFill(0x00AA00); - this._graphics.drawRect(Plot.W_MARGIN + (ii + 1) * horizontal_space - horizontal_space / 2.0, Plot.H_MARGIN + this._height - len, horizontal_space / 2.0, len); + this._graphics.drawRect( + Plot.W_MARGIN + (ii + 1) * horizontalSpace - horizontalSpace / 2.0, + Plot.H_MARGIN + this._height - len, horizontalSpace / 2.0, len + ); } else { let ghostlen: number = (this._ghostData[ii] / this._upperBounds[ii]) * this._height; this._graphics.beginFill(0x00AA00); - this._graphics.drawRect(Plot.W_MARGIN + (ii + 1) * horizontal_space - horizontal_space / 2.0, Plot.H_MARGIN + this._height - len, horizontal_space / 4.0, len); + this._graphics.drawRect( + Plot.W_MARGIN + (ii + 1) * horizontalSpace - horizontalSpace / 2.0, + Plot.H_MARGIN + this._height - len, horizontalSpace / 4.0, len + ); this._graphics.beginFill(0xAA0000); - this._graphics.drawRect(Plot.W_MARGIN + (ii + 1) * horizontal_space - horizontal_space / 4.0, Plot.H_MARGIN + this._height - ghostlen, horizontal_space / 4.0, ghostlen); + this._graphics.drawRect( + Plot.W_MARGIN + (ii + 1) * horizontalSpace - horizontalSpace / 4.0, + Plot.H_MARGIN + this._height - ghostlen, horizontalSpace / 4.0, ghostlen + ); } } } else if (this.type === PlotType.LINE) { this._graphics.lineStyle(1, 0xAAAAAA, 1); for (let ii = 0; ii < this._data.length; ii++) { - let x_coord = Plot.W_MARGIN + (ii + 1) * horizontal_space - horizontal_space / 2.0 + x; - this._graphics.moveTo(x_coord, 0); - this._graphics.lineTo(x_coord, this._height); + let xCoord = Plot.W_MARGIN + (ii + 1) * horizontalSpace - horizontalSpace / 2.0 + x; + this._graphics.moveTo(xCoord, 0); + this._graphics.lineTo(xCoord, this._height); } for (let ii = 0; ii < 10; ii++) { - let y_coord = ii / 10 * (this._height - Plot.H_MARGIN) + y; - this._graphics.moveTo(0, y_coord + Plot.H_MARGIN); - this._graphics.lineTo(this._width, y_coord + Plot.H_MARGIN); + let yCoord = ii / 10 * (this._height - Plot.H_MARGIN) + y; + this._graphics.moveTo(0, yCoord + Plot.H_MARGIN); + this._graphics.lineTo(this._width, yCoord + Plot.H_MARGIN); } this._graphics.lineStyle(2, 0x00AA00); for (let ii = 0; ii < this._data.length; ii++) { let hlen: number = (this._data[ii] / (this._upperBounds[ii])) * (this._height - Plot.H_MARGIN); if (ii === 0) { - this._graphics.moveTo(Plot.W_MARGIN + (ii + 1) * horizontal_space - horizontal_space / 2.0, this._height - hlen); + this._graphics.moveTo( + Plot.W_MARGIN + (ii + 1) * horizontalSpace - horizontalSpace / 2.0, + this._height - hlen + ); } else { - this._graphics.lineTo(Plot.W_MARGIN + (ii + 1) * horizontal_space - horizontal_space / 2.0, this._height - hlen); + this._graphics.lineTo( + Plot.W_MARGIN + (ii + 1) * horizontalSpace - horizontalSpace / 2.0, + this._height - hlen + ); } } @@ -116,39 +131,45 @@ export default class Plot extends Container { for (let ii = 0; ii < this._ghostData.length; ii++) { let ghosthlen: number = (this._ghostData[ii] / this._upperBounds[ii]) * this._height; if (ii === 0) { - this._graphics.moveTo(Plot.W_MARGIN + (ii + 1) * horizontal_space - horizontal_space / 2.0, Plot.H_MARGIN + this._height - ghosthlen); + this._graphics.moveTo( + Plot.W_MARGIN + (ii + 1) * horizontalSpace - horizontalSpace / 2.0, + Plot.H_MARGIN + this._height - ghosthlen + ); } else { - this._graphics.lineTo(Plot.W_MARGIN + (ii + 1) * horizontal_space - horizontal_space / 2.0, Plot.H_MARGIN + this._height - ghosthlen); + this._graphics.lineTo( + Plot.W_MARGIN + (ii + 1) * horizontalSpace - horizontalSpace / 2.0, + Plot.H_MARGIN + this._height - ghosthlen + ); } } } } else if (this.type === PlotType.SCATTER) { this._graphics.lineStyle(1, 0xAAAAAA, 1); for (let ii = 10; ii < this._numBases; ii += 10) { - let x_coord = (ii / this._numBases) * this._width + x; - let y_coord = (ii / this._numBases) * this._height + y; + let xCoord = (ii / this._numBases) * this._width + x; + let yCoord = (ii / this._numBases) * this._height + y; - this._graphics.moveTo(x_coord, 0); - this._graphics.lineTo(x_coord, this._height); + this._graphics.moveTo(xCoord, 0); + this._graphics.lineTo(xCoord, this._height); - this._graphics.moveTo(0, y_coord); - this._graphics.lineTo(this._width, y_coord); + this._graphics.moveTo(0, yCoord); + this._graphics.lineTo(this._width, yCoord); } for (let ii = 0; ii < this._data2D.length; ii += 3) { - let x_coord = ((this._data2D[ii + 1])) * horizontal_space + x; - let y_coord = ((this._data2D[ii])) * vertical_space - 1 + y; + let xCoord = ((this._data2D[ii + 1])) * horizontalSpace + x; + let yCoord = ((this._data2D[ii])) * verticalSpace - 1 + y; - let min_col = 0.1; - let prob_r: number = 1.0 - ((this._data2D[ii + 2]) * (1 - min_col) + min_col); - let prob_g: number = 1.0 - ((this._data2D[ii + 2]) * (1 - min_col) + min_col); - let prob_b: number = 1.0 - ((this._data2D[ii + 2]) * (1 - min_col) + min_col); + let minCol = 0.1; + let probR: number = 1.0 - ((this._data2D[ii + 2]) * (1 - minCol) + minCol); + let probG: number = 1.0 - ((this._data2D[ii + 2]) * (1 - minCol) + minCol); + let probB: number = 1.0 - ((this._data2D[ii + 2]) * (1 - minCol) + minCol); - let prob_color: number = ColorUtil.compose(prob_r, prob_g, prob_b); + let probColor: number = ColorUtil.compose(probR, probG, probB); this._graphics.lineStyle(0, 0, 0); - this._graphics.beginFill(prob_color); - this._graphics.drawRect(x_coord, y_coord, horizontal_space, vertical_space); + this._graphics.beginFill(probColor); + this._graphics.drawRect(xCoord, yCoord, horizontalSpace, verticalSpace); this._graphics.endFill(); } @@ -174,8 +195,8 @@ export default class Plot extends Container { let labelString: string = this._labels[ii]; if (labelString.length > 0) { let label: Text = Fonts.arial(labelString).color(0xffffff).build(); - label.width = horizontal_space; - label.x = Plot.W_MARGIN + (ii + 0.5) * horizontal_space; + label.width = horizontalSpace; + label.x = Plot.W_MARGIN + (ii + 0.5) * horizontalSpace; label.y = Plot.H_MARGIN + this._height; this.addChild(label); this._labelFields.push(label); diff --git a/src/eterna/UndoBlock.ts b/src/eterna/UndoBlock.ts index dc9ebc1dc..4345b1ad9 100644 --- a/src/eterna/UndoBlock.ts +++ b/src/eterna/UndoBlock.ts @@ -1,9 +1,9 @@ -import {JSONUtil} from "flashbang/util"; -import EPars from "eterna/EPars"; -import {Folder} from "eterna/folding"; -import {default as Plot, PlotType} from "eterna/Plot"; -import {Oligo, Pose2D} from "eterna/pose2D"; -import {Utility} from "./util"; +import {JSONUtil} from 'flashbang/util'; +import EPars from 'eterna/EPars'; +import {Folder} from 'eterna/folding'; +import Plot, {PlotType} from 'eterna/Plot'; +import {Oligo, Pose2D} from 'eterna/pose2D'; +import {Utility} from './util'; export enum UndoBlockParam { GU = 0, @@ -24,11 +24,15 @@ export enum UndoBlockParam { } export default class UndoBlock { - public constructor(seq: number[]) { + constructor(seq: number[]) { this._sequence = seq.slice(); } public toJSON(): any { + // TODO: Updating this requires changing all content in the DB AND + // migrating all autosave content on boot for however long we want to allow + // players to migrate their autosaves + /* eslint-disable @typescript-eslint/camelcase */ return { sequence_: this._sequence, pairs_array_: this._pairsArray, @@ -44,23 +48,24 @@ export default class UndoBlock { forced_struct_: this._forcedStruct, target_conditions_: this._targetConditions }; + /* eslint-enable @typescript-eslint/camelcase */ } public fromJSON(json: any): void { try { - this._sequence = JSONUtil.require(json, "sequence_"); - this._pairsArray = JSONUtil.require(json, "pairs_array_"); - this._paramsArray = JSONUtil.require(json, "params_array_"); - this._stable = JSONUtil.require(json, "stable_"); - this._targetOligo = JSONUtil.require(json, "target_oligo_"); - this._targetOligos = JSONUtil.require(json, "target_oligos_"); - this._oligoOrder = JSONUtil.require(json, "oligo_order_"); - this._oligosPaired = JSONUtil.require(json, "oligos_paired_"); - this._targetPairs = JSONUtil.require(json, "target_pairs_"); - this._targetOligoOrder = JSONUtil.require(json, "target_oligo_order_"); - this._puzzleLocks = JSONUtil.require(json, "puzzle_locks_"); - this._forcedStruct = JSONUtil.require(json, "forced_struct_"); - this._targetConditions = JSONUtil.require(json, "target_conditions_"); + this._sequence = JSONUtil.require(json, 'sequence_'); + this._pairsArray = JSONUtil.require(json, 'pairs_array_'); + this._paramsArray = JSONUtil.require(json, 'params_array_'); + this._stable = JSONUtil.require(json, 'stable_'); + this._targetOligo = JSONUtil.require(json, 'target_oligo_'); + this._targetOligos = JSONUtil.require(json, 'target_oligos_'); + this._oligoOrder = JSONUtil.require(json, 'oligo_order_'); + this._oligosPaired = JSONUtil.require(json, 'oligos_paired_'); + this._targetPairs = JSONUtil.require(json, 'target_pairs_'); + this._targetOligoOrder = JSONUtil.require(json, 'target_oligo_order_'); + this._puzzleLocks = JSONUtil.require(json, 'puzzle_locks_'); + this._forcedStruct = JSONUtil.require(json, 'forced_struct_'); + this._targetConditions = JSONUtil.require(json, 'target_conditions_'); } catch (e) { throw new Error(`Error parsing UndoBlock JSON: ${e}`); } @@ -70,22 +75,22 @@ export default class UndoBlock { return this._targetOligos; } - public set targetOligos(target_oligos: Oligo[]) { - this._targetOligos = target_oligos == null ? null : JSON.parse(JSON.stringify(target_oligos)); + public set targetOligos(targetOligos: Oligo[]) { + this._targetOligos = targetOligos == null ? null : JSON.parse(JSON.stringify(targetOligos)); } public get targetOligo(): number[] { return this._targetOligo; } - public set targetOligo(target_oligo: number[]) { - this._targetOligo = target_oligo == null ? null : target_oligo.slice(); + public set targetOligo(targetOligo: number[]) { + this._targetOligo = targetOligo == null ? null : targetOligo.slice(); } public get oligoMode(): number { let tc: any = this.targetConditions; if (tc == null) return 0; - return tc["fold_mode"] == null ? Pose2D.OLIGO_MODE_DIMER : Number(tc["fold_mode"]); + return tc['fold_mode'] == null ? Pose2D.OLIGO_MODE_DIMER : Number(tc['fold_mode']); } public get oligoName(): string { @@ -93,39 +98,39 @@ export default class UndoBlock { if (tc == null) { return null; } - return tc.hasOwnProperty("oligo_name") ? tc["oligo_name"] : null; + return Object.prototype.hasOwnProperty.call(tc, 'oligo_name') ? tc['oligo_name'] : null; } public get oligoOrder(): number[] { return this._oligoOrder; } - public set oligoOrder(oligo_order: number[]) { - this._oligoOrder = oligo_order == null ? null : oligo_order.slice(); + public set oligoOrder(oligoOrder: number[]) { + this._oligoOrder = oligoOrder == null ? null : oligoOrder.slice(); } public get oligosPaired(): number { return this._oligosPaired; } - public set oligosPaired(oligos_paired: number) { - this._oligosPaired = oligos_paired; + public set oligosPaired(oligosPaired: number) { + this._oligosPaired = oligosPaired; } public get targetPairs(): number[] { return this._targetPairs; } - public set targetPairs(target_pairs: number[]) { - this._targetPairs = target_pairs.slice(); + public set targetPairs(targetPairs: number[]) { + this._targetPairs = targetPairs.slice(); } public get targetOligoOrder(): number[] { return this._targetOligoOrder; } - public set targetOligoOrder(oligo_order: number[]) { - this._targetOligoOrder = oligo_order == null ? null : oligo_order.slice(); + public set targetOligoOrder(oligoOrder: number[]) { + this._targetOligoOrder = oligoOrder == null ? null : oligoOrder.slice(); } public get sequence(): number[] { @@ -192,39 +197,39 @@ export default class UndoBlock { } public setBasics(folder: Folder, temp: number = 37): void { - let best_pairs: number[] = this.getPairs(temp); + let bestPairs: number[] = this.getPairs(temp); let seq: number[] = this._sequence; - this.setParam(UndoBlockParam.GU, EPars.numGUPairs(seq, best_pairs), temp); - this.setParam(UndoBlockParam.GC, EPars.numGCPairs(seq, best_pairs), temp); - this.setParam(UndoBlockParam.AU, EPars.numUAPairs(seq, best_pairs), temp); - this.setParam(UndoBlockParam.STACK, EPars.getLongestStackLength(best_pairs), temp); + this.setParam(UndoBlockParam.GU, EPars.numGUPairs(seq, bestPairs), temp); + this.setParam(UndoBlockParam.GC, EPars.numGCPairs(seq, bestPairs), temp); + this.setParam(UndoBlockParam.AU, EPars.numUAPairs(seq, bestPairs), temp); + this.setParam(UndoBlockParam.STACK, EPars.getLongestStackLength(bestPairs), temp); this.setParam(UndoBlockParam.REPETITION, EPars.getSequenceRepetition(EPars.sequenceToString(seq), 5), temp); - let full_seq: number[] = seq.slice(); + let fullSeq: number[] = seq.slice(); if (this._targetOligo) { - if (this.oligoMode === Pose2D.OLIGO_MODE_DIMER) full_seq.push(EPars.RNABASE_CUT); + if (this.oligoMode === Pose2D.OLIGO_MODE_DIMER) fullSeq.push(EPars.RNABASE_CUT); if (this.oligoMode === Pose2D.OLIGO_MODE_EXT5P) { - full_seq = this._targetOligo.concat(full_seq); + fullSeq = this._targetOligo.concat(fullSeq); } else { - full_seq = full_seq.concat(this._targetOligo); + fullSeq = fullSeq.concat(this._targetOligo); } } else if (this._targetOligos) { for (let ii = 0; ii < this._targetOligos.length; ii++) { - full_seq.push(EPars.RNABASE_CUT); - full_seq = full_seq.concat(this._targetOligos[this._oligoOrder[ii]].sequence); + fullSeq.push(EPars.RNABASE_CUT); + fullSeq = fullSeq.concat(this._targetOligos[this._oligoOrder[ii]].sequence); } } let nnfe: number[] = []; - let total_fe: number = folder.scoreStructures(full_seq, best_pairs, temp, nnfe); - this.setParam(UndoBlockParam.FE, total_fe, temp); + let totalFE: number = folder.scoreStructures(fullSeq, bestPairs, temp, nnfe); + this.setParam(UndoBlockParam.FE, totalFE, temp); this.setParam(UndoBlockParam.NNFE_ARRAY, nnfe, temp); } public updateMeltingPointAndDotPlot(folder: Folder): void { if (this.getParam(UndoBlockParam.DOTPLOT, 37) == null) { - let dot_array: number[] = folder.getDotPlot(this.sequence, this.getPairs(37), 37); - this.setParam(UndoBlockParam.DOTPLOT, dot_array, 37); - this._dotPlotData = dot_array.slice(); + let dotArray: number[] = folder.getDotPlot(this.sequence, this.getPairs(37), 37); + this.setParam(UndoBlockParam.DOTPLOT, dotArray, 37); + this._dotPlotData = dotArray.slice(); } for (let ii = 37; ii < 100; ii += 10) { @@ -233,72 +238,72 @@ export default class UndoBlock { } if (this.getParam(UndoBlockParam.DOTPLOT, ii) == null) { - let dot_temp_array: number[] = folder.getDotPlot(this.sequence, this.getPairs(ii), ii); - this.setParam(UndoBlockParam.DOTPLOT, dot_temp_array, ii); + let dotTempArray: number[] = folder.getDotPlot(this.sequence, this.getPairs(ii), ii); + this.setParam(UndoBlockParam.DOTPLOT, dotTempArray, ii); } } - let ref_pairs: number[] = this.getPairs(37); + let refPairs: number[] = this.getPairs(37); - let pair_scores: number[] = []; - let max_pair_scores: number[] = []; + let pairScores: number[] = []; + let maxPairScores: number[] = []; for (let ii = 37; ii < 100; ii += 10) { if (this.getParam(UndoBlockParam.PROB_SCORE, ii)) { - pair_scores.push(1 - this.getParam(UndoBlockParam.PAIR_SCORE, ii)); - max_pair_scores.push(1.0); + pairScores.push(1 - this.getParam(UndoBlockParam.PAIR_SCORE, ii)); + maxPairScores.push(1.0); continue; } - let cur_dat: number[] = this.getParam(UndoBlockParam.DOTPLOT, ii); - let cur_pairs: number[] = this.getPairs(ii); - let prob_score = 0; - let score_count = 0; - - for (let jj = 0; jj < cur_dat.length; jj += 3) { - let index_i: number = cur_dat[jj] - 1; - let index_j: number = cur_dat[jj + 1] - 1; - - if (index_i < index_j) { - if (ref_pairs[index_i] === index_j) { - prob_score += Number(cur_dat[jj + 2]); - score_count++; + let curDat: number[] = this.getParam(UndoBlockParam.DOTPLOT, ii); + let curPairs: number[] = this.getPairs(ii); + let probScore = 0; + let scoreCount = 0; + + for (let jj = 0; jj < curDat.length; jj += 3) { + let indexI: number = curDat[jj] - 1; + let indexJ: number = curDat[jj + 1] - 1; + + if (indexI < indexJ) { + if (refPairs[indexI] === indexJ) { + probScore += Number(curDat[jj + 2]); + scoreCount++; } - } else if (index_j < index_i) { - if (ref_pairs[index_j] === index_i) { - prob_score += Number(cur_dat[jj + 2]); - score_count++; + } else if (indexJ < indexI) { + if (refPairs[indexJ] === indexI) { + probScore += Number(curDat[jj + 2]); + scoreCount++; } } } - if (score_count > 0) { - prob_score /= score_count; + if (scoreCount > 0) { + probScore /= scoreCount; } - let num_paired = 0; - for (let jj = 0; jj < cur_pairs.length; jj++) { - if (cur_pairs[jj] > jj) { - num_paired += 2; + let numPaired = 0; + for (let jj = 0; jj < curPairs.length; jj++) { + if (curPairs[jj] > jj) { + numPaired += 2; } } - let pair_score: number = Number(num_paired) / ref_pairs.length; + let pairScore: number = Number(numPaired) / refPairs.length; - pair_scores.push(1 - pair_score); - max_pair_scores.push(1.0); + pairScores.push(1 - pairScore); + maxPairScores.push(1.0); - this.setParam(UndoBlockParam.PROB_SCORE, prob_score, ii); - this.setParam(UndoBlockParam.PAIR_SCORE, pair_score, ii); + this.setParam(UndoBlockParam.PROB_SCORE, probScore, ii); + this.setParam(UndoBlockParam.PAIR_SCORE, pairScore, ii); } - this._meltPlotPairScores = pair_scores; - this._meltPlotMaxPairScores = max_pair_scores; + this._meltPlotPairScores = pairScores; + this._meltPlotMaxPairScores = maxPairScores; - let init_score: number = this.getParam(UndoBlockParam.PROB_SCORE, 37); + let initScore: number = this.getParam(UndoBlockParam.PROB_SCORE, 37); let meltpoint = 107; for (let ii = 47; ii < 100; ii += 10) { - let current_score: number = this.getParam(UndoBlockParam.PROB_SCORE, ii); - if (current_score < init_score * 0.5) { + let currentScore: number = this.getParam(UndoBlockParam.PROB_SCORE, ii); + if (currentScore < initScore * 0.5) { meltpoint = ii; break; } @@ -322,8 +327,9 @@ export default class UndoBlock { /** * Return map of current base indices to adjusted base indices when oligos are rearranged * according to otherorder - * @param otherOrder An array of indexes, where the index refers to the new index the oligo at the given position in the old - * array should be placed at. E.g., given oligos in order A B C, [1,2,0] means their new order should be C, A, B + * @param otherOrder An array of indexes, where the index refers to the new index + * the oligo at the given position in the old array should be placed at. + * E.g., given oligos in order A B C, [1,2,0] means their new order should be C, A, B * (oligo A, with the old index of 0, should be at new index 1) */ public reorderedOligosIndexMap(otherOrder: number[]): number[] { diff --git a/src/eterna/achievements/AchievementBox.ts b/src/eterna/achievements/AchievementBox.ts index 83c80edf1..716c362fd 100644 --- a/src/eterna/achievements/AchievementBox.ts +++ b/src/eterna/achievements/AchievementBox.ts @@ -1,14 +1,14 @@ -import * as log from "loglevel"; -import {Point, Sprite, Text} from "pixi.js"; -import {ContainerObject} from "flashbang/objects"; +import * as log from 'loglevel'; +import {Point, Sprite, Text} from 'pixi.js'; +import {ContainerObject} from 'flashbang/objects'; import { AlphaTask, DelayTask, ParallelTask, ScaleTask, SerialTask -} from "flashbang/tasks"; -import {Easing, TextureUtil} from "flashbang/util"; -import {PlaySoundTask, Sounds} from "eterna/resources"; -import {GameButton, GamePanel, GamePanelType} from "eterna/ui"; -import {Fonts} from "eterna/util"; -import {VibrateTask} from "eterna/vfx"; +} from 'flashbang/tasks'; +import {Easing, TextureUtil} from 'flashbang/util'; +import {PlaySoundTask, Sounds} from 'eterna/resources'; +import {GameButton, GamePanel, GamePanelType} from 'eterna/ui'; +import {Fonts} from 'eterna/util'; +import {VibrateTask} from 'eterna/vfx'; export default class AchievementBox extends ContainerObject { constructor(imageURL: string, text: string) { @@ -49,7 +49,7 @@ export default class AchievementBox extends ContainerObject { imageSprite.position = new Point(15, 35); panel.container.addChild(imageSprite); - let titleTxt = Fonts.arial("Congratulations!", 18).color(0xffffff).bold().build(); + let titleTxt = Fonts.arial('Congratulations!', 18).color(0xffffff).bold().build(); titleTxt.position = new Point(160, 5); panel.container.addChild(titleTxt); @@ -60,7 +60,7 @@ export default class AchievementBox extends ContainerObject { this._descriptionTxt.position = new Point(160, 50); panel.container.addChild(this._descriptionTxt); - this._okButton = new GameButton().label("CLOSE", 18); + this._okButton = new GameButton().label('CLOSE', 18); panel.addObject(this._okButton, panel.container); this._okButton.container.position = new Point( (panel.width - this._okButton.container.width) * 0.5, diff --git a/src/eterna/achievements/AchievementManager.ts b/src/eterna/achievements/AchievementManager.ts index 57355dff5..b007603c7 100644 --- a/src/eterna/achievements/AchievementManager.ts +++ b/src/eterna/achievements/AchievementManager.ts @@ -1,10 +1,10 @@ import { HAlign, VAlign, GameObject, GameObjectRef -} from "flashbang/core"; -import {CallbackTask, FunctionTask, SerialTask} from "flashbang/tasks"; -import {DisplayUtil} from "flashbang/util"; -import {GameMode} from "eterna/mode"; -import AchievementBox from "./AchievementBox"; +} from 'flashbang/core'; +import {CallbackTask, FunctionTask, SerialTask} from 'flashbang/tasks'; +import {DisplayUtil} from 'flashbang/util'; +import {GameMode} from 'eterna/mode'; +import AchievementBox from './AchievementBox'; export default class AchievementManager extends GameObject { /** True if there's an achievement animation playing, or about to play */ @@ -28,8 +28,8 @@ export default class AchievementManager extends GameObject { public awardAchievements(achievementData: any): Promise { if (achievementData != null) { - for (let key in achievementData) { - if (achievementData.hasOwnProperty(key)) { + for (let key of Object.keys(achievementData)) { + if (Object.prototype.hasOwnProperty.call(achievementData, key)) { let data: AchievementData = achievementData[key]; this._pending.push(data); } @@ -42,11 +42,11 @@ export default class AchievementManager extends GameObject { } private maybeShowNextAchievement(): void { - if (this._pending.length == 0 || this._cur.isLive) { + if (this._pending.length === 0 || this._cur.isLive) { return; } - (this.mode as GameMode).pushUILock("ShowAchievement"); + (this.mode as GameMode).pushUILock('ShowAchievement'); let nextData: AchievementData = this._pending.shift(); let view = new AchievementBox(nextData.image, nextData.past); @@ -57,7 +57,7 @@ export default class AchievementManager extends GameObject { view.destroyed.connect(() => { this.maybeShowNextAchievement(); - (this.mode as GameMode).popUILock("ShowAchievement"); + (this.mode as GameMode).popUILock('ShowAchievement'); }); let updateLoc = () => { diff --git a/src/eterna/achievements/index.ts b/src/eterna/achievements/index.ts index ef5ad0f3a..ffeb7d7aa 100644 --- a/src/eterna/achievements/index.ts +++ b/src/eterna/achievements/index.ts @@ -1,2 +1,2 @@ -export {default as AchievementBox} from "./AchievementBox"; -export {default as AchievementManager} from "./AchievementManager"; +export {default as AchievementBox} from './AchievementBox'; +export {default as AchievementManager} from './AchievementManager'; diff --git a/src/eterna/debug/TestMode.ts b/src/eterna/debug/TestMode.ts index 2260ba475..9aa6d010a 100644 --- a/src/eterna/debug/TestMode.ts +++ b/src/eterna/debug/TestMode.ts @@ -1,8 +1,8 @@ -import {GameMode} from "../mode"; -import {ViewSolutionDialog} from "../mode/DesignBrowser"; +import {GameMode} from '../mode'; +import {ViewSolutionDialog} from '../mode/DesignBrowser'; import { Puzzle, PuzzleManager, Solution, SolutionManager -} from "../puzzle"; +} from '../puzzle'; export default class TestMode extends GameMode { protected setup(): void { diff --git a/src/eterna/debug/index.ts b/src/eterna/debug/index.ts index 8623b3889..faa24a290 100644 --- a/src/eterna/debug/index.ts +++ b/src/eterna/debug/index.ts @@ -1 +1,2 @@ -export {default as TestMode} from "./TestMode"; +/* eslint-disable import/prefer-default-export */ +export {default as TestMode} from './TestMode'; diff --git a/src/eterna/emscripten/EmscriptenUtil.ts b/src/eterna/emscripten/EmscriptenUtil.ts index 93bed1b78..acad42996 100644 --- a/src/eterna/emscripten/EmscriptenUtil.ts +++ b/src/eterna/emscripten/EmscriptenUtil.ts @@ -1,4 +1,5 @@ -import * as stdcpp from "./stdcpp"; +// eslint-disable-next-line import/no-unresolved +import * as stdcpp from './stdcpp'; export default class EmscriptenUtil { /** @@ -8,7 +9,7 @@ export default class EmscriptenUtil { public static loadProgram(module: any): Promise { return new Promise((resolve, _) => { module.default({noInitialRun: true}).then((program: any) => { - if (program.hasOwnProperty("callMain")) { + if (Object.prototype.hasOwnProperty.call(program, 'callMain')) { program.callMain(); } @@ -17,8 +18,8 @@ export default class EmscriptenUtil { // resolving our promise with the program will recurse infinitely. // https://github.com/kripken/emscripten/issues/5820 // TODO: remove this if and when emscripten is fixed - if (program.hasOwnProperty("then")) { - delete program["then"]; + if (Object.prototype.hasOwnProperty.call(program, 'then')) { + delete program['then']; } resolve(program); diff --git a/src/eterna/emscripten/index.ts b/src/eterna/emscripten/index.ts index 880d272ac..4fc976bea 100644 --- a/src/eterna/emscripten/index.ts +++ b/src/eterna/emscripten/index.ts @@ -1 +1,2 @@ -export {default as EmscriptenUtil} from "./EmscriptenUtil"; +/* eslint-disable import/prefer-default-export */ +export {default as EmscriptenUtil} from './EmscriptenUtil'; diff --git a/src/eterna/folding/Folder.ts b/src/eterna/folding/Folder.ts index 2bef17281..626bc7ede 100644 --- a/src/eterna/folding/Folder.ts +++ b/src/eterna/folding/Folder.ts @@ -1,15 +1,12 @@ -import {PoseOp} from "eterna/pose2D"; +import {PoseOp} from 'eterna/pose2D'; export default abstract class Folder { - protected constructor() { - } - public abstract get name (): string; public abstract get isFunctional (): boolean; public getCache(key: any): any { - let key_str = JSON.stringify(key); - return this._cache.get(key_str); + let keyStr = JSON.stringify(key); + return this._cache.get(keyStr); } public get canScoreStructures(): boolean { @@ -20,7 +17,9 @@ export default abstract class Folder { return 0; } - public foldSequence(seq: number[], second_best_pairs: number[], desired_pairs: string = null, temp: number = 37): number[] { + public foldSequence( + seq: number[], secondBestPairs: number[], desiredPairs: string = null, temp: number = 37 + ): number[] { return null; } @@ -28,7 +27,10 @@ export default abstract class Folder { return false; } - public foldSequenceWithBindingSite(seq: number[], target_pairs: number[], binding_site: number[], bonus: number, version: number = 2.0, temp: number = 37): number[] { + public foldSequenceWithBindingSite( + seq: number[], targetPairs: number[], bindingSite: number[], bonus: number, + version: number = 2.0, temp: number = 37 + ): number[] { return null; } @@ -36,7 +38,9 @@ export default abstract class Folder { return false; } - public cofoldSequence(seq: number[], second_best_pairs: number[], malus: number = 0, desired_pairs: string = null, temp: number = 37): number[] { + public cofoldSequence( + seq: number[], secondBestPairs: number[], malus: number = 0, desiredPairs: string = null, temp: number = 37 + ): number[] { return null; } @@ -44,7 +48,10 @@ export default abstract class Folder { return false; } - public cofoldSequenceWithBindingSite(seq: number[], binding_site: number[], bonus: number, desired_pairs: string = null, malus: number = 0, temp: number = 37): number[] { + public cofoldSequenceWithBindingSite( + seq: number[], bindingSite: number[], bonus: number, desiredPairs: string = null, + malus: number = 0, temp: number = 37 + ): number[] { return null; } @@ -60,11 +67,15 @@ export default abstract class Folder { return false; } - public multifold(seq: number[], second_best_pairs: number[], oligos: any[], desired_pairs: string = null, temp: number = 37): any { + public multifold( + seq: number[], secondBestPairs: number[], oligos: any[], desiredPairs: string = null, temp: number = 37 + ): any { return null; } - public multifoldUnroll(seq: number[], second_best_pairs: number[], oligos: any[], desired_pairs: string = null, temp: number = 37): PoseOp[] { + public multifoldUnroll( + seq: number[], secondBestPairs: number[], oligos: any[], desiredPairs: string = null, temp: number = 37 + ): PoseOp[] { return null; } @@ -82,11 +93,16 @@ export default abstract class Folder { return false; } - public hairpinEnergy(size: number, type: number, si1: number, sj1: number, sequence: number[], i: number, j: number): number { + public hairpinEnergy( + size: number, type: number, si1: number, sj1: number, sequence: number[], i: number, j: number + ): number { return 0; } - public loopEnergy(n1: number, n2: number, type: number, type_2: number, si1: number, sj1: number, sp1: number, sq1: number, b1: boolean, b2: boolean): number { + public loopEnergy( + n1: number, n2: number, type: number, + type2: number, si1: number, sj1: number, sp1: number, sq1: number, b1: boolean, b2: boolean + ): number { return 0; } @@ -94,13 +110,13 @@ export default abstract class Folder { return 0; } - public mlEnergy(pairs: number[], S: number[], i: number, is_extloop: boolean): number { + public mlEnergy(pairs: number[], S: number[], i: number, isExtloop: boolean): number { return 0; } protected putCache(key: Record, data: any): void { - let key_str = JSON.stringify(key); - this._cache.set(key_str, data); + let keyStr = JSON.stringify(key); + this._cache.set(keyStr, data); } protected resetCache(): void { diff --git a/src/eterna/folding/FolderManager.ts b/src/eterna/folding/FolderManager.ts index 3719dcdd6..2075410f6 100644 --- a/src/eterna/folding/FolderManager.ts +++ b/src/eterna/folding/FolderManager.ts @@ -1,8 +1,8 @@ -import Eterna from "eterna/Eterna"; -import Folder from "./Folder"; -import RNAFoldBasic from "./RNAFoldBasic"; -import Vienna from "./Vienna"; -import LinearFoldC from "./LinearFoldC"; +import Eterna from 'eterna/Eterna'; +import Folder from './Folder'; +import RNAFoldBasic from './RNAFoldBasic'; +import Vienna from './Vienna'; +import LinearFoldC from './LinearFoldC'; export default class FolderManager { public static get instance(): FolderManager { @@ -40,17 +40,17 @@ export default class FolderManager { return null; } - public getNextFolder(folder_name: string, filter_cb: (folder: Folder) => boolean = null): Folder { + public getNextFolder(folderName: string, filterCB: (folder: Folder) => boolean = null): Folder { let curFolderIdx = -1; for (let ii = 0; ii < this._folders.length; ii++) { - if (this._folders[ii].name.toLowerCase() === folder_name.toLowerCase()) { + if (this._folders[ii].name.toLowerCase() === folderName.toLowerCase()) { curFolderIdx = ii; break; } } if (curFolderIdx < 0) { - throw new Error(`No such folder '${folder_name}'`); + throw new Error(`No such folder '${folderName}'`); } for (let jj = 1; jj < this._folders.length; jj++) { @@ -61,7 +61,7 @@ export default class FolderManager { || folder.name === RNAFoldBasic.NAME || folder.name === LinearFoldC.NAME || !folder.isFunctional - || (filter_cb != null && filter_cb(folder))) { + || (filterCB != null && filterCB(folder))) { continue; } diff --git a/src/eterna/folding/LinearFoldBase.ts b/src/eterna/folding/LinearFoldBase.ts index bfc2978f5..72190d340 100644 --- a/src/eterna/folding/LinearFoldBase.ts +++ b/src/eterna/folding/LinearFoldBase.ts @@ -1,14 +1,16 @@ -import * as log from "loglevel"; -import {EmscriptenUtil} from "eterna/emscripten"; -import EPars from "eterna/EPars"; -import {FullFoldResult} from "./engines/LinearFold_lib"; -import * as LinearFold_lib from "./engines/LinearFold_lib/index"; -import {FullEvalResult} from "./engines/vienna_lib"; -import Folder from "./Folder"; -import FoldUtil from "./FoldUtil"; +import * as log from 'loglevel'; +import {EmscriptenUtil} from 'eterna/emscripten'; +import EPars from 'eterna/EPars'; +/* eslint-disable import/no-duplicates, import/no-unresolved */ +import * as LinearFoldLib from './engines/LinearFoldLib'; +import {FullFoldResult} from './engines/LinearFoldLib'; +import {FullEvalResult} from './engines/ViennaLib'; +/* eslint-enable import/no-duplicates, import/no-unresolved */ +import Folder from './Folder'; +import FoldUtil from './FoldUtil'; export default abstract class LinearFoldBase extends Folder { - protected constructor(lib: LinearFold_lib) { + protected constructor(lib: LinearFoldLib) { super(); this._lib = lib; } @@ -18,7 +20,7 @@ export default abstract class LinearFoldBase extends Folder { } public getDotPlot(seq: number[], pairs: number[], temp: number = 37): number[] { - log.warn("LinearFold.get_dot_plot: unimplemented"); + log.warn('LinearFold.getDotPlot: unimplemented'); return []; } @@ -32,7 +34,7 @@ export default abstract class LinearFoldBase extends Folder { public scoreStructures(seq: number[], pairs: number[], temp: number = 37, outNodes: number[] = null): number { let key: any = { - primitive: "score", seq, pairs, temp + primitive: 'score', seq, pairs, temp }; let cache: FullEvalCache = this.getCache(key); @@ -53,7 +55,7 @@ export default abstract class LinearFoldBase extends Folder { ); cache = {energy: result.energy, nodes: EmscriptenUtil.stdVectorToArray(result.nodes)}; } catch (e) { - log.error("FullEval error", e); + log.error('FullEval error', e); return 0; } finally { if (result != null) { @@ -79,7 +81,7 @@ export default abstract class LinearFoldBase extends Folder { let retB: number = this.scoreStructures(seqB, pairsB, temp, nodesB); if (nodesA[0] !== -1 || nodesB[0] !== -1) { - throw new Error("Something went terribly wrong in score_structures()"); + throw new Error('Something went terribly wrong in scoreStructures()'); } cache.nodes.splice(0); // make empty @@ -105,12 +107,14 @@ export default abstract class LinearFoldBase extends Folder { return energy; } - public foldSequence(seq: number[], second_best_pairs: number[], desired_pairs: string = null, temp: number = 37): number[] { + public foldSequence( + seq: number[], secondBestPairs: number[], desiredPairs: string = null, temp: number = 37 + ): number[] { let key: any = { - primitive: "fold", + primitive: 'fold', seq, - second_best_pairs, - desired_pairs, + secondBestPairs, + desiredPairs, temp }; @@ -131,7 +135,7 @@ export default abstract class LinearFoldBase extends Folder { result = this._lib.FullFoldDefault(seqStr); return EPars.parenthesisToPairs(result.structure); } catch (e) { - log.error("FullFoldDefault error", e); + log.error('FullFoldDefault error', e); return []; } finally { if (result != null) { @@ -145,8 +149,11 @@ export default abstract class LinearFoldBase extends Folder { return false; } - public foldSequenceWithBindingSite(seq: number[], target_pairs: number[], binding_site: number[], bonus: number, version: number = 1.0, temp: number = 37): number[] { - log.warn("LinearFold.fold_sequence_with_binding_site: unimplemented"); + public foldSequenceWithBindingSite( + seq: number[], targetPairs: number[], bindingSite: number[], bonus: number, + version: number = 1.0, temp: number = 37 + ): number[] { + log.warn('LinearFold.foldSequenceWithBindingSite: unimplemented'); return this.foldSequence(seq, null); } @@ -154,8 +161,10 @@ export default abstract class LinearFoldBase extends Folder { return false; } - public cofoldSequence(seq: number[], second_best_pairs: number[], malus: number = 0, desired_pairs: string = null, temp: number = 37): number[] { - log.warn("LinearFold.cofold_sequence: unimplemented"); + public cofoldSequence( + seq: number[], secondBestPairs: number[], malus: number = 0, desiredPairs: string = null, temp: number = 37 + ): number[] { + log.warn('LinearFold.cofoldSequence: unimplemented'); return this.foldSequence(seq, null); } @@ -163,32 +172,40 @@ export default abstract class LinearFoldBase extends Folder { return false; } - public cofoldSequenceWithBindingSite(seq: number[], binding_site: number[], bonus: number, desired_pairs: string = null, malus: number = 0, temp: number = 37): number[] { - log.warn("LinearFold.cofold_sequence_with_binding_site: unimplemented"); + public cofoldSequenceWithBindingSite( + seq: number[], bindingSite: number[], bonus: number, desiredPairs: string = null, + malus: number = 0, temp: number = 37 + ): number[] { + log.warn('LinearFold.cofoldSequenceWithBindingSite: unimplemented'); return this.foldSequence(seq, null); } - public mlEnergy(pairs: number[], S: number[], i: number, is_extloop: boolean): number { - log.warn("LinearFold.ml_energy: unimplemented"); + public mlEnergy(pairs: number[], S: number[], i: number, isExtloop: boolean): number { + log.warn('LinearFold.mlEnergy: unimplemented'); return 0; } public cutInLoop(i: number): number { - log.warn("LinearFold.cut_in_loop: unimplemented"); + log.warn('LinearFold.cutInLoop: unimplemented'); return 0; } - public loopEnergy(n1: number, n2: number, type: number, type_2: number, si1: number, sj1: number, sp1: number, sq1: number, b1: boolean, b2: boolean): number { - log.warn("LinearFold.loop_energy: unimplemented"); + public loopEnergy( + n1: number, n2: number, type: number, type2: number, + si1: number, sj1: number, sp1: number, sq1: number, b1: boolean, b2: boolean + ): number { + log.warn('LinearFold.loopEnergy: unimplemented'); return 0; } - public hairpinEnergy(size: number, type: number, si1: number, sj1: number, sequence: number[], i: number, j: number): number { - log.warn("LinearFold.hairpin_energy: unimplemented"); + public hairpinEnergy( + size: number, type: number, si1: number, sj1: number, sequence: number[], i: number, j: number + ): number { + log.warn('LinearFold.hairpinEnergy: unimplemented'); return 0; } - private readonly _lib: LinearFold_lib; + private readonly _lib: LinearFoldLib; } interface FullEvalCache { diff --git a/src/eterna/folding/LinearFoldC.ts b/src/eterna/folding/LinearFoldC.ts index a5f0b408c..c7a331801 100644 --- a/src/eterna/folding/LinearFoldC.ts +++ b/src/eterna/folding/LinearFoldC.ts @@ -1,15 +1,15 @@ -import {EmscriptenUtil} from "eterna/emscripten"; -import LinearFoldBase from "./LinearFoldBase"; +import {EmscriptenUtil} from 'eterna/emscripten'; +import LinearFoldBase from './LinearFoldBase'; export default class LinearFoldC extends LinearFoldBase { - public static readonly NAME = "LinearFoldC"; + public static readonly NAME = 'LinearFoldC'; /** * Asynchronously creates a new instance of the Vienna folder. * @returns {Promise} */ public static create(): Promise { - return import("./engines/LinearFoldC") + return import('./engines/LinearFoldC') .then((module: any) => EmscriptenUtil.loadProgram(module)) .then((program: any) => new LinearFoldC(program)); } diff --git a/src/eterna/folding/LinearFoldV.ts b/src/eterna/folding/LinearFoldV.ts index 420ab37ca..a9f3ee67b 100644 --- a/src/eterna/folding/LinearFoldV.ts +++ b/src/eterna/folding/LinearFoldV.ts @@ -1,15 +1,15 @@ -import {EmscriptenUtil} from "eterna/emscripten"; -import LinearFoldBase from "./LinearFoldBase"; +import {EmscriptenUtil} from 'eterna/emscripten'; +import LinearFoldBase from './LinearFoldBase'; export default class LinearFoldV extends LinearFoldBase { - public static readonly NAME = "LinearFoldV"; + public static readonly NAME = 'LinearFoldV'; /** * Asynchronously creates a new instance of the Vienna folder. * @returns {Promise} */ public static create(): Promise { - return import("./engines/LinearFoldV") + return import('./engines/LinearFoldV') .then((module: any) => EmscriptenUtil.loadProgram(module)) .then((program: any) => new LinearFoldV(program)); } diff --git a/src/eterna/folding/NuPACK.ts b/src/eterna/folding/NuPACK.ts index 7dce295b0..111df942c 100644 --- a/src/eterna/folding/NuPACK.ts +++ b/src/eterna/folding/NuPACK.ts @@ -1,27 +1,29 @@ -import * as log from "loglevel"; -import {EmscriptenUtil} from "eterna/emscripten"; -import EPars from "eterna/EPars"; -import {PoseOp} from "eterna/pose2D"; -import {int} from "eterna/util"; -import * as nupack_lib from "./engines/nupack_lib/index"; -import {DotPlotResult, FullEvalResult, FullFoldResult} from "./engines/nupack_lib/index"; -import Folder from "./Folder"; -import FoldUtil from "./FoldUtil"; +import * as log from 'loglevel'; +import {EmscriptenUtil} from 'eterna/emscripten'; +import EPars from 'eterna/EPars'; +import {PoseOp} from 'eterna/pose2D'; +import {int} from 'eterna/util'; +/* eslint-disable import/no-duplicates, import/no-unresolved */ +import * as NupackLib from './engines/NupackLib'; +import {DotPlotResult, FullEvalResult, FullFoldResult} from './engines/NupackLib'; +/* eslint-enable import/no-duplicates, import/no-unresolved */ +import Folder from './Folder'; +import FoldUtil from './FoldUtil'; export default class NuPACK extends Folder { - public static NAME = "NuPACK"; + public static NAME = 'NuPACK'; /** * Asynchronously creates a new instance of the NuPACK folder. * @returns {Promise} */ public static create(): Promise { - return import("./engines/nupack") + return import('./engines/nupack') .then((module: any) => EmscriptenUtil.loadProgram(module)) .then((program: any) => new NuPACK(program)); } - private constructor(lib: nupack_lib) { + private constructor(lib: NupackLib) { super(); this._lib = lib; } @@ -34,22 +36,22 @@ export default class NuPACK extends Folder { /* override */ public getDotPlot(seq: number[], pairs: number[], temp: number = 37): number[] { let key: any = { - primitive: "dotplot", seq, pairs, temp + primitive: 'dotplot', seq, pairs, temp }; - let ret_array: number[] = this.getCache(key); - if (ret_array != null) { + let retArray: number[] = this.getCache(key); + if (retArray != null) { // trace("dotplot cache hit"); - return ret_array.slice(); + return retArray.slice(); } - let seq_str: string = EPars.sequenceToString(seq); + let seqStr: string = EPars.sequenceToString(seq); let result: DotPlotResult = null; try { - result = this._lib.GetDotPlot(temp, seq_str); - ret_array = EmscriptenUtil.stdVectorToArray(result.plot); + result = this._lib.GetDotPlot(temp, seqStr); + retArray = EmscriptenUtil.stdVectorToArray(result.plot); } catch (e) { - log.error("GetDotPlot error", e); + log.error('GetDotPlot error', e); return []; } finally { if (result != null) { @@ -58,8 +60,8 @@ export default class NuPACK extends Folder { } } - this.putCache(key, ret_array.slice()); - return ret_array; + this.putCache(key, retArray.slice()); + return retArray; } /* override */ @@ -80,7 +82,7 @@ export default class NuPACK extends Folder { /* override */ public scoreStructures(seq: number[], pairs: number[], temp: number = 37, outNodes: number[] = null): number { let key: any = { - primitive: "score", seq, pairs, temp + primitive: 'score', seq, pairs, temp }; let cache: FullEvalCache = this.getCache(key); if (cache != null) { @@ -99,7 +101,7 @@ export default class NuPACK extends Folder { EPars.pairsToParenthesis(pairs)); cache = {energy: result.energy, nodes: EmscriptenUtil.stdVectorToArray(result.nodes)}; } catch (e) { - log.error("FullEval error", e); + log.error('FullEval error', e); return 0; } finally { if (result != null) { @@ -128,7 +130,7 @@ export default class NuPACK extends Folder { let retB: number = this.scoreStructures(seqB, pairsB, temp, nodesB); if (nodesA[0] >= 0 || nodesB[0] !== -1) { - throw new Error("Something went terribly wrong in score_structures()"); + throw new Error('Something went terribly wrong in scoreStructures()'); } cache.nodes.splice(0); // make empty @@ -167,12 +169,14 @@ export default class NuPACK extends Folder { } /* override */ - public foldSequence(seq: number[], second_best_pairs: number[], desired_pairs: string = null, temp: number = 37): number[] { - let key: any = { - primitive: "fold", + public foldSequence( + seq: number[], secondBestPairs: number[], desiredPairs: string = null, temp: number = 37 + ): number[] { + let key = { + primitive: 'fold', seq, - second_best_pairs, - desired_pairs, + secondBestPairs, + desiredPairs, temp }; let pairs: number[] = this.getCache(key); @@ -191,42 +195,48 @@ export default class NuPACK extends Folder { } /* override */ - public foldSequenceWithBindingSite(seq: number[], target_pairs: number[], binding_site: number[], bonus: number, version: number = 1.0, temp: number = 37): number[] { - let key: any = { - primitive: "fold_aptamer", + public foldSequenceWithBindingSite( + seq: number[], targetPairs: number[], bindingSite: number[], bonus: number, + version: number = 1.0, temp: number = 37 + ): number[] { + let key = { + primitive: 'foldAptamer', seq, - target_pairs, - binding_site, + targetPairs, + bindingSite, bonus, version, temp }; let pairs: number[] = this.getCache(key); if (pairs != null) { - // trace("fold_aptamer cache hit"); + // trace("foldAptamer cache hit"); return pairs.slice(); } - let site_groups: number[][] = []; - let last_index = -1; - let current_group: number[] = []; + let siteGroups: number[][] = []; + let lastIndex = -1; + let currentGroup: number[] = []; - for (let jj = 0; jj < binding_site.length; jj++) { - if (last_index < 0 || binding_site[jj] - last_index === 1) { - current_group.push(binding_site[jj]); - last_index = binding_site[jj]; + for (let jj = 0; jj < bindingSite.length; jj++) { + if (lastIndex < 0 || bindingSite[jj] - lastIndex === 1) { + currentGroup.push(bindingSite[jj]); + lastIndex = bindingSite[jj]; } else { - site_groups.push(current_group); - current_group = []; - current_group.push(binding_site[jj]); - last_index = binding_site[jj]; + siteGroups.push(currentGroup); + currentGroup = []; + currentGroup.push(bindingSite[jj]); + lastIndex = bindingSite[jj]; } } - if (current_group.length > 0) { - site_groups.push(current_group); + if (currentGroup.length > 0) { + siteGroups.push(currentGroup); } - pairs = this.foldSequenceWithBindingSiteImpl(seq, site_groups[0][0], site_groups[0][site_groups[0].length - 1], site_groups[1][site_groups[1].length - 1], site_groups[1][0], bonus, temp); + pairs = this.foldSequenceWithBindingSiteImpl( + seq, siteGroups[0][0], siteGroups[0][siteGroups[0].length - 1], siteGroups[1][siteGroups[1].length - 1], + siteGroups[1][0], bonus, temp + ); this.putCache(key, pairs.slice()); return pairs; @@ -238,27 +248,29 @@ export default class NuPACK extends Folder { } /* override */ - public cofoldSequence(seq: number[], second_best_pairs: number[], malus: number = 0, desired_pairs: string = null, temp: number = 37): number[] { + public cofoldSequence( + seq: number[], secondBestPairs: number[], malus: number = 0, desiredPairs: string = null, temp: number = 37 + ): number[] { let cut: number = seq.indexOf(EPars.RNABASE_CUT); if (cut < 0) { - throw new Error("Missing cutting point"); + throw new Error('Missing cutting point'); } let key: any = { - primitive: "cofold", + primitive: 'cofold', seq, - second_best_pairs, + secondBestPairs, malus, - desired_pairs, + desiredPairs, temp }; - let co_pairs: number[] = this.getCache(key); - if (co_pairs != null) { + let coPairs: number[] = this.getCache(key); + if (coPairs != null) { // trace("cofold cache hit"); - return co_pairs.slice(); + return coPairs.slice(); } - // FIXME: what about desired_pairs? (forced structure) + // FIXME: what about desiredPairs? (forced structure) let seqA: number[] = seq.slice(0, cut); let pairsA: number[] = this.foldSequence(seqA, null, null, temp); let nodesA: number[] = []; @@ -269,73 +281,76 @@ export default class NuPACK extends Folder { let nodesB: number[] = []; let feB: number = this.scoreStructures(seqB, pairsB, temp, nodesB); - co_pairs = this.cofoldSequenceImpl(seq); - let co_nodes: number[] = []; - let co_fe: number = this.scoreStructures(seq, co_pairs, temp, co_nodes); + coPairs = this.cofoldSequenceImpl(seq); + let coNodes: number[] = []; + let coFE: number = this.scoreStructures(seq, coPairs, temp, coNodes); - if (co_fe + malus >= feA + feB) { + if (coFE + malus >= feA + feB) { let struc = `${EPars.pairsToParenthesis(pairsA)}&${EPars.pairsToParenthesis(pairsB)}`; - co_pairs = EPars.parenthesisToPairs(struc); + coPairs = EPars.parenthesisToPairs(struc); } - this.putCache(key, co_pairs.slice()); - return co_pairs; + this.putCache(key, coPairs.slice()); + return coPairs; } /* override */ - public can_cofold_with_binding_site(): boolean { + public get canCofoldWithBindingSite(): boolean { return true; } /* override */ - public cofoldSequenceWithBindingSite(seq: number[], binding_site: number[], bonus: number, desired_pairs: string = null, malus: number = 0, temp: number = 37): number[] { + public cofoldSequenceWithBindingSite( + seq: number[], bindingSite: number[], bonus: number, desiredPairs: string = null, + malus: number = 0, temp: number = 37 + ): number[] { let cut: number = seq.indexOf(EPars.RNABASE_CUT); if (cut < 0) { - throw new Error("Missing cutting point"); + throw new Error('Missing cutting point'); } let key: any = { - primitive: "cofold_aptamer", + primitive: 'cofoldAptamer', seq, malus, - desired_pairs, - binding_site, + desiredPairs, + bindingSite, bonus, temp }; - let co_pairs: number[] = this.getCache(key); - if (co_pairs != null) { - // trace("cofold_aptamer cache hit"); - return co_pairs.slice(); + let coPairs: number[] = this.getCache(key); + if (coPairs != null) { + // trace("cofoldAptamer cache hit"); + return coPairs.slice(); } // IMPORTANT: assumption is that the binding site is in segment A - // FIXME: what about desired_pairs? (forced structure) + // FIXME: what about desiredPairs? (forced structure) - let site_groups: number[][] = []; - let last_index = -1; - let current_group: number[] = []; + let siteGroups: number[][] = []; + let lastIndex = -1; + let currentGroup: number[] = []; - for (let jj = 0; jj < binding_site.length; jj++) { - if (last_index < 0 || binding_site[jj] - last_index === 1) { - current_group.push(binding_site[jj]); - last_index = binding_site[jj]; + for (let jj = 0; jj < bindingSite.length; jj++) { + if (lastIndex < 0 || bindingSite[jj] - lastIndex === 1) { + currentGroup.push(bindingSite[jj]); + lastIndex = bindingSite[jj]; } else { - site_groups.push(current_group); - current_group = []; - current_group.push(binding_site[jj]); - last_index = binding_site[jj]; + siteGroups.push(currentGroup); + currentGroup = []; + currentGroup.push(bindingSite[jj]); + lastIndex = bindingSite[jj]; } } - if (current_group.length > 0) { - site_groups.push(current_group); + if (currentGroup.length > 0) { + siteGroups.push(currentGroup); } let seqA: number[] = seq.slice(0, cut); - let pairsA: number[] = this.foldSequenceWithBindingSite(seqA, null, binding_site, bonus, 2.5, temp); + let pairsA: number[] = this.foldSequenceWithBindingSite(seqA, null, bindingSite, bonus, 2.5, temp); let nodesA: number[] = []; let feA: number = this.scoreStructures(seqA, pairsA, temp, nodesA); - if (FoldUtil.bindingSiteFormed(pairsA, site_groups)) { + if (FoldUtil.bindingSiteFormed(pairsA, siteGroups)) { feA += bonus; } @@ -344,20 +359,23 @@ export default class NuPACK extends Folder { let nodesB: number[] = []; let feB: number = this.scoreStructures(seqB, pairsB, temp, nodesB); - co_pairs = this.cofoldSequenceWithBindingSiteImpl(seq, desired_pairs, site_groups[0][0], site_groups[0][site_groups[0].length - 1], site_groups[1][site_groups[1].length - 1], site_groups[1][0], bonus, temp); - let co_nodes: number[] = []; - let co_fe: number = this.scoreStructures(seq, co_pairs, temp, co_nodes); - if (FoldUtil.bindingSiteFormed(co_pairs, site_groups)) { - co_fe += bonus; + coPairs = this.cofoldSequenceWithBindingSiteImpl( + seq, desiredPairs, siteGroups[0][0], siteGroups[0][siteGroups[0].length - 1], + siteGroups[1][siteGroups[1].length - 1], siteGroups[1][0], bonus, temp + ); + let coNodes: number[] = []; + let coFE: number = this.scoreStructures(seq, coPairs, temp, coNodes); + if (FoldUtil.bindingSiteFormed(coPairs, siteGroups)) { + coFE += bonus; } - if (co_fe + malus >= feA + feB) { + if (coFE + malus >= feA + feB) { let struc = `${EPars.pairsToParenthesis(pairsA)}&${EPars.pairsToParenthesis(pairsB)}`; - co_pairs = EPars.parenthesisToPairs(struc); + coPairs = EPars.parenthesisToPairs(struc); } - this.putCache(key, co_pairs.slice()); - return co_pairs; + this.putCache(key, coPairs.slice()); + return coPairs; } /* override */ @@ -366,13 +384,15 @@ export default class NuPACK extends Folder { } /* override */ - public multifold(seq: number[], second_best_pairs: number[], oligos: any[], desired_pairs: string = null, temp: number = 37): any { + public multifold( + seq: number[], secondBestPairs: number[], oligos: any[], desiredPairs: string = null, temp: number = 37 + ): any { let key: any = { - primitive: "multifold", + primitive: 'multifold', seq, - second_best_pairs, + secondBestPairs, oligos, - desired_pairs, + desiredPairs, temp }; let mfold: any = this.getCache(key); @@ -382,50 +402,50 @@ export default class NuPACK extends Folder { } mfold = {}; - mfold["pairs"] = null; - mfold["order"] = null; - mfold["count"] = -1; + mfold['pairs'] = null; + mfold['order'] = null; + mfold['count'] = -1; - let best_fe = 1000000; + let bestFE = 1000000; let order: number[] = []; - let num_oligo: number = oligos.length; + let numOligo: number = oligos.length; - for (let ii = 0; ii < num_oligo; ii++) { + for (let ii = 0; ii < numOligo; ii++) { order.push(ii); } let more: boolean; do { - for (let ii = num_oligo; ii >= 0; ii--) { - let ms_seq: number[] = seq.slice(); + for (let ii = numOligo; ii >= 0; ii--) { + let msSeq: number[] = seq.slice(); for (let jj = 0; jj < ii; jj++) { - ms_seq.push(EPars.RNABASE_CUT); - ms_seq = ms_seq.concat(oligos[order[jj]].seq); + msSeq.push(EPars.RNABASE_CUT); + msSeq = msSeq.concat(oligos[order[jj]].seq); } - let ms_pairs: number[]; + let msPairs: number[]; if (ii === 0) { - ms_pairs = this.foldSequence(ms_seq, null, null, temp); + msPairs = this.foldSequence(msSeq, null, null, temp); } else { - ms_pairs = this.cofoldSeq2(ms_seq, null, null, temp); + msPairs = this.cofoldSeq2(msSeq, null, null, temp); } - let ms_nodes: number[] = []; - let ms_fe: number = this.scoreStructures(ms_seq, ms_pairs, temp, ms_nodes); + let msNodes: number[] = []; + let msFE: number = this.scoreStructures(msSeq, msPairs, temp, msNodes); for (let jj = 0; jj < ii; jj++) { - ms_fe += oligos[order[jj]].malus; + msFE += oligos[order[jj]].malus; } - for (let jj = ii; jj < num_oligo; jj++) { - let s_pairs: number[] = this.foldSequence(oligos[order[jj]].seq, null, null, temp); - let s_nodes: number[] = []; - let s_fe: number = this.scoreStructures(oligos[order[jj]].seq, s_pairs, temp, s_nodes); - - let struc = `${EPars.pairsToParenthesis(ms_pairs)}&${EPars.pairsToParenthesis(s_pairs)}`; - ms_pairs = EPars.parenthesisToPairs(struc); - ms_fe += s_fe; + for (let jj = ii; jj < numOligo; jj++) { + let sPairs: number[] = this.foldSequence(oligos[order[jj]].seq, null, null, temp); + let sNodes: number[] = []; + let sFE: number = this.scoreStructures(oligos[order[jj]].seq, sPairs, temp, sNodes); + + let struc = `${EPars.pairsToParenthesis(msPairs)}&${EPars.pairsToParenthesis(sPairs)}`; + msPairs = EPars.parenthesisToPairs(struc); + msFE += sFE; } - if (ms_fe < best_fe) { - best_fe = ms_fe; - mfold.pairs = ms_pairs.slice(); + if (msFE < bestFE) { + bestFE = msFE; + mfold.pairs = msPairs.slice(); mfold.order = order.slice(); mfold.count = ii; } @@ -438,40 +458,42 @@ export default class NuPACK extends Folder { return mfold; } - public multifoldUnroll(seq: number[], second_best_pairs: number[], oligos: any[], desired_pairs: string = null, temp: number = 37): PoseOp[] { + public multifoldUnroll( + seq: number[], secondBestPairs: number[], oligos: any[], desiredPairs: string = null, temp: number = 37 + ): PoseOp[] { let ops: PoseOp[] = []; let order: number[] = []; - let num_oligo: number = oligos.length; + let numOligo: number = oligos.length; - for (let ii = 0; ii < num_oligo; ii++) { + for (let ii = 0; ii < numOligo; ii++) { order.push(ii); } - for (let ii = 0; ii < num_oligo; ii++) { + for (let ii = 0; ii < numOligo; ii++) { ops.push(new PoseOp(null, () => this.foldSequence(oligos[ii].seq, null, null, temp))); } let more: boolean; do { - for (let ii = num_oligo; ii >= 0; ii--) { - let ms_seq: number[] = seq.slice(); + for (let ii = numOligo; ii >= 0; ii--) { + let msSeq: number[] = seq.slice(); for (let jj = 0; jj < ii; jj++) { - ms_seq.push(EPars.RNABASE_CUT); - ms_seq = ms_seq.concat(oligos[order[jj]].seq); + msSeq.push(EPars.RNABASE_CUT); + msSeq = msSeq.concat(oligos[order[jj]].seq); } if (ii === 0) { - ops.push(new PoseOp(null, () => this.foldSequence(ms_seq, null, null, temp))); + ops.push(new PoseOp(null, () => this.foldSequence(msSeq, null, null, temp))); } else { - ops.push(new PoseOp(null, () => this.cofoldSeq2(ms_seq, null, null, temp))); + ops.push(new PoseOp(null, () => this.cofoldSeq2(msSeq, null, null, temp))); } } more = FoldUtil.nextPerm(order); } while (more); - ops.push(new PoseOp(null, () => this.multifold(seq, second_best_pairs, oligos, desired_pairs, temp))); + ops.push(new PoseOp(null, () => this.multifold(seq, secondBestPairs, oligos, desiredPairs, temp))); return ops; } @@ -483,7 +505,7 @@ export default class NuPACK extends Folder { result = this._lib.FullFoldTemperature(temp, seqStr); return EPars.parenthesisToPairs(result.structure); } catch (e) { - log.error("FullFoldTemperature error", e); + log.error('FullFoldTemperature error', e); return []; } finally { if (result != null) { @@ -493,7 +515,9 @@ export default class NuPACK extends Folder { } } - private foldSequenceWithBindingSiteImpl(seq: number[], i: number, p: number, j: number, q: number, bonus: number, temp: number = 37): number[] { + private foldSequenceWithBindingSiteImpl( + seq: number[], i: number, p: number, j: number, q: number, bonus: number, temp: number = 37 + ): number[] { const seqStr = EPars.sequenceToString(seq, false, false); let result: FullFoldResult = null; @@ -501,7 +525,7 @@ export default class NuPACK extends Folder { result = this._lib.FullFoldWithBindingSite(seqStr, i, p, j, q, -bonus); return EPars.parenthesisToPairs(result.structure); } catch (e) { - log.error("FullFoldWithBindingSite error", e); + log.error('FullFoldWithBindingSite error', e); return []; } finally { if (result != null) { @@ -517,10 +541,10 @@ export default class NuPACK extends Folder { let result: FullFoldResult = null; try { result = this._lib.CoFoldSequence(seqStr); - log.debug("done cofolding"); + log.debug('done cofolding'); return EPars.parenthesisToPairs(result.structure); } catch (e) { - log.error("CoFoldSequence error", e); + log.error('CoFoldSequence error', e); return []; } finally { if (result != null) { @@ -530,16 +554,18 @@ export default class NuPACK extends Folder { } } - private cofoldSequenceWithBindingSiteImpl(seq: number[], str: string, i: number, p: number, j: number, q: number, bonus: number, temp: number = 37): number[] { + private cofoldSequenceWithBindingSiteImpl( + seq: number[], str: string, i: number, p: number, j: number, q: number, bonus: number, temp: number = 37 + ): number[] { const seqStr = EPars.sequenceToString(seq, true, false); let result: FullFoldResult; try { result = this._lib.CoFoldSequenceWithBindingSite(seqStr, i, p, j, q, -bonus); - log.debug("done cofolding_wbs"); + log.debug('done cofoldingWBS'); return EPars.parenthesisToPairs(result.structure); } catch (e) { - log.error("CoFoldSequenceWithBindingSite error", e); + log.error('CoFoldSequenceWithBindingSite error', e); return []; } finally { if (result != null) { @@ -549,27 +575,29 @@ export default class NuPACK extends Folder { } } - private cofoldSeq2(seq: number[], second_best_pairs: number[], desired_pairs: string = null, temp: number = 37): number[] { + private cofoldSeq2( + seq: number[], secondBestPairs: number[], desiredPairs: string = null, temp: number = 37 + ): number[] { let key: any = { - primitive: "cofold2", + primitive: 'cofold2', seq, - second_best_pairs, - desired_pairs, + secondBestPairs, + desiredPairs, temp }; - let co_pairs: number[] = this.getCache(key); - if (co_pairs != null) { + let coPairs: number[] = this.getCache(key); + if (coPairs != null) { // trace("cofold2 cache hit"); - return co_pairs.slice(); + return coPairs.slice(); } - co_pairs = this.cofoldSequenceImpl(seq); + coPairs = this.cofoldSequenceImpl(seq); - this.putCache(key, co_pairs.slice()); - return co_pairs; + this.putCache(key, coPairs.slice()); + return coPairs; } - private readonly _lib: nupack_lib; + private readonly _lib: NupackLib; } interface FullEvalCache { diff --git a/src/eterna/folding/RNAFoldBasic.ts b/src/eterna/folding/RNAFoldBasic.ts index c698eac4c..934c53178 100644 --- a/src/eterna/folding/RNAFoldBasic.ts +++ b/src/eterna/folding/RNAFoldBasic.ts @@ -1,8 +1,9 @@ -import EPars from "eterna/EPars"; -import Folder from "./Folder"; +import * as log from 'loglevel'; +import EPars from 'eterna/EPars'; +import Folder from './Folder'; export default class RNAFoldBasic extends Folder { - public static readonly NAME = "Basic"; + public static readonly NAME = 'Basic'; /** Asynchronously creates a new instance of the RNAFoldBasic folder. */ public static create(): Promise { @@ -33,11 +34,13 @@ export default class RNAFoldBasic extends Folder { return score; } - public foldSequence(seq: number[], second_best_pairs: number[], desired_pairs: string = null, temp: number = 37): number[] { + public foldSequence( + seq: number[], secondBestPairs: number[], desiredPairs: string = null, temp: number = 37 + ): number[] { let n: number = seq.length; let pairs: number[] = new Array(n); - let dp_array: number[] = new Array(n * n); - let trace_array: number[] = new Array(n * n); + let dpArray: number[] = new Array(n * n); + let traceArray: number[] = new Array(n * n); for (let ii = 0; ii < n; ii++) { pairs[ii] = -1; @@ -46,113 +49,111 @@ export default class RNAFoldBasic extends Folder { let index: number = ii * n + jj; if (ii > jj + 1) { - dp_array[index] = -1; + dpArray[index] = -1; } else if ((ii === jj) || (ii + 1 === jj) || (ii === jj + 1)) { - dp_array[index] = 0; + dpArray[index] = 0; } else { - dp_array[index] = -1; + dpArray[index] = -1; } - trace_array[index] = 0; + traceArray[index] = 0; } } for (let iter = 1; iter < n; iter++) { - let ii_walker = 0; - let jj_walker: number = iter; + let iiWalker = 0; + let jjWalker: number = iter; - while (jj_walker < n) { - let max_case = 0; - let max_val = -1; - let current_val = 0; + while (jjWalker < n) { + let maxCase = 0; + let maxVal = -1; + let currentVal = 0; - if (ii_walker < n - 1 && jj_walker > 0 && ii_walker < jj_walker - 1) { - if (EPars.pairType(seq[ii_walker], seq[jj_walker])) { - current_val = dp_array[(ii_walker + 1) * n + jj_walker - 1] + 1; + if (iiWalker < n - 1 && jjWalker > 0 && iiWalker < jjWalker - 1) { + if (EPars.pairType(seq[iiWalker], seq[jjWalker])) { + currentVal = dpArray[(iiWalker + 1) * n + jjWalker - 1] + 1; - if (current_val < 1) { - console.warn("Something is wrong with DP case 1", ii_walker, jj_walker); + if (currentVal < 1) { + log.warn('Something is wrong with DP case 1', iiWalker, jjWalker); } - if (current_val > max_val) { - max_val = current_val; - max_case = 1; + if (currentVal > maxVal) { + maxVal = currentVal; + maxCase = 1; } } } - if (jj_walker > 0) { - current_val = dp_array[(ii_walker) * n + jj_walker - 1]; + if (jjWalker > 0) { + currentVal = dpArray[(iiWalker) * n + jjWalker - 1]; - if (current_val < 0) { - console.warn("Something is wrong with DP case 3", ii_walker, jj_walker); + if (currentVal < 0) { + log.warn('Something is wrong with DP case 3', iiWalker, jjWalker); } - if (current_val > max_val) { - max_val = current_val; - max_case = 3; + if (currentVal > maxVal) { + maxVal = currentVal; + maxCase = 3; } } - if (ii_walker < n - 1) { - current_val = dp_array[(ii_walker + 1) * n + jj_walker]; + if (iiWalker < n - 1) { + currentVal = dpArray[(iiWalker + 1) * n + jjWalker]; - if (current_val < 0) { - console.warn("Something is wrong with DP case 2", ii_walker, jj_walker); + if (currentVal < 0) { + log.warn('Something is wrong with DP case 2', iiWalker, jjWalker); } - if (current_val > max_val) { - max_val = current_val; - max_case = 2; + if (currentVal > maxVal) { + maxVal = currentVal; + maxCase = 2; } } - if (ii_walker + 1 < jj_walker) { - for (let kk_walker: number = ii_walker + 1; kk_walker < jj_walker; kk_walker++) { - if (dp_array[ii_walker * n + kk_walker] < 0 || dp_array[kk_walker * n + jj_walker] < 0) { - console.warn("Something is wrong with DP case k"); + if (iiWalker + 1 < jjWalker) { + for (let kkWalker: number = iiWalker + 1; kkWalker < jjWalker; kkWalker++) { + if (dpArray[iiWalker * n + kkWalker] < 0 || dpArray[kkWalker * n + jjWalker] < 0) { + log.warn('Something is wrong with DP case k'); } - current_val = dp_array[ii_walker * n + kk_walker] + dp_array[(kk_walker + 1) * n + jj_walker]; + currentVal = dpArray[iiWalker * n + kkWalker] + dpArray[(kkWalker + 1) * n + jjWalker]; - if (current_val > max_val) { - max_val = current_val; - max_case = -kk_walker; + if (currentVal > maxVal) { + maxVal = currentVal; + maxCase = -kkWalker; } } } - dp_array[ii_walker * n + jj_walker] = max_val; - trace_array[ii_walker * n + jj_walker] = max_case; + dpArray[iiWalker * n + jjWalker] = maxVal; + traceArray[iiWalker * n + jjWalker] = maxCase; - ii_walker++; - jj_walker++; + iiWalker++; + jjWalker++; } } - this.tracePairs(trace_array, pairs, n, 0, n - 1); + this.tracePairs(traceArray, pairs, n, 0, n - 1); return pairs; } - private tracePairs(trace_array: number[], pairs: number[], n: number, ii_start: number, jj_start: number): void { - let dir: number = trace_array[ii_start * n + jj_start]; + private tracePairs(traceArray: number[], pairs: number[], n: number, iiStart: number, jjStart: number): void { + let dir: number = traceArray[iiStart * n + jjStart]; if (dir === 1) { - pairs[ii_start] = jj_start; - pairs[jj_start] = ii_start; + pairs[iiStart] = jjStart; + pairs[jjStart] = iiStart; - this.tracePairs(trace_array, pairs, n, ii_start + 1, jj_start - 1); + this.tracePairs(traceArray, pairs, n, iiStart + 1, jjStart - 1); } else if (dir === 2) { - this.tracePairs(trace_array, pairs, n, ii_start + 1, jj_start); + this.tracePairs(traceArray, pairs, n, iiStart + 1, jjStart); } else if (dir === 3) { - this.tracePairs(trace_array, pairs, n, ii_start, jj_start - 1); - } else if (dir === 0) { - - } else { + this.tracePairs(traceArray, pairs, n, iiStart, jjStart - 1); + } else if (dir !== 0) { let kk: number = -dir; - this.tracePairs(trace_array, pairs, n, ii_start, kk); - this.tracePairs(trace_array, pairs, n, kk + 1, jj_start); + this.tracePairs(traceArray, pairs, n, iiStart, kk); + this.tracePairs(traceArray, pairs, n, kk + 1, jjStart); } } } diff --git a/src/eterna/folding/Vienna.ts b/src/eterna/folding/Vienna.ts index 37498951c..f8aa55e76 100644 --- a/src/eterna/folding/Vienna.ts +++ b/src/eterna/folding/Vienna.ts @@ -1,27 +1,29 @@ -import * as log from "loglevel"; -import {EmscriptenUtil} from "eterna/emscripten"; -import EPars from "eterna/EPars"; -import {RNALayout} from "eterna/pose2D"; -import {CSVParser} from "eterna/util"; -import * as vienna_lib from "./engines/vienna_lib/index"; -import {DotPlotResult, FullEvalResult, FullFoldResult} from "./engines/vienna_lib/index"; -import Folder from "./Folder"; -import FoldUtil from "./FoldUtil"; +import * as log from 'loglevel'; +import {EmscriptenUtil} from 'eterna/emscripten'; +import EPars from 'eterna/EPars'; +import {RNALayout} from 'eterna/pose2D'; +import {Utility} from 'eterna/util'; +/* eslint-disable import/no-duplicates, import/no-unresolved */ +import * as ViennaLib from './engines/ViennaLib'; +import {DotPlotResult, FullEvalResult, FullFoldResult} from './engines/ViennaLib'; +/* eslint-enable import/no-duplicates, import/no-unresolved */ +import Folder from './Folder'; +import FoldUtil from './FoldUtil'; export default class Vienna extends Folder { - public static readonly NAME: string = "Vienna"; + public static readonly NAME: string = 'Vienna'; /** * Asynchronously creates a new instance of the Vienna folder. * @returns {Promise} */ public static create(): Promise { - return import("./engines/vienna") + return import('./engines/vienna') .then((module: any) => EmscriptenUtil.loadProgram(module)) .then((program: any) => new Vienna(program)); } - private constructor(lib: vienna_lib) { + private constructor(lib: ViennaLib) { super(); this._lib = lib; } @@ -32,24 +34,24 @@ export default class Vienna extends Folder { public getDotPlot(seq: number[], pairs: number[], temp: number = 37): number[] { let key: any = { - primitive: "dotplot", seq, pairs, temp + primitive: 'dotplot', seq, pairs, temp }; - let ret_array: number[] = this.getCache(key); - if (ret_array != null) { + let retArray: number[] = this.getCache(key); + if (retArray != null) { // log.debug("dotplot cache hit"); - return ret_array.slice(); + return retArray.slice(); } - let secstruct_str: string = EPars.pairsToParenthesis(pairs); - let seq_str: string = EPars.sequenceToString(seq); + let secstructStr: string = EPars.pairsToParenthesis(pairs); + let seqStr: string = EPars.sequenceToString(seq); let probabilitiesString: string; let result: DotPlotResult; try { - result = this._lib.GetDotPlot(temp, seq_str, secstruct_str); + result = this._lib.GetDotPlot(temp, seqStr, secstructStr); probabilitiesString = result.probabilitiesString; } catch (e) { - log.error("GetDotPlot error", e); + log.error('GetDotPlot error', e); return []; } finally { if (result != null) { @@ -58,27 +60,27 @@ export default class Vienna extends Folder { } } - let temp_array: string[] = CSVParser.splitOnWhitespace(probabilitiesString); - ret_array = []; + let tempArray: string[] = Utility.splitOnWhitespace(probabilitiesString); + retArray = []; - if (temp_array.length % 4 !== 0) { - throw new Error(`Something's wrong with dot plot return ${temp_array.length}`); + if (tempArray.length % 4 !== 0) { + throw new Error(`Something's wrong with dot plot return ${tempArray.length}`); } - for (let ii = 0; ii < temp_array.length; ii += 4) { - if (temp_array[ii + 3] === "ubox") { - ret_array.push(Number(temp_array[ii])); - ret_array.push(Number(temp_array[ii + 1])); - ret_array.push(Number(temp_array[ii + 2])); + for (let ii = 0; ii < tempArray.length; ii += 4) { + if (tempArray[ii + 3] === 'ubox') { + retArray.push(Number(tempArray[ii])); + retArray.push(Number(tempArray[ii + 1])); + retArray.push(Number(tempArray[ii + 2])); } else { - ret_array.push(Number(temp_array[ii + 1])); - ret_array.push(Number(temp_array[ii])); - ret_array.push(Number(temp_array[ii + 2])); + retArray.push(Number(tempArray[ii + 1])); + retArray.push(Number(tempArray[ii])); + retArray.push(Number(tempArray[ii + 2])); } } - this.putCache(key, ret_array.slice()); - return ret_array; + this.putCache(key, retArray.slice()); + return retArray; } public get name(): string { @@ -95,7 +97,7 @@ export default class Vienna extends Folder { public scoreStructures(seq: number[], pairs: number[], temp: number = 37, outNodes: number[] = null): number { let key: any = { - primitive: "score", seq, pairs, temp + primitive: 'score', seq, pairs, temp }; let cache: FullEvalCache = this.getCache(key); @@ -115,7 +117,7 @@ export default class Vienna extends Folder { EPars.pairsToParenthesis(pairs)); cache = {energy: result.energy, nodes: EmscriptenUtil.stdVectorToArray(result.nodes)}; } catch (e) { - log.error("FullEval error", e); + log.error('FullEval error', e); return 0; } finally { if (result != null) { @@ -141,7 +143,7 @@ export default class Vienna extends Folder { let retB: number = this.scoreStructures(seqB, pairsB, temp, nodesB); if (nodesA[0] !== -1 || nodesB[0] !== -1) { - throw new Error("Something went terribly wrong in score_structures()"); + throw new Error('Something went terribly wrong in scoreStructures()'); } cache.nodes.splice(0); // make empty @@ -167,12 +169,14 @@ export default class Vienna extends Folder { return energy; } - public foldSequence(seq: number[], second_best_pairs: number[], desired_pairs: string = null, temp: number = 37): number[] { + public foldSequence( + seq: number[], secondBestPairs: number[], desiredPairs: string = null, temp: number = 37 + ): number[] { let key: any = { - primitive: "fold", + primitive: 'fold', seq, - second_best_pairs, - desired_pairs, + secondBestPairs, + desiredPairs, temp }; let pairs: number[] = this.getCache(key); @@ -181,7 +185,7 @@ export default class Vienna extends Folder { return pairs.slice(); } - pairs = this.foldSequenceImpl(seq, desired_pairs, temp); + pairs = this.foldSequenceImpl(seq, desiredPairs, temp); this.putCache(key, pairs.slice()); return pairs; } @@ -190,51 +194,57 @@ export default class Vienna extends Folder { return true; } - public foldSequenceWithBindingSite(seq: number[], target_pairs: number[], binding_site: number[], bonus: number, version: number = 1.0, temp: number = 37): number[] { + public foldSequenceWithBindingSite( + seq: number[], targetPairs: number[], bindingSite: number[], bonus: number, + version: number = 1.0, temp: number = 37 + ): number[] { let key: any = { - primitive: "fold_aptamer", + primitive: 'foldAptamer', seq, - target_pairs, - binding_site, + targetPairs, + bindingSite, bonus, version, temp }; let pairs: number[] = this.getCache(key); if (pairs != null) { - // log.debug("fold_aptamer cache hit"); + // log.debug("foldAptamer cache hit"); return pairs.slice(); } if (!(version >= 2.0)) { - pairs = this.foldSequenceWithBindingSiteOld(seq, target_pairs, binding_site, bonus); + pairs = this.foldSequenceWithBindingSiteOld(seq, targetPairs, bindingSite, bonus); this.putCache(key, pairs.slice()); return pairs; } - let site_groups: number[][] = []; - let last_index = -1; - let current_group: number[] = []; + let siteGroups: number[][] = []; + let lastIndex = -1; + let currentGroup: number[] = []; - for (let jj = 0; jj < binding_site.length; jj++) { - if (last_index < 0 || binding_site[jj] - last_index === 1) { - current_group.push(binding_site[jj]); - last_index = binding_site[jj]; + for (let jj = 0; jj < bindingSite.length; jj++) { + if (lastIndex < 0 || bindingSite[jj] - lastIndex === 1) { + currentGroup.push(bindingSite[jj]); + lastIndex = bindingSite[jj]; } else { - site_groups.push(current_group); - current_group = []; - current_group.push(binding_site[jj]); - last_index = binding_site[jj]; + siteGroups.push(currentGroup); + currentGroup = []; + currentGroup.push(bindingSite[jj]); + lastIndex = bindingSite[jj]; } } - if (current_group.length > 0) { - site_groups.push(current_group); + if (currentGroup.length > 0) { + siteGroups.push(currentGroup); } - if (site_groups.length === 2) { - pairs = this.foldSequenceWithBindingSiteImpl(seq, site_groups[0][0], site_groups[0][site_groups[0].length - 1], site_groups[1][site_groups[1].length - 1], site_groups[1][0], bonus, temp); + if (siteGroups.length === 2) { + pairs = this.foldSequenceWithBindingSiteImpl( + seq, siteGroups[0][0], siteGroups[0][siteGroups[0].length - 1], siteGroups[1][siteGroups[1].length - 1], + siteGroups[1][0], bonus, temp + ); } else { - pairs = this.foldSequenceWithBindingSiteOld(seq, target_pairs, binding_site, bonus); + pairs = this.foldSequenceWithBindingSiteOld(seq, targetPairs, bindingSite, bonus); } this.putCache(key, pairs.slice()); @@ -245,27 +255,29 @@ export default class Vienna extends Folder { return true; } - public cofoldSequence(seq: number[], second_best_pairs: number[], malus: number = 0, desired_pairs: string = null, temp: number = 37): number[] { + public cofoldSequence( + seq: number[], secondBestPairs: number[], malus: number = 0, desiredPairs: string = null, temp: number = 37 + ): number[] { let cut: number = seq.indexOf(EPars.RNABASE_CUT); if (cut < 0) { - throw new Error("Missing cutting point"); + throw new Error('Missing cutting point'); } - let key: any = { - primitive: "cofold", + let key = { + primitive: 'cofold', seq, - second_best_pairs, + secondBestPairs, malus, - desired_pairs, + desiredPairs, temp }; - let co_pairs: number[] = this.getCache(key); - if (co_pairs != null) { + let coPairs: number[] = this.getCache(key); + if (coPairs != null) { // log.debug("cofold cache hit"); - return co_pairs.slice(); + return coPairs.slice(); } - // FIXME: what about desired_pairs? (forced structure) + // FIXME: what about desiredPairs? (forced structure) let seqA: number[] = seq.slice(0, cut); let pairsA: number[] = this.foldSequence(seqA, null, null, temp); let nodesA: number[] = []; @@ -276,96 +288,102 @@ export default class Vienna extends Folder { let nodesB: number[] = []; let feB: number = this.scoreStructures(seqB, pairsB, temp, nodesB); - co_pairs = this.cofoldSequenceImpl(seq, desired_pairs, temp); - let co_nodes: number[] = []; - let co_fe: number = this.scoreStructures(seq, co_pairs, temp, co_nodes); + coPairs = this.cofoldSequenceImpl(seq, desiredPairs, temp); + let coNodes: number[] = []; + let coFE: number = this.scoreStructures(seq, coPairs, temp, coNodes); - if (co_fe + malus >= feA + feB) { + if (coFE + malus >= feA + feB) { let struc = `${EPars.pairsToParenthesis(pairsA)}&${EPars.pairsToParenthesis(pairsB)}`; - co_pairs = EPars.parenthesisToPairs(struc); + coPairs = EPars.parenthesisToPairs(struc); } - this.putCache(key, co_pairs.slice()); - return co_pairs; + this.putCache(key, coPairs.slice()); + return coPairs; } public get canCofoldWithBindingSite(): boolean { return true; } - public cofoldSequenceWithBindingSite(seq: number[], binding_site: number[], bonus: number, desired_pairs: string = null, malus: number = 0, temp: number = 37): number[] { + public cofoldSequenceWithBindingSite( + seq: number[], bindingSite: number[], bonus: number, desiredPairs: string = null, + malus: number = 0, temp: number = 37 + ): number[] { let cut: number = seq.indexOf(EPars.RNABASE_CUT); if (cut < 0) { - throw new Error("Missing cutting point"); + throw new Error('Missing cutting point'); } let key: any = { - primitive: "cofold_aptamer", + primitive: 'cofoldAptamer', seq, malus, - desired_pairs, - binding_site, + desiredPairs, + bindingSite, bonus, temp }; - let co_pairs: number[] = this.getCache(key); - if (co_pairs != null) { - // log.debug("cofold_aptamer cache hit"); - return co_pairs.slice(); + let coPairs: number[] = this.getCache(key); + if (coPairs != null) { + // log.debug("cofoldAptamer cache hit"); + return coPairs.slice(); } // IMPORTANT: assumption is that the binding site is in segment A - // FIXME: what about desired_pairs? (forced structure) + // FIXME: what about desiredPairs? (forced structure) - let site_groups: number[][] = []; - let last_index = -1; - let current_group: number[] = []; + let siteGroups: number[][] = []; + let lastIndex = -1; + let currentGroup: number[] = []; - for (let jj = 0; jj < binding_site.length; jj++) { - if (last_index < 0 || binding_site[jj] - last_index === 1) { - current_group.push(binding_site[jj]); - last_index = binding_site[jj]; + for (let jj = 0; jj < bindingSite.length; jj++) { + if (lastIndex < 0 || bindingSite[jj] - lastIndex === 1) { + currentGroup.push(bindingSite[jj]); + lastIndex = bindingSite[jj]; } else { - site_groups.push(current_group); - current_group = []; - current_group.push(binding_site[jj]); - last_index = binding_site[jj]; + siteGroups.push(currentGroup); + currentGroup = []; + currentGroup.push(bindingSite[jj]); + lastIndex = bindingSite[jj]; } } - if (current_group.length > 0) { - site_groups.push(current_group); + if (currentGroup.length > 0) { + siteGroups.push(currentGroup); } let seqA: number[] = seq.slice(0, cut); - let pairsA: number[] = this.foldSequenceWithBindingSite(seqA, null, binding_site, bonus, 2.5, temp); + let pairsA: number[] = this.foldSequenceWithBindingSite(seqA, null, bindingSite, bonus, 2.5, temp); let nodesA: number[] = []; let feA: number = this.scoreStructures(seqA, pairsA, temp, nodesA); - if (FoldUtil.bindingSiteFormed(pairsA, site_groups)) feA += bonus; + if (FoldUtil.bindingSiteFormed(pairsA, siteGroups)) feA += bonus; let seqB: number[] = seq.slice(cut + 1); let pairsB: number[] = this.foldSequence(seqB, null, null, temp); let nodesB: number[] = []; let feB: number = this.scoreStructures(seqB, pairsB, temp, nodesB); - co_pairs = this.cofoldSequenceWithBindingSiteImpl(seq, desired_pairs, site_groups[0][0], site_groups[0][site_groups[0].length - 1], site_groups[1][site_groups[1].length - 1], site_groups[1][0], bonus, temp); - let co_nodes: number[] = []; - let co_fe: number = this.scoreStructures(seq, co_pairs, temp, co_nodes); - if (FoldUtil.bindingSiteFormed(co_pairs, site_groups)) co_fe += bonus; + coPairs = this.cofoldSequenceWithBindingSiteImpl( + seq, desiredPairs, siteGroups[0][0], siteGroups[0][siteGroups[0].length - 1], + siteGroups[1][siteGroups[1].length - 1], siteGroups[1][0], bonus, temp + ); + let coNodes: number[] = []; + let coFE: number = this.scoreStructures(seq, coPairs, temp, coNodes); + if (FoldUtil.bindingSiteFormed(coPairs, siteGroups)) coFE += bonus; - if (co_fe + malus >= feA + feB) { + if (coFE + malus >= feA + feB) { let struc = `${EPars.pairsToParenthesis(pairsA)}&${EPars.pairsToParenthesis(pairsB)}`; - co_pairs = EPars.parenthesisToPairs(struc); + coPairs = EPars.parenthesisToPairs(struc); } - this.putCache(key, co_pairs.slice()); - return co_pairs; + this.putCache(key, coPairs.slice()); + return coPairs; } - public mlEnergy(pairs: number[], S: number[], i: number, is_extloop: boolean): number { + public mlEnergy(pairs: number[], S: number[], i: number, isExtloop: boolean): number { let energy: number; - let cx_energy: number; - let best_energy: number; - best_energy = EPars.INF; + let cxEnergy: number; + let bestEnergy: number; + bestEnergy = EPars.INF; let i1: number; let j: number; let p: number; @@ -380,13 +398,14 @@ export default class Vienna extends Folder { let dangles: number = EPars.DANGLES; - if (is_extloop) { + if (isExtloop) { for (x = 0; x <= EPars.NBPAIRS; x++) { mlintern[x] = EPars.mlIntern(x) - EPars.mlIntern(1); /* 0 or TerminalAU */ } - mlclosing = mlbase = 0; + mlbase = 0; + mlclosing = 0; } else { for (x = 0; x <= EPars.NBPAIRS; x++) { mlintern[x] = EPars.mlIntern(x); @@ -415,12 +434,12 @@ export default class Vienna extends Folder { p = i + 1; u = 0; energy = 0; - cx_energy = EPars.INF; + cxEnergy = EPars.INF; do { /* walk around the multi-loop */ let tt: number; - let new_cx: number; - new_cx = EPars.INF; + let newCx: number; + newCx = EPars.INF; /* hope over unpaired positions */ while (p <= pairs[0] && pairs[p] === 0) p++; @@ -429,7 +448,8 @@ export default class Vienna extends Folder { u += p - i1 - 1; /* get position of pairing partner */ if (p === pairs[0] + 1) { - q = tt = 0; + tt = 0; + q = 0; /* virtual root pair */ } else { q = pairs[p]; @@ -439,7 +459,7 @@ export default class Vienna extends Folder { } energy += mlintern[tt]; - cx_energy += mlintern[tt]; + cxEnergy += mlintern[tt]; if (dangles) { let dang5 = 0; @@ -455,14 +475,14 @@ export default class Vienna extends Folder { } switch (p - i1 - 1) { - case 0: /* adjacent helices */ - case 1: /* 1 unpaired base between helices */ - dang = (dangles === 2) ? (dang3 + dang5) : Math.min(dang3, dang5); - energy += dang; - break; - - default: /* many unpaired base between helices */ - energy += dang5 + dang3; + case 0: /* adjacent helices */ + case 1: /* 1 unpaired base between helices */ + dang = (dangles === 2) ? (dang3 + dang5) : Math.min(dang3, dang5); + energy += dang; + break; + + default: /* many unpaired base between helices */ + energy += dang5 + dang3; } type = tt; } @@ -471,10 +491,10 @@ export default class Vienna extends Folder { p = q + 1; } while (q !== i); - best_energy = Math.min(energy, best_energy); - /* don't use cx_energy here */ + bestEnergy = Math.min(energy, bestEnergy); + /* don't use cxEnergy here */ - if (dangles !== 3 || is_extloop) { + if (dangles !== 3 || isExtloop) { break; /* may break cofold with co-ax */ } @@ -486,7 +506,7 @@ export default class Vienna extends Folder { i = pairs[p]; } - energy = best_energy; + energy = bestEnergy; energy += mlclosing; energy += mlbase * u; @@ -498,8 +518,12 @@ export default class Vienna extends Folder { return 0; } - public loopEnergy(n1: number, n2: number, type: number, type_2: number, si1: number, sj1: number, sp1: number, sq1: number, b1: boolean, b2: boolean): number { - let loop_score = 0; + public loopEnergy( + n1: number, n2: number, + type: number, type2: number, + si1: number, sj1: number, sp1: number, sq1: number, b1: boolean, b2: boolean + ): number { + let loopScore = 0; /* compute energy of degree 2 loop (stack bulge or interior) */ let nl: number; @@ -514,99 +538,101 @@ export default class Vienna extends Folder { } if (nl === 0) { - return EPars.getStackScore(type, type_2, b1, b2); + return EPars.getStackScore(type, type2, b1, b2); /* stack */ } if (ns === 0) { /* bulge */ if (nl <= EPars.MAXLOOP) { - loop_score = EPars.BULGE_37[nl]; + loopScore = EPars.BULGE_37[nl]; } else { - loop_score = EPars.get_bulge(nl); + loopScore = EPars.getBulge(nl); } if (nl === 1) { - loop_score += EPars.getStackScore(type, type_2, b1, b2); + loopScore += EPars.getStackScore(type, type2, b1, b2); } else { if (type > 2) { - loop_score += EPars.TERM_AU; + loopScore += EPars.TERM_AU; } - if (type_2 > 2) { - loop_score += EPars.TERM_AU; + if (type2 > 2) { + loopScore += EPars.TERM_AU; } } - return loop_score; - } else { /* interior loop */ + return loopScore; + } else { + /* interior loop */ if (ns === 1) { - if (nl === 1) // 1x1 loop - { - return EPars.getInt11(type, type_2, si1, sj1); + if (nl === 1) { + // 1x1 loop + return EPars.getInt11(type, type2, si1, sj1); } - if (nl === 2) { // 2x1 loop + if (nl === 2) { + // 2x1 loop if (n1 === 1) { - loop_score = EPars.getInt21(type, type_2, si1, sq1, sj1); + loopScore = EPars.getInt21(type, type2, si1, sq1, sj1); } else { - loop_score = EPars.getInt21(type_2, type, sq1, si1, sp1); + loopScore = EPars.getInt21(type2, type, sq1, si1, sp1); } - return loop_score; + return loopScore; } - } else if (n1 === 2 && n2 === 2) // 2x2 loop - { - return EPars.getInt22(type, type_2, si1, sp1, sq1, sj1); + } else if (n1 === 2 && n2 === 2) { + // 2x2 loop + return EPars.getInt22(type, type2, si1, sp1, sq1, sj1); } - { - /* generic interior loop (no else here!) */ - if ((n1 + n2 <= EPars.MAXLOOP)) { - loop_score = EPars.INTERNAL_37[n1 + n2]; - } else { - loop_score = EPars.getInternal(n1 + n2); - } - - loop_score += Math.min(EPars.MAX_NINIO, (nl - ns) * EPars.F_ninio37[2]); - loop_score += EPars.internalMismatch(type, si1, sj1) + EPars.internalMismatch(type_2, sq1, sp1); + /* generic interior loop (no else here!) */ + if ((n1 + n2 <= EPars.MAXLOOP)) { + loopScore = EPars.INTERNAL_37[n1 + n2]; + } else { + loopScore = EPars.getInternal(n1 + n2); } + + loopScore += Math.min(EPars.MAX_NINIO, (nl - ns) * EPars.F_ninio37[2]); + loopScore += EPars.internalMismatch(type, si1, sj1) + EPars.internalMismatch(type2, sq1, sp1); } - return loop_score; + return loopScore; } - public hairpinEnergy(size: number, type: number, si1: number, sj1: number, sequence: number[], i: number, j: number): number { - let hairpin_score = 0; + public hairpinEnergy( + size: number, type: number, si1: number, sj1: number, sequence: number[], i: number, j: number + ): number { + let hairpinScore = 0; if (size <= 30) { - hairpin_score = EPars.HAIRPIN_37[size]; + hairpinScore = EPars.HAIRPIN_37[size]; } else { - hairpin_score = EPars.HAIRPIN_37[30] + Number(EPars.LXC * Math.log((size) / 30.0)); + hairpinScore = EPars.HAIRPIN_37[30] + Number(EPars.LXC * Math.log((size) / 30.0)); } if (size === 4) { - let loop_str = ""; + let loopStr = ''; for (let walker: number = i; walker <= j; walker++) { if (sequence[walker] === EPars.RNABASE_ADENINE) { - loop_str += "A"; + loopStr += 'A'; } else if (sequence[walker] === EPars.RNABASE_GUANINE) { - loop_str += "G"; + loopStr += 'G'; } else if (sequence[walker] === EPars.RNABASE_URACIL) { - loop_str += "U"; + loopStr += 'U'; } else if (sequence[walker] === EPars.RNABASE_CYTOSINE) { - loop_str += "C"; + loopStr += 'C'; } } - hairpin_score += EPars.getTetraLoopBonus(loop_str); + hairpinScore += EPars.getTetraLoopBonus(loopStr); } if (size === 3) { if (type > 2) { - hairpin_score += EPars.TERM_AU; + hairpinScore += EPars.TERM_AU; } } else { - hairpin_score += EPars.hairpinMismatch(type, si1, sj1); + hairpinScore += EPars.hairpinMismatch(type, si1, sj1); } - return hairpin_score; + return hairpinScore; } private foldSequenceImpl(seq: number[], structStr: string = null, temp: number = 37): number[] { @@ -614,10 +640,10 @@ export default class Vienna extends Folder { let result: FullFoldResult; try { - result = this._lib.FullFoldTemperature(temp, seqStr, structStr || ""); + result = this._lib.FullFoldTemperature(temp, seqStr, structStr || ''); return EPars.parenthesisToPairs(result.structure); } catch (e) { - log.error("FullFoldTemperature error", e); + log.error('FullFoldTemperature error', e); return []; } finally { if (result != null) { @@ -627,16 +653,18 @@ export default class Vienna extends Folder { } } - private foldSequenceWithBindingSiteImpl(seq: number[], i: number, p: number, j: number, q: number, bonus: number, temp: number = 37): number[] { + private foldSequenceWithBindingSiteImpl( + seq: number[], i: number, p: number, j: number, q: number, bonus: number, temp: number = 37 + ): number[] { const seqStr = EPars.sequenceToString(seq, false, false); - const structStr = ""; + const structStr = ''; let result: FullFoldResult; try { result = this._lib.FullFoldWithBindingSite(seqStr, structStr, i + 1, p + 1, j + 1, q + 1, -bonus); return EPars.parenthesisToPairs(result.structure); } catch (e) { - log.error("FullFoldWithBindingSite error", e); + log.error('FullFoldWithBindingSite error', e); return []; } finally { if (result != null) { @@ -648,15 +676,15 @@ export default class Vienna extends Folder { private cofoldSequenceImpl(seq: number[], str: string = null, temp: number = 37): number[] { const seqStr = EPars.sequenceToString(seq, true, false); - const structStr: string = str || ""; + const structStr: string = str || ''; let result: FullFoldResult; try { result = this._lib.CoFoldSequence(seqStr, structStr); - log.debug("done cofolding"); + log.debug('done cofolding'); return EPars.parenthesisToPairs(result.structure); } catch (e) { - log.error("CoFoldSequence error", e); + log.error('CoFoldSequence error', e); return []; } finally { if (result != null) { @@ -666,17 +694,19 @@ export default class Vienna extends Folder { } } - private cofoldSequenceWithBindingSiteImpl(seq: number[], str: string, i: number, p: number, j: number, q: number, bonus: number, temp: number = 37): number[] { + private cofoldSequenceWithBindingSiteImpl( + seq: number[], str: string, i: number, p: number, j: number, q: number, bonus: number, temp: number = 37 + ): number[] { const seqStr = EPars.sequenceToString(seq, true, false); - const structStr: string = str || ""; + const structStr: string = str || ''; let result: FullFoldResult; try { result = this._lib.CoFoldSequenceWithBindingSite(seqStr, structStr, i + 1, p + 1, j + 1, q + 1, -bonus); - log.debug("done cofolding"); + log.debug('done cofolding'); return EPars.parenthesisToPairs(result.structure); } catch (e) { - log.error("CoFoldSequenceWithBindingSite error", e); + log.error('CoFoldSequenceWithBindingSite error', e); return []; } finally { if (result != null) { @@ -686,53 +716,55 @@ export default class Vienna extends Folder { } } - private foldSequenceWithBindingSiteOld(seq: number[], target_pairs: number[], binding_site: number[], bonus: number, temp: number = 37): number[] { - let best_pairs: number[]; - let native_pairs: number[] = this.foldSequence(seq, null, null); - - let native_tree: RNALayout = new RNALayout(); - native_tree.setupTree(native_pairs); - native_tree.scoreTree(seq, this); - let native_score: number = native_tree.totalScore; - - let target_satisfied: number[] = EPars.getSatisfiedPairs(target_pairs, seq); - let target_tree: RNALayout = new RNALayout(); - target_tree.setupTree(target_satisfied); - target_tree.scoreTree(seq, this); - let target_score: number = target_tree.totalScore; - - let native_bound = true; - let target_bound = true; - - for (let bb = 0; bb < binding_site.length; bb++) { - let bi: number = binding_site[bb]; - if (target_pairs[bi] !== native_pairs[bi]) { - native_bound = false; + private foldSequenceWithBindingSiteOld( + seq: number[], targetPairs: number[], bindingSite: number[], bonus: number, temp: number = 37 + ): number[] { + let bestPairs: number[]; + let nativePairs: number[] = this.foldSequence(seq, null, null); + + let nativeTree: RNALayout = new RNALayout(); + nativeTree.setupTree(nativePairs); + nativeTree.scoreTree(seq, this); + let nativeScore: number = nativeTree.totalScore; + + let targetSatisfied: number[] = EPars.getSatisfiedPairs(targetPairs, seq); + let targetTree: RNALayout = new RNALayout(); + targetTree.setupTree(targetSatisfied); + targetTree.scoreTree(seq, this); + let targetScore: number = targetTree.totalScore; + + let nativeBound = true; + let targetBound = true; + + for (let bb = 0; bb < bindingSite.length; bb++) { + let bi: number = bindingSite[bb]; + if (targetPairs[bi] !== nativePairs[bi]) { + nativeBound = false; } - if (target_pairs[bi] !== target_satisfied[bi]) { - target_bound = false; + if (targetPairs[bi] !== targetSatisfied[bi]) { + targetBound = false; } } - if (target_bound) { - target_score += bonus; + if (targetBound) { + targetScore += bonus; } - if (native_bound) { - native_score += bonus; + if (nativeBound) { + nativeScore += bonus; } - if (target_score < native_score) { - best_pairs = target_satisfied; + if (targetScore < nativeScore) { + bestPairs = targetSatisfied; } else { - best_pairs = native_pairs; + bestPairs = nativePairs; } - return best_pairs; + return bestPairs; } - private readonly _lib: vienna_lib; + private readonly _lib: ViennaLib; } interface FullEvalCache { diff --git a/src/eterna/folding/Vienna2.ts b/src/eterna/folding/Vienna2.ts index 36f08fc30..b1cd5df9f 100644 --- a/src/eterna/folding/Vienna2.ts +++ b/src/eterna/folding/Vienna2.ts @@ -1,27 +1,29 @@ -import * as log from "loglevel"; -import {EmscriptenUtil} from "eterna/emscripten"; -import EPars from "eterna/EPars"; -import {RNALayout} from "eterna/pose2D"; -import {CSVParser} from "eterna/util"; -import * as vrna2_lib from "./engines/vrna2_lib/index"; -import {DotPlotResult, FullEvalResult, FullFoldResult} from "./engines/vrna2_lib/index"; -import Folder from "./Folder"; -import FoldUtil from "./FoldUtil"; +import * as log from 'loglevel'; +import {EmscriptenUtil} from 'eterna/emscripten'; +import EPars from 'eterna/EPars'; +import {RNALayout} from 'eterna/pose2D'; +import {Utility} from 'eterna/util'; +/* eslint-disable import/no-duplicates, import/no-unresolved */ +import * as Vienna2Lib from './engines/Viena2Lib'; +import {DotPlotResult, FullEvalResult, FullFoldResult} from './engines/Viena2Lib'; +/* eslint-enable import/no-duplicates, import/no-unresolved */ +import Folder from './Folder'; +import FoldUtil from './FoldUtil'; export default class Vienna2 extends Folder { - public static NAME = "Vienna2"; + public static NAME = 'Vienna2'; /** * Asynchronously creates a new instance of the Vienna folder. * @returns {Promise} */ public static create(): Promise { - return import("./engines/vrna2") + return import('./engines/vrna2') .then((module: any) => EmscriptenUtil.loadProgram(module)) .then((program: any) => new Vienna2(program)); } - private constructor(lib: vrna2_lib) { + private constructor(lib: Vienna2Lib) { super(); this._lib = lib; } @@ -34,23 +36,23 @@ export default class Vienna2 extends Folder { /* override */ public getDotPlot(seq: number[], pairs: number[], temp: number = 37): number[] { let key: any = { - primitive: "dotplot", seq, pairs, temp + primitive: 'dotplot', seq, pairs, temp }; - let ret_array: number[] = this.getCache(key); - if (ret_array != null) { - return ret_array.slice(); + let retArray: number[] = this.getCache(key); + if (retArray != null) { + return retArray.slice(); } - let secstruct_str: string = EPars.pairsToParenthesis(pairs); - let seq_str: string = EPars.sequenceToString(seq); + let secstructStr: string = EPars.pairsToParenthesis(pairs); + let seqStr: string = EPars.sequenceToString(seq); let probabilitiesString: string; let result: DotPlotResult; try { - result = this._lib.GetDotPlot(temp, seq_str, secstruct_str); + result = this._lib.GetDotPlot(temp, seqStr, secstructStr); probabilitiesString = result.probabilitiesString; } catch (e) { - log.error("GetDotPlot error", e); + log.error('GetDotPlot error', e); return []; } finally { if (result != null) { @@ -59,27 +61,27 @@ export default class Vienna2 extends Folder { } } - let temp_array: string[] = CSVParser.splitOnWhitespace(probabilitiesString); - ret_array = []; + let tempArray: string[] = Utility.splitOnWhitespace(probabilitiesString); + retArray = []; - if (temp_array.length % 4 !== 0) { - throw new Error(`Something's wrong with dot plot return ${temp_array.length}`); + if (tempArray.length % 4 !== 0) { + throw new Error(`Something's wrong with dot plot return ${tempArray.length}`); } - for (let ii = 0; ii < temp_array.length; ii += 4) { - if (temp_array[ii + 3] === "ubox") { - ret_array.push(Number(temp_array[ii])); - ret_array.push(Number(temp_array[ii + 1])); - ret_array.push(Number(temp_array[ii + 2])); + for (let ii = 0; ii < tempArray.length; ii += 4) { + if (tempArray[ii + 3] === 'ubox') { + retArray.push(Number(tempArray[ii])); + retArray.push(Number(tempArray[ii + 1])); + retArray.push(Number(tempArray[ii + 2])); } else { - ret_array.push(Number(temp_array[ii + 1])); - ret_array.push(Number(temp_array[ii])); - ret_array.push(Number(temp_array[ii + 2])); + retArray.push(Number(tempArray[ii + 1])); + retArray.push(Number(tempArray[ii])); + retArray.push(Number(tempArray[ii + 2])); } } - this.putCache(key, ret_array.slice()); - return ret_array; + this.putCache(key, retArray.slice()); + return retArray; } /* override */ @@ -100,7 +102,7 @@ export default class Vienna2 extends Folder { /* override */ public scoreStructures(seq: number[], pairs: number[], temp: number = 37, outNodes: number[] = null): number { let key: any = { - primitive: "score", seq, pairs, temp + primitive: 'score', seq, pairs, temp }; let cache: FullEvalCache = this.getCache(key); @@ -120,7 +122,7 @@ export default class Vienna2 extends Folder { EPars.pairsToParenthesis(pairs)); cache = {energy: result.energy, nodes: EmscriptenUtil.stdVectorToArray(result.nodes)}; } catch (e) { - log.error("FullEval error", e); + log.error('FullEval error', e); return 0; } finally { if (result != null) { @@ -146,7 +148,7 @@ export default class Vienna2 extends Folder { let retB: number = this.scoreStructures(seqB, pairsB, temp, nodesB); if (nodesA[0] !== -1 || nodesB[0] !== -1) { - throw new Error("Something went terribly wrong in score_structures()"); + throw new Error('Something went terribly wrong in scoreStructures()'); } cache.nodes.splice(0); // make empty @@ -173,12 +175,14 @@ export default class Vienna2 extends Folder { } /* override */ - public foldSequence(seq: number[], second_best_pairs: number[], desired_pairs: string = null, temp: number = 37): number[] { + public foldSequence( + seq: number[], secondBestPairs: number[], desiredPairs: string = null, temp: number = 37 + ): number[] { let key: any = { - primitive: "fold", + primitive: 'fold', seq, - second_best_pairs, - desired_pairs, + secondBestPairs, + desiredPairs, temp }; let pairs: number[] = this.getCache(key); @@ -187,7 +191,7 @@ export default class Vienna2 extends Folder { return pairs.slice(); } - pairs = this.foldSequenceImpl(seq, desired_pairs, temp); + pairs = this.foldSequenceImpl(seq, desiredPairs, temp); this.putCache(key, pairs.slice()); return pairs; } @@ -197,58 +201,61 @@ export default class Vienna2 extends Folder { } /* override */ - public foldSequenceWithBindingSite(seq: number[], target_pairs: number[], binding_site: number[], bonus: number, version: number = 1.0, temp: number = 37): number[] { + public foldSequenceWithBindingSite( + seq: number[], targetPairs: number[], bindingSite: number[], bonus: number, + version: number = 1.0, temp: number = 37 + ): number[] { let key: any = { - primitive: "fold_aptamer", + primitive: 'foldAptamer', seq, - target_pairs, - binding_site, + targetPairs, + bindingSite, bonus, version, temp }; let pairs: number[] = this.getCache(key); if (pairs != null) { - // trace("fold_aptamer cache hit"); + // trace("foldAptamer cache hit"); return pairs.slice(); } if (!(version >= 2.0)) { - pairs = this.foldSequenceWithBindingSiteOld(seq, target_pairs, binding_site, bonus); + pairs = this.foldSequenceWithBindingSiteOld(seq, targetPairs, bindingSite, bonus); this.putCache(key, pairs.slice()); return pairs; } - let site_groups: number[][] = []; - let last_index = -1; - let current_group: number[] = []; + let siteGroups: number[][] = []; + let lastIndex = -1; + let currentGroup: number[] = []; - for (let jj = 0; jj < binding_site.length; jj++) { - if (last_index < 0 || binding_site[jj] - last_index === 1) { - current_group.push(binding_site[jj]); - last_index = binding_site[jj]; + for (let jj = 0; jj < bindingSite.length; jj++) { + if (lastIndex < 0 || bindingSite[jj] - lastIndex === 1) { + currentGroup.push(bindingSite[jj]); + lastIndex = bindingSite[jj]; } else { - site_groups.push(current_group); - current_group = []; - current_group.push(binding_site[jj]); - last_index = binding_site[jj]; + siteGroups.push(currentGroup); + currentGroup = []; + currentGroup.push(bindingSite[jj]); + lastIndex = bindingSite[jj]; } } - if (current_group.length > 0) { - site_groups.push(current_group); + if (currentGroup.length > 0) { + siteGroups.push(currentGroup); } - if (site_groups.length === 2) { + if (siteGroups.length === 2) { pairs = this.foldSequenceWithBindingSiteImpl( seq, - site_groups[0][0], - site_groups[0][site_groups[0].length - 1], - site_groups[1][site_groups[1].length - 1], - site_groups[1][0], + siteGroups[0][0], + siteGroups[0][siteGroups[0].length - 1], + siteGroups[1][siteGroups[1].length - 1], + siteGroups[1][0], bonus ); } else { - pairs = this.foldSequenceWithBindingSiteOld(seq, target_pairs, binding_site, bonus); + pairs = this.foldSequenceWithBindingSiteOld(seq, targetPairs, bindingSite, bonus); } this.putCache(key, pairs.slice()); @@ -261,27 +268,29 @@ export default class Vienna2 extends Folder { } /* override */ - public cofoldSequence(seq: number[], second_best_pairs: number[], malus: number = 0, desired_pairs: string = null, temp: number = 37): number[] { + public cofoldSequence( + seq: number[], secondBestPairs: number[], malus: number = 0, desiredPairs: string = null, temp: number = 37 + ): number[] { let cut: number = seq.indexOf(EPars.RNABASE_CUT); if (cut < 0) { - throw new Error("Missing cutting point"); + throw new Error('Missing cutting point'); } let key: any = { - primitive: "cofold", + primitive: 'cofold', seq, - second_best_pairs, + secondBestPairs, malus, - desired_pairs, + desiredPairs, temp }; - let co_pairs: number[] = this.getCache(key); - if (co_pairs != null) { + let coPairs: number[] = this.getCache(key); + if (coPairs != null) { // trace("cofold cache hit"); - return co_pairs.slice(); + return coPairs.slice(); } - // FIXME: what about desired_pairs? (forced structure) + // FIXME: what about desiredPairs? (forced structure) let seqA: number[] = seq.slice(0, cut); let pairsA: number[] = this.foldSequence(seqA, null, null, temp); let nodesA: number[] = []; @@ -292,17 +301,17 @@ export default class Vienna2 extends Folder { let nodesB: number[] = []; let feB: number = this.scoreStructures(seqB, pairsB, temp, nodesB); - co_pairs = this.cofoldSequenceImpl(seq, desired_pairs); - let co_nodes: number[] = []; - let co_fe: number = this.scoreStructures(seq, co_pairs, temp, co_nodes); + coPairs = this.cofoldSequenceImpl(seq, desiredPairs); + let coNodes: number[] = []; + let coFE: number = this.scoreStructures(seq, coPairs, temp, coNodes); - if (co_fe + malus >= feA + feB) { + if (coFE + malus >= feA + feB) { let struc = `${EPars.pairsToParenthesis(pairsA)}&${EPars.pairsToParenthesis(pairsB)}`; - co_pairs = EPars.parenthesisToPairs(struc); + coPairs = EPars.parenthesisToPairs(struc); } - this.putCache(key, co_pairs.slice()); - return co_pairs; + this.putCache(key, coPairs.slice()); + return coPairs; } /* override */ @@ -311,86 +320,89 @@ export default class Vienna2 extends Folder { } /* override */ - public cofoldSequenceWithBindingSite(seq: number[], binding_site: number[], bonus: number, desired_pairs: string = null, malus: number = 0, temp: number = 37): number[] { + public cofoldSequenceWithBindingSite( + seq: number[], bindingSite: number[], bonus: number, desiredPairs: string = null, + malus: number = 0, temp: number = 37 + ): number[] { let cut: number = seq.indexOf(EPars.RNABASE_CUT); if (cut < 0) { - throw new Error("Missing cutting point"); + throw new Error('Missing cutting point'); } let key: any = { - primitive: "cofold_aptamer", + primitive: 'cofoldAptamer', seq, malus, - desired_pairs, - binding_site, + desiredPairs, + bindingSite, bonus, temp }; - let co_pairs: number[] = this.getCache(key); - if (co_pairs != null) { - // trace("cofold_aptamer cache hit"); - return co_pairs.slice(); + let coPairs: number[] = this.getCache(key); + if (coPairs != null) { + // trace("cofoldAptamer cache hit"); + return coPairs.slice(); } // IMPORTANT: assumption is that the binding site is in segment A // FIXME: what about desired_pairs? (forced structure) - let site_groups: number[][] = []; - let last_index = -1; - let current_group: number[] = []; + let siteGroups: number[][] = []; + let lastIndex = -1; + let currentGroup: number[] = []; - for (let jj = 0; jj < binding_site.length; jj++) { - if (last_index < 0 || binding_site[jj] - last_index === 1) { - current_group.push(binding_site[jj]); - last_index = binding_site[jj]; + for (let jj = 0; jj < bindingSite.length; jj++) { + if (lastIndex < 0 || bindingSite[jj] - lastIndex === 1) { + currentGroup.push(bindingSite[jj]); + lastIndex = bindingSite[jj]; } else { - site_groups.push(current_group); - current_group = []; - current_group.push(binding_site[jj]); - last_index = binding_site[jj]; + siteGroups.push(currentGroup); + currentGroup = []; + currentGroup.push(bindingSite[jj]); + lastIndex = bindingSite[jj]; } } - if (current_group.length > 0) { - site_groups.push(current_group); + if (currentGroup.length > 0) { + siteGroups.push(currentGroup); } let seqA: number[] = seq.slice(0, cut); - let pairsA: number[] = this.foldSequenceWithBindingSite(seqA, null, binding_site, bonus, 2.5, temp); + let pairsA: number[] = this.foldSequenceWithBindingSite(seqA, null, bindingSite, bonus, 2.5, temp); let nodesA: number[] = []; let feA: number = this.scoreStructures(seqA, pairsA, temp, nodesA); - if (FoldUtil.bindingSiteFormed(pairsA, site_groups)) feA += bonus; + if (FoldUtil.bindingSiteFormed(pairsA, siteGroups)) feA += bonus; let seqB: number[] = seq.slice(cut + 1); let pairsB: number[] = this.foldSequence(seqB, null, null, temp); let nodesB: number[] = []; let feB: number = this.scoreStructures(seqB, pairsB, temp, nodesB); - co_pairs = this.cofoldSequenceWithBindingSiteImpl( + coPairs = this.cofoldSequenceWithBindingSiteImpl( seq, - desired_pairs, - site_groups[0][0], - site_groups[0][site_groups[0].length - 1], - site_groups[1][site_groups[1].length - 1], - site_groups[1][0], + desiredPairs, + siteGroups[0][0], + siteGroups[0][siteGroups[0].length - 1], + siteGroups[1][siteGroups[1].length - 1], + siteGroups[1][0], bonus ); - let co_nodes: number[] = []; - let co_fe: number = this.scoreStructures(seq, co_pairs, temp, co_nodes); - if (FoldUtil.bindingSiteFormed(co_pairs, site_groups)) co_fe += bonus; + let coNodes: number[] = []; + let coFE: number = this.scoreStructures(seq, coPairs, temp, coNodes); + if (FoldUtil.bindingSiteFormed(coPairs, siteGroups)) coFE += bonus; - if (co_fe + malus >= feA + feB) { + if (coFE + malus >= feA + feB) { let struc = `${EPars.pairsToParenthesis(pairsA)}&${EPars.pairsToParenthesis(pairsB)}`; - co_pairs = EPars.parenthesisToPairs(struc); + coPairs = EPars.parenthesisToPairs(struc); } - this.putCache(key, co_pairs.slice()); - return co_pairs; + this.putCache(key, coPairs.slice()); + return coPairs; } /* override */ protected loadCustomParams(): boolean { - log.info("TODO: Vienna2.load_custom_params"); + log.info('TODO: Vienna2.load_custom_params'); return false; // if (this._lib != null && this._lib.hasOwnProperty("loadParams")) { // let success: boolean = (this._lib.loadParams("custom.par") === 0); @@ -401,11 +413,11 @@ export default class Vienna2 extends Folder { } /* override */ - public mlEnergy(pairs: number[], S: number[], i: number, is_extloop: boolean): number { + public mlEnergy(pairs: number[], S: number[], i: number, isExtloop: boolean): number { let energy: number; - let cx_energy: number; - let best_energy: number; - best_energy = EPars.INF; + let cxEnergy: number; + let bestEnergy: number; + bestEnergy = EPars.INF; let i1: number; let j: number; let p: number; @@ -420,13 +432,14 @@ export default class Vienna2 extends Folder { let dangles: number = EPars.DANGLES; - if (is_extloop) { + if (isExtloop) { for (x = 0; x <= EPars.NBPAIRS; x++) { mlintern[x] = EPars.mlIntern(x) - EPars.mlIntern(1); /* 0 or TerminalAU */ } - mlclosing = mlbase = 0; + mlbase = 0; + mlclosing = 0; } else { for (x = 0; x <= EPars.NBPAIRS; x++) { mlintern[x] = EPars.mlIntern(x); @@ -455,12 +468,12 @@ export default class Vienna2 extends Folder { p = i + 1; u = 0; energy = 0; - cx_energy = EPars.INF; + cxEnergy = EPars.INF; do { /* walk around the multi-loop */ let tt: number; - let new_cx: number; - new_cx = EPars.INF; + let newCx: number; + newCx = EPars.INF; /* hope over unpaired positions */ while (p <= pairs[0] && pairs[p] === 0) p++; @@ -469,7 +482,8 @@ export default class Vienna2 extends Folder { u += p - i1 - 1; /* get position of pairing partner */ if (p === pairs[0] + 1) { - q = tt = 0; + tt = 0; + q = 0; /* virtual root pair */ } else { q = pairs[p]; @@ -479,7 +493,7 @@ export default class Vienna2 extends Folder { } energy += mlintern[tt]; - cx_energy += mlintern[tt]; + cxEnergy += mlintern[tt]; if (dangles) { let dang5 = 0; @@ -495,14 +509,14 @@ export default class Vienna2 extends Folder { } switch (p - i1 - 1) { - case 0: /* adjacent helices *this./* adjacent helices */ - case 1: /* 1 unpaired base between helices *this./* 1 unpaired base between helices */ - dang = (dangles === 2) ? (dang3 + dang5) : Math.min(dang3, dang5); - energy += dang; - break; - - default: /* many unpaired base between helices *this./* many unpaired base between helices */ - energy += dang5 + dang3; + case 0: /* adjacent helices *this./* adjacent helices */ + case 1: /* 1 unpaired base between helices *this./* 1 unpaired base between helices */ + dang = (dangles === 2) ? (dang3 + dang5) : Math.min(dang3, dang5); + energy += dang; + break; + + default: /* many unpaired base between helices *this./* many unpaired base between helices */ + energy += dang5 + dang3; } type = tt; } @@ -511,10 +525,10 @@ export default class Vienna2 extends Folder { p = q + 1; } while (q !== i); - best_energy = Math.min(energy, best_energy); - /* don't use cx_energy here */ + bestEnergy = Math.min(energy, bestEnergy); + /* don't use cxEnergy here */ - if (dangles !== 3 || is_extloop) { + if (dangles !== 3 || isExtloop) { break; /* may break cofold with co-ax */ } @@ -526,7 +540,7 @@ export default class Vienna2 extends Folder { i = pairs[p]; } - energy = best_energy; + energy = bestEnergy; energy += mlclosing; energy += mlbase * u; @@ -540,8 +554,12 @@ export default class Vienna2 extends Folder { } /* override */ - public loopEnergy(n1: number, n2: number, type: number, type_2: number, si1: number, sj1: number, sp1: number, sq1: number, b1: boolean, b2: boolean): number { - let loop_score = 0; + public loopEnergy( + n1: number, n2: number, + type: number, type2: number, + si1: number, sj1: number, sp1: number, sq1: number, b1: boolean, b2: boolean + ): number { + let loopScore = 0; /* compute energy of degree 2 loop (stack bulge or interior) */ let nl: number; @@ -556,100 +574,102 @@ export default class Vienna2 extends Folder { } if (nl === 0) { - return EPars.getStackScore(type, type_2, b1, b2); + return EPars.getStackScore(type, type2, b1, b2); /* stack */ } if (ns === 0) { /* bulge */ if (nl <= EPars.MAXLOOP) { - loop_score = EPars.BULGE_37[nl]; + loopScore = EPars.BULGE_37[nl]; } else { - loop_score = EPars.get_bulge(nl); + loopScore = EPars.getBulge(nl); } if (nl === 1) { - loop_score += EPars.getStackScore(type, type_2, b1, b2); + loopScore += EPars.getStackScore(type, type2, b1, b2); } else { if (type > 2) { - loop_score += EPars.TERM_AU; + loopScore += EPars.TERM_AU; } - if (type_2 > 2) { - loop_score += EPars.TERM_AU; + if (type2 > 2) { + loopScore += EPars.TERM_AU; } } - return loop_score; - } else { /* interior loop */ + return loopScore; + } else { + /* interior loop */ if (ns === 1) { - if (nl === 1) // 1x1 loop - { - return EPars.getInt11(type, type_2, si1, sj1); + if (nl === 1) { + // 1x1 loop + return EPars.getInt11(type, type2, si1, sj1); } - if (nl === 2) { // 2x1 loop + if (nl === 2) { + // 2x1 loop if (n1 === 1) { - loop_score = EPars.getInt21(type, type_2, si1, sq1, sj1); + loopScore = EPars.getInt21(type, type2, si1, sq1, sj1); } else { - loop_score = EPars.getInt21(type_2, type, sq1, si1, sp1); + loopScore = EPars.getInt21(type2, type, sq1, si1, sp1); } - return loop_score; + return loopScore; } - } else if (n1 === 2 && n2 === 2) // 2x2 loop - { - return EPars.getInt22(type, type_2, si1, sp1, sq1, sj1); + } else if (n1 === 2 && n2 === 2) { + // 2x2 loop + return EPars.getInt22(type, type2, si1, sp1, sq1, sj1); } - { - /* generic interior loop (no else here!) */ - if ((n1 + n2 <= EPars.MAXLOOP)) { - loop_score = EPars.INTERNAL_37[n1 + n2]; - } else { - loop_score = EPars.getInternal(n1 + n2); - } - - loop_score += Math.min(EPars.MAX_NINIO, (nl - ns) * EPars.F_ninio37[2]); - loop_score += EPars.internalMismatch(type, si1, sj1) + EPars.internalMismatch(type_2, sq1, sp1); + /* generic interior loop (no else here!) */ + if ((n1 + n2 <= EPars.MAXLOOP)) { + loopScore = EPars.INTERNAL_37[n1 + n2]; + } else { + loopScore = EPars.getInternal(n1 + n2); } + + loopScore += Math.min(EPars.MAX_NINIO, (nl - ns) * EPars.F_ninio37[2]); + loopScore += EPars.internalMismatch(type, si1, sj1) + EPars.internalMismatch(type2, sq1, sp1); } - return loop_score; + return loopScore; } /* override */ - public hairpinEnergy(size: number, type: number, si1: number, sj1: number, sequence: number[], i: number, j: number): number { - let hairpin_score = 0; + public hairpinEnergy( + size: number, type: number, si1: number, sj1: number, sequence: number[], i: number, j: number + ): number { + let hairpinScore = 0; if (size <= 30) { - hairpin_score = EPars.HAIRPIN_37[size]; + hairpinScore = EPars.HAIRPIN_37[size]; } else { - hairpin_score = EPars.HAIRPIN_37[30] + Number(EPars.LXC * Math.log((size) / 30.0)); + hairpinScore = EPars.HAIRPIN_37[30] + Number(EPars.LXC * Math.log((size) / 30.0)); } if (size === 4) { - let loop_str = ""; + let loopStr = ''; for (let walker: number = i; walker <= j; walker++) { if (sequence[walker] === EPars.RNABASE_ADENINE) { - loop_str += "A"; + loopStr += 'A'; } else if (sequence[walker] === EPars.RNABASE_GUANINE) { - loop_str += "G"; + loopStr += 'G'; } else if (sequence[walker] === EPars.RNABASE_URACIL) { - loop_str += "U"; + loopStr += 'U'; } else if (sequence[walker] === EPars.RNABASE_CYTOSINE) { - loop_str += "C"; + loopStr += 'C'; } } - hairpin_score += EPars.getTetraLoopBonus(loop_str); + hairpinScore += EPars.getTetraLoopBonus(loopStr); } if (size === 3) { if (type > 2) { - hairpin_score += EPars.TERM_AU; + hairpinScore += EPars.TERM_AU; } } else { - hairpin_score += EPars.hairpinMismatch(type, si1, sj1); + hairpinScore += EPars.hairpinMismatch(type, si1, sj1); } - return hairpin_score; + return hairpinScore; } private foldSequenceImpl(seq: number[], structStr: string = null, temp: number = 37): number[] { @@ -657,10 +677,10 @@ export default class Vienna2 extends Folder { let result: FullFoldResult; try { - result = this._lib.FullFoldTemperature(temp, seqStr, structStr || ""); + result = this._lib.FullFoldTemperature(temp, seqStr, structStr || ''); return EPars.parenthesisToPairs(result.structure); } catch (e) { - log.error("FullFoldTemperature error", e); + log.error('FullFoldTemperature error', e); return []; } finally { if (result != null) { @@ -670,16 +690,18 @@ export default class Vienna2 extends Folder { } } - private foldSequenceWithBindingSiteImpl(seq: number[], i: number, p: number, j: number, q: number, bonus: number): number[] { + private foldSequenceWithBindingSiteImpl( + seq: number[], i: number, p: number, j: number, q: number, bonus: number + ): number[] { const seqStr = EPars.sequenceToString(seq, false, false); - const structStr = ""; + const structStr = ''; let result: FullFoldResult; try { result = this._lib.FullFoldWithBindingSite(seqStr, structStr, i + 1, p + 1, j + 1, q + 1, -bonus); return EPars.parenthesisToPairs(result.structure); } catch (e) { - log.error("FullFoldWithBindingSite error", e); + log.error('FullFoldWithBindingSite error', e); return []; } finally { if (result != null) { @@ -691,15 +713,15 @@ export default class Vienna2 extends Folder { private cofoldSequenceImpl(seq: number[], str: string = null): number[] { const seqStr = EPars.sequenceToString(seq, true, false); - const structStr: string = str || ""; + const structStr: string = str || ''; let result: FullFoldResult; try { result = this._lib.CoFoldSequence(seqStr, structStr); - log.debug("done cofolding"); + log.debug('done cofolding'); return EPars.parenthesisToPairs(result.structure); } catch (e) { - log.error("CoFoldSequence error", e); + log.error('CoFoldSequence error', e); return []; } finally { if (result != null) { @@ -709,17 +731,19 @@ export default class Vienna2 extends Folder { } } - private cofoldSequenceWithBindingSiteImpl(seq: number[], str: string, i: number, p: number, j: number, q: number, bonus: number): number[] { + private cofoldSequenceWithBindingSiteImpl( + seq: number[], str: string, i: number, p: number, j: number, q: number, bonus: number + ): number[] { const seqStr = EPars.sequenceToString(seq, true, false); - const structStr: string = str || ""; + const structStr: string = str || ''; let result: FullFoldResult; try { result = this._lib.CoFoldSequenceWithBindingSite(seqStr, structStr, i + 1, p + 1, j + 1, q + 1, -bonus); - log.debug("done cofolding"); + log.debug('done cofolding'); return EPars.parenthesisToPairs(result.structure); } catch (e) { - log.error("CoFoldSequenceWithBindingSite error", e); + log.error('CoFoldSequenceWithBindingSite error', e); return []; } finally { if (result != null) { @@ -729,53 +753,55 @@ export default class Vienna2 extends Folder { } } - private foldSequenceWithBindingSiteOld(seq: number[], target_pairs: number[], binding_site: number[], bonus: number): number[] { - let best_pairs: number[]; - let native_pairs: number[] = this.foldSequence(seq, null, null); - - let native_tree: RNALayout = new RNALayout(); - native_tree.setupTree(native_pairs); - native_tree.scoreTree(seq, this); - let native_score: number = native_tree.totalScore; - - let target_satisfied: number[] = EPars.getSatisfiedPairs(target_pairs, seq); - let target_tree: RNALayout = new RNALayout(); - target_tree.setupTree(target_satisfied); - target_tree.scoreTree(seq, this); - let target_score: number = target_tree.totalScore; - - let native_bound = true; - let target_bound = true; - - for (let bb = 0; bb < binding_site.length; bb++) { - let bi: number = binding_site[bb]; - if (target_pairs[bi] !== native_pairs[bi]) { - native_bound = false; + private foldSequenceWithBindingSiteOld( + seq: number[], targetpairs: number[], bindingSite: number[], bonus: number + ): number[] { + let bestPairs: number[]; + let nativePairs: number[] = this.foldSequence(seq, null, null); + + let nativeTree: RNALayout = new RNALayout(); + nativeTree.setupTree(nativePairs); + nativeTree.scoreTree(seq, this); + let nativeScore: number = nativeTree.totalScore; + + let targetSatisfied: number[] = EPars.getSatisfiedPairs(targetpairs, seq); + let targetTree: RNALayout = new RNALayout(); + targetTree.setupTree(targetSatisfied); + targetTree.scoreTree(seq, this); + let targetScore: number = targetTree.totalScore; + + let nativeBound = true; + let targetBound = true; + + for (let bb = 0; bb < bindingSite.length; bb++) { + let bi: number = bindingSite[bb]; + if (targetpairs[bi] !== nativePairs[bi]) { + nativeBound = false; } - if (target_pairs[bi] !== target_satisfied[bi]) { - target_bound = false; + if (targetpairs[bi] !== targetSatisfied[bi]) { + targetBound = false; } } - if (target_bound) { - target_score += bonus; + if (targetBound) { + targetScore += bonus; } - if (native_bound) { - native_score += bonus; + if (nativeBound) { + nativeScore += bonus; } - if (target_score < native_score) { - best_pairs = target_satisfied; + if (targetScore < nativeScore) { + bestPairs = targetSatisfied; } else { - best_pairs = native_pairs; + bestPairs = nativePairs; } - return best_pairs; + return bestPairs; } - private readonly _lib: vrna2_lib; + private readonly _lib: Vienna2Lib; } interface FullEvalCache { diff --git a/src/eterna/folding/engines/LinearFold_lib/index.d.ts b/src/eterna/folding/engines/LinearFoldLib/index.d.ts similarity index 87% rename from src/eterna/folding/engines/LinearFold_lib/index.d.ts rename to src/eterna/folding/engines/LinearFoldLib/index.d.ts index 2dcb5183d..093a34965 100644 --- a/src/eterna/folding/engines/LinearFold_lib/index.d.ts +++ b/src/eterna/folding/engines/LinearFoldLib/index.d.ts @@ -21,18 +21,18 @@ import * as stdcpp from "../../../emscripten/stdcpp"; -export = LinearFold_lib; +export = LinearFoldLib; /*~ Write your module's methods and properties in this class */ -declare class LinearFold_lib { - FullFoldDefault(seqString: string): LinearFold_lib.FullFoldResult; - FullEval(seqString: string, structString: string): LinearFold_lib.FullEvalResult; +declare class LinearFoldLib { + FullFoldDefault(seqString: string): LinearFoldLib.FullFoldResult; + FullEval(seqString: string, structString: string): LinearFoldLib.FullEvalResult; } /*~ If you want to expose types from your module as well, you can *~ place them in this block. */ -declare namespace LinearFold_lib { +declare namespace LinearFoldLib { export interface FullFoldResult { structure: string; diff --git a/src/eterna/folding/engines/nupack_lib/index.d.ts b/src/eterna/folding/engines/NupackLib/index.d.ts similarity index 78% rename from src/eterna/folding/engines/nupack_lib/index.d.ts rename to src/eterna/folding/engines/NupackLib/index.d.ts index b1d4c9978..7237ecdbf 100644 --- a/src/eterna/folding/engines/nupack_lib/index.d.ts +++ b/src/eterna/folding/engines/NupackLib/index.d.ts @@ -20,24 +20,24 @@ */ import * as stdcpp from "../../../emscripten/stdcpp"; -export = nupack_lib; +export = NupackLib; /*~ Write your module's methods and properties in this class */ -declare class nupack_lib { - FullEval(temperature_in: number, seqString: string, structString: string): nupack_lib.FullEvalResult; - - FullFoldDefault(seqString: string): nupack_lib.FullFoldResult; - FullFoldTemperature(temperature_in: number, seqString: string): nupack_lib.FullFoldResult; - GetDotPlot(temperature_in: number, seqString: string): nupack_lib.DotPlotResult; - FullFoldWithBindingSite(seqString: string, switch_bp_i: number, switch_bp_p: number, switch_bp_j: number, switch_bp_q: number, switch_bp_bonus: number): nupack_lib.FullFoldResult; - CoFoldSequence(seqString: string): nupack_lib.FullFoldResult; - CoFoldSequenceWithBindingSite(seqString: string, switch_bp_i: number, switch_bp_p: number, switch_bp_j: number, switch_bp_q: number, switch_bp_bonus: number): nupack_lib.FullFoldResult; +declare class NupackLib { + FullEval(temperature_in: number, seqString: string, structString: string): NupackLib.FullEvalResult; + + FullFoldDefault(seqString: string): NupackLib.FullFoldResult; + FullFoldTemperature(temperature_in: number, seqString: string): NupackLib.FullFoldResult; + GetDotPlot(temperature_in: number, seqString: string): NupackLib.DotPlotResult; + FullFoldWithBindingSite(seqString: string, switch_bp_i: number, switch_bp_p: number, switch_bp_j: number, switch_bp_q: number, switch_bp_bonus: number): NupackLib.FullFoldResult; + CoFoldSequence(seqString: string): NupackLib.FullFoldResult; + CoFoldSequenceWithBindingSite(seqString: string, switch_bp_i: number, switch_bp_p: number, switch_bp_j: number, switch_bp_q: number, switch_bp_bonus: number): NupackLib.FullFoldResult; } /*~ If you want to expose types from your module as well, you can *~ place them in this block. */ -declare namespace nupack_lib { +declare namespace NupackLib { export interface FullEvalResult { nodes: stdcpp.vector; energy: number; diff --git a/src/eterna/folding/engines/vienna_lib/index.d.ts b/src/eterna/folding/engines/Viena2Lib/index.d.ts similarity index 77% rename from src/eterna/folding/engines/vienna_lib/index.d.ts rename to src/eterna/folding/engines/Viena2Lib/index.d.ts index 2e7ae48ef..8f6473125 100644 --- a/src/eterna/folding/engines/vienna_lib/index.d.ts +++ b/src/eterna/folding/engines/Viena2Lib/index.d.ts @@ -20,24 +20,24 @@ */ import * as stdcpp from "../../../emscripten/stdcpp"; -export = vienna_lib; +export = Vienna2Lib; /*~ Write your module's methods and properties in this class */ -declare class vienna_lib { - FullEval (temperature_in: number, seqString: string, structString: string): vienna_lib.FullEvalResult; - - FullFoldDefault(seqString: string, structString: string): vienna_lib.FullFoldResult; - FullFoldTemperature (temperature_in: number, seqString: string, structString: string): vienna_lib.FullFoldResult; - GetDotPlot (temperature_in: number, seqString: string, dotplotStructString: string): vienna_lib.DotPlotResult; - FullFoldWithBindingSite (seqString: string, structString: string, switch_bp_i: number, switch_bp_p: number, switch_bp_j: number, switch_bp_q: number, switch_bp_bonus: number): vienna_lib.FullFoldResult; - CoFoldSequence (seqString: string, structString: string): vienna_lib.FullFoldResult; - CoFoldSequenceWithBindingSite (seqString: string, structString: string, switch_bp_i: number, switch_bp_p: number, switch_bp_j: number, switch_bp_q: number, switch_bp_bonus: number): vienna_lib.FullFoldResult; +declare class Vienna2Lib { + FullEval (temperature_in: number, seqString: string, structString: string): Vienna2Lib.FullEvalResult; + + FullFoldDefault(seqString: string, structString: string): Vienna2Lib.FullFoldResult; + FullFoldTemperature (temperature_in: number, seqString: string, structString: string): Vienna2Lib.FullFoldResult; + GetDotPlot (temperature_in: number, seqString: string, dotplotStructString: string): Vienna2Lib.DotPlotResult; + FullFoldWithBindingSite (seqString: string, structString: string, switch_bp_i: number, switch_bp_p: number, switch_bp_j: number, switch_bp_q: number, switch_bp_bonus: number): Vienna2Lib.FullFoldResult; + CoFoldSequence (seqString: string, structString: string): Vienna2Lib.FullFoldResult; + CoFoldSequenceWithBindingSite (seqString: string, structString: string, switch_bp_i: number, switch_bp_p: number, switch_bp_j: number, switch_bp_q: number, switch_bp_bonus: number): Vienna2Lib.FullFoldResult; } /*~ If you want to expose types from your module as well, you can *~ place them in this block. */ -declare namespace vienna_lib { +declare namespace Vienna2Lib { export interface FullEvalResult { nodes: stdcpp.vector; energy: number; diff --git a/src/eterna/folding/engines/vrna2_lib/index.d.ts b/src/eterna/folding/engines/ViennaLib/index.d.ts similarity index 77% rename from src/eterna/folding/engines/vrna2_lib/index.d.ts rename to src/eterna/folding/engines/ViennaLib/index.d.ts index 349ac6c6b..9f6dd056e 100644 --- a/src/eterna/folding/engines/vrna2_lib/index.d.ts +++ b/src/eterna/folding/engines/ViennaLib/index.d.ts @@ -20,24 +20,24 @@ */ import * as stdcpp from "../../../emscripten/stdcpp"; -export = vrna2_lib; +export = ViennaLib; /*~ Write your module's methods and properties in this class */ -declare class vrna2_lib { - FullEval (temperature_in: number, seqString: string, structString: string): vrna2_lib.FullEvalResult; - - FullFoldDefault(seqString: string, structString: string): vrna2_lib.FullFoldResult; - FullFoldTemperature (temperature_in: number, seqString: string, structString: string): vrna2_lib.FullFoldResult; - GetDotPlot (temperature_in: number, seqString: string, dotplotStructString: string): vrna2_lib.DotPlotResult; - FullFoldWithBindingSite (seqString: string, structString: string, switch_bp_i: number, switch_bp_p: number, switch_bp_j: number, switch_bp_q: number, switch_bp_bonus: number): vrna2_lib.FullFoldResult; - CoFoldSequence (seqString: string, structString: string): vrna2_lib.FullFoldResult; - CoFoldSequenceWithBindingSite (seqString: string, structString: string, switch_bp_i: number, switch_bp_p: number, switch_bp_j: number, switch_bp_q: number, switch_bp_bonus: number): vrna2_lib.FullFoldResult; +declare class ViennaLib { + FullEval (temperature_in: number, seqString: string, structString: string): ViennaLib.FullEvalResult; + + FullFoldDefault(seqString: string, structString: string): ViennaLib.FullFoldResult; + FullFoldTemperature (temperature_in: number, seqString: string, structString: string): ViennaLib.FullFoldResult; + GetDotPlot (temperature_in: number, seqString: string, dotplotStructString: string): ViennaLib.DotPlotResult; + FullFoldWithBindingSite (seqString: string, structString: string, switch_bp_i: number, switch_bp_p: number, switch_bp_j: number, switch_bp_q: number, switch_bp_bonus: number): ViennaLib.FullFoldResult; + CoFoldSequence (seqString: string, structString: string): ViennaLib.FullFoldResult; + CoFoldSequenceWithBindingSite (seqString: string, structString: string, switch_bp_i: number, switch_bp_p: number, switch_bp_j: number, switch_bp_q: number, switch_bp_bonus: number): ViennaLib.FullFoldResult; } /*~ If you want to expose types from your module as well, you can *~ place them in this block. */ -declare namespace vrna2_lib { +declare namespace ViennaLib { export interface FullEvalResult { nodes: stdcpp.vector; energy: number; diff --git a/src/eterna/folding/index.ts b/src/eterna/folding/index.ts index 078281637..83fb4add5 100644 --- a/src/eterna/folding/index.ts +++ b/src/eterna/folding/index.ts @@ -1,10 +1,10 @@ -export {default as Folder} from "./Folder"; -export {default as FolderManager} from "./FolderManager"; -export {default as FoldUtil} from "./FoldUtil"; -export {default as LinearFoldBase} from "./LinearFoldBase"; -export {default as LinearFoldC} from "./LinearFoldC"; -export {default as LinearFoldV} from "./LinearFoldV"; -export {default as NuPACK} from "./NuPACK"; -export {default as RNAFoldBasic} from "./RNAFoldBasic"; -export {default as Vienna} from "./Vienna"; -export {default as Vienna2} from "./Vienna2"; +export {default as Folder} from './Folder'; +export {default as FolderManager} from './FolderManager'; +export {default as FoldUtil} from './FoldUtil'; +export {default as LinearFoldBase} from './LinearFoldBase'; +export {default as LinearFoldC} from './LinearFoldC'; +export {default as LinearFoldV} from './LinearFoldV'; +export {default as NuPACK} from './NuPACK'; +export {default as RNAFoldBasic} from './RNAFoldBasic'; +export {default as Vienna} from './Vienna'; +export {default as Vienna2} from './Vienna2'; diff --git a/src/eterna/index.ts b/src/eterna/index.ts index 7a868fa6b..552b681ac 100644 --- a/src/eterna/index.ts +++ b/src/eterna/index.ts @@ -1,6 +1,6 @@ -import * as log from "loglevel"; -import EternaApp from "eterna/EternaApp"; +import * as log from 'loglevel'; +import EternaApp from 'eterna/EternaApp'; -const isProduction = process.env.NODE_ENV === "production"; -log.setLevel(isProduction ? "info" : "trace"); +const isProduction = process.env.NODE_ENV === 'production'; +log.setLevel(isProduction ? 'info' : 'trace'); (window as any).EternaApp = EternaApp; diff --git a/src/eterna/mode/CopyTextDialogMode.ts b/src/eterna/mode/CopyTextDialogMode.ts index b8893cbb2..fb12e67d0 100644 --- a/src/eterna/mode/CopyTextDialogMode.ts +++ b/src/eterna/mode/CopyTextDialogMode.ts @@ -1,11 +1,11 @@ -import {Graphics} from "pixi.js"; -import {Flashbang, AppMode} from "flashbang/core"; -import {KeyCode} from "flashbang/input"; -import {TextInputPanel} from "eterna/ui"; +import {Graphics} from 'pixi.js'; +import {Flashbang, AppMode} from 'flashbang/core'; +import {KeyCode} from 'flashbang/input'; +import {TextInputPanel} from 'eterna/ui'; /** Show a dialog with text that the user can copy */ export default class CopyTextDialogMode extends AppMode { - public constructor(text: string, dialogTitle?: string) { + constructor(text: string, dialogTitle?: string) { super(); this._text = text; this._dialogTitle = dialogTitle; @@ -21,9 +21,9 @@ export default class CopyTextDialogMode extends AppMode { if (this._dialogTitle != null) { inputPanel.title = this._dialogTitle; } - inputPanel.okButtonLabel = "Copy"; + inputPanel.okButtonLabel = 'Copy'; - let textField = inputPanel.addField("Text", Math.min(400, Math.max(200, Flashbang.stageWidth - 200)), false); + let textField = inputPanel.addField('Text', Math.min(400, Math.max(200, Flashbang.stageWidth - 200)), false); textField.text = this._text; textField.readOnly = true; @@ -37,7 +37,7 @@ export default class CopyTextDialogMode extends AppMode { inputPanel.okClicked.connect(() => { setTimeout(() => { textField.setFocus(true); - document.execCommand("copy"); + document.execCommand('copy'); this.close(); }); }); diff --git a/src/eterna/mode/DesignBrowser/CustomizeColumnOrderDialog.ts b/src/eterna/mode/DesignBrowser/CustomizeColumnOrderDialog.ts index d3f21519b..fd3276810 100644 --- a/src/eterna/mode/DesignBrowser/CustomizeColumnOrderDialog.ts +++ b/src/eterna/mode/DesignBrowser/CustomizeColumnOrderDialog.ts @@ -1,19 +1,19 @@ -import {Container, Point, Text} from "pixi.js"; -import {HAlign, VAlign} from "flashbang/core"; -import {HLayoutContainer, VLayoutContainer} from "flashbang/layout"; -import {Arrays, DisplayUtil} from "flashbang/util"; -import {Signal} from "signals"; -import {Bitmaps} from "eterna/resources"; +import {Container, Point, Text} from 'pixi.js'; +import {HAlign, VAlign} from 'flashbang/core'; +import {HLayoutContainer, VLayoutContainer} from 'flashbang/layout'; +import {Arrays, DisplayUtil} from 'flashbang/util'; +import {Signal} from 'signals'; +import {Bitmaps} from 'eterna/resources'; import { Dialog, FixedWidthTextField, GameButton, GamePanel, GamePanelType -} from "eterna/ui"; -import {Fonts, GraphicsUtil} from "eterna/util"; -import {DesignCategory} from "./DesignBrowserMode"; +} from 'eterna/ui'; +import {Fonts, GraphicsUtil} from 'eterna/util'; +import {DesignCategory} from './DesignBrowserMode'; export default class CustomizeColumnOrderDialog extends Dialog { public readonly columnsReorganized = new Signal(); - public constructor(allCategories: DesignCategory[], curColumns: DesignCategory[], disabled: Set = null) { + constructor(allCategories: DesignCategory[], curColumns: DesignCategory[], disabled: Set = null) { super(); this._allColumnCategories = allCategories.slice(); this._initialColumns = curColumns.slice(); @@ -42,7 +42,7 @@ export default class CustomizeColumnOrderDialog extends Dialog { this._curCategoryText = new FixedWidthTextField( this._allColumnCategories[0], - Fonts.arial("", 17).color(0xffffff).style, + Fonts.arial('', 17).color(0xffffff).style, 140, HAlign.CENTER ); addCriterionLayout.addChild(this._curCategoryText); @@ -53,11 +53,11 @@ export default class CustomizeColumnOrderDialog extends Dialog { addCriterionLayout.addHSpacer(10); - this._addCriterionButton = new GameButton().label("Add", 15); + this._addCriterionButton = new GameButton().label('Add', 15); this._addCriterionButton.clicked.connect(() => this.addCurrentCriteria()); this.addObject(this._addCriterionButton, addCriterionLayout); - let resetButton = new GameButton().label("Reset", 15); + let resetButton = new GameButton().label('Reset', 15); resetButton.clicked.connect(() => this.reset()); this.addObject(resetButton, addCriterionLayout); @@ -65,7 +65,7 @@ export default class CustomizeColumnOrderDialog extends Dialog { this._panelContent.addVSpacer(20); - let okButton = new GameButton().label("Ok", 20); + let okButton = new GameButton().label('Ok', 20); okButton.clicked.connect(() => this.close(null)); this.addObject(okButton, this._panelContent); @@ -106,7 +106,7 @@ export default class CustomizeColumnOrderDialog extends Dialog { } private getColumnIdx(category: DesignCategory): number { - return this._columnUIs.findIndex(ui => ui.category == category); + return this._columnUIs.findIndex(ui => ui.category === category); } private getUnusedColumns(): DesignCategory[] { @@ -270,7 +270,7 @@ class ColumnUI { public moveDownButton: GameButton; public removeButton: GameButton; - public constructor(category: DesignCategory) { + constructor(category: DesignCategory) { this.category = category; } diff --git a/src/eterna/mode/DesignBrowser/DataCol.ts b/src/eterna/mode/DesignBrowser/DataCol.ts index b5103ff3a..1037fbb59 100644 --- a/src/eterna/mode/DesignBrowser/DataCol.ts +++ b/src/eterna/mode/DesignBrowser/DataCol.ts @@ -1,31 +1,31 @@ import { Container, Graphics, Point, Text -} from "pixi.js"; -import {Flashbang} from "flashbang/core"; -import {ContainerObject} from "flashbang/objects"; -import {TextBuilder} from "flashbang/util"; -import {Signal, UnitSignal} from "signals"; -import Feedback from "eterna/Feedback"; -import {Solution} from "eterna/puzzle"; -import {GameButton, TextInputObject} from "eterna/ui"; -import {Fonts, int, Utility} from "eterna/util"; -import {DesignBrowserDataType, DesignCategory} from "./DesignBrowserMode"; -import SequenceStringListView from "./SequenceStringListView"; -import {SortOrder} from "./SortOptions"; +} from 'pixi.js'; +import {Flashbang} from 'flashbang/core'; +import {ContainerObject} from 'flashbang/objects'; +import {TextBuilder} from 'flashbang/util'; +import {Signal, UnitSignal} from 'signals'; +import Feedback from 'eterna/Feedback'; +import {Solution} from 'eterna/puzzle'; +import {GameButton, TextInputObject} from 'eterna/ui'; +import {Fonts, int, Utility} from 'eterna/util'; +import {DesignBrowserDataType, DesignCategory} from './DesignBrowserMode'; +import SequenceStringListView from './SequenceStringListView'; +import {SortOrder} from './SortOptions'; export default class DataCol extends ContainerObject { public readonly sortOrderChanged = new Signal(); public readonly filtersChanged = new UnitSignal(); public readonly category: DesignCategory; - constructor(data_type: DesignBrowserDataType, category: DesignCategory, - data_width: number, fonttype: string, + constructor(dataType: DesignBrowserDataType, category: DesignCategory, + dataWidth: number, fonttype: string, fontSize: number, sortable: boolean) { super(); this.category = category; - this._data_type = data_type; - this._dataWidth = data_width; + this._dataType = dataType; + this._dataWidth = dataWidth; this._fontType = fonttype; this._fontSize = fontSize; this._sortable = sortable; @@ -42,16 +42,18 @@ export default class DataCol extends ContainerObject { this.container.addChild(this._graphics); let dataDisplayBuilder = new TextBuilder().font(this._fontType).fontSize(this._fontSize).color(0xffffff); - this._line_height = dataDisplayBuilder.computeLineHeight(); + this._lineHeight = dataDisplayBuilder.computeLineHeight(); this._dataDisplay = dataDisplayBuilder.build(); - // this._dataDisplay.set_text("A\nA"); + // this._dataDisplay.setText("A\nA"); // let metr: TextLineMetrics = this._dataDisplay.GetTextBox().getLineMetrics(0); - // this._line_height = metr.height + metr.leading / 2; + // this._lineHeight = metr.height + metr.leading / 2; this._dataDisplay.position = new Point(11, DataCol.DATA_H); this.container.addChild(this._dataDisplay); - this._sequencesView = new SequenceStringListView(this._fontType, this._fontSize, true, this._fontSize, this._line_height); + this._sequencesView = new SequenceStringListView( + this._fontType, this._fontSize, true, this._fontSize, this._lineHeight + ); this._sequencesView.position = new Point(0, DataCol.DATA_H); this.container.addChild(this._sequencesView); @@ -69,37 +71,43 @@ export default class DataCol extends ContainerObject { const TEXT_INPUT_SIZE = 13; - if (this._data_type == DesignBrowserDataType.STRING) { - this._filterField1 = new TextInputObject(TEXT_INPUT_SIZE, this._dataWidth - 22).showFakeTextInputWhenNotFocused(); + if (this._dataType === DesignBrowserDataType.STRING) { + this._filterField1 = new TextInputObject( + TEXT_INPUT_SIZE, this._dataWidth - 22 + ).showFakeTextInputWhenNotFocused(); this._filterField1.tabIndex = -1; // prevent tab-selection this._filterField1.display.position = new Point(11, 54); this.addObject(this._filterField1, this.container); this._filterField1.valueChanged.connect(() => this.filtersChanged.emit()); - this._filterLabel1 = Fonts.arial("search", 14).color(0xffffff).build(); + this._filterLabel1 = Fonts.arial('search', 14).color(0xffffff).build(); this._filterLabel1.position = new Point(11, 33); this.container.addChild(this._filterLabel1); } else { - this._filterField1 = new TextInputObject(TEXT_INPUT_SIZE, (this._dataWidth - 29) * 0.5).showFakeTextInputWhenNotFocused(); + this._filterField1 = new TextInputObject( + TEXT_INPUT_SIZE, (this._dataWidth - 29) * 0.5 + ).showFakeTextInputWhenNotFocused(); this._filterField1.tabIndex = -1; // prevent tab-selection this._filterField1.display.position = new Point(11, 54); this.addObject(this._filterField1, this.container); this._filterField1.valueChanged.connect(() => this.filtersChanged.emit()); - this._filterLabel1 = Fonts.arial("min", 14).color(0xffffff).build(); + this._filterLabel1 = Fonts.arial('min', 14).color(0xffffff).build(); this._filterLabel1.position = new Point(11, 33); this.container.addChild(this._filterLabel1); - this._filterField2 = new TextInputObject(TEXT_INPUT_SIZE, (this._dataWidth - 29) * 0.5).showFakeTextInputWhenNotFocused(); + this._filterField2 = new TextInputObject( + TEXT_INPUT_SIZE, (this._dataWidth - 29) * 0.5 + ).showFakeTextInputWhenNotFocused(); this._filterField2.tabIndex = -1; // prevent tab-selection this._filterField2.display.position = new Point(11 + (this._dataWidth - 29) / 2 + 7, 54); this.addObject(this._filterField2, this.container); this._filterField2.valueChanged.connect(() => this.filtersChanged.emit()); - this._filterLabel2 = Fonts.arial("max", 14).color(0xffffff).build(); + this._filterLabel2 = Fonts.arial('max', 14).color(0xffffff).build(); this._filterLabel2.position = new Point((this._dataWidth - 7) / 2 + 7, 33); this.container.addChild(this._filterLabel2); } @@ -121,12 +129,12 @@ export default class DataCol extends ContainerObject { private updateLayout(): void { this._sequencesView.setSize(this._width, this._height); - this._numDisplay = Math.floor((this._height - 70 - 20) / this._line_height); + this._numDisplay = Math.floor((this._height - 70 - 20) / this._lineHeight); this.updateView(); this.bgColor = this._fillColor; } - public set_pairs(pairs: number[]): void { + public setPairs(pairs: number[]): void { this._pairsArray = pairs.slice(); } @@ -140,12 +148,12 @@ export default class DataCol extends ContainerObject { return [-1, -1]; } - let ii = int((mouseLoc.y - DataCol.DATA_H) / this._line_height); + let ii = int((mouseLoc.y - DataCol.DATA_H) / this._lineHeight); if (ii >= this._numDisplay) { return [-1, -1]; } - return [ii, int(DataCol.DATA_H + (ii * this._line_height) - mouseLoc.y)]; + return [ii, int(DataCol.DATA_H + (ii * this._lineHeight) - mouseLoc.y)]; } public setFilter(filter1: string, filter2: string): void { @@ -159,14 +167,14 @@ export default class DataCol extends ContainerObject { this._sortOrder = sortOrder; this._labelArrow.clear(); - if (this._sortOrder == SortOrder.DECREASING) { + if (this._sortOrder === SortOrder.DECREASING) { this._labelArrow.beginFill(0xFFFFFF, 0.8); this._labelArrow.moveTo(this._label.container.width + 4, 8); this._labelArrow.lineTo(this._label.container.width + 14, 8); this._labelArrow.lineTo(this._label.container.width + 9, 18); this._labelArrow.lineTo(this._label.container.width + 4, 8); this._labelArrow.endFill(); - } else if (this._sortOrder == SortOrder.INCREASING) { + } else if (this._sortOrder === SortOrder.INCREASING) { this._labelArrow.beginFill(0xFFFFFF, 0.8); this._labelArrow.moveTo(this._label.container.width + 4, 18); this._labelArrow.lineTo(this._label.container.width + 14, 18); @@ -178,26 +186,26 @@ export default class DataCol extends ContainerObject { /** True if the solution passes our filter options */ public shouldDisplay(sol: Solution): boolean { - if (this._data_type == DesignBrowserDataType.STRING) { - let query_string: string = this._filterField1.text; - if (query_string.length == 0) { + if (this._dataType === DesignBrowserDataType.STRING) { + let queryString: string = this._filterField1.text; + if (queryString.length === 0) { return true; } - let target_low: string = sol.getProperty(this.category).toLowerCase(); + let targetLow: string = sol.getProperty(this.category).toLowerCase(); - return (target_low.search(query_string.toLowerCase()) >= 0); + return (targetLow.search(queryString.toLowerCase()) >= 0); } else { - let query_min: string = this._filterField1.text; - if (query_min.length > 0) { - if (sol.getProperty(this.category) < Number(query_min)) { + let queryMin: string = this._filterField1.text; + if (queryMin.length > 0) { + if (sol.getProperty(this.category) < Number(queryMin)) { return false; } } - let query_max: string = this._filterField2.text; - if (query_max.length > 0) { - if (sol.getProperty(this.category) > Number(query_max)) { + let queryMax: string = this._filterField2.text; + if (queryMax.length > 0) { + if (sol.getProperty(this.category) > Number(queryMax)) { return false; } } @@ -241,18 +249,18 @@ export default class DataCol extends ContainerObject { this._feedback = feedback; } - public set_data_and_display(raw: any[]): void { + public setDataAndDisplay(raw: any[]): void { this._rawData = []; for (let ii = 0; ii < raw.length; ii++) { - if (this._data_type == DesignBrowserDataType.INT) { + if (this._dataType === DesignBrowserDataType.INT) { this._rawData.push(int(raw[ii])); - } else if (this._data_type == DesignBrowserDataType.STRING) { + } else if (this._dataType === DesignBrowserDataType.STRING) { this._rawData.push(`${raw[ii]}`); - } else if (this._data_type == DesignBrowserDataType.NUMBER) { + } else if (this._dataType === DesignBrowserDataType.NUMBER) { this._rawData.push(Number(raw[ii])); } else { - throw new Error(`Unrecognized data type ${this._data_type}`); + throw new Error(`Unrecognized data type ${this._dataType}`); } } @@ -261,7 +269,7 @@ export default class DataCol extends ContainerObject { public set scrollProgress(offset: number) { offset = int(offset); - if (this._offset != offset) { + if (this._offset !== offset) { this._offset = offset; this.updateView(); } @@ -275,7 +283,7 @@ export default class DataCol extends ContainerObject { this._graphics.drawRect(0, 0, this._dataWidth, this._height); this._graphics.endFill(); - if (this.category == "Sequence") { + if (this.category === 'Sequence') { this._graphics.lineStyle(1, 0x92A8BB, 0.4); for (let ii = 0; ii < this._dataWidth / 70 + 1; ii++) { this._graphics.moveTo(ii * 70 + 90, 85); @@ -285,9 +293,9 @@ export default class DataCol extends ContainerObject { } private toggleSortState(): void { - if (this._sortOrder == SortOrder.INCREASING) { + if (this._sortOrder === SortOrder.INCREASING) { this._sortOrder = SortOrder.DECREASING; - } else if (this._sortOrder == SortOrder.DECREASING) { + } else if (this._sortOrder === SortOrder.DECREASING) { this._sortOrder = SortOrder.NONE; } else { this._sortOrder = SortOrder.INCREASING; @@ -297,113 +305,113 @@ export default class DataCol extends ContainerObject { } private updateView(): void { - let dataString = ""; + let dataString = ''; let boardData: string[] = []; - let board_exp_data: any[] = []; + let boardExpData: any[] = []; - let pairs_length = 0; + let pairsLength = 0; if (this._pairsArray != null) { for (let pair of this._pairsArray) { if (pair >= 0) { - pairs_length++; + pairsLength++; } } - pairs_length /= 2; + pairsLength /= 2; } for (let ii = this._offset; ii < this._offset + this._numDisplay; ii++) { if (ii >= this._rawData.length) { - dataString += "\n"; + dataString += '\n'; } else { let rawstr = Utility.stripHtmlTags(`${this._rawData[ii]}`); // trace(rawstr); switch (this.category) { - case DesignCategory.Sequence: - boardData.push(rawstr); - board_exp_data.push(this._feedback[ii]); + case DesignCategory.SEQUENCE: + boardData.push(rawstr); + boardExpData.push(this._feedback[ii]); - break; + break; - case DesignCategory.Votes: - if (this._rawData[ii] >= 0) { - dataString += `${rawstr}\n`; - } else { - dataString += "-\n"; - } - break; + case DesignCategory.VOTES: + if (this._rawData[ii] >= 0) { + dataString += `${rawstr}\n`; + } else { + dataString += '-\n'; + } + break; - case DesignCategory.My_Votes: - if (this._rawData[ii] >= 0) { - dataString += `${rawstr}\n`; - } else { - dataString += "-\n"; - } + case DesignCategory.MY_VOTES: + if (this._rawData[ii] >= 0) { + dataString += `${rawstr}\n`; + } else { + dataString += '-\n'; + } - break; + break; - case DesignCategory.Synthesis_score: - let exp: Feedback = null; - if (this._feedback != null) { - exp = this._feedback[ii]; - } + case DesignCategory.SYNTHESIS_SCORE: { + let exp: Feedback = null; + if (this._feedback != null) { + exp = this._feedback[ii]; + } - if (exp == null) { - dataString += "-\n"; - } else { - let brent_data: any = exp.brentTheoData; - if (brent_data != null) { - dataString += `${Utility.roundTo(brent_data["score"], 3)}x`; - dataString += ` (${Utility.roundTo(brent_data["ribo_without_theo"], 3)} / ${Utility.roundTo(brent_data["ribo_with_theo"], 3)})\n`; - } else if (this._rawData[ii] >= 0) { - dataString += `${rawstr} / 100\n`; - } else if (this._rawData[ii] < 0) { - dataString += `${Feedback.EXPDISPLAYS[Feedback.EXPCODES.indexOf(this._rawData[ii])]}\n`; + if (exp == null) { + dataString += '-\n'; } else { - dataString += "-\n"; + let brentData: any = exp.brentTheoData; + if (brentData != null) { + dataString += `${Utility.roundTo(brentData['score'], 3)}x`; + dataString += ` (${Utility.roundTo(brentData['ribo_without_theo'], 3)} / ${Utility.roundTo(brentData['ribo_with_theo'], 3)})\n`; + } else if (this._rawData[ii] >= 0) { + dataString += `${rawstr} / 100\n`; + } else if (this._rawData[ii] < 0) { + dataString += `${Feedback.EXPDISPLAYS[Feedback.EXPCODES.indexOf(this._rawData[ii])]}\n`; + } else { + dataString += '-\n'; + } } + break; } - break; + case DesignCategory.TITLE: + dataString += `${rawstr}\n`; + break; - case DesignCategory.Title: - dataString += `${rawstr}\n`; - break; + case DesignCategory.MELTING_POINT: + dataString += `${rawstr} 'C\n`; + break; - case DesignCategory.Melting_Point: - dataString += `${rawstr} 'C\n`; - break; + case DesignCategory.FREE_ENERGY: + dataString += `${rawstr} kcal\n`; + break; - case DesignCategory.Free_Energy: - dataString += `${rawstr} kcal\n`; - break; + case DesignCategory.GU_PAIRS: + if (pairsLength > 0) { + dataString += `${rawstr} (${Math.round(this._rawData[ii] / pairsLength * 100)}%)\n`; + } else { + dataString += `${rawstr}\n`; + } + break; - case DesignCategory.GU_Pairs: - if (pairs_length > 0) { - dataString += `${rawstr} (${Math.round(this._rawData[ii] / pairs_length * 100)}%)\n`; - } else { - dataString += `${rawstr}\n`; - } - break; + case DesignCategory.GC_PAIRS: + if (pairsLength > 0) { + dataString += `${rawstr} (${Math.round(this._rawData[ii] / pairsLength * 100)}%)\n`; + } else { + dataString += `${rawstr}\n`; + } + break; - case DesignCategory.GC_Pairs: - if (pairs_length > 0) { - dataString += `${rawstr} (${Math.round(this._rawData[ii] / pairs_length * 100)}%)\n`; - } else { - dataString += `${rawstr}\n`; - } - break; + case DesignCategory.UA_PAIRS: + if (pairsLength > 0) { + dataString += `${rawstr} (${Math.round(this._rawData[ii] / pairsLength * 100)}%)\n`; + } else { + dataString += `${rawstr}\n`; + } + break; - case DesignCategory.UA_Pairs: - if (pairs_length > 0) { - dataString += `${rawstr} (${Math.round(this._rawData[ii] / pairs_length * 100)}%)\n`; - } else { + default: dataString += `${rawstr}\n`; - } - break; - - default: - dataString += `${rawstr}\n`; - break; + break; } } } @@ -412,21 +420,21 @@ export default class DataCol extends ContainerObject { if (boardData.length > 0) { if (this._showExp) { - this._sequencesView.set_sequences(boardData, board_exp_data, this._pairsArray); + this._sequencesView.setSequences(boardData, boardExpData, this._pairsArray); } else { - this._sequencesView.set_sequences(boardData, null, this._pairsArray); + this._sequencesView.setSequences(boardData, null, this._pairsArray); } this._sequencesView.position = new Point(11 + this._dataDisplay.width + 5, DataCol.DATA_H); } else { - this._sequencesView.set_sequences(null, null, null); + this._sequencesView.setSequences(null, null, null); } } private readonly _fontType: string; private readonly _fontSize: number; private readonly _sortable: boolean; - private readonly _data_type: DesignBrowserDataType; + private readonly _dataType: DesignBrowserDataType; private _graphics: Graphics; @@ -437,7 +445,7 @@ export default class DataCol extends ContainerObject { private _rawData: any[] = []; private _dataWidth: number; - private _line_height: number; + private _lineHeight: number; private _label: GameButton; private _labelArrow: Graphics; private _filterField1: TextInputObject; diff --git a/src/eterna/mode/DesignBrowser/DesignBrowserMode.ts b/src/eterna/mode/DesignBrowser/DesignBrowserMode.ts index fe02330d1..4c7eda17d 100644 --- a/src/eterna/mode/DesignBrowser/DesignBrowserMode.ts +++ b/src/eterna/mode/DesignBrowser/DesignBrowserMode.ts @@ -1,35 +1,35 @@ -import * as log from "loglevel"; -import MultiStyleText from "pixi-multistyle-text"; +import * as log from 'loglevel'; +import MultiStyleText from 'pixi-multistyle-text'; import { Container, Graphics, Point, Sprite, Text -} from "pixi.js"; -import {Flashbang, HAlign, VAlign} from "flashbang/core"; -import {HLayoutContainer} from "flashbang/layout"; -import {ContainerObject, SceneObject} from "flashbang/objects"; +} from 'pixi.js'; +import {Flashbang, HAlign, VAlign} from 'flashbang/core'; +import {HLayoutContainer} from 'flashbang/layout'; +import {ContainerObject, SceneObject} from 'flashbang/objects'; import { AlphaTask, CallbackTask, DelayTask, LocationTask, RepeatingTask, SerialTask -} from "flashbang/tasks"; -import {DisplayUtil, Easing, MathUtil} from "flashbang/util"; -import EPars from "eterna/EPars"; -import Eterna from "eterna/Eterna"; -import Feedback from "eterna/Feedback"; -import {Puzzle, Solution, SolutionManager} from "eterna/puzzle"; -import {BitmapManager, Bitmaps} from "eterna/resources"; +} from 'flashbang/tasks'; +import {DisplayUtil, Easing, MathUtil} from 'flashbang/util'; +import EPars from 'eterna/EPars'; +import Eterna from 'eterna/Eterna'; +import Feedback from 'eterna/Feedback'; +import {Puzzle, Solution, SolutionManager} from 'eterna/puzzle'; +import {BitmapManager, Bitmaps} from 'eterna/resources'; import { GameButton, GamePanel, HTMLTextObject, SliderBar, URLButton -} from "eterna/ui"; -import {Fonts, int} from "eterna/util"; -import {GameMode} from "eterna/mode"; -import CustomizeColumnOrderDialog from "./CustomizeColumnOrderDialog"; -import DataCol from "./DataCol"; -import DotLine from "./DotLine"; -import GridLines from "./GridLines"; -import MarkerBoxView from "./MarkerBoxView"; -import SelectionBox from "./SelectionBox"; -import SortOptions, {SortOrder} from "./SortOptions"; -import SortOptionsDialog from "./SortOptionsDialog"; -import ViewSolutionDialog from "./ViewSolutionDialog"; -import VoteProcessor from "./VoteProcessor"; +} from 'eterna/ui'; +import {Fonts, int} from 'eterna/util'; +import {GameMode} from 'eterna/mode'; +import CustomizeColumnOrderDialog from './CustomizeColumnOrderDialog'; +import DataCol from './DataCol'; +import DotLine from './DotLine'; +import GridLines from './GridLines'; +import MarkerBoxView from './MarkerBoxView'; +import SelectionBox from './SelectionBox'; +import SortOptions, {SortOrder} from './SortOptions'; +import SortOptionsDialog from './SortOptionsDialog'; +import ViewSolutionDialog from './ViewSolutionDialog'; +import VoteProcessor from './VoteProcessor'; export enum DesignBrowserDataType { INT = 0, @@ -38,21 +38,21 @@ export enum DesignBrowserDataType { } export enum DesignCategory { - Id = "Id", - Title = "Title", - Designer = "Designer", - Votes = "Votes", - My_Votes = "My Votes", - Description = "Description", - Round = "Round", - GC_Pairs = "GC Pairs", - UA_Pairs = "UA Pairs", - GU_Pairs = "GU Pairs", - Melting_Point = "Melting Point", - Free_Energy = "Free Energy", - Synthesized = "Synthesized", - Synthesis_score = "Synthesis score", - Sequence = "Sequence", + ID = 'Id', + TITLE = 'Title', + DESIGNER = 'Designer', + VOTES = 'Votes', + MY_VOTES = 'My Votes', + DESCRIPTION = 'Description', + ROUND = 'Round', + GC_PAIRS = 'GC Pairs', + UA_PAIRS = 'UA Pairs', + GU_PAIRS = 'GU Pairs', + MELTING_POINT = 'Melting Point', + FREE_ENERGY = 'Free Energy', + SYNTHESIZED = 'Synthesized', + SYNTHESIS_SCORE = 'Synthesis score', + SEQUENCE = 'Sequence', } function AllCategories(): DesignCategory[] { @@ -93,16 +93,16 @@ export default class DesignBrowserMode extends GameMode { const HMARGIN = 17; // the height of a line of text in the DataCol objects - let lineHeight = Fonts.arial("", 14).computeLineHeight(); + let lineHeight = Fonts.arial('', 14).computeLineHeight(); - this._votesText = new MultiStyleText("You have...", { + this._votesText = new MultiStyleText('You have...', { default: { fontFamily: Fonts.ARIAL, fontSize: 12, fill: 0xffffff }, bold: { - fontStyle: "bold", + fontStyle: 'bold', fill: 0xffcc00 } }); @@ -113,12 +113,12 @@ export default class DesignBrowserMode extends GameMode { this._votesPanel.display.position = new Point(0, -this._votesPanel.height - 2); this._vSlider = new SliderBar(true); - this._vSlider.set_progress(0); + this._vSlider.setProgress(0); this._vSlider.scrollChanged.connect(scrollValue => this.setScrollVertical(scrollValue)); this.addObject(this._vSlider, this._content); this._hSlider = new SliderBar(false); - this._hSlider.set_progress(0); + this._hSlider.setProgress(0); this._hSlider.scrollChanged.connect(scrollValue => this.setScrollHorizontal(scrollValue)); this.addObject(this._hSlider, this._content); @@ -167,21 +167,21 @@ export default class DesignBrowserMode extends GameMode { } let sortableCategories = [ - DesignCategory.Id, - DesignCategory.Title, - DesignCategory.Designer, - DesignCategory.Description, - DesignCategory.Round, - DesignCategory.GC_Pairs, - DesignCategory.UA_Pairs, - DesignCategory.GU_Pairs, - DesignCategory.Melting_Point, - DesignCategory.Free_Energy, - DesignCategory.Synthesis_score + DesignCategory.ID, + DesignCategory.TITLE, + DesignCategory.DESIGNER, + DesignCategory.DESCRIPTION, + DesignCategory.ROUND, + DesignCategory.GC_PAIRS, + DesignCategory.UA_PAIRS, + DesignCategory.GU_PAIRS, + DesignCategory.MELTING_POINT, + DesignCategory.FREE_ENERGY, + DesignCategory.SYNTHESIS_SCORE ]; if (!this._novote) { - sortableCategories.push(DesignCategory.Votes); - sortableCategories.push(DesignCategory.My_Votes); + sortableCategories.push(DesignCategory.VOTES); + sortableCategories.push(DesignCategory.MY_VOTES); } this._sortOptions = new SortOptions(sortableCategories); @@ -195,7 +195,7 @@ export default class DesignBrowserMode extends GameMode { .over(Bitmaps.ImgColoringOver) .down(Bitmaps.ImgColoringOver) .selected(Bitmaps.ImgColoringSelected) - .tooltip("Color sequences based on base colors as in the game."); + .tooltip('Color sequences based on base colors as in the game.'); this._letterColorButton.toggled.value = true; this.addObject(this._letterColorButton, this._toolbarLayout); this._letterColorButton.clicked.connect(() => this.setSequenceLetterColor()); @@ -205,7 +205,7 @@ export default class DesignBrowserMode extends GameMode { .over(Bitmaps.ImgFlaskOver) .down(Bitmaps.ImgFlaskOver) .selected(Bitmaps.ImgFlaskSelected) - .tooltip("Color sequences based on experimental data."); + .tooltip('Color sequences based on experimental data.'); this._expColorButton.toggled.value = false; this.addObject(this._expColorButton, this._toolbarLayout); this._expColorButton.clicked.connect(() => this.setSequenceExpColor()); @@ -216,7 +216,7 @@ export default class DesignBrowserMode extends GameMode { .up(Bitmaps.ImgEditSortOptions) .over(Bitmaps.ImgEditSortOptionsOver) .down(Bitmaps.ImgEditSortOptionsHit) - .tooltip("Editor sort options."); + .tooltip('Editor sort options.'); this.addObject(editSortBtn, this._toolbarLayout); editSortBtn.clicked.connect(() => this.showSortDialog()); @@ -226,7 +226,7 @@ export default class DesignBrowserMode extends GameMode { .up(Bitmaps.ImgColumns) .over(Bitmaps.ImgColumnsOver) .down(Bitmaps.ImgColumnsHit) - .tooltip("Select and reorder columns."); + .tooltip('Select and reorder columns.'); this.addObject(this._customizeButton, this._toolbarLayout); this._customizeButton.clicked.connect(() => this.showCustomizeColumnOrderDialog()); @@ -236,7 +236,7 @@ export default class DesignBrowserMode extends GameMode { .up(Bitmaps.ImgReturn) .over(Bitmaps.ImgReturnOver) .down(Bitmaps.ImgReturnHit) - .tooltip("Return to game."); + .tooltip('Return to game.'); this.addObject(this._returnToGameButton, this._toolbarLayout); this._returnToGameButton.clicked.connect(() => this.returnToGame()); @@ -280,9 +280,9 @@ export default class DesignBrowserMode extends GameMode { } public onMouseWheelEvent(e: WheelEvent): void { - if (!this.isDialogOrNotifShowing && e.deltaY != 0 && this._filteredSolutions != null) { + if (!this.isDialogOrNotifShowing && e.deltaY !== 0 && this._filteredSolutions != null) { const progress = (this._firstVisSolutionIdx + (e.deltaY * 0.25)) / this._filteredSolutions.length; - this._vSlider.set_progress(MathUtil.clamp(progress, 0, 1)); + this._vSlider.setProgress(MathUtil.clamp(progress, 0, 1)); } else { super.onMouseWheelEvent(e); } @@ -328,7 +328,9 @@ export default class DesignBrowserMode extends GameMode { super.enter(); this.refreshSolutions(); const {existingPoseEditMode} = Eterna.app; - this._returnToGameButton.display.visible = (existingPoseEditMode != null && existingPoseEditMode.puzzleID == this.puzzleID); + this._returnToGameButton.display.visible = ( + existingPoseEditMode != null && existingPoseEditMode.puzzleID === this.puzzleID + ); Eterna.chat.pushHideChat(); } @@ -342,7 +344,7 @@ export default class DesignBrowserMode extends GameMode { this._expColorButton.toggled.value = false; for (let dataCol of this._dataCols) { - if (dataCol.category == DesignCategory.Sequence) { + if (dataCol.category === DesignCategory.SEQUENCE) { dataCol.showExp = false; } } @@ -353,21 +355,24 @@ export default class DesignBrowserMode extends GameMode { this._expColorButton.toggled.value = true; for (let dataCol of this._dataCols) { - if (dataCol.category == DesignCategory.Sequence) { + if (dataCol.category === DesignCategory.SEQUENCE) { dataCol.showExp = true; } } } - private switchToPoseEditForSolution(solution: Solution): void { + private async switchToPoseEditForSolution(solution: Solution): Promise { this.pushUILock(); - Eterna.app.switchToPoseEdit(this._puzzle, false, {initSolution: solution, solutions: this._filteredSolutions.slice()}) - .then(() => this.popUILock()) - .catch((e) => { - log.error(e); - this.popUILock(); - }); + try { + await Eterna.app.switchToPoseEdit( + this._puzzle, false, {initSolution: solution, solutions: this._filteredSolutions.slice()} + ); + } catch (e) { + log.error(e); + } finally { + this.popUILock(); + } } private switchToFeedbackViewForSolution(solution: Solution): void { @@ -383,12 +388,12 @@ export default class DesignBrowserMode extends GameMode { private navigateToSolution(solution: Solution): void { this.closeCurDialog(); - window.open(`/node/${solution.nodeID}/edit`, "soleditwindow"); + window.open(`/node/${solution.nodeID}/edit`, 'soleditwindow'); } private sortOnSolution(solution: Solution): void { this.closeCurDialog(); - this._sortOptions.addCriteria(DesignCategory.Sequence, SortOrder.INCREASING, solution.sequence); + this._sortOptions.addCriteria(DesignCategory.SEQUENCE, SortOrder.INCREASING, solution.sequence); this.showSortDialog(); } @@ -404,7 +409,7 @@ export default class DesignBrowserMode extends GameMode { private unpublish(solution: Solution): void { this.pushUILock(); - let statusText = DesignBrowserMode.createStatusText("Deleting..."); + let statusText = DesignBrowserMode.createStatusText('Deleting...'); this.addObject(statusText, this.notifLayer); DisplayUtil.positionRelativeToStage(statusText.display, HAlign.CENTER, VAlign.CENTER, @@ -429,7 +434,7 @@ export default class DesignBrowserMode extends GameMode { private vote(solution: Solution): void { this.pushUILock(); - let statusText = DesignBrowserMode.createStatusText("Submitting..."); + let statusText = DesignBrowserMode.createStatusText('Submitting...'); this.addObject(statusText, this.notifLayer); DisplayUtil.positionRelativeToStage(statusText.display, HAlign.CENTER, VAlign.CENTER, @@ -441,12 +446,12 @@ export default class DesignBrowserMode extends GameMode { this.closeCurDialog(); }; - Eterna.client.toggleSolutionVote(solution.nodeID, this._puzzle.nodeID, solution.getProperty("My Votes")) + Eterna.client.toggleSolutionVote(solution.nodeID, this._puzzle.nodeID, solution.getProperty('My Votes')) .then((data) => { - this._voteProcessor.process_data(data["votes"]); - this.sync_votes(); + this._voteProcessor.processData(data['votes']); + this.syncVotes(); - let cheevs: any = data["new_achievements"]; + let cheevs: any = data['new_achievements']; if (cheevs != null) { this._achievements.awardAchievements(cheevs).then(() => { /* ignore result */ }); } @@ -552,11 +557,13 @@ export default class DesignBrowserMode extends GameMode { private showCustomizeColumnOrderDialog(): void { let disabledCategories = new Set(); if (this._novote) { - disabledCategories.add(DesignCategory.Votes); - disabledCategories.add(DesignCategory.My_Votes); + disabledCategories.add(DesignCategory.VOTES); + disabledCategories.add(DesignCategory.MY_VOTES); } - let dialog = this.showDialog(new CustomizeColumnOrderDialog(AllCategories(), this._categories, disabledCategories)); + let dialog = this.showDialog( + new CustomizeColumnOrderDialog(AllCategories(), this._categories, disabledCategories) + ); dialog.columnsReorganized.connect((columnNames) => { this._categories = columnNames; Eterna.settings.designBrowserColumnNames.value = columnNames; @@ -566,7 +573,7 @@ export default class DesignBrowserMode extends GameMode { } private updateSortOption(category: DesignCategory, sortOrder: SortOrder, sortArgs: any[] = null): void { - if (sortOrder != SortOrder.NONE) { + if (sortOrder !== SortOrder.NONE) { this._sortOptions.addCriteria(category, sortOrder, sortArgs); } else { this._sortOptions.removeCriteria(category); @@ -615,7 +622,7 @@ export default class DesignBrowserMode extends GameMode { } if (progress < 0) { - progress = this._vSlider.get_progress(); + progress = this._vSlider.getProgress(); } if (this._filteredSolutions != null) { @@ -635,11 +642,11 @@ export default class DesignBrowserMode extends GameMode { } private updateVotes(): void { - this._voteProcessor.update_votes(this._puzzle.nodeID, this._puzzle.round) - .then(() => this.sync_votes()); + this._voteProcessor.updateVotes(this._puzzle.nodeID, this._puzzle.round) + .then(() => this.syncVotes()); } - private sync_votes(): void { + private syncVotes(): void { let {votesLeft} = this._voteProcessor; let {round} = this._puzzle; let available: number = this._puzzle.numSubmissions; @@ -649,7 +656,7 @@ export default class DesignBrowserMode extends GameMode { this._votesText.text = `You have ${votesLeft} votes and ` + `${available - mySolutionTitles.length} solution slots left.`; } else { - this._votesText.text = "This puzzle has been cleared."; + this._votesText.text = 'This puzzle has been cleared.'; } const WMARGIN = 22; @@ -660,7 +667,7 @@ export default class DesignBrowserMode extends GameMode { } private rebuildDataColumns(filters: DesignBrowserFilter[] = null): void { - const FONT = "Arial"; + const FONT = 'Arial'; const FONT_SIZE = 14; if (this._dataCols != null) { @@ -671,36 +678,36 @@ export default class DesignBrowserMode extends GameMode { this._dataCols = []; for (let category of this._categories) { - if (this._novote && (category == DesignCategory.Votes || category == DesignCategory.My_Votes)) { + if (this._novote && (category === DesignCategory.VOTES || category === DesignCategory.MY_VOTES)) { continue; } let column: DataCol; switch (category) { - case DesignCategory.Title: - column = new DataCol(DesignBrowserDataType.STRING, category, 250, FONT, FONT_SIZE, true); - break; - case DesignCategory.Designer: - column = new DataCol(DesignBrowserDataType.STRING, category, 220, FONT, FONT_SIZE, true); - break; - case DesignCategory.Description: - column = new DataCol(DesignBrowserDataType.STRING, category, 300, FONT, FONT_SIZE, true); - break; - case DesignCategory.Sequence: - column = new DataCol(DesignBrowserDataType.STRING, category, 0, FONT, FONT_SIZE, false); - break; - case DesignCategory.Synthesized: - column = new DataCol(DesignBrowserDataType.STRING, category, 100, FONT, FONT_SIZE, true); - break; - case DesignCategory.Votes: - column = new DataCol(DesignBrowserDataType.NUMBER, category, 100, FONT, FONT_SIZE, true); - break; - case DesignCategory.Synthesis_score: - column = new DataCol(DesignBrowserDataType.NUMBER, category, 170, FONT, FONT_SIZE, true); - break; - default: - column = new DataCol(DesignBrowserDataType.NUMBER, category, 125, FONT, FONT_SIZE, true); - break; + case DesignCategory.TITLE: + column = new DataCol(DesignBrowserDataType.STRING, category, 250, FONT, FONT_SIZE, true); + break; + case DesignCategory.DESIGNER: + column = new DataCol(DesignBrowserDataType.STRING, category, 220, FONT, FONT_SIZE, true); + break; + case DesignCategory.DESCRIPTION: + column = new DataCol(DesignBrowserDataType.STRING, category, 300, FONT, FONT_SIZE, true); + break; + case DesignCategory.SEQUENCE: + column = new DataCol(DesignBrowserDataType.STRING, category, 0, FONT, FONT_SIZE, false); + break; + case DesignCategory.SYNTHESIZED: + column = new DataCol(DesignBrowserDataType.STRING, category, 100, FONT, FONT_SIZE, true); + break; + case DesignCategory.VOTES: + column = new DataCol(DesignBrowserDataType.NUMBER, category, 100, FONT, FONT_SIZE, true); + break; + case DesignCategory.SYNTHESIS_SCORE: + column = new DataCol(DesignBrowserDataType.NUMBER, category, 170, FONT, FONT_SIZE, true); + break; + default: + column = new DataCol(DesignBrowserDataType.NUMBER, category, 125, FONT, FONT_SIZE, true); + break; } column.setSize(this.contentWidth, this.contentHeight); @@ -712,7 +719,7 @@ export default class DesignBrowserMode extends GameMode { if (filters != null) { for (let filter of filters) { - if (filter.category == category) { + if (filter.category === category) { column.setFilter(filter.arg1, filter.arg2); break; } @@ -723,19 +730,19 @@ export default class DesignBrowserMode extends GameMode { this.layoutColumns(false); } - private setData(solutions: Solution[], animate: boolean, initialize_only: boolean = false): void { + private setData(solutions: Solution[], animate: boolean, initializeOnly: boolean = false): void { if (this._dataCols == null) { this.rebuildDataColumns(this._initialDataFilters); } - if (initialize_only) { + if (initializeOnly) { return; } let puz: Puzzle = this._puzzle; for (let dataCol of this._dataCols) { - let data_array: any[] = []; + let dataArray: any[] = []; let {category} = dataCol; let feedbacks: Feedback[] = []; @@ -748,39 +755,39 @@ export default class DesignBrowserMode extends GameMode { // single row of raw data let singleLineRawData: Solution = solutions[ii]; - if (category == DesignCategory.Sequence) { - data_array.push(singleLineRawData.sequence); - if (ii == 0) { + if (category === DesignCategory.SEQUENCE) { + dataArray.push(singleLineRawData.sequence); + if (ii === 0) { dataCol.setWidth(singleLineRawData.sequence.length * 16); dataCol.drawGridText(); } - } else if (category == DesignCategory.Description) { - let des = singleLineRawData.getProperty("Description"); + } else if (category === DesignCategory.DESCRIPTION) { + let des = singleLineRawData.getProperty('Description'); if (des.length < 45) { - data_array.push(des); + dataArray.push(des); } else { - data_array.push(`${des.substr(0, 40)}...`); + dataArray.push(`${des.substr(0, 40)}...`); } - } else if (category == DesignCategory.Title) { - let des = singleLineRawData.getProperty("Title"); + } else if (category === DesignCategory.TITLE) { + let des = singleLineRawData.getProperty('Title'); if (des.length < 30) { - data_array.push(des); + dataArray.push(des); } else { - data_array.push(`${des.substr(0, 25)}...`); + dataArray.push(`${des.substr(0, 25)}...`); } } else { let rawdata: any = singleLineRawData.getProperty(category); - data_array.push(rawdata); + dataArray.push(rawdata); } } - if (category == DesignCategory.Sequence || category == DesignCategory.Synthesis_score) { + if (category === DesignCategory.SEQUENCE || category === DesignCategory.SYNTHESIS_SCORE) { dataCol.expFeedback = feedbacks; } - dataCol.set_pairs(EPars.parenthesisToPairs(puz.getSecstruct())); + dataCol.setPairs(EPars.parenthesisToPairs(puz.getSecstruct())); // Setting and Displaying all raw data for each column - dataCol.set_data_and_display(data_array); + dataCol.setDataAndDisplay(dataArray); } this.refreshMarkingBoxes(); @@ -789,7 +796,7 @@ export default class DesignBrowserMode extends GameMode { private getSolutionIndex(solutionID: number): number { for (let ii = 0; ii < this._filteredSolutions.length; ii++) { - if (this._filteredSolutions[ii].nodeID == solutionID) { + if (this._filteredSolutions[ii].nodeID === solutionID) { return ii; } } @@ -806,7 +813,7 @@ export default class DesignBrowserMode extends GameMode { for (let ii = 0; ii < this._dataCols.length; ii++) { let col: DataCol = this._dataCols[ii]; if (animate) { - col.replaceNamedObject("AnimateLocation", + col.replaceNamedObject('AnimateLocation', new LocationTask(this._wholeRowWidth, 0, 0.5, Easing.easeOut)); } else { col.display.position = new Point(this._wholeRowWidth, 0); @@ -814,7 +821,7 @@ export default class DesignBrowserMode extends GameMode { this._wholeRowWidth += col.width; - if (ii % 2 == 0) { + if (ii % 2 === 0) { col.bgColor = 0x012034; } else { col.bgColor = 0x1A2F43; @@ -847,7 +854,7 @@ export default class DesignBrowserMode extends GameMode { private returnToGame(): void { const {existingPoseEditMode} = Eterna.app; - if (existingPoseEditMode != null && existingPoseEditMode.puzzleID == this.puzzleID) { + if (existingPoseEditMode != null && existingPoseEditMode.puzzleID === this.puzzleID) { this.pushUILock(); Eterna.app.switchToPoseEdit(this._puzzle, true) .then(() => this.popUILock()) @@ -893,28 +900,28 @@ export default class DesignBrowserMode extends GameMode { private _voteProcessor: VoteProcessor; private static readonly DEFAULT_COLUMNS: DesignCategory[] = [ - DesignCategory.Id, - DesignCategory.Title, - DesignCategory.Designer, - DesignCategory.Votes, - DesignCategory.My_Votes, - DesignCategory.Description, - DesignCategory.Round, - DesignCategory.GC_Pairs, - DesignCategory.UA_Pairs, - DesignCategory.GU_Pairs, - DesignCategory.Melting_Point, - DesignCategory.Free_Energy, - DesignCategory.Synthesized, - DesignCategory.Synthesis_score, - DesignCategory.Sequence + DesignCategory.ID, + DesignCategory.TITLE, + DesignCategory.DESIGNER, + DesignCategory.VOTES, + DesignCategory.MY_VOTES, + DesignCategory.DESCRIPTION, + DesignCategory.ROUND, + DesignCategory.GC_PAIRS, + DesignCategory.UA_PAIRS, + DesignCategory.GU_PAIRS, + DesignCategory.MELTING_POINT, + DesignCategory.FREE_ENERGY, + DesignCategory.SYNTHESIZED, + DesignCategory.SYNTHESIS_SCORE, + DesignCategory.SEQUENCE ]; } class MaskBox extends Graphics { public setSize(width: number, height: number): void { - if (this._width == width && this._height == height) { + if (this._width === width && this._height === height) { return; } diff --git a/src/eterna/mode/DesignBrowser/DotLine.ts b/src/eterna/mode/DesignBrowser/DotLine.ts index 6d7a729f0..3c0439b06 100644 --- a/src/eterna/mode/DesignBrowser/DotLine.ts +++ b/src/eterna/mode/DesignBrowser/DotLine.ts @@ -1,7 +1,7 @@ -import {Graphics} from "pixi.js"; +import {Graphics} from 'pixi.js'; export default class DotLine extends Graphics { - public constructor(thickness: number, color: number) { + constructor(thickness: number, color: number) { super(); this._thickness = thickness; this._color = color; @@ -12,7 +12,7 @@ export default class DotLine extends Graphics { } public set length(value: number) { - if (this._length == value) { + if (this._length === value) { return; } this._length = value; @@ -20,25 +20,25 @@ export default class DotLine extends Graphics { this.clear(); this.lineStyle(this._thickness, this._color); - let w_walker = 0; + let wWalker = 0; let index = 0; while (1) { - let len_to_go = 0; - if (index % 3 == 0) { - len_to_go = DotLine.LONG_LEN; + let lenToGo = 0; + if (index % 3 === 0) { + lenToGo = DotLine.LONG_LEN; } else { - len_to_go = DotLine.SHORT_LEN; + lenToGo = DotLine.SHORT_LEN; } - if (len_to_go + w_walker >= this._length) { - len_to_go = this._length - len_to_go; + if (lenToGo + wWalker >= this._length) { + lenToGo = this._length - lenToGo; break; } - this.moveTo(w_walker, 0); - this.lineTo(w_walker + len_to_go, 0); + this.moveTo(wWalker, 0); + this.lineTo(wWalker + lenToGo, 0); - w_walker += len_to_go + DotLine.SHORT_LEN; + wWalker += lenToGo + DotLine.SHORT_LEN; index++; } } diff --git a/src/eterna/mode/DesignBrowser/GridLines.ts b/src/eterna/mode/DesignBrowser/GridLines.ts index acc3b0a04..941d868c1 100644 --- a/src/eterna/mode/DesignBrowser/GridLines.ts +++ b/src/eterna/mode/DesignBrowser/GridLines.ts @@ -1,4 +1,4 @@ -import {Graphics} from "pixi.js"; +import {Graphics} from 'pixi.js'; // GridLines class written by Jerry Fu // Draws any number of lines covering the entire width of the design browser at a specified interval, diff --git a/src/eterna/mode/DesignBrowser/LabComments.ts b/src/eterna/mode/DesignBrowser/LabComments.ts index a15693996..bca59f860 100644 --- a/src/eterna/mode/DesignBrowser/LabComments.ts +++ b/src/eterna/mode/DesignBrowser/LabComments.ts @@ -1,35 +1,35 @@ -import Eterna from "eterna/Eterna"; -import {Utility} from "eterna/util"; +import Eterna from 'eterna/Eterna'; +import {Utility} from 'eterna/util'; export default class LabComments { constructor(nid: number) { - this._solution_nid = nid; - this._comments_data = []; + this._solutionNID = nid; + this._commentsData = []; } public update(): Promise { - return Eterna.client.getSolutionComments(this._solution_nid) + return Eterna.client.getSolutionComments(this._solutionNID) .then((data) => { - this._comments_data = data["data"]["comments"]; - return this._comments_data; + this._commentsData = data['data']['comments']; + return this._commentsData; }); } - public submit_comment(body: string): Promise { + public submitComment(body: string): Promise { body = Utility.stripHtmlTags(body); body = Utility.stripQuotationsAndNewlines(body); - return Eterna.client.submitSolutionComment(this._solution_nid, body) + return Eterna.client.submitSolutionComment(this._solutionNID, body) .then((data) => { - this._comments_data = data["data"]["comments"]; - return this._comments_data; + this._commentsData = data['data']['comments']; + return this._commentsData; }); } - public get_comments(): any[] { - return this._comments_data; + public getComments(): any[] { + return this._commentsData; } - private readonly _solution_nid: number; - private _comments_data: any[]; + private readonly _solutionNID: number; + private _commentsData: any[]; } diff --git a/src/eterna/mode/DesignBrowser/MarkerBoxView.ts b/src/eterna/mode/DesignBrowser/MarkerBoxView.ts index ef90105a3..217470a12 100644 --- a/src/eterna/mode/DesignBrowser/MarkerBoxView.ts +++ b/src/eterna/mode/DesignBrowser/MarkerBoxView.ts @@ -1,5 +1,5 @@ -import {Container, Point} from "pixi.js"; -import SelectionBox from "./SelectionBox"; +import {Container, Point} from 'pixi.js'; +import SelectionBox from './SelectionBox'; export default class MarkerBoxView extends Container { constructor(color: number, markerHeight: number) { @@ -50,7 +50,7 @@ export default class MarkerBoxView extends Container { public removeMarker(index: number): void { let removeIndex = -1; for (let ii = 0; ii < this._indices.length; ii++) { - if (index == this._indices[ii]) { + if (index === this._indices[ii]) { removeIndex = ii; break; } @@ -64,7 +64,7 @@ export default class MarkerBoxView extends Container { } public updateView(firstVisIdx: number): void { - if (this._markers == null || this._markers.length == 0) { + if (this._markers == null || this._markers.length === 0) { return; } diff --git a/src/eterna/mode/DesignBrowser/SelectionBox.ts b/src/eterna/mode/DesignBrowser/SelectionBox.ts index 8529492aa..591eaf342 100644 --- a/src/eterna/mode/DesignBrowser/SelectionBox.ts +++ b/src/eterna/mode/DesignBrowser/SelectionBox.ts @@ -1,7 +1,7 @@ -import {Graphics} from "pixi.js"; +import {Graphics} from 'pixi.js'; export default class SelectionBox extends Graphics { - public constructor(color: number) { + constructor(color: number) { super(); this._color = color; } diff --git a/src/eterna/mode/DesignBrowser/SequenceStringListView.ts b/src/eterna/mode/DesignBrowser/SequenceStringListView.ts index a9158f5f8..8de60f3bb 100644 --- a/src/eterna/mode/DesignBrowser/SequenceStringListView.ts +++ b/src/eterna/mode/DesignBrowser/SequenceStringListView.ts @@ -1,15 +1,15 @@ import { Container, Graphics, Sprite, Texture -} from "pixi.js"; -import {TextBuilder, TextureUtil} from "flashbang/util"; -import EPars from "eterna/EPars"; -import Eterna from "eterna/Eterna"; -import ExpPainter from "eterna/ExpPainter"; -import Feedback from "eterna/Feedback"; -import {EternaTextureUtil} from "eterna/util"; +} from 'pixi.js'; +import {TextBuilder, TextureUtil} from 'flashbang/util'; +import EPars from 'eterna/EPars'; +import Eterna from 'eterna/Eterna'; +import ExpPainter from 'eterna/ExpPainter'; +import Feedback from 'eterna/Feedback'; +import {EternaTextureUtil} from 'eterna/util'; export default class SequenceStringListView extends Container { - public constructor(fontname: string, fontsize: number, fontbold: boolean, letterWidth: number, letterHeight: number) { + constructor(fontname: string, fontsize: number, fontbold: boolean, letterWidth: number, letterHeight: number) { super(); this._letterWidth = letterWidth; @@ -24,10 +24,10 @@ export default class SequenceStringListView extends Container { .color(0xffffff) .bold(fontbold); - this._letterTextures = SequenceStringListView.createLetterBitmaps(textBuilder, "A") - .concat(SequenceStringListView.createLetterBitmaps(textBuilder, "U")) - .concat(SequenceStringListView.createLetterBitmaps(textBuilder, "G")) - .concat(SequenceStringListView.createLetterBitmaps(textBuilder, "C")); + this._letterTextures = SequenceStringListView.createLetterBitmaps(textBuilder, 'A') + .concat(SequenceStringListView.createLetterBitmaps(textBuilder, 'U')) + .concat(SequenceStringListView.createLetterBitmaps(textBuilder, 'G')) + .concat(SequenceStringListView.createLetterBitmaps(textBuilder, 'C')); } public setSize(width: number, height: number): void { @@ -35,7 +35,7 @@ export default class SequenceStringListView extends Container { this._height = height; } - public set_sequences(sequences: string[], exp_data: Feedback[], pairs: number[]): void { + public setSequences(sequences: string[], expData: Feedback[], pairs: number[]): void { this._graphics.clear(); if (this._content != null) { this._content.destroy({children: true}); @@ -49,35 +49,37 @@ export default class SequenceStringListView extends Container { this._content = new Container(); this.addChild(this._content); - let use_exp: boolean = exp_data != null; + let useExp: boolean = expData != null; for (let ii = 0; ii < sequences.length; ii++) { let seq: string = sequences[ii]; - let shape_data: number[] = null; - let shape_data_start = 0; - let exp_painter: ExpPainter = null; - let is_there_shape_threshold = false; - let shape_threshold = 0; - let shape_max = 0; - - if (exp_data != null && exp_data[ii] != null) { - shape_data = exp_data[ii].getShapeData(); - shape_data_start = exp_data[ii].getShapeStartIndex(); + let shapeData: number[] = null; + let shapeDataStart = 0; + let expPainter: ExpPainter = null; + let isThereShapeThreshold = false; + let shapeThreshold = 0; + let shapeMax = 0; + + if (expData != null && expData[ii] != null) { + shapeData = expData[ii].getShapeData(); + shapeDataStart = expData[ii].getShapeStartIndex(); } - if (shape_data != null) { - shape_data = ExpPainter.transformData(exp_data[ii].getShapeData(), exp_data[ii].getShapeMax(), exp_data[ii].getShapeMin()); - is_there_shape_threshold = true; - shape_threshold = exp_data[ii].getShapeThreshold(); - shape_max = exp_data[ii].getShapeMax(); - - exp_painter = new ExpPainter(shape_data, shape_data_start); - exp_painter.continuous = Eterna.settings.useContinuousColors.value; - exp_painter.extendedScale = Eterna.settings.useExtendedColors.value; + if (shapeData != null) { + shapeData = ExpPainter.transformData( + expData[ii].getShapeData(), expData[ii].getShapeMax(), expData[ii].getShapeMin() + ); + isThereShapeThreshold = true; + shapeThreshold = expData[ii].getShapeThreshold(); + shapeMax = expData[ii].getShapeMax(); + + expPainter = new ExpPainter(shapeData, shapeDataStart); + expPainter.continuous = Eterna.settings.useContinuousColors.value; + expPainter.extendedScale = Eterna.settings.useExtendedColors.value; } for (let jj = 0; jj < seq.length; jj++) { - if (ii == 0 && exp_data != null) { + if (ii === 0 && expData != null) { if (pairs[jj] < 0) { this._graphics.beginFill(0xCCCC00, 0.5); } else { @@ -93,38 +95,40 @@ export default class SequenceStringListView extends Container { this._graphics.endFill(); } - let letter_index = 0; - let letter: string = seq.charAt(jj); - - if (letter == "A") { - letter_index = SequenceStringListView.A_INDEX; - } else if (letter == "U") { - letter_index = SequenceStringListView.U_INDEX; - } else if (letter == "G") { - letter_index = SequenceStringListView.G_INDEX; - } else if (letter == "C") { - letter_index = SequenceStringListView.C_INDEX; + let letterIndex = 0; + let letter = seq.charAt(jj); + + if (letter === 'A') { + letterIndex = SequenceStringListView.A_INDEX; + } else if (letter === 'U') { + letterIndex = SequenceStringListView.U_INDEX; + } else if (letter === 'G') { + letterIndex = SequenceStringListView.G_INDEX; + } else if (letter === 'C') { + letterIndex = SequenceStringListView.C_INDEX; } - let bd_index = 0; + let bdIndex = 0; - if (!use_exp) { - bd_index = letter_index * SequenceStringListView.NUM_DATA_PER_LETTER; - } else if (shape_data == null || jj < shape_data_start || jj >= shape_data.length + shape_data_start) { - bd_index = letter_index * SequenceStringListView.NUM_DATA_PER_LETTER + ExpPainter.NUM_COLORS * 3 + 1 + 1; + if (!useExp) { + bdIndex = letterIndex * SequenceStringListView.NUM_DATA_PER_LETTER; + } else if (shapeData == null || jj < shapeDataStart || jj >= shapeData.length + shapeDataStart) { + bdIndex = ( + letterIndex * SequenceStringListView.NUM_DATA_PER_LETTER + ExpPainter.NUM_COLORS * 3 + 1 + 1 + ); } else { - let color_index = 0; + let colorIndex = 0; - if (is_there_shape_threshold) { - color_index = exp_painter.getColorLevelWithMidpoint(jj, shape_threshold, shape_max); + if (isThereShapeThreshold) { + colorIndex = expPainter.getColorLevelWithMidpoint(jj, shapeThreshold, shapeMax); } else { - color_index = exp_painter.getColorLevel(jj); + colorIndex = expPainter.getColorLevel(jj); } - bd_index = letter_index * SequenceStringListView.NUM_DATA_PER_LETTER + 1 + color_index; + bdIndex = letterIndex * SequenceStringListView.NUM_DATA_PER_LETTER + 1 + colorIndex; } - let letterSprite = new Sprite(this._letterTextures[bd_index]); + let letterSprite = new Sprite(this._letterTextures[bdIndex]); letterSprite.x = jj * this._letterWidth; letterSprite.y = ii * this._letterHeight; this._content.addChild(letterSprite); @@ -138,21 +142,21 @@ export default class SequenceStringListView extends Container { let tf = textBuilder.text(letter).build(); let tfTex = TextureUtil.renderToTexture(tf); - let color = EPars.getLetterColor(letter); + let baseColor = EPars.getLetterColor(letter); textures.push(EternaTextureUtil.colorTransform( tfTex, - color / (256 * 256), - (color % (256 * 256)) / 256, - color % 256, 0, 0, 0 + baseColor / (256 * 256), + (baseColor % (256 * 256)) / 256, + baseColor % 256, 0, 0, 0 )); for (let ii = -ExpPainter.NUM_COLORS; ii <= 2 * ExpPainter.NUM_COLORS + 1; ii++) { - let color = ExpPainter.getColorByLevel(ii); + let expColor = ExpPainter.getColorByLevel(ii); textures.push(EternaTextureUtil.colorTransform( tfTex, - color / (256 * 256), - (color % (256 * 256)) / 256, - color % 256, 0, 0, 0 + expColor / (256 * 256), + (expColor % (256 * 256)) / 256, + expColor % 256, 0, 0, 0 )); } diff --git a/src/eterna/mode/DesignBrowser/SolutionDescBox.ts b/src/eterna/mode/DesignBrowser/SolutionDescBox.ts index 741e38a53..6e2302274 100644 --- a/src/eterna/mode/DesignBrowser/SolutionDescBox.ts +++ b/src/eterna/mode/DesignBrowser/SolutionDescBox.ts @@ -1,19 +1,20 @@ -import MultiStyleText from "pixi-multistyle-text"; -import {Point, Text} from "pixi.js"; -import {HAlign} from "flashbang/core"; -import {HLayoutContainer, VLayoutContainer} from "flashbang/layout"; -import {SceneObject} from "flashbang/objects"; -import {AlphaTask, RepeatingTask, SerialTask} from "flashbang/tasks"; -import Eterna from "eterna/Eterna"; -import Feedback from "eterna/Feedback"; -import {EternaURL} from "eterna/net"; -import {Puzzle, Solution} from "eterna/puzzle"; +import MultiStyleText from 'pixi-multistyle-text'; +import {Point, Text} from 'pixi.js'; +import {HAlign} from 'flashbang/core'; +import {HLayoutContainer, VLayoutContainer} from 'flashbang/layout'; +import {SceneObject} from 'flashbang/objects'; +import {AlphaTask, RepeatingTask, SerialTask} from 'flashbang/tasks'; +import {Assert} from 'flashbang/util'; +import Eterna from 'eterna/Eterna'; +import Feedback from 'eterna/Feedback'; +import {EternaURL} from 'eterna/net'; +import {Puzzle, Solution} from 'eterna/puzzle'; import { GameButton, GamePanel, GamePanelType, HTMLTextObject, TextInputObject, VScrollBox -} from "eterna/ui"; -import {Fonts, Utility} from "eterna/util"; -import {CopyTextDialogMode, GameMode} from "eterna/mode"; -import LabComments from "./LabComments"; +} from 'eterna/ui'; +import {Fonts, Utility} from 'eterna/util'; +import {CopyTextDialogMode, GameMode} from 'eterna/mode'; +import LabComments from './LabComments'; export default class SolutionDescBox extends GamePanel { constructor(solution: Solution, puzzle: Puzzle) { @@ -28,7 +29,7 @@ export default class SolutionDescBox extends GamePanel { super.added(); const boxTitleText = `${Utility.stripHtmlTags(this._solution.title)} by ${Utility.stripHtmlTags(this._solution.playerName)}`; this._boxTitle = new HTMLTextObject(boxTitleText).font(Fonts.ARIAL).fontSize(16).selectable(false) @@ -36,41 +37,47 @@ export default class SolutionDescBox extends GamePanel { this._boxTitle.display.position = new Point(20, 20); this.addObject(this._boxTitle, this.container); - this._copySolutionButton = new GameButton().label("Get URL for this design", 10); + this._copySolutionButton = new GameButton().label('Get URL for this design', 10); this._copySolutionButton.display.position = new Point(20, 45); this.addObject(this._copySolutionButton, this.container); const solutionURL = Eterna.SERVER_URL + EternaURL.createURL({ - page: "browse_solution", + page: 'browse_solution', puznid: this._puzzle.nodeID, - filter1: "Id", + filter1: 'Id', + // TODO: Update website so that these can be camelcase + /* eslint-disable @typescript-eslint/camelcase */ filter1_arg1: this._solution.nodeID, filter1_arg2: this._solution.nodeID + /* eslint-enable @typescript-eslint/camelcase */ }); this._copySolutionButton.clicked.connect( - () => this.modeStack.pushMode(new CopyTextDialogMode(solutionURL, "Solution URL")) + () => this.modeStack.pushMode(new CopyTextDialogMode(solutionURL, 'Solution URL')) ); - this._copyPlayerButton = new GameButton().label("Get URL for all designs by this player", 10); + this._copyPlayerButton = new GameButton().label('Get URL for all designs by this player', 10); this._copyPlayerButton.display.position = new Point(20 + this._copySolutionButton.container.width + 10, 45); this.addObject(this._copyPlayerButton, this.container); const playerURL = Eterna.SERVER_URL + EternaURL.createURL({ - page: "browse_player", + page: 'browse_player', puznid: this._puzzle.nodeID, - filter1: "Designer", + filter1: 'Designer', + // TODO: Update website so that these can be camelcase + /* eslint-disable @typescript-eslint/camelcase */ filter1_arg1: this._solution.playerName + /* eslint-enable @typescript-eslint/camelcase */ }); this._copyPlayerButton.clicked.connect( - () => this.modeStack.pushMode(new CopyTextDialogMode(playerURL, "Player URL")) + () => this.modeStack.pushMode(new CopyTextDialogMode(playerURL, 'Player URL')) ); this._commentInput = new TextInputObject(14) - .placeholderText("Enter your comment here") + .placeholderText('Enter your comment here') .showFakeTextInputWhenNotFocused(); this.addObject(this._commentInput, this.container); - this._commentButton = new GameButton().label("Post", 14); + this._commentButton = new GameButton().label('Post', 14); this._commentButton.clicked.connect(() => this.submitComment()); this.addObject(this._commentButton, this.container); @@ -79,7 +86,7 @@ export default class SolutionDescBox extends GamePanel { this._commentInput.display.visible = false; this._commentButton.display.visible = false; - let loadingText = SolutionDescBox.createLoadingText("Loading comments..."); + let loadingText = SolutionDescBox.createLoadingText('Loading comments...'); loadingText.display.position = new Point( (this._width - loadingText.display.width) * 0.5, this._height - 30 @@ -91,7 +98,7 @@ export default class SolutionDescBox extends GamePanel { this._commentInput.display.visible = true; this._commentButton.display.visible = true; - this._commentInput.text = ""; + this._commentInput.text = ''; this.updateDescriptionAndComments(commentsData); }); @@ -106,12 +113,14 @@ export default class SolutionDescBox extends GamePanel { pxdelta = e.deltaY; break; case WheelEvent.DOM_DELTA_LINE: - // 13 -> body font size + // 13 -> body font size pxdelta = e.deltaY * 13; break; case WheelEvent.DOM_DELTA_PAGE: pxdelta = e.deltaY * this._height; break; + default: + throw new Error('Unhandled scroll delta mode'); } this._descriptionAndComments.scrollTo( @@ -171,12 +180,16 @@ export default class SolutionDescBox extends GamePanel { let commentLayout = new HLayoutContainer(4); layout.addChild(commentLayout); - let url = EternaURL.createURL({page: "player", uid: comment["uid"]}); - let userButton = new GameButton().label(comment["name"], 10); - userButton.clicked.connect(() => window.open(url, "_blank")); + let url = EternaURL.createURL({page: 'player', uid: comment['uid']}); + let userButton = new GameButton().label(comment['name'], 10); + + // eslint-disable-next-line no-loop-func + userButton.clicked.connect(() => window.open(url, '_blank')); this._descriptionAndComments.addObject(userButton, commentLayout); - let comm = Fonts.arial(comment["comment"], 13).color(0xffffff).wordWrap(true, this._width - 40).build(); + let comm = Fonts.arial( + comment['comment'], 13 + ).color(0xffffff).wordWrap(true, this._width - 40).build(); this._descriptionAndCommentsTexts.push(comm); commentLayout.addChild(comm); } @@ -192,28 +205,28 @@ export default class SolutionDescBox extends GamePanel { } private submitComment(): void { - if (this._commentInput.text == "") { - (this.mode as GameMode).showNotification("You cannot post an empty comment"); + if (this._commentInput.text === '') { + (this.mode as GameMode).showNotification('You cannot post an empty comment'); return; } this._commentInput.display.visible = false; this._commentButton.display.visible = false; - let submittingText = SolutionDescBox.createLoadingText("Submitting your comment..."); + let submittingText = SolutionDescBox.createLoadingText('Submitting your comment...'); this.addObject(submittingText, this.container); submittingText.display.position = new Point( (this._width - submittingText.display.width) * 0.5, this._height - 30 ); - this._comments.submit_comment(this._commentInput.text) + this._comments.submitComment(this._commentInput.text) .then((commentsData) => { submittingText.destroySelf(); this._commentInput.display.visible = true; this._commentButton.display.visible = true; - this._commentInput.text = ""; + this._commentInput.text = ''; this.updateDescriptionAndComments(commentsData); }); @@ -229,30 +242,31 @@ export default class SolutionDescBox extends GamePanel { } private getSolutionText(solution: Solution, puzzle: Puzzle): MultiStyleText { - let text = ""; + let text = ''; if (solution.expFeedback != null) { - if (solution.expFeedback.isFailed() == 0) { - text += "[SYNTHESIZED!]\n" - + "This design was synthesized with score " - + `${solution.getProperty("Synthesis score")} / 100\n\n`; + if (solution.expFeedback.isFailed() === 0) { + text += '[SYNTHESIZED!]\n' + + 'This design was synthesized with score ' + + `${solution.getProperty('Synthesis score')} / 100\n\n`; } else { let failureIdx = Feedback.EXPCODES.indexOf(solution.expFeedback.isFailed()); text += `${Feedback.EXPDISPLAYS_LONG[failureIdx] } Score : ${Feedback.EXPSCORES[failureIdx]} / 100\n\n`; } - } else if (solution.getProperty("Synthesized") == "y") { - text += "[WAITING]\n" - + "This design is being synthesized and waiting for results. \n\n"; - } else if (solution.getProperty("Round") < puzzle.round) { - text += "[OLD]\n" - + "This design was submitted in round " - + `${solution.getProperty("Round")}.` - + " You can't vote on designs from previous rounds. But you can use or resubmit this design by clicking on " - + "\"Modify\".\n\n"; + } else if (solution.getProperty('Synthesized') === 'y') { + text += '[WAITING]\n' + + 'This design is being synthesized and waiting for results. \n\n'; + } else if (solution.getProperty('Round') < puzzle.round) { + text += '[OLD]\n' + + 'This design was submitted in round ' + + `${solution.getProperty('Round')}.` + + " You can't vote on designs from previous rounds." + + 'But you can use or resubmit this design by clicking on ' + + '"Modify".\n\n'; } - text += "Design description\n\n"; + text += 'Design description\n\n'; text += Utility.stripHtmlTags(solution.fullDescription); return new MultiStyleText(text, { @@ -263,7 +277,7 @@ export default class SolutionDescBox extends GamePanel { wordWrap: true, wordWrapWidth: this._width - 40 }, - bold: {fontStyle: "bold"}, + bold: {fontStyle: 'bold'}, orange: {fill: 0xffcc00} }); } diff --git a/src/eterna/mode/DesignBrowser/SortOptions.ts b/src/eterna/mode/DesignBrowser/SortOptions.ts index b0f95fd4d..c0ee2c2e1 100644 --- a/src/eterna/mode/DesignBrowser/SortOptions.ts +++ b/src/eterna/mode/DesignBrowser/SortOptions.ts @@ -1,7 +1,7 @@ -import {Arrays} from "flashbang/util"; -import {UnitSignal} from "signals"; -import {Solution} from "eterna/puzzle"; -import {DesignCategory} from "./DesignBrowserMode"; +import {Arrays} from 'flashbang/util'; +import {UnitSignal} from 'signals'; +import {Solution} from 'eterna/puzzle'; +import {DesignCategory} from './DesignBrowserMode'; export enum SortOrder { INCREASING = 1, @@ -14,7 +14,7 @@ export class SortCriterion { public sortOrder: SortOrder; public arg: string; - public constructor(category: DesignCategory, order: SortOrder, arg: string = null) { + constructor(category: DesignCategory, order: SortOrder, arg: string = null) { this.category = category; this.sortOrder = order; this.arg = arg; @@ -25,8 +25,8 @@ export default class SortOptions { /** Emitted when any of our sort options have changed */ public readonly sortChanged = new UnitSignal(); - public constructor(validCategories: DesignCategory[]) { - if (validCategories == null || validCategories.length == 0) { + constructor(validCategories: DesignCategory[]) { + if (validCategories == null || validCategories.length === 0) { throw new Error("Sort names length can't be 0"); } @@ -62,31 +62,31 @@ export default class SortOptions { let aProperty: any; let bProperty: any; - if (criterion.category == DesignCategory.Sequence) { - let anchor_sequence: string = criterion.arg; - let a_string: string = a.sequence; - if (a_string == null) throw new Error(`solution ${a.nodeID} invalid`); - let b_string: string = b.sequence; - if (b_string == null) throw new Error(`solution ${b.nodeID} invalid`); - if (a_string.length != anchor_sequence.length || b_string.length != anchor_sequence.length) { - throw new Error("Wrong anchor sequence length"); + if (criterion.category === DesignCategory.SEQUENCE) { + let anchorSequence: string = criterion.arg; + let aString: string = a.sequence; + if (aString == null) throw new Error(`solution ${a.nodeID} invalid`); + let bString: string = b.sequence; + if (bString == null) throw new Error(`solution ${b.nodeID} invalid`); + if (aString.length !== anchorSequence.length || bString.length !== anchorSequence.length) { + throw new Error('Wrong anchor sequence length'); } - let a_score = 0; - let b_score = 0; + let aScore = 0; + let bScore = 0; - for (let jj = 0; jj < a_string.length; jj++) { - if (a_string.charAt(jj) != anchor_sequence.charAt(jj)) { - a_score++; + for (let jj = 0; jj < aString.length; jj++) { + if (aString.charAt(jj) !== anchorSequence.charAt(jj)) { + aScore++; } - if (b_string.charAt(jj) != anchor_sequence.charAt(jj)) { - b_score++; + if (bString.charAt(jj) !== anchorSequence.charAt(jj)) { + bScore++; } } - aProperty = a_score; - bProperty = b_score; + aProperty = aScore; + bProperty = bScore; } else { aProperty = a.getProperty(criterion.category); bProperty = b.getProperty(criterion.category); diff --git a/src/eterna/mode/DesignBrowser/SortOptionsDialog.ts b/src/eterna/mode/DesignBrowser/SortOptionsDialog.ts index a9530b184..edb5b1df1 100644 --- a/src/eterna/mode/DesignBrowser/SortOptionsDialog.ts +++ b/src/eterna/mode/DesignBrowser/SortOptionsDialog.ts @@ -1,16 +1,16 @@ import { Container, Graphics, Point, Text -} from "pixi.js"; -import {HAlign, VAlign} from "flashbang/core"; -import {HLayoutContainer, VLayoutContainer} from "flashbang/layout"; -import {Arrays, DisplayUtil} from "flashbang/util"; -import {Bitmaps} from "eterna/resources"; +} from 'pixi.js'; +import {HAlign, VAlign} from 'flashbang/core'; +import {HLayoutContainer, VLayoutContainer} from 'flashbang/layout'; +import {Arrays, DisplayUtil} from 'flashbang/util'; +import {Bitmaps} from 'eterna/resources'; import { Dialog, FixedWidthTextField, GameButton, GamePanel, GamePanelType -} from "eterna/ui"; -import {Fonts, GraphicsUtil} from "eterna/util"; -import {DesignCategory} from "./DesignBrowserMode"; -import SortOptions, {SortOrder} from "./SortOptions"; +} from 'eterna/ui'; +import {Fonts, GraphicsUtil} from 'eterna/util'; +import {DesignCategory} from './DesignBrowserMode'; +import SortOptions, {SortOrder} from './SortOptions'; export default class SortOptionsDialog extends Dialog { public readonly options: SortOptions; @@ -42,7 +42,7 @@ export default class SortOptionsDialog extends Dialog { this._curCategoryText = new FixedWidthTextField( this.options.validCategories[0], - Fonts.arial("", 17).color(0xffffff).style, + Fonts.arial('', 17).color(0xffffff).style, 140, HAlign.CENTER ); addCriterionLayout.addChild(this._curCategoryText); @@ -53,11 +53,11 @@ export default class SortOptionsDialog extends Dialog { addCriterionLayout.addHSpacer(10); - this._toggleCurSortOrderButton = new GameButton().label("increasing", 15); + this._toggleCurSortOrderButton = new GameButton().label('increasing', 15); this._toggleCurSortOrderButton.clicked.connect(() => this.toggleCurrentSortOrder()); this.addObject(this._toggleCurSortOrderButton, addCriterionLayout); - this._addCriterionButton = new GameButton().label("Add", 15); + this._addCriterionButton = new GameButton().label('Add', 15); this._addCriterionButton.clicked.connect(() => this.addCurrentCriteria()); this.addObject(this._addCriterionButton, addCriterionLayout); @@ -65,7 +65,7 @@ export default class SortOptionsDialog extends Dialog { this._panelContent.addVSpacer(20); - let okButton = new GameButton().label("Ok", 20); + let okButton = new GameButton().label('Ok', 20); okButton.clicked.connect(() => this.close(null)); this.addObject(okButton, this._panelContent); @@ -90,7 +90,7 @@ export default class SortOptionsDialog extends Dialog { ui.container.addChild(ui.categoryText); ui.sortOrderButton = new GameButton() - .label(sortOrder === SortOrder.INCREASING ? "increasing" : "decreasing", 15); + .label(sortOrder === SortOrder.INCREASING ? 'increasing' : 'decreasing', 15); ui.sortOrderButton.clicked.connect(() => this.toggleSort(category)); ui.sortOrderButton.display.position = new Point(180, 0); this.addObject(ui.sortOrderButton, ui.container); @@ -116,10 +116,10 @@ export default class SortOptionsDialog extends Dialog { this.options.addCriteria(category, order, args); if (curIdx >= 0) { - if (order == SortOrder.INCREASING) { - this._criteriaUI[curIdx].sortOrderButton.label("increasing", 15); + if (order === SortOrder.INCREASING) { + this._criteriaUI[curIdx].sortOrderButton.label('increasing', 15); } else { - this._criteriaUI[curIdx].sortOrderButton.label("decreasing", 15); + this._criteriaUI[curIdx].sortOrderButton.label('decreasing', 15); } if (curIdx > 0) { @@ -151,10 +151,10 @@ export default class SortOptionsDialog extends Dialog { private toggleCurrentSortOrder(): void { this._addCriteriaSortOrder *= -1; - if (this._addCriteriaSortOrder == SortOrder.INCREASING) { - this._toggleCurSortOrderButton.label("increasing", 15); + if (this._addCriteriaSortOrder === SortOrder.INCREASING) { + this._toggleCurSortOrderButton.label('increasing', 15); } else { - this._toggleCurSortOrderButton.label("decreasing", 15); + this._toggleCurSortOrderButton.label('decreasing', 15); } } @@ -203,10 +203,10 @@ export default class SortOptionsDialog extends Dialog { let newSortOrder = this.options.toggleSort(category); let ui = this._criteriaUI[index]; - if (newSortOrder == SortOrder.INCREASING) { - ui.sortOrderButton.label("increasing", 15); + if (newSortOrder === SortOrder.INCREASING) { + ui.sortOrderButton.label('increasing', 15); } else { - ui.sortOrderButton.label("decreasing", 15); + ui.sortOrderButton.label('decreasing', 15); } } diff --git a/src/eterna/mode/DesignBrowser/ViewSolutionDialog.ts b/src/eterna/mode/DesignBrowser/ViewSolutionDialog.ts index f6ea1aab1..a39f5c60a 100644 --- a/src/eterna/mode/DesignBrowser/ViewSolutionDialog.ts +++ b/src/eterna/mode/DesignBrowser/ViewSolutionDialog.ts @@ -1,20 +1,20 @@ import { Container, Graphics, Point, Sprite, Text -} from "pixi.js"; -import {Flashbang, HAlign, VAlign} from "flashbang/core"; -import {HLayoutContainer} from "flashbang/layout"; -import {DisplayUtil, MathUtil} from "flashbang/util"; -import {UnitSignal} from "signals"; -import EPars from "eterna/EPars"; -import Eterna from "eterna/Eterna"; -import ExpPainter from "eterna/ExpPainter"; -import {Puzzle, Solution} from "eterna/puzzle"; -import {Bitmaps} from "eterna/resources"; +} from 'pixi.js'; +import {Flashbang, HAlign, VAlign} from 'flashbang/core'; +import {HLayoutContainer} from 'flashbang/layout'; +import {DisplayUtil, MathUtil} from 'flashbang/util'; +import {UnitSignal} from 'signals'; +import EPars from 'eterna/EPars'; +import Eterna from 'eterna/Eterna'; +import ExpPainter from 'eterna/ExpPainter'; +import {Puzzle, Solution} from 'eterna/puzzle'; +import {Bitmaps} from 'eterna/resources'; import { Dialog, GameButton, GamePanel, PoseThumbnail, PoseThumbnailType -} from "eterna/ui"; -import {Fonts} from "eterna/util"; -import SolutionDescBox from "./SolutionDescBox"; +} from 'eterna/ui'; +import {Fonts} from 'eterna/util'; +import SolutionDescBox from './SolutionDescBox'; export default class ViewSolutionDialog extends Dialog { public readonly playClicked = new UnitSignal(); @@ -24,7 +24,7 @@ export default class ViewSolutionDialog extends Dialog { public readonly editClicked = new UnitSignal(); public readonly deleteClicked = new UnitSignal(); - public constructor(solution: Solution, puzzle: Puzzle, voteDisabled: boolean) { + constructor(solution: Solution, puzzle: Puzzle, voteDisabled: boolean) { super(); this._solution = solution; this._puzzle = puzzle; @@ -49,16 +49,18 @@ export default class ViewSolutionDialog extends Dialog { EPars.parenthesisToPairs(this._puzzle.getSecstruct()), 3, PoseThumbnailType.BASE_COLORED); let playButton = new ThumbnailAndTextButton() - .text("View/Copy") + .text('View/Copy') .thumbnail(playThumbnail) - .tooltip("Click to view this design in the game.\nYou can also modify the design and create a new one."); + .tooltip('Click to view this design in the game.\nYou can also modify the design and create a new one.'); playButton.clicked.connect(() => this.playClicked.emit()); this.addObject(playButton, this._actionButtonsLayout); if (this._solution.expFeedback != null && this._solution.expFeedback.isFailed() === 0) { // SEE RESULT (allowed if the solution is synthesized) let expdata = this._solution.expFeedback; - let shapeData = ExpPainter.transformData(expdata.getShapeData(), expdata.getShapeMax(), expdata.getShapeMin()); + let shapeData = ExpPainter.transformData( + expdata.getShapeData(), expdata.getShapeMax(), expdata.getShapeMin() + ); let resultThumbnail = new Sprite(); PoseThumbnail.drawToSprite( resultThumbnail, @@ -73,50 +75,53 @@ export default class ViewSolutionDialog extends Dialog { ); let seeResultButton = new ThumbnailAndTextButton() - .text("See Result") + .text('See Result') .thumbnail(resultThumbnail) - .tooltip("Click to see the experimental result!"); + .tooltip('Click to see the experimental result!'); seeResultButton.clicked.connect(() => this.seeResultClicked.emit()); this.addObject(seeResultButton, this._actionButtonsLayout); - } else { + } else if ( + this._solution.getProperty('Synthesized') === 'n' + && this._solution.getProperty('Round') === this._puzzle.round + ) { // VOTE (disallowed is solution is synthesized or old) - if (this._solution.getProperty("Synthesized") === "n" && this._solution.getProperty("Round") == this._puzzle.round) { - let voteButton = new ThumbnailAndTextButton(); - if (this._solution.getProperty("My Votes") == 0) { - voteButton - .thumbnail(Sprite.fromImage(Bitmaps.ImgVotes)) - .text("Vote") - .tooltip("Vote on this design."); - } else { - let rotatedSprite = Sprite.fromImage(Bitmaps.ImgVotes); - rotatedSprite.rotation = MathUtil.deg2Rad * 180; - let thumbnail = new Container(); - thumbnail.addChild(rotatedSprite); - voteButton - .thumbnail(thumbnail) - .text("Unvote") - .tooltip("Take back your vote on this design."); - } - voteButton.clicked.connect(() => this.voteClicked.emit()); - this.addObject(voteButton, this._actionButtonsLayout); + let voteButton = new ThumbnailAndTextButton(); + if (this._solution.getProperty('My Votes') === 0) { + voteButton + .thumbnail(Sprite.fromImage(Bitmaps.ImgVotes)) + .text('Vote') + .tooltip('Vote on this design.'); + } else { + let rotatedSprite = Sprite.fromImage(Bitmaps.ImgVotes); + rotatedSprite.rotation = MathUtil.deg2Rad * 180; + let thumbnail = new Container(); + thumbnail.addChild(rotatedSprite); + voteButton + .thumbnail(thumbnail) + .text('Unvote') + .tooltip('Take back your vote on this design.'); } + voteButton.clicked.connect(() => this.voteClicked.emit()); + this.addObject(voteButton, this._actionButtonsLayout); } let sortImage = Sprite.fromImage(Bitmaps.ImgNextInside); sortImage.scale = new Point(0.3, 0.3); let sortButton = new ThumbnailAndTextButton() - .text("Sort") + .text('Sort') .thumbnail(sortImage) - .tooltip("Sort based on similarity to this design."); + .tooltip('Sort based on similarity to this design.'); sortButton.clicked.connect(() => this.sortClicked.emit()); this.addObject(sortButton, this._actionButtonsLayout); // DELETE (only allowed if the puzzle belongs to us and has no votes) - if (this._solution.getProperty("Round") == this._puzzle.round - && this._solution.playerID == Eterna.playerID - && this._solution.getProperty("Votes") === 0) { + if ( + this._solution.getProperty('Round') === this._puzzle.round + && this._solution.playerID === Eterna.playerID + && this._solution.getProperty('Votes') === 0 + ) { let deleteButton = new ThumbnailAndTextButton() - .text("Delete") + .text('Delete') .thumbnail(new Graphics() .beginFill(0, 0) .lineStyle(2, 0xC0DCE7) @@ -126,19 +131,19 @@ export default class ViewSolutionDialog extends Dialog { .lineTo(65, 65) .moveTo(65, 10) .lineTo(10, 65)) - .tooltip("Delete this design to retrieve your slots for this round"); + .tooltip('Delete this design to retrieve your slots for this round'); deleteButton.clicked.connect(() => this.deleteClicked.emit()); this.addObject(deleteButton, this._actionButtonsLayout); } this._actionButtonsLayout.layout(); - this._cancelButton = new GameButton().label("Cancel", 12); + this._cancelButton = new GameButton().label('Cancel', 12); this.addObject(this._cancelButton, this._content); this._cancelButton.clicked.connect(() => this.close(null)); if (Eterna.DEV_MODE) { - this._editButton = new GameButton().label("Edit", 12); + this._editButton = new GameButton().label('Edit', 12); this.addObject(this._editButton, this._content); this._editButton.clicked.connect(() => this.editClicked.emit()); } @@ -204,7 +209,7 @@ export default class ViewSolutionDialog extends Dialog { } class ThumbnailAndTextButton extends GameButton { - public constructor() { + constructor() { super(); this._view = new Container(); @@ -217,7 +222,7 @@ class ThumbnailAndTextButton extends GameButton { .endFill(); this._view.addChild(this._bgFrame); - this._textField = Fonts.arial("", 14).bold().color(0xffffff).build(); + this._textField = Fonts.arial('', 14).bold().color(0xffffff).build(); this._view.addChild(this._textField); this.allStates(this._view); diff --git a/src/eterna/mode/DesignBrowser/VoteProcessor.ts b/src/eterna/mode/DesignBrowser/VoteProcessor.ts index 9702af15c..07a2894fa 100644 --- a/src/eterna/mode/DesignBrowser/VoteProcessor.ts +++ b/src/eterna/mode/DesignBrowser/VoteProcessor.ts @@ -1,9 +1,9 @@ -import Eterna from "eterna/Eterna"; -import {SolutionManager} from "eterna/puzzle"; -import {int} from "eterna/util"; +import Eterna from 'eterna/Eterna'; +import {SolutionManager} from 'eterna/puzzle'; +import {int} from 'eterna/util'; export default class VoteProcessor { - public process_data(data: any[]): void { + public processData(data: any[]): void { let solutionIDs: number[] = []; let voteCounts: number[] = []; let myVoteCounts: number[] = []; @@ -14,26 +14,26 @@ export default class VoteProcessor { for (let ii = data.length - 1; ii >= 0; ii--) { let obj: any = data[ii]; - let nid = Number(obj["solnid"]); - let is_mine: boolean = Eterna.playerID == Number(obj["uid"]); - let vote_count: number = int(obj["count"]); + let nid = Number(obj['solnid']); + let isMine: boolean = Eterna.playerID === Number(obj['uid']); + let voteCount: number = int(obj['count']); let index = solutionIDs.indexOf(nid); if (index < 0) { solutionIDs.push(nid); - voteCounts.push(vote_count); - if (is_mine) { - myVoteCounts.push(vote_count); - totalMyVotes += vote_count; + voteCounts.push(voteCount); + if (isMine) { + myVoteCounts.push(voteCount); + totalMyVotes += voteCount; } else { myVoteCounts.push(0); } } else { - voteCounts[index] += vote_count; - if (is_mine) { - myVoteCounts[index] += vote_count; - totalMyVotes += vote_count; + voteCounts[index] += voteCount; + if (isMine) { + myVoteCounts[index] += voteCount; + totalMyVotes += voteCount; } } } @@ -52,10 +52,10 @@ export default class VoteProcessor { return this._votesLeft; } - public update_votes(puznid: number, round: number): Promise { + public updateVotes(puznid: number, round: number): Promise { return Eterna.client.getPuzzleVotes(puznid, round).then((json) => { - let data: any = json["data"]; - this.process_data(data["votes"]); + let data: any = json['data']; + this.processData(data['votes']); }); } diff --git a/src/eterna/mode/DesignBrowser/index.ts b/src/eterna/mode/DesignBrowser/index.ts index 58f6e0622..7148d2de8 100644 --- a/src/eterna/mode/DesignBrowser/index.ts +++ b/src/eterna/mode/DesignBrowser/index.ts @@ -1,16 +1,16 @@ -export {default as CustomizeColumnOrderDialog} from "./CustomizeColumnOrderDialog"; -export {default as DataCol} from "./DataCol"; +export {default as CustomizeColumnOrderDialog} from './CustomizeColumnOrderDialog'; +export {default as DataCol} from './DataCol'; export { default as DesignBrowserMode, DesignBrowserDataType, DesignCategory, DesignBrowserFilter -} from "./DesignBrowserMode"; -export {default as DotLine} from "./DotLine"; -export {default as GridLines} from "./GridLines"; -export {default as LabComments} from "./LabComments"; -export {default as MarkerBoxView} from "./MarkerBoxView"; -export {default as SelectionBox} from "./SelectionBox"; -export {default as SequenceStringListView} from "./SequenceStringListView"; -export {default as SolutionDescBox} from "./SolutionDescBox"; -export {default as SortOptions, SortOrder, SortCriterion} from "./SortOptions"; -export {default as SortOptionsDialog} from "./SortOptionsDialog"; -export {default as ViewSolutionDialog} from "./ViewSolutionDialog"; -export {default as VoteProcessor} from "./VoteProcessor"; +} from './DesignBrowserMode'; +export {default as DotLine} from './DotLine'; +export {default as GridLines} from './GridLines'; +export {default as LabComments} from './LabComments'; +export {default as MarkerBoxView} from './MarkerBoxView'; +export {default as SelectionBox} from './SelectionBox'; +export {default as SequenceStringListView} from './SequenceStringListView'; +export {default as SolutionDescBox} from './SolutionDescBox'; +export {default as SortOptions, SortOrder, SortCriterion} from './SortOptions'; +export {default as SortOptionsDialog} from './SortOptionsDialog'; +export {default as ViewSolutionDialog} from './ViewSolutionDialog'; +export {default as VoteProcessor} from './VoteProcessor'; diff --git a/src/eterna/mode/ErrorDialogMode.ts b/src/eterna/mode/ErrorDialogMode.ts index f3f83bd67..cb167557d 100644 --- a/src/eterna/mode/ErrorDialogMode.ts +++ b/src/eterna/mode/ErrorDialogMode.ts @@ -1,14 +1,14 @@ -import {Graphics, Point} from "pixi.js"; -import {Flashbang, HAlign, AppMode} from "flashbang/core"; -import {VLayoutContainer} from "flashbang/layout"; -import {ErrorUtil} from "flashbang/util"; -import {GameButton, GamePanel, GamePanelType} from "eterna/ui"; -import {Fonts} from "eterna/util"; +import {Graphics, Point} from 'pixi.js'; +import {Flashbang, HAlign, AppMode} from 'flashbang/core'; +import {VLayoutContainer} from 'flashbang/layout'; +import {ErrorUtil} from 'flashbang/util'; +import {GameButton, GamePanel, GamePanelType} from 'eterna/ui'; +import {Fonts} from 'eterna/util'; export default class ErrorDialogMode extends AppMode { public readonly error: any; - public constructor(error: any) { + constructor(error: any) { super(); this.error = error; } @@ -22,12 +22,12 @@ export default class ErrorDialogMode extends AppMode { this.container.addChild(bg); let panel = new GamePanel(GamePanelType.NORMAL, 1.0, 0x152843, 0.27, 0xC0DCE7); - panel.title = "Fatal Error!"; + panel.title = 'Fatal Error!'; this.addObject(panel, this.container); let panelLayout = new VLayoutContainer(0, HAlign.CENTER); panel.container.addChild(panelLayout); - panelLayout.addChild(Fonts.arial("", 15) + panelLayout.addChild(Fonts.arial('', 15) .text(ErrorUtil.getErrString(this.error, false)) .color(0xC0DCE7) .wordWrap(true, 300) @@ -35,7 +35,7 @@ export default class ErrorDialogMode extends AppMode { panelLayout.addVSpacer(20); - let okButton = new GameButton().label("OK", 16); + let okButton = new GameButton().label('OK', 16); panel.addObject(okButton, panelLayout); okButton.clicked.connect(() => this.modeStack.removeMode(this)); diff --git a/src/eterna/mode/FeedbackViewMode.ts b/src/eterna/mode/FeedbackViewMode.ts index 6cd17c540..fb4316907 100644 --- a/src/eterna/mode/FeedbackViewMode.ts +++ b/src/eterna/mode/FeedbackViewMode.ts @@ -1,25 +1,30 @@ -import * as log from "loglevel"; -import {DisplayObject, Point, Text} from "pixi.js"; -import {HAlign, VAlign} from "flashbang/core"; -import {KeyboardEventType, KeyCode} from "flashbang/input"; -import {DisplayUtil} from "flashbang/util"; -import Constants from "eterna/Constants"; -import EPars from "eterna/EPars"; -import Eterna from "eterna/Eterna"; -import Feedback from "eterna/Feedback"; -import UndoBlock from "eterna/UndoBlock"; -import {Folder, FolderManager, Vienna} from "eterna/folding"; -import {GameMode} from "eterna/mode"; -import {PoseField} from "eterna/pose2D"; -import {Puzzle, Solution} from "eterna/puzzle"; +import * as log from 'loglevel'; +import {DisplayObject, Point, Text} from 'pixi.js'; +import {HAlign, VAlign} from 'flashbang/core'; +import {KeyboardEventType, KeyCode} from 'flashbang/input'; +import {DisplayUtil} from 'flashbang/util'; +import Constants from 'eterna/Constants'; +import EPars from 'eterna/EPars'; +import Eterna from 'eterna/Eterna'; +import Feedback from 'eterna/Feedback'; +import UndoBlock from 'eterna/UndoBlock'; +import {Folder, FolderManager, Vienna} from 'eterna/folding'; +import {GameMode} from 'eterna/mode'; +import {PoseField} from 'eterna/pose2D'; +import {Puzzle, Solution} from 'eterna/puzzle'; import { EternaViewOptionsDialog, EternaViewOptionsMode, SpecBoxDialog, URLButton, Toolbar, ToolbarType -} from "eterna/ui"; -import {Fonts, Utility} from "eterna/util"; -import {Background} from "eterna/vfx"; +} from 'eterna/ui'; +import {Fonts, Utility} from 'eterna/util'; +import {Background} from 'eterna/vfx'; + +enum PoseFoldMode { + ESTIMATE = 'ESTIMATE', + TARGET = 'TARGET', +} export default class FeedbackViewMode extends GameMode { - public constructor(solution: Solution, puzzle: Puzzle) { + constructor(solution: Solution, puzzle: Puzzle) { super(); this._solution = solution; this._puzzle = puzzle; @@ -39,7 +44,7 @@ export default class FeedbackViewMode extends GameMode { this._puzzleTitle.position = new Point(33, 8); this.uiLayer.addChild(this._puzzleTitle); - this._title = Fonts.arial("", 12).color(0xffffff).bold().build(); + this._title = Fonts.arial('', 12).color(0xffffff).bold().build(); this._title.position = new Point(33, 30); this.uiLayer.addChild(this._title); @@ -86,12 +91,16 @@ export default class FeedbackViewMode extends GameMode { let poseFields: PoseField[] = []; for (let ii = 0; ii < secstructs.length; ii++) { let secs: string = secstructs[ii]; - if (secs != null && secs.length != this._sequence.length) { - log.warn("Solution secondary structure and sequence length doesn't match", secs.length, this._sequence.length); + if (secs != null && secs.length !== this._sequence.length) { + log.warn( + "Solution secondary structure and sequence length doesn't match", + secs.length, + this._sequence.length + ); if (secs.length < this._sequence.length) { let diff: number = this._sequence.length - secs.length; for (let jj = 0; jj < diff; ++jj) { - secs += "."; + secs += '.'; } } else { secs = secs.slice(0, this._sequence.length); @@ -117,8 +126,8 @@ export default class FeedbackViewMode extends GameMode { this.setupShape(); - let see_shape: boolean = (this._feedback.getShapeData() != null); - if (see_shape) { + let seeShape: boolean = (this._feedback.getShapeData() != null); + if (seeShape) { this.showExperimentalColors(); } @@ -175,28 +184,32 @@ export default class FeedbackViewMode extends GameMode { } /* override */ - protected onSetPip(pip_mode: boolean): void { - if (pip_mode) { + protected onSetPip(pipMode: boolean): void { + if (pipMode) { if (this._toolbar.stateToggle != null) { this._toolbar.stateToggle.display.visible = false; } - if (this._foldMode == PoseFoldMode.ESTIMATE) { + if (this._foldMode === PoseFoldMode.ESTIMATE) { this.setToEstimateMode(); } else { this.setToTargetMode(); } - let min_zoom = -1; + let minZoom = -1; for (let pose of this._poses) { - min_zoom = Math.max(min_zoom, pose.computeDefaultZoomLevel()); + minZoom = Math.max(minZoom, pose.computeDefaultZoomLevel()); } for (let ii = 0; ii < this._poses.length; ii++) { let field: PoseField = this._poseFields[ii]; if (this._targetConditions[ii] != null) { - if (this._targetConditions[ii]["type"] == "aptamer") { - field.pose.setMolecularBinding(this._targetConditions[ii]["site"], this._targetConditions[ii]["binding_pairs"], this._targetConditions[ii]["bonus"] / 100.0); + if (this._targetConditions[ii]['type'] === 'aptamer') { + field.pose.setMolecularBinding( + this._targetConditions[ii]['site'], + this._targetConditions[ii]['binding_pairs'], + this._targetConditions[ii]['bonus'] / 100.0 + ); } else { field.pose.setMolecularBinding(null, null, null); } @@ -206,7 +219,7 @@ export default class FeedbackViewMode extends GameMode { } for (let pose of this._poses) { - pose.setZoomLevel(min_zoom, true, true); + pose.setZoomLevel(minZoom, true, true); } if (this._isExpColor) { @@ -301,12 +314,16 @@ export default class FeedbackViewMode extends GameMode { } } - private changeTarget(target_index: number): void { - this._currentIndex = target_index; + private changeTarget(targetIndex: number): void { + this._currentIndex = targetIndex; if (this._targetConditions[this._currentIndex] != null) { - if (this._targetConditions[this._currentIndex]["type"] == "aptamer") { - this._poseFields[0].pose.setMolecularBinding(this._targetConditions[this._currentIndex]["site"], this._targetConditions[this._currentIndex]["binding_pairs"], this._targetConditions[this._currentIndex]["bonus"] / 100.0); + if (this._targetConditions[this._currentIndex]['type'] === 'aptamer') { + this._poseFields[0].pose.setMolecularBinding( + this._targetConditions[this._currentIndex]['site'], + this._targetConditions[this._currentIndex]['binding_pairs'], + this._targetConditions[this._currentIndex]['bonus'] / 100.0 + ); } else { this._poseFields[0].pose.setMolecularBinding(null, null, null); } @@ -314,7 +331,7 @@ export default class FeedbackViewMode extends GameMode { this._poseFields[0].pose.setMolecularBinding(null, null, 0); } - if (this._foldMode == PoseFoldMode.ESTIMATE) { + if (this._foldMode === PoseFoldMode.ESTIMATE) { this.setToEstimateMode(); } else { this.setToTargetMode(); @@ -363,16 +380,16 @@ export default class FeedbackViewMode extends GameMode { } private scoreFeedback(): void { - let titleText = ""; + let titleText = ''; let brentData: any = this._feedback.brentTheoData; let score: number; if (brentData != null) { // / Brent's theophylline data titleText += (`${this._solution.title}\n`); - titleText += `Cleavage suppression : x ${Utility.roundTo(brentData["score"], 2)}\n`; - titleText += `(Cleavage without Theophylline molecule : ${Utility.roundTo(brentData["ribo_without_theo"], 2)}`; - titleText += ` / with Theophylline : ${Utility.roundTo(brentData["ribo_with_theo"], 2)})`; + titleText += `Cleavage suppression : x ${Utility.roundTo(brentData['score'], 2)}\n`; + titleText += `(Cleavage without Theophylline molecule : ${Utility.roundTo(brentData['ribo_without_theo'], 2)}`; + titleText += ` / with Theophylline : ${Utility.roundTo(brentData['ribo_with_theo'], 2)})`; } else { // / Default fallback to usual SHAPE data if (Eterna.DEV_MODE) { @@ -384,16 +401,16 @@ export default class FeedbackViewMode extends GameMode { this._feedback.getShapeThreshold(this._currentIndex), this._feedback.getShapeMax(this._currentIndex) ); - titleText += (`${this._solution.title}\n` + `Synthesis score : ${score} / 100`); + titleText += (`${this._solution.title}\nSynthesis score : ${score} / 100`); } else { - titleText += (`${this._solution.title}\n` + `Synthesis score : ${this._solution.getProperty("Synthesis score")} / 100`); + titleText += (`${this._solution.title}\nSynthesis score : ${this._solution.getProperty('Synthesis score')} / 100`); } if (this._targetConditions.length > 1) { - titleText += "\n("; + titleText += '\n('; for (let ii = 0; ii < this._targetConditions.length; ii++) { if (ii > 0) { - titleText += ", "; + titleText += ', '; } score = Feedback.scoreFeedback( @@ -407,7 +424,7 @@ export default class FeedbackViewMode extends GameMode { titleText += `state ${ii + 1} : ${score} / 100`; } - titleText += ")"; + titleText += ')'; } } this._title.text = titleText; @@ -420,38 +437,38 @@ export default class FeedbackViewMode extends GameMode { } private foldEstimate(index: number): void { - let shape_threshold: number = this._feedback.getShapeThreshold(index); - let shape_data: number[] = this._feedback.getShapeData(index); - let start_index: number = this._feedback.getShapeStartIndex(index); - let puzzle_locks: boolean[] = this._puzzle.puzzleLocks; - let shape_max: number = this._feedback.getShapeMax(index); - let shape_min: number = this._feedback.getShapeMin(index); - - let desired_pairs = ""; - - for (let ii = 0; ii < start_index; ii++) { - if (puzzle_locks[ii]) { - desired_pairs += "U0"; + let shapeThreshold: number = this._feedback.getShapeThreshold(index); + let shapeData: number[] = this._feedback.getShapeData(index); + let startIndex: number = this._feedback.getShapeStartIndex(index); + let {puzzleLocks} = this._puzzle; + let shapeMax: number = this._feedback.getShapeMax(index); + let shapeMin: number = this._feedback.getShapeMin(index); + + let desiredPairs = ''; + + for (let ii = 0; ii < startIndex; ii++) { + if (puzzleLocks[ii]) { + desiredPairs += 'U0'; } else { - desired_pairs += "P0"; + desiredPairs += 'P0'; } } - for (let ii = 0; ii < shape_data.length; ii++) { - if (ii + start_index >= this._sequence.length) { + for (let ii = 0; ii < shapeData.length; ii++) { + if (ii + startIndex >= this._sequence.length) { break; } - if (puzzle_locks[ii + start_index]) { - desired_pairs += "U0"; + if (puzzleLocks[ii + startIndex]) { + desiredPairs += 'U0'; continue; } - if (shape_data[ii] < shape_threshold) { - desired_pairs += "P"; + if (shapeData[ii] < shapeThreshold) { + desiredPairs += 'P'; let lev = 0; - if (Math.abs(shape_threshold - shape_min) > Constants.EPSILON) { - lev = (shape_threshold - shape_data[ii]) / (shape_threshold - shape_min); + if (Math.abs(shapeThreshold - shapeMin) > Constants.EPSILON) { + lev = (shapeThreshold - shapeData[ii]) / (shapeThreshold - shapeMin); if (lev >= 1) { lev = 0.95; } else if (lev < 0) { @@ -459,34 +476,34 @@ export default class FeedbackViewMode extends GameMode { } } - desired_pairs += Number(Math.floor(lev * 10)).toString(); - } else if (shape_data[ii] > shape_threshold) { - desired_pairs += "U"; + desiredPairs += Number(Math.floor(lev * 10)).toString(); + } else if (shapeData[ii] > shapeThreshold) { + desiredPairs += 'U'; let lev = 0; - if (Math.abs(shape_max - shape_threshold) > Constants.EPSILON) { - lev = (shape_data[ii] - shape_threshold) / (shape_max - shape_threshold); + if (Math.abs(shapeMax - shapeThreshold) > Constants.EPSILON) { + lev = (shapeData[ii] - shapeThreshold) / (shapeMax - shapeThreshold); if (lev >= 1) { lev = 0.95; } else if (lev < 0) { lev = 0; } } - desired_pairs += Number(Math.floor(lev * 10)).toString(); + desiredPairs += Number(Math.floor(lev * 10)).toString(); } else { - desired_pairs += "P0"; + desiredPairs += 'P0'; } } - for (let ii = shape_data.length + start_index; ii < this._sequence.length; ii++) { - if (puzzle_locks[ii]) { - desired_pairs += "U0"; + for (let ii = shapeData.length + startIndex; ii < this._sequence.length; ii++) { + if (puzzleLocks[ii]) { + desiredPairs += 'U0'; } else { - desired_pairs += "P0"; + desiredPairs += 'P0'; } } let folder: Folder = FolderManager.instance.getFolder(Vienna.NAME); - this._shapePairs[index] = folder.foldSequence(this._sequence, null, desired_pairs); + this._shapePairs[index] = folder.foldSequence(this._sequence, null, desiredPairs); } private loadDesignBrowser(): void { @@ -524,8 +541,3 @@ export default class FeedbackViewMode extends GameMode { private _targetConditions: any[]; private _isExpColor: boolean; } - -enum PoseFoldMode { - ESTIMATE = "ESTIMATE", - TARGET = "TARGET", -} diff --git a/src/eterna/mode/GameMode.ts b/src/eterna/mode/GameMode.ts index 3f631e405..9a2fa0e7a 100644 --- a/src/eterna/mode/GameMode.ts +++ b/src/eterna/mode/GameMode.ts @@ -1,18 +1,18 @@ -import * as log from "loglevel"; -import {Container, Point} from "pixi.js"; -import {Flashbang, AppMode, GameObjectRef} from "flashbang/core"; -import {SceneObject} from "flashbang/objects"; -import {AchievementManager} from "eterna/achievements"; -import Eterna from "eterna/Eterna"; -import {EternaURL} from "eterna/net"; -import {Pose2D, PoseField} from "eterna/pose2D"; +import * as log from 'loglevel'; +import {Container, Point} from 'pixi.js'; +import {Flashbang, AppMode, GameObjectRef} from 'flashbang/core'; +import {SceneObject} from 'flashbang/objects'; +import {AchievementManager} from 'eterna/achievements'; +import Eterna from 'eterna/Eterna'; +import {EternaURL} from 'eterna/net'; +import {Pose2D, PoseField} from 'eterna/pose2D'; import { ConfirmDialog, ContextMenu, Dialog, NotificationDialog, Tooltips, UILockDialog, URLButton -} from "eterna/ui"; -import {ExternalInterface, ExternalInterfaceCtx} from "eterna/util"; -import {Folder} from "eterna/folding"; -import UndoBlock from "eterna/UndoBlock"; -import EPars from "eterna/EPars"; +} from 'eterna/ui'; +import {ExternalInterface, ExternalInterfaceCtx} from 'eterna/util'; +import {Folder} from 'eterna/folding'; +import UndoBlock from 'eterna/UndoBlock'; +import EPars from 'eterna/EPars'; export default abstract class GameMode extends AppMode { public readonly bgLayer = new Container(); @@ -69,7 +69,7 @@ export default abstract class GameMode extends AppMode { /** Show a dialog. Removes any existing dialog. */ public showDialog(dialog: T): T { if (this._dialogRef.isLive) { - log.warn("Dialog already showing"); + log.warn('Dialog already showing'); this._dialogRef.destroyObject(); } @@ -87,7 +87,7 @@ export default abstract class GameMode extends AppMode { */ public showNotification(message: string, extraButtonTitle?: string): NotificationDialog { if (this._notifRef.isLive) { - log.warn("Notification already showing"); + log.warn('Notification already showing'); this._notifRef.destroyObject(); } @@ -96,7 +96,7 @@ export default abstract class GameMode extends AppMode { // Hide dialogs while a notification is showing this.dialogLayer.visible = false; - notif.destroyed.connect(() => this.dialogLayer.visible = true); + notif.destroyed.connect(() => { this.dialogLayer.visible = true; }); return notif; } @@ -117,7 +117,7 @@ export default abstract class GameMode extends AppMode { if (this._uiLockRef.isLive) { (this._uiLockRef.object as UILockDialog).releaseRef(name); } else { - log.warn("UILockDialog not currently active"); + log.warn('UILockDialog not currently active'); } } @@ -125,13 +125,13 @@ export default abstract class GameMode extends AppMode { return this._poseFields.length; } - public ropSetPip(pip_mode: boolean): void { - this.setPip(pip_mode); + public ropSetPip(pipMode: boolean): void { + this.setPip(pipMode); } protected registerScriptInterface(ctx: ExternalInterfaceCtx): void { if (this._modeScriptInterface != null) { - throw new Error("ExternalInterfaceCtx already registered for this mode"); + throw new Error('ExternalInterfaceCtx already registered for this mode'); } this._modeScriptInterface = ctx; @@ -155,21 +155,23 @@ export default abstract class GameMode extends AppMode { this._poseFields = []; this._poses = []; - newPoseFields.forEach((newPoseField, idx) => { - this._poseFields.push(newPoseField); - this._poses.push(newPoseField.pose); - newPoseField.pose.getEnergyDelta = () => { + newPoseFields.forEach((newField, idx) => { + this._poseFields.push(newField); + this._poses.push(newField.pose); + newField.pose.getEnergyDelta = () => { // Sanity check if (this._folder) { let poseidx = this._isPipMode ? idx : this._curTargetIndex; - let score = (pairs: number[]) => this._folder.scoreStructures(newPoseField.pose.fullSequence, pairs); + let score = (pairs: number[]) => this._folder.scoreStructures(newField.pose.fullSequence, pairs); // This changes between PoseEdit mode and PuzzleEditMode - let targetPairs: number[] = this._targetPairs ? this._targetPairs[poseidx] : this.getCurrentTargetPairs(poseidx); + let targetPairs: number[] = this._targetPairs + ? this._targetPairs[poseidx] : this.getCurrentTargetPairs(poseidx); let nativePairs: number[] = this.getCurrentUndoBlock(poseidx).getPairs(); - return score(EPars.getSatisfiedPairs(targetPairs, newPoseField.pose.fullSequence)) - score(nativePairs); + return score(EPars.getSatisfiedPairs(targetPairs, newField.pose.fullSequence)) + - score(nativePairs); } return -1; }; @@ -182,10 +184,10 @@ export default abstract class GameMode extends AppMode { this.setPip(!this._isPipMode); } - protected setPip(pip_mode: boolean): void { - this._isPipMode = pip_mode; + protected setPip(pipMode: boolean): void { + this._isPipMode = pipMode; this.layoutPoseFields(); - this.onSetPip(pip_mode); + this.onSetPip(pipMode); } protected layoutPoseFields(): void { @@ -211,11 +213,11 @@ export default abstract class GameMode extends AppMode { } } - protected onSetPip(pip_mode: boolean): void { + protected onSetPip(pipMode: boolean): void { } protected postScreenshot(screenshot: ArrayBuffer): void { - this.pushUILock("Screenshot"); + this.pushUILock('Screenshot'); Eterna.client.postScreenshot(screenshot) .then((filename) => { @@ -231,7 +233,7 @@ export default abstract class GameMode extends AppMode { this.showNotification(`There was an error posting the screenshot\n${err}`); }) ./* finally */then(() => { - this.popUILock("Screenshot"); + this.popUILock('Screenshot'); }); } @@ -272,7 +274,7 @@ export default abstract class GameMode extends AppMode { } protected static createHomeButton(): URLButton { - let button = new URLButton("Go to Home", EternaURL.createURL({page: "lab_bench"})); + let button = new URLButton('Go to Home', EternaURL.createURL({page: 'lab_bench'})); button.selectable(false); return button; } @@ -305,7 +307,7 @@ export default abstract class GameMode extends AppMode { } class ContextMenuDialog extends Dialog { - public constructor(menu: ContextMenu, menuLoc: Point) { + constructor(menu: ContextMenu, menuLoc: Point) { super(); this._menu = menu; this._menuLoc = menuLoc; diff --git a/src/eterna/mode/LoadingMode.ts b/src/eterna/mode/LoadingMode.ts index bf3effdd0..06c95c412 100644 --- a/src/eterna/mode/LoadingMode.ts +++ b/src/eterna/mode/LoadingMode.ts @@ -1,17 +1,17 @@ -import {Text} from "pixi.js"; -import {Flashbang, AppMode, ObjectTask} from "flashbang/core"; -import {ContainerObject} from "flashbang/objects"; +import {Text} from 'pixi.js'; +import {Flashbang, AppMode, ObjectTask} from 'flashbang/core'; +import {ContainerObject} from 'flashbang/objects'; import { DelayTask, RepeatingTask, ScaleTask, SerialTask -} from "flashbang/tasks"; -import {Easing} from "flashbang/util"; -import Eterna from "eterna/Eterna"; -import {Fonts} from "eterna/util"; -import {Background} from "eterna/vfx"; +} from 'flashbang/tasks'; +import {Easing} from 'flashbang/util'; +import Eterna from 'eterna/Eterna'; +import {Fonts} from 'eterna/util'; +import {Background} from 'eterna/vfx'; /** Displays a simple animation while we're loading assets */ export default class LoadingMode extends AppMode { - public constructor(text: string) { + constructor(text: string) { super(); this._text = text; } diff --git a/src/eterna/mode/PoseEdit/Booster.ts b/src/eterna/mode/PoseEdit/Booster.ts index b8d8683be..d3b5b040b 100644 --- a/src/eterna/mode/PoseEdit/Booster.ts +++ b/src/eterna/mode/PoseEdit/Booster.ts @@ -1,13 +1,13 @@ -import * as log from "loglevel"; -import {Texture} from "pixi.js"; -import {TextureUtil} from "flashbang/util"; -import EPars from "eterna/EPars"; -import Eterna from "eterna/Eterna"; -import {Pose2D} from "eterna/pose2D"; -import {Sounds} from "eterna/resources"; -import {GameButton} from "eterna/ui"; -import {ExternalInterface, ExternalInterfaceCtx} from "eterna/util"; -import {GameMode} from "eterna/mode"; +import * as log from 'loglevel'; +import {Texture} from 'pixi.js'; +import {TextureUtil} from 'flashbang/util'; +import EPars from 'eterna/EPars'; +import Eterna from 'eterna/Eterna'; +import {Pose2D} from 'eterna/pose2D'; +import {Sounds} from 'eterna/resources'; +import {GameButton} from 'eterna/ui'; +import {ExternalInterface, ExternalInterfaceCtx} from 'eterna/util'; +import {GameMode} from 'eterna/mode'; export enum BoosterType { PAINTER = 1, @@ -16,14 +16,14 @@ export enum BoosterType { export default class Booster { public static create(mode: GameMode, data: any): Promise { - if (!data["type"]) { - return Promise.reject("Invalid booster definition (missing 'type')"); - } else if (!data["icons_b64"] || data["icons_b64"].length != 5) { - return Promise.reject("Invalid booster definition (missing or malformed 'icons_b64'"); + if (!data['type']) { + return Promise.reject(new Error("Invalid booster definition (missing 'type')")); + } else if (!data['icons_b64'] || data['icons_b64'].length !== 5) { + return Promise.reject(new Error("Invalid booster definition (missing or malformed 'icons_b64'")); } // load icons - let iconData: string[] = data["icons_b64"]; + let iconData: string[] = data['icons_b64']; let buttonStateTextures: Texture[] = new Array(iconData.length); let imageLoaders: Promise[] = []; for (let ii = 0; ii < iconData.length; ++ii) { @@ -40,20 +40,20 @@ export default class Booster { return Promise.all(imageLoaders) .then(() => mode.waitTillActive()) .then(() => { - let type: BoosterType = Number(data["type"]); - let tool_color = -1; - if (type == BoosterType.PAINTER) { - tool_color = Booster._toolColorCounter++; - log.info(`color_num=${tool_color}`); + let type: BoosterType = Number(data['type']); + let toolColor = -1; + if (type === BoosterType.PAINTER) { + toolColor = Booster._toolColorCounter++; + log.info(`color_num=${toolColor}`); } return new Booster( mode, type, - tool_color, - data["label"], - data["tooltip"], - data["script"], + toolColor, + data['label'], + data['tooltip'], + data['script'], buttonStateTextures ); }); @@ -62,23 +62,23 @@ export default class Booster { private constructor( view: GameMode, type: BoosterType, - tool_color: number, + toolColor: number, label: string, tooltip: string, - script_nid: string, + scriptNID: string, buttonStateTextures: Texture[] ) { this._view = view; this._type = type; - this._toolColor = tool_color; + this._toolColor = toolColor; this._label = label; this._tooltip = tooltip; - this._scriptID = script_nid; + this._scriptID = scriptNID; this._buttonStateTextures = buttonStateTextures; for (let ii = 0; ii < this._view.numPoseFields; ii++) { let pose: Pose2D = this._view.getPose(ii); - pose.registerPaintTool(tool_color, this); + pose.registerPaintTool(toolColor, this); } } @@ -88,7 +88,7 @@ export default class Booster { public createButton(fontsize: number = 22): GameButton { let button: GameButton = new GameButton().allStates(this._buttonStateTextures[0]); - if (this._type == BoosterType.PAINTER) { + if (this._type === BoosterType.PAINTER) { if (this._buttonStateTextures[0] !== undefined) { button.up(this._buttonStateTextures[0]); } @@ -114,75 +114,77 @@ export default class Booster { } public onLoad(): void { - this.executeScript(null, "ON_LOAD", -1); + this.executeScript(null, 'ON_LOAD', -1); } - public onPaint(pose: Pose2D, base_num: number): void { + public onPaint(pose: Pose2D, baseNum: number): void { Eterna.sound.playSound(Sounds.SoundPaint); - this.executeScript(pose, "MOUSE_DOWN", base_num); + this.executeScript(pose, 'MOUSE_DOWN', baseNum); } - public onPainting(pose: Pose2D, base_num: number): void { - this.executeScript(pose, "MOUSE_MOVE", base_num); + public onPainting(pose: Pose2D, baseNum: number): void { + this.executeScript(pose, 'MOUSE_MOVE', baseNum); } public onRun(): void { this.executeScript(null, null, -1); } - private executeScript(pose: Pose2D, cmd: string, base_num: number): void { + private executeScript(pose: Pose2D, cmd: string, baseNum: number): void { let scriptInterface = new ExternalInterfaceCtx(); - scriptInterface.addCallback("set_sequence_string", (seq: string): boolean => { - let seq_arr: number[] = EPars.stringToSequence(seq); - if (seq_arr.indexOf(EPars.RNABASE_UNDEFINED) >= 0 || seq_arr.indexOf(EPars.RNABASE_CUT) >= 0) { + scriptInterface.addCallback('set_sequence_string', (seq: string): boolean => { + let seqArr: number[] = EPars.stringToSequence(seq); + if (seqArr.indexOf(EPars.RNABASE_UNDEFINED) >= 0 || seqArr.indexOf(EPars.RNABASE_CUT) >= 0) { log.info(`Invalid characters in ${seq}`); return false; } - if (this._type == BoosterType.PAINTER && pose) { - pose.setMutated(seq_arr); + if (this._type === BoosterType.PAINTER && pose) { + pose.setMutated(seqArr); } else { let prevForceSync = this._view.forceSync; this._view.forceSync = true; for (let ii = 0; ii < this._view.numPoseFields; ii++) { pose = this._view.getPose(ii); - pose.pasteSequence(seq_arr); + pose.pasteSequence(seqArr); } this._view.forceSync = prevForceSync; } return true; }); - scriptInterface.addCallback("set_tracked_indices", (marks: any[], color: number = 0x000000): void => { + scriptInterface.addCallback('set_tracked_indices', (marks: any[], color: number = 0x000000): void => { for (let ii = 0; ii < this._view.numPoseFields; ii++) { - let pose: Pose2D = this._view.getPose(ii); - pose.clearTracking(); + let poseToMark: Pose2D = this._view.getPose(ii); + poseToMark.clearTracking(); for (let mark of marks) { - pose.addBaseMark(mark, color); + poseToMark.addBaseMark(mark, color); } } }); - scriptInterface.addCallback("set_script_status", (): void => {}); + scriptInterface.addCallback('set_script_status', (): void => {}); const useUILock = this._type === BoosterType.ACTION; - const LOCK_NAME = "BoosterScript"; + const LOCK_NAME = 'BoosterScript'; - if (this._type == BoosterType.ACTION) { + if (this._type === BoosterType.ACTION) { this._view.pushUILock(LOCK_NAME); } const scriptParams = this._type === BoosterType.ACTION ? {} : { command: cmd, - param: base_num.toString() + param: baseNum.toString() }; ExternalInterface.runScript(this._scriptID, {params: scriptParams, ctx: scriptInterface}) .then((ret) => { if (useUILock) { this._view.popUILock(LOCK_NAME); - Eterna.sound.playSound(ret != null && ret["result"] ? Sounds.SoundScriptDone : Sounds.SoundScriptFail); + Eterna.sound.playSound( + ret != null && ret['result'] ? Sounds.SoundScriptDone : Sounds.SoundScriptFail + ); } }) .catch(() => { diff --git a/src/eterna/mode/PoseEdit/MissionClearedPanel.ts b/src/eterna/mode/PoseEdit/MissionClearedPanel.ts index 18e9eda51..dc251a21b 100644 --- a/src/eterna/mode/PoseEdit/MissionClearedPanel.ts +++ b/src/eterna/mode/PoseEdit/MissionClearedPanel.ts @@ -1,23 +1,23 @@ import { Container, Graphics, Point, Text -} from "pixi.js"; -import {Flashbang, HAlign, VAlign} from "flashbang/core"; -import {VLayoutContainer} from "flashbang/layout"; -import {ContainerObject, DOMObject} from "flashbang/objects"; -import {AlphaTask} from "flashbang/tasks"; -import {DisplayUtil} from "flashbang/util"; -import {RankScroll} from "eterna/rank"; -import {Bitmaps} from "eterna/resources"; +} from 'pixi.js'; +import {Flashbang, HAlign, VAlign} from 'flashbang/core'; +import {VLayoutContainer} from 'flashbang/layout'; +import {ContainerObject, DOMObject} from 'flashbang/objects'; +import {AlphaTask} from 'flashbang/tasks'; +import {DisplayUtil} from 'flashbang/util'; +import {RankScroll} from 'eterna/rank'; +import {Bitmaps} from 'eterna/resources'; import { GameButton, GamePanel, GamePanelType, HTMLTextObject -} from "eterna/ui"; -import {Fonts} from "eterna/util"; +} from 'eterna/ui'; +import {Fonts} from 'eterna/util'; export default class MissionClearedPanel extends ContainerObject { public nextButton: GameButton; public closeButton: GameButton; - public constructor(hasNextPuzzle: boolean, infoText: string = null, moreText: string = null) { + constructor(hasNextPuzzle: boolean, infoText: string = null, moreText: string = null) { super(); this._hasNextPuzzle = hasNextPuzzle; @@ -34,9 +34,9 @@ export default class MissionClearedPanel extends ContainerObject { this._contentLayout = new VLayoutContainer(25, HAlign.CENTER); this.container.addChild(this._contentLayout); - this._contentLayout.addChild(Fonts.stdLight("Mission Accomplished!", 36).color(0xFFCC00).build()); + this._contentLayout.addChild(Fonts.stdLight('Mission Accomplished!', 36).color(0xFFCC00).build()); - const infoText: string = this._infoText || "You have solved the puzzle, congratulations!"; + const infoText: string = this._infoText || 'You have solved the puzzle, congratulations!'; const infoObj = new HTMLTextObject(infoText, MissionClearedPanel.WIDTH - 60) .font(Fonts.STDFONT_REGULAR) .fontSize(20) @@ -44,7 +44,7 @@ export default class MissionClearedPanel extends ContainerObject { .lineHeight(1.2) .selectable(false); // Images should be centered, even if the HTML doesn't specify it - DOMObject.applyStyleRecursive(infoObj.element, {display: "block", margin: "auto"}, false, ["img"]); + DOMObject.applyStyleRecursive(infoObj.element, {display: 'block', margin: 'auto'}, false, ['img']); this.addObject(infoObj, this._contentLayout); if (this._moreText != null) { @@ -58,24 +58,24 @@ export default class MissionClearedPanel extends ContainerObject { this._rankScrollHeading = new GamePanel(GamePanelType.NORMAL, 1.0, 0x2D4159); this.addObject(this._rankScrollHeading, this._rankScrollContainer); - this._tfPlayer = Fonts.stdBold("PLAYER", 14).bold().color(0xffffff).build(); + this._tfPlayer = Fonts.stdBold('PLAYER', 14).bold().color(0xffffff).build(); this._tfPlayer.position = new Point(10, 2); this._rankScrollHeading.container.addChild(this._tfPlayer); - let tfRank: Text = Fonts.stdBold("RANK", 14).bold().color(0xffffff).build(); + let tfRank: Text = Fonts.stdBold('RANK', 14).bold().color(0xffffff).build(); tfRank.position = new Point(10 + 130, 2); this._rankScrollHeading.container.addChild(tfRank); - let tfCoin: Text = Fonts.stdBold("POINTS", 14).bold().color(0xffffff).build(); + let tfCoin: Text = Fonts.stdBold('POINTS', 14).bold().color(0xffffff).build(); tfCoin.position = new Point(10 + 130 + 85, 2); this._rankScrollHeading.container.addChild(tfCoin); this.closeButton = new GameButton() .allStates(Bitmaps.ImgCross) - .tooltip("Stay in this puzzle and review your design"); + .tooltip('Stay in this puzzle and review your design'); this.addObject(this.closeButton, this.container); - this.nextButton = new GameButton().label(this._hasNextPuzzle ? "NEXT PUZZLE" : "WHAT'S NEXT?"); + this.nextButton = new GameButton().label(this._hasNextPuzzle ? 'NEXT PUZZLE' : "WHAT'S NEXT?"); this.addObject(this.nextButton, this.container); this.regs.add(this.mode.resized.connect(() => this.onResize())); diff --git a/src/eterna/mode/PoseEdit/MissionIntroMode.ts b/src/eterna/mode/PoseEdit/MissionIntroMode.ts index f08c01e82..3b746c106 100644 --- a/src/eterna/mode/PoseEdit/MissionIntroMode.ts +++ b/src/eterna/mode/PoseEdit/MissionIntroMode.ts @@ -1,19 +1,21 @@ import { Container, Graphics, Point, Sprite -} from "pixi.js"; -import {Flashbang, AppMode} from "flashbang/core"; -import {DisplayObjectPointerTarget, InputUtil, KeyCode} from "flashbang/input"; -import {DisplayUtil, StyledTextBuilder} from "flashbang/util"; -import EPars from "eterna/EPars"; -import Eterna from "eterna/Eterna"; -import {Bitmaps} from "eterna/resources"; +} from 'pixi.js'; +import {Flashbang, AppMode} from 'flashbang/core'; +import {DisplayObjectPointerTarget, InputUtil, KeyCode} from 'flashbang/input'; +import {DisplayUtil, StyledTextBuilder} from 'flashbang/util'; +import EPars from 'eterna/EPars'; +import Eterna from 'eterna/Eterna'; +import {Bitmaps} from 'eterna/resources'; import { ConstraintBox, GameButton, HTMLTextObject, PoseThumbnail, PoseThumbnailType -} from "eterna/ui"; -import {Fonts} from "eterna/util"; +} from 'eterna/ui'; +import {Fonts} from 'eterna/util'; export default class MissionIntroMode extends AppMode { - public constructor(puzzleName: string, puzzleDescription: string, puzzleThumbnails: number[][], constraintBoxes: ConstraintBox[]) { + constructor( + puzzleName: string, puzzleDescription: string, puzzleThumbnails: number[][], constraintBoxes: ConstraintBox[] + ) { super(); this._puzzleName = puzzleName; this._puzzleDescription = puzzleDescription; @@ -32,7 +34,7 @@ export default class MissionIntroMode extends AppMode { let moleculeImg = Sprite.fromImage(Bitmaps.MissionBackgroundImage); this.container.addChild(moleculeImg); - let missionText = Fonts.stdLight("MISSION", 48).color(0xFFCC00).build(); + let missionText = Fonts.stdLight('MISSION', 48).color(0xFFCC00).build(); this.container.addChild(missionText); const descriptionStyle = { @@ -64,7 +66,7 @@ export default class MissionIntroMode extends AppMode { .maxWidth(Flashbang.stageWidth); this.addObject(nameLabel, this.container); - let goalsLabel = Fonts.stdLight("GOAL", 24).color(0xffcc00).build(); + let goalsLabel = Fonts.stdLight('GOAL', 24).color(0xffcc00).build(); this.container.addChild(goalsLabel); this._goalsBG = Sprite.fromImage(Bitmaps.MissionPuzzleThumbnailImage); @@ -242,7 +244,8 @@ export default class MissionIntroMode extends AppMode { } private scrollDown(): void { - let limit = -this._constraintsHeight + 367 + 60 + this._constraintBoxes[this._constraintBoxes.length - 1].container.height; + let limit = -this._constraintsHeight + 367 + 60 + + this._constraintBoxes[this._constraintBoxes.length - 1].container.height; this._constraintsLayer.y = Math.max(this._constraintsLayer.y - 10, limit); } @@ -278,7 +281,9 @@ export default class MissionIntroMode extends AppMode { this._constraintMask.clear(); this._constraintMask.beginFill(0x00FF00, 0); - this._constraintMask.drawRect(0, topY, Flashbang.stageWidth, botY + this._scrollDownButton.container.height - topY); + this._constraintMask.drawRect( + 0, topY, Flashbang.stageWidth, botY + this._scrollDownButton.container.height - topY + ); this._constraintMask.x = 0; this._constraintMask.y = 0; this._constraintsLayer.mask = this._constraintMask; diff --git a/src/eterna/mode/PoseEdit/PoseEditMode.ts b/src/eterna/mode/PoseEdit/PoseEditMode.ts index 4ed73edaa..d5138d21e 100644 --- a/src/eterna/mode/PoseEdit/PoseEditMode.ts +++ b/src/eterna/mode/PoseEdit/PoseEditMode.ts @@ -1,35 +1,43 @@ -import * as log from "loglevel"; -import {Container, DisplayObject, Point, Sprite, Text} from "pixi.js"; -import {Flashbang, HAlign, VAlign, GameObjectRef} from "flashbang/core"; -import {KeyboardEventType, KeyCode} from "flashbang/input"; -import {SpriteObject} from "flashbang/objects"; -import {AlphaTask, SelfDestructTask, SerialTask} from "flashbang/tasks"; -import {Assert, DisplayUtil, Easing} from "flashbang/util"; -import EPars from "eterna/EPars"; -import Eterna from "eterna/Eterna"; -import {Folder, FolderManager, FoldUtil} from "eterna/folding"; -import {CopyTextDialogMode, GameMode, PuzzleEditPoseData} from "eterna/mode"; -import {EternaURL} from "eterna/net"; -import {Oligo, Pose2D, PoseField, PoseOp, PuzzleEditOp} from "eterna/pose2D"; +import * as log from 'loglevel'; +import { + Container, DisplayObject, Point, Sprite, Text +} from 'pixi.js'; +import { + Flashbang, HAlign, VAlign, GameObjectRef +} from 'flashbang/core'; +import {KeyboardEventType, KeyCode} from 'flashbang/input'; +import {SpriteObject} from 'flashbang/objects'; +import {AlphaTask, SelfDestructTask, SerialTask} from 'flashbang/tasks'; +import {Assert, DisplayUtil, Easing} from 'flashbang/util'; +import EPars from 'eterna/EPars'; +import Eterna from 'eterna/Eterna'; +import {Folder, FolderManager, FoldUtil} from 'eterna/folding'; +import {CopyTextDialogMode, GameMode, PuzzleEditPoseData} from 'eterna/mode'; +import {EternaURL} from 'eterna/net'; +import { + Oligo, Pose2D, PoseField, PoseOp, PuzzleEditOp +} from 'eterna/pose2D'; import { Constraints, ConstraintType, BoostersData, PoseState, Puzzle, PuzzleType, PuzzleManager, Solution, SolutionManager -} from "eterna/puzzle"; -import {BitmapManager, Bitmaps, Sounds} from "eterna/resources"; -import {RNAScript} from "eterna/rscript"; +} from 'eterna/puzzle'; +import {BitmapManager, Bitmaps, Sounds} from 'eterna/resources'; +import {RNAScript} from 'eterna/rscript'; import { ActionBar, ConstraintBox, ConstraintBoxType, ContextMenu, EternaViewOptionsDialog, EternaViewOptionsMode, GameButton, GamePanel, HTMLTextObject, GetPaletteTargetBaseType, PaletteTargetType, PasteSequenceDialog, SpecBox, SpecBoxDialog, URLButton, Toolbar, ToolbarType -} from "eterna/ui"; -import {default as UndoBlock, UndoBlockParam} from "eterna/UndoBlock"; -import {ExternalInterface, ExternalInterfaceCtx, Fonts, int} from "eterna/util"; -import {Background, BubbleSweep} from "eterna/vfx"; -import MissionClearedPanel from "./MissionClearedPanel"; -import MissionIntroMode from "./MissionIntroMode"; -import SubmitPoseDetails from "./SubmitPoseDetails"; -import SubmitPoseDialog from "./SubmitPoseDialog"; -import SubmittingDialog from "./SubmittingDialog"; +} from 'eterna/ui'; +import UndoBlock, {UndoBlockParam} from 'eterna/UndoBlock'; +import { + ExternalInterface, ExternalInterfaceCtx, Fonts, int +} from 'eterna/util'; +import {Background, BubbleSweep} from 'eterna/vfx'; +import MissionClearedPanel from './MissionClearedPanel'; +import MissionIntroMode from './MissionIntroMode'; +import SubmitPoseDetails from './SubmitPoseDetails'; +import SubmitPoseDialog from './SubmitPoseDialog'; +import SubmittingDialog from './SubmittingDialog'; type InteractionEvent = PIXI.interaction.InteractionEvent; @@ -54,8 +62,29 @@ export interface PoseEditParams { solutions?: Solution[]; } +interface ConstraintInfo { + wrongPairs: number[]; + restrictedLocal: number[][]; + maxAllowedGuanine: number; + maxAllowedCytosine: number; + maxAllowedAdenine: number; +} + +interface OligoDef { + sequence: string; + malus: number; + name: string; + bind?: boolean; + concentration?: string; + label?: string; +} + +enum ConstraintStatus { + SATISFIED = 'satisfied', UNSATISFIED = 'unsatisfied', PENDING = 'pending' +} + export default class PoseEditMode extends GameMode { - public constructor(puzzle: Puzzle, params: PoseEditParams, autosaveData: any[] = null) { + constructor(puzzle: Puzzle, params: PoseEditParams, autosaveData: any[] = null) { super(); this._puzzle = puzzle; this._params = params; @@ -76,7 +105,7 @@ export default class PoseEditMode extends GameMode { this._background = new Background(); this.addObject(this._background, this.bgLayer); - let toolbarType = this._puzzle.puzzleType == PuzzleType.EXPERIMENTAL ? ToolbarType.LAB : ToolbarType.PUZZLE; + let toolbarType = this._puzzle.puzzleType === PuzzleType.EXPERIMENTAL ? ToolbarType.LAB : ToolbarType.PUZZLE; this._toolbar = new Toolbar(toolbarType, { states: this._puzzle.getSecstructs().length, showHint: this._puzzle.hint != null, @@ -101,7 +130,7 @@ export default class PoseEditMode extends GameMode { this.pushUILock(); Eterna.app.switchToDesignBrowser(this._puzzle) .then(() => this.popUILock()) - .catch(e => { + .catch((e) => { log.error(e); this.popUILock(); }); @@ -111,16 +140,16 @@ export default class PoseEditMode extends GameMode { this._toolbar.targetButton.clicked.connect(() => this.togglePoseState()); this._toolbar.specButton.clicked.connect(() => this.showSpec()); this._toolbar.copyButton.clicked.connect(() => this.showCopySequenceDialog()); - this._toolbar.pasteButton.clicked.connect(() => this.showPasteSequenceDialog()); + this._toolbar.pasteButton.clicked.connect(() => this.showPasteSequenceDialog()); this._toolbar.viewOptionsButton.clicked.connect(() => this.showViewOptionsDialog()); this._toolbar.screenshotButton.clicked.connect(() => this.postScreenshot(this.createScreenshot())); this._toolbar.pipButton.clicked.connect(() => this.togglePip()); - this._toolbar.stateToggle.stateChanged.connect((targetIdx) => this.changeTarget(targetIdx)); + this._toolbar.stateToggle.stateChanged.connect(targetIdx => this.changeTarget(targetIdx)); this._toolbar.freezeButton.clicked.connect(() => this.toggleFreeze()); - this._toolbar.palette.targetClicked.connect((targetType) => this.onPaletteTargetSelected(targetType)); + this._toolbar.palette.targetClicked.connect(targetType => this.onPaletteTargetSelected(targetType)); this._toolbar.pairSwapButton.clicked.connect(() => this.onSwapClicked()); this._toolbar.hintButton.clicked.connect(() => this.onHintClicked()); @@ -134,7 +163,7 @@ export default class PoseEditMode extends GameMode { this._undockSpecBoxButton = new GameButton() .allStates(Bitmaps.ImgMaximize) - .tooltip("Re-maximize") + .tooltip('Re-maximize') .hotkey(KeyCode.KeyM); this._undockSpecBoxButton.clicked.connect(() => { this._dockedSpecBox.display.visible = false; @@ -157,17 +186,17 @@ export default class PoseEditMode extends GameMode { this._scriptbar = new ActionBar(50); this.addObject(this._scriptbar, this.uiLayer); - this._nidField = Fonts.arial("", 16).color(0xffffff).build(); + this._nidField = Fonts.arial('', 16).color(0xffffff).build(); this._nidField.width = 100; this._nidField.height = 20; this._runButton = new GameButton().allStates(Bitmaps.MingFold); - this._runStatus = Fonts.arial("idle", 16).bold().color(0xC0C0C0).build(); + this._runStatus = Fonts.arial('idle', 16).bold().color(0xC0C0C0).build(); this._runStatus.width = 200; this._runStatus.height = 20; - this._targetName = Fonts.stdRegular("", 18).build(); + this._targetName = Fonts.stdRegular('', 18).build(); this._targetName.visible = false; this.uiLayer.addChild(this._targetName); @@ -176,7 +205,7 @@ export default class PoseEditMode extends GameMode { this.addObject(this._homeButton, this.uiLayer); // Async text shows above our UI lock, and right below all dialogs - this._asynchText = Fonts.arial("folding...", 12).bold().color(0xffffff).build(); + this._asynchText = Fonts.arial('folding...', 12).bold().color(0xffffff).build(); this._asynchText.position = new Point(16, 200); this.dialogLayer.addChild(this._asynchText); this.hideAsyncText(); @@ -211,22 +240,26 @@ export default class PoseEditMode extends GameMode { private updateUILayout(): void { DisplayUtil.positionRelativeToStage( this._toolbar.display, HAlign.CENTER, VAlign.BOTTOM, - HAlign.CENTER, VAlign.BOTTOM, 20, -20); + HAlign.CENTER, VAlign.BOTTOM, 20, -20 + ); DisplayUtil.positionRelativeToStage( this._homeButton.display, HAlign.RIGHT, VAlign.TOP, - HAlign.RIGHT, VAlign.TOP, 0, 5); + HAlign.RIGHT, VAlign.TOP, 0, 5 + ); DisplayUtil.positionRelativeToStage( this._solutionNameText, HAlign.CENTER, VAlign.TOP, - HAlign.CENTER, VAlign.TOP, 0, 8); + HAlign.CENTER, VAlign.TOP, 0, 8 + ); this._exitButton.display.position = new Point(Flashbang.stageWidth - 85, Flashbang.stageHeight - 60); this._undockSpecBoxButton.display.position = new Point(Flashbang.stageWidth - 22, 5); this._scriptbar.display.position = new Point( Flashbang.stageWidth - 20 - this._scriptbar.width, - Flashbang.stageHeight - 129); + Flashbang.stageHeight - 129 + ); this.layoutConstraints(); @@ -244,7 +277,7 @@ export default class PoseEditMode extends GameMode { } private showPasteSequenceDialog(): void { - this.showDialog(new PasteSequenceDialog()).closed.then(sequence => { + this.showDialog(new PasteSequenceDialog()).closed.then((sequence) => { if (sequence != null) { for (let pose of this._poses) { pose.pasteSequence(EPars.stringToSequence(sequence)); @@ -254,29 +287,29 @@ export default class PoseEditMode extends GameMode { } private showViewOptionsDialog(): void { - let mode = this._puzzle.puzzleType === PuzzleType.EXPERIMENTAL ? - EternaViewOptionsMode.LAB : - EternaViewOptionsMode.PUZZLE; + let mode = this._puzzle.puzzleType === PuzzleType.EXPERIMENTAL + ? EternaViewOptionsMode.LAB + : EternaViewOptionsMode.PUZZLE; this.showDialog(new EternaViewOptionsDialog(mode)); } private showCopySequenceDialog(): void { let sequenceString = EPars.sequenceToString(this._poses[0].sequence); - this.modeStack.pushMode(new CopyTextDialogMode(sequenceString, "Current Sequence")); + this.modeStack.pushMode(new CopyTextDialogMode(sequenceString, 'Current Sequence')); } public setPuzzleState(newstate: PuzzleState): void { this._puzState = newstate; } - public set puzzleDefaultMode(default_mode: PoseState) { - this._puzzle.defaultMode = default_mode; + public set puzzleDefaultMode(defaultMode: PoseState) { + this._puzzle.defaultMode = defaultMode; } - public ropChangeTarget(target_index: number): void { - this.changeTarget(target_index); + public ropChangeTarget(targetIndex: number): void { + this.changeTarget(targetIndex); if (this._toolbar.stateToggle != null) { - this._toolbar.stateToggle.state = target_index; + this._toolbar.stateToggle.state = targetIndex; } } @@ -318,10 +351,10 @@ export default class PoseEditMode extends GameMode { this._ropPresets.push(() => this.setShowTotalEnergy(show)); } - public selectFolder(folder_name: string): boolean { - if (this._folder.name === folder_name) return true; - let folder: Folder = FolderManager.instance.getFolder(folder_name); - if (this._puzzle.hasTargetType("multistrand") && !folder.canMultifold) { + public selectFolder(folderName: string): boolean { + if (this._folder.name === folderName) return true; + let folder: Folder = FolderManager.instance.getFolder(folderName); + if (this._puzzle.hasTargetType('multistrand') && !folder.canMultifold) { return false; } @@ -344,7 +377,7 @@ export default class PoseEditMode extends GameMode { this._hintBoxRef.destroyObject(); } else { let hintBox = new GamePanel(); - hintBox.title = "Hint"; // by " + _puzzle.get_coauthor()); + hintBox.title = 'Hint'; // by " + _puzzle.get_coauthor()); let hintText = new HTMLTextObject(this._puzzle.hint, 400).font(Fonts.ARIAL).color(0xffffff); hintText.display.position = new Point(10, 38); @@ -355,16 +388,17 @@ export default class PoseEditMode extends GameMode { let updatePosition = () => { hintBox.display.position = new Point( Flashbang.stageWidth - 440, - Flashbang.stageHeight - hintBox.container.height - 90); + Flashbang.stageHeight - hintBox.container.height - 90 + ); }; updatePosition(); - hintBox.setSize(420, hintText.height + 46) + hintBox.setSize(420, hintText.height + 46); hintBox.regs.add(this.resized.connect(updatePosition)); } } - public public_start_countdown(): void { + public publicStartCountdown(): void { this.startCountdown(); } @@ -382,16 +416,15 @@ export default class PoseEditMode extends GameMode { this._seqStacks[this._stackLevel] = []; for (let ii = 0; ii < this._poses.length; ii++) { - let undo_block: UndoBlock = new UndoBlock([]); - undo_block.fromJSON(foldData[ii]); - this._seqStacks[this._stackLevel][ii] = undo_block; + let undoBlock: UndoBlock = new UndoBlock([]); + undoBlock.fromJSON(foldData[ii]); + this._seqStacks[this._stackLevel][ii] = undoBlock; } this.savePosesMarkersContexts(); this.moveUndoStack(); this.updateScore(); this.transformPosesMarkers(); - } else { const sequence = EPars.stringToSequence(solution.sequence); for (let pose of this._poses) { @@ -405,8 +438,8 @@ export default class PoseEditMode extends GameMode { this._curSolution = solution; }; - if (this._puzzle.hasTargetType("multistrand")) { - this.showAsyncText("retrieving..."); + if (this._puzzle.hasTargetType('multistrand')) { + this.showAsyncText('retrieving...'); solution.queryFoldData().then(result => setSolution(result)); } else { setSolution(null); @@ -418,14 +451,15 @@ export default class PoseEditMode extends GameMode { this._solutionNameText.visible = true; DisplayUtil.positionRelativeToStage( this._solutionNameText, HAlign.CENTER, VAlign.TOP, - HAlign.CENTER, VAlign.TOP, 0, 8); + HAlign.CENTER, VAlign.TOP, 0, 8 + ); } private setPuzzle(): void { - let pose_fields: PoseField[] = []; + let poseFields: PoseField[] = []; - let target_secstructs: string[] = this._puzzle.getSecstructs(); - let target_conditions: any[] = this._puzzle.targetConditions; + let targetSecstructs: string[] = this._puzzle.getSecstructs(); + let targetConditions: any[] = this._puzzle.targetConditions; // TSC: this crashes, and doesn't seem to accomplish anything // let before_reset: number[] = null; @@ -433,19 +467,19 @@ export default class PoseEditMode extends GameMode { // before_reset = this._puzzle.transform_sequence(this.get_current_undo_block(0).get_sequence(), 0); // } - let bind_addbase_cb = (pose: Pose2D, kk: number) => { + let bindAddbaseCB = (pose: Pose2D, kk: number) => { pose.addBaseCallback = ((parenthesis: string, mode: PuzzleEditOp, index: number) => { pose.baseShift(parenthesis, mode, index); this.poseEditByTarget(kk); }); }; - let bind_pose_edit = (pose: Pose2D, index: number) => { + let bindPoseEdit = (pose: Pose2D, index: number) => { pose.poseEditCallback = (() => { this.poseEditByTarget(index); }); }; - let bind_track_moves = (pose: Pose2D, index: number) => { + let bindTrackMoves = (pose: Pose2D, index: number) => { pose.trackMovesCallback = ((count: number, moves: any[]) => { this._moveCount += count; if (moves) { @@ -454,32 +488,32 @@ export default class PoseEditMode extends GameMode { }); }; - let bind_mousedown_event = function (pose: Pose2D, index: number): void { - pose.startMousedownCallback = ((e: InteractionEvent, closest_dist: number, closest_index: number) => { - for (let ii: number = 0; ii < pose_fields.length; ++ii) { - let pose_field: PoseField = pose_fields[ii]; - let pose: Pose2D = pose_field.pose; + let bindMousedownEvent = (pose: Pose2D, index: number) => { + pose.startMousedownCallback = ((e: InteractionEvent, closestDist: number, closestIndex: number) => { + for (let ii = 0; ii < poseFields.length; ++ii) { + let poseField: PoseField = poseFields[ii]; + let poseToNotify: Pose2D = poseField.pose; if (index === ii) { - pose.onPoseMouseDown(e, closest_index); + poseToNotify.onPoseMouseDown(e, closestIndex); } else { - pose.onPoseMouseDownPropagate(e, closest_index); + poseToNotify.onPoseMouseDownPropagate(e, closestIndex); } } }); }; - for (let ii = 0; ii < target_conditions.length; ii++) { - let pose_field: PoseField = new PoseField(true); - this.addObject(pose_field, this.poseLayer); - let pose: Pose2D = pose_field.pose; - bind_addbase_cb(pose, ii); - bind_pose_edit(pose, ii); - bind_track_moves(pose, ii); - bind_mousedown_event(pose, ii); - pose_fields.push(pose_field); + for (let ii = 0; ii < targetConditions.length; ii++) { + let poseField: PoseField = new PoseField(true); + this.addObject(poseField, this.poseLayer); + let pose: Pose2D = poseField.pose; + bindAddbaseCB(pose, ii); + bindPoseEdit(pose, ii); + bindTrackMoves(pose, ii); + bindMousedownEvent(pose, ii); + poseFields.push(poseField); } - this.setPoseFields(pose_fields); + this.setPoseFields(poseFields); this._isDatabrowserMode = false; // if (this.root.loaderInfo.parameters.databrowser @@ -487,26 +521,25 @@ export default class PoseEditMode extends GameMode { // this._is_databrowser_mode = true; // } - for (let ii = 0; ii < target_secstructs.length; ii++) { - this._targetPairs.push(EPars.parenthesisToPairs(target_secstructs[ii])); - this._targetConditions.push(target_conditions[ii]); + for (let ii = 0; ii < targetSecstructs.length; ii++) { + this._targetPairs.push(EPars.parenthesisToPairs(targetSecstructs[ii])); + this._targetConditions.push(targetConditions[ii]); this._targetOligos.push(null); this._targetOligosOrder.push(null); this._targetOligo.push(null); this._oligoMode.push(null); this._oligoName.push(null); - if (target_conditions[ii] && target_conditions[ii]['oligo_sequence']) { - this._targetOligo[ii] = EPars.stringToSequence(target_conditions[ii]['oligo_sequence']); - this._oligoMode[ii] = - target_conditions[ii]["fold_mode"] == null ? - Pose2D.OLIGO_MODE_DIMER : - Number(target_conditions[ii]["fold_mode"]); - this._oligoName[ii] = target_conditions[ii]['oligo_name']; - } - if (target_conditions[ii] && target_conditions[ii]['oligos']) { - let odefs: OligoDef[] = target_conditions[ii]['oligos']; + if (targetConditions[ii] && targetConditions[ii]['oligo_sequence']) { + this._targetOligo[ii] = EPars.stringToSequence(targetConditions[ii]['oligo_sequence']); + this._oligoMode[ii] = targetConditions[ii]['fold_mode'] == null + ? Pose2D.OLIGO_MODE_DIMER + : Number(targetConditions[ii]['fold_mode']); + this._oligoName[ii] = targetConditions[ii]['oligo_name']; + } + if (targetConditions[ii] && targetConditions[ii]['oligos']) { + let odefs: OligoDef[] = targetConditions[ii]['oligos']; let ndefs: Oligo[] = []; - for (let jj: number = 0; jj < odefs.length; jj++) { + for (let jj = 0; jj < odefs.length; jj++) { ndefs.push({ sequence: EPars.stringToSequence(odefs[jj].sequence), malus: odefs[jj].malus, @@ -534,9 +567,10 @@ export default class PoseEditMode extends GameMode { this.addObject(puzzleTitle, this.uiLayer); DisplayUtil.positionRelative( puzzleTitle.display, HAlign.LEFT, VAlign.CENTER, - puzzleIcon, HAlign.RIGHT, VAlign.CENTER, 3, 0); + puzzleIcon, HAlign.RIGHT, VAlign.CENTER, 3, 0 + ); - this._solutionNameText = Fonts.arial("", 14).bold().color(0xc0c0c0).build(); + this._solutionNameText = Fonts.arial('', 14).bold().color(0xc0c0c0).build(); this.uiLayer.addChild(this._solutionNameText); this._constraintsLayer.visible = true; @@ -549,7 +583,7 @@ export default class PoseEditMode extends GameMode { this._toolbar.palette.clickTarget(PaletteTargetType.A); } - let numConstraints: number = 0; + let numConstraints = 0; let constraints: string[] = []; if (this._puzzle.constraints != null) { numConstraints = this._puzzle.constraints.length; @@ -561,7 +595,7 @@ export default class PoseEditMode extends GameMode { if (numConstraints > 0) { if (numConstraints % 2 !== 0) { - throw new Error("Wrong constraints length"); + throw new Error('Wrong constraints length'); } for (let constraintIdx = 0; constraintIdx < numConstraints; constraintIdx += 2) { @@ -616,7 +650,7 @@ export default class PoseEditMode extends GameMode { let pairs: number[] = EPars.parenthesisToPairs(this._puzzle.getSecstruct()); - /// Setup Action bar + // / Setup Action bar this._scriptbar.clearItems(false); // this._scriptbar.visible = false; @@ -649,7 +683,7 @@ export default class PoseEditMode extends GameMode { this._folderButton = new GameButton() .allStates(Bitmaps.ShapeImg) .label(this._folder.name, 22) - .tooltip("Select the folding engine."); + .tooltip('Select the folding engine.'); this._folderButton.display.position = new Point(17, 160); this._folderButton.display.scale = new Point(0.5, 0.5); this.addObject(this._folderButton, this.uiLayer); @@ -686,17 +720,15 @@ export default class PoseEditMode extends GameMode { if (seq == null) { seq = this._puzzle.getBeginningSequence(ii); if (this._puzzle.puzzleType === PuzzleType.CHALLENGE && !this._params.isReset) { - let saved_seq: number[] = this._puzzle.savedSequence; - if (saved_seq != null) { - if (saved_seq.length === seq.length) { - seq = saved_seq; + let savedSeq: number[] = this._puzzle.savedSequence; + if (savedSeq != null) { + if (savedSeq.length === seq.length) { + seq = savedSeq; } } } - } else { - if (this._puzzle.puzzleType === PuzzleType.EXPERIMENTAL && this._puzzle.isUsingTails) { - seq = Puzzle.probeTail(seq); - } + } else if (this._puzzle.puzzleType === PuzzleType.EXPERIMENTAL && this._puzzle.isUsingTails) { + seq = Puzzle.probeTail(seq); } this._poses[ii].sequence = this._puzzle.transformSequence(seq, ii); @@ -724,9 +756,8 @@ export default class PoseEditMode extends GameMode { // We don't load saved data if we're viewing someone else's solution // If there's an initial solution, still autoload if we've previously played - if (!this._params.isReset && - this._params.initSolution == null) { - + if (!this._params.isReset + && this._params.initSolution == null) { this.loadSavedData(); } @@ -736,7 +767,8 @@ export default class PoseEditMode extends GameMode { } else { this._opQueue.push(new PoseOp( this._targetPairs.length, - () => this.setPuzzleEpilog(initialSequence, this._params.isReset))); + () => this.setPuzzleEpilog(initialSequence, this._params.isReset) + )); } this._poseEditByTargetCb = null; }; @@ -756,16 +788,14 @@ export default class PoseEditMode extends GameMode { } private buildScriptInterface(): void { - this._scriptInterface.addCallback("set_script_status", (txt: string): void => { + this._scriptInterface.addCallback('set_script_status', (txt: string): void => { this._runStatus.style.fill = 0xC0C0C0; this._runStatus.text = txt; }); - this._scriptInterface.addCallback("get_sequence_string", (): string => { - return this.getPose(0).getSequenceString(); - }); + this._scriptInterface.addCallback('get_sequence_string', (): string => this.getPose(0).getSequenceString()); - this._scriptInterface.addCallback("get_full_sequence", (indx: number): string => { + this._scriptInterface.addCallback('get_full_sequence', (indx: number): string => { if (indx < 0 || indx >= this._poses.length) { return null; } else { @@ -773,58 +803,56 @@ export default class PoseEditMode extends GameMode { } }); - this._scriptInterface.addCallback("get_locks", (): boolean[] => { + this._scriptInterface.addCallback('get_locks', (): boolean[] => { let pose: Pose2D = this.getPose(0); return pose.puzzleLocks.slice(0, pose.sequence.length); }); - this._scriptInterface.addCallback("get_targets", (): any[] => { + this._scriptInterface.addCallback('get_targets', (): any[] => { let conditions = this._puzzle.targetConditions; if (conditions.length === 0) { conditions.push(null); } - for (let ii: number = 0; ii < conditions.length; ii++) { + for (let ii = 0; ii < conditions.length; ii++) { if (conditions[ii] == null) { conditions[ii] = {}; - conditions[ii]['type'] = "single"; + conditions[ii]['type'] = 'single'; conditions[ii]['secstruct'] = this._puzzle.getSecstruct(ii); } } return JSON.parse(JSON.stringify(conditions)); }); - this._scriptInterface.addCallback("get_native_structure", (indx: number): string => { + this._scriptInterface.addCallback('get_native_structure', (indx: number): string => { if (indx < 0 || indx >= this._poses.length) return null; - let native_pairs = this.getCurrentUndoBlock(indx).getPairs(); - return EPars.pairsToParenthesis(native_pairs); + let nativepairs = this.getCurrentUndoBlock(indx).getPairs(); + return EPars.pairsToParenthesis(nativepairs); }); - this._scriptInterface.addCallback("get_full_structure", (indx: number): string => { + this._scriptInterface.addCallback('get_full_structure', (indx: number): string => { if (indx < 0 || indx >= this._poses.length) { return null; } - let native_pairs: number[] = this.getCurrentUndoBlock(indx).getPairs(); - let seq_arr: number[] = this.getPose(indx).fullSequence; - return EPars.pairsToParenthesis(native_pairs, seq_arr); + let nativePairs: number[] = this.getCurrentUndoBlock(indx).getPairs(); + let seqArr: number[] = this.getPose(indx).fullSequence; + return EPars.pairsToParenthesis(nativePairs, seqArr); }); - this._scriptInterface.addCallback("get_free_energy", (indx: number): number => { + this._scriptInterface.addCallback('get_free_energy', (indx: number): number => { if (indx < 0 || indx >= this._poses.length) { return Number.NaN; } return this.getCurrentUndoBlock(indx).getParam(UndoBlockParam.FE); }); - this._scriptInterface.addCallback("get_constraints", (): any[] => { - return JSON.parse(JSON.stringify(this._puzzle.constraints)); - }); + this._scriptInterface.addCallback( + 'get_constraints', (): any[] => JSON.parse(JSON.stringify(this._puzzle.constraints)) + ); - this._scriptInterface.addCallback("check_constraints", (): boolean => { - return this.checkConstraints(false); - }); + this._scriptInterface.addCallback('check_constraints', (): boolean => this.checkConstraints(false)); - this._scriptInterface.addCallback("constraint_satisfied", (idx: number): boolean => { + this._scriptInterface.addCallback('constraint_satisfied', (idx: number): boolean => { this.checkConstraints(true); if (idx >= 0 && idx < this.constraintCount) { let o: ConstraintBox = this.getConstraint(idx); @@ -834,60 +862,65 @@ export default class PoseEditMode extends GameMode { } }); - this._scriptInterface.addCallback("get_tracked_indices", (): number[] => this.getPose(0).trackedIndices); - this._scriptInterface.addCallback("get_barcode_indices", (): number[] => this._puzzle.barcodeIndices); - this._scriptInterface.addCallback("is_barcode_available", + this._scriptInterface.addCallback('get_tracked_indices', (): number[] => this.getPose(0).trackedIndices); + this._scriptInterface.addCallback('get_barcode_indices', (): number[] => this._puzzle.barcodeIndices); + this._scriptInterface.addCallback('is_barcode_available', (seq: string): boolean => SolutionManager.instance.checkRedundancyByHairpin(seq)); - this._scriptInterface.addCallback("current_folder", (): string => this._folder.name); + this._scriptInterface.addCallback('current_folder', (): string => this._folder.name); - this._scriptInterface.addCallback("fold", (seq: string, constraint: string = null): string => { - let seq_arr: number[] = EPars.stringToSequence(seq); - let folded: number[] = this._folder.foldSequence(seq_arr, null, constraint); + this._scriptInterface.addCallback('fold', (seq: string, constraint: string = null): string => { + let seqArr: number[] = EPars.stringToSequence(seq); + let folded: number[] = this._folder.foldSequence(seqArr, null, constraint); return EPars.pairsToParenthesis(folded); }); - this._scriptInterface.addCallback("fold_with_binding_site", (seq: string, site: number[], bonus: number): string => { - let seq_arr: number[] = EPars.stringToSequence(seq); - let folded: number[] = this._folder.foldSequenceWithBindingSite(seq_arr, null, site, Math.floor(bonus * 100), 2.5); - return EPars.pairsToParenthesis(folded); - }); + this._scriptInterface.addCallback('fold_with_binding_site', + (seq: string, site: number[], bonus: number): string => { + let seqArr: number[] = EPars.stringToSequence(seq); + let folded: number[] = this._folder.foldSequenceWithBindingSite( + seqArr, null, site, Math.floor(bonus * 100), 2.5 + ); + return EPars.pairsToParenthesis(folded); + }); - this._scriptInterface.addCallback("energy_of_structure", (seq: string, secstruct: string): number => { - let seq_arr: number[] = EPars.stringToSequence(seq); - let struct_arr: number[] = EPars.parenthesisToPairs(secstruct); - let free_energy: number = this._folder.scoreStructures(seq_arr, struct_arr); - return 0.01 * free_energy; + this._scriptInterface.addCallback('energy_of_structure', (seq: string, secstruct: string): number => { + let seqArr: number[] = EPars.stringToSequence(seq); + let structArr: number[] = EPars.parenthesisToPairs(secstruct); + let freeEnergy: number = this._folder.scoreStructures(seqArr, structArr); + return 0.01 * freeEnergy; }); - this._scriptInterface.addCallback("pairing_probabilities", (seq: string, secstruct: string = null): number[] => { - let seq_arr: number[] = EPars.stringToSequence(seq); - let folded: number[]; - if (secstruct) { - folded = EPars.parenthesisToPairs(secstruct); - } else { - folded = this._folder.foldSequence(seq_arr, null, null); - } - let pp: number[] = this._folder.getDotPlot(seq_arr, folded); - return pp.slice(); - }); + this._scriptInterface.addCallback('pairing_probabilities', + (seq: string, secstruct: string = null): number[] => { + let seqArr: number[] = EPars.stringToSequence(seq); + let folded: number[]; + if (secstruct) { + folded = EPars.parenthesisToPairs(secstruct); + } else { + folded = this._folder.foldSequence(seqArr, null, null); + } + let pp: number[] = this._folder.getDotPlot(seqArr, folded); + return pp.slice(); + }); - this._scriptInterface.addCallback("cofold", (seq: string, oligo: string, malus: number = 0., constraint: string = null): string => { - let len: number = seq.length; - let cseq: string = seq + "&" + oligo; - let seq_arr: number[] = EPars.stringToSequence(cseq); - let folded: number[] = this._folder.cofoldSequence(seq_arr, null, Math.floor(malus * 100), constraint); - return EPars.pairsToParenthesis(folded.slice(0, len)) - + "&" + EPars.pairsToParenthesis(folded.slice(len)); - }); + this._scriptInterface.addCallback('cofold', + (seq: string, oligo: string, malus: number = 0.0, constraint: string = null): string => { + let len: number = seq.length; + let cseq = `${seq}&${oligo}`; + let seqArr: number[] = EPars.stringToSequence(cseq); + let folded: number[] = this._folder.cofoldSequence(seqArr, null, Math.floor(malus * 100), constraint); + return `${EPars.pairsToParenthesis(folded.slice(0, len)) + }&${EPars.pairsToParenthesis(folded.slice(len))}`; + }); if (this._puzzle.puzzleType === PuzzleType.EXPERIMENTAL) { - this._scriptInterface.addCallback("select_folder", (folder_name: string): boolean => { - return this.selectFolder(folder_name); - }); + this._scriptInterface.addCallback( + 'select_folder', (folderName: string): boolean => this.selectFolder(folderName) + ); - this._scriptInterface.addCallback("load_parameters_from_buffer", (str: string): boolean => { - log.info("TODO: load_parameters_from_buffer"); + this._scriptInterface.addCallback('load_parameters_from_buffer', (str: string): boolean => { + log.info('TODO: load_parameters_from_buffer'); return false; // let buf: ByteArray = new ByteArray; // buf.writeUTFBytes(str); @@ -900,7 +933,7 @@ export default class PoseEditMode extends GameMode { } // Miscellanous - this._scriptInterface.addCallback("sparks_effect", (from: number, to: number): void => { + this._scriptInterface.addCallback('sparks_effect', (from: number, to: number): void => { // FIXME: check PiP mode and handle accordingly for (let pose of this._poses) { pose.praiseSequence(from, to); @@ -908,47 +941,49 @@ export default class PoseEditMode extends GameMode { }); // Setters - this._scriptInterface.addCallback("set_sequence_string", (seq: string): boolean => { - let seq_arr: number[] = EPars.stringToSequence(seq); - if (seq_arr.indexOf(EPars.RNABASE_UNDEFINED) >= 0 || seq_arr.indexOf(EPars.RNABASE_CUT) >= 0) { - log.info("Invalid characters in " + seq); + this._scriptInterface.addCallback('set_sequence_string', (seq: string): boolean => { + let seqArr: number[] = EPars.stringToSequence(seq); + if (seqArr.indexOf(EPars.RNABASE_UNDEFINED) >= 0 || seqArr.indexOf(EPars.RNABASE_CUT) >= 0) { + log.info(`Invalid characters in ${seq}`); return false; } let prevForceSync = this.forceSync; this.forceSync = true; for (let pose of this._poses) { - pose.pasteSequence(seq_arr); + pose.pasteSequence(seqArr); } this.forceSync = prevForceSync; - this.moveHistoryAddSequence("paste", seq); + this.moveHistoryAddSequence('paste', seq); return true; }); - this._scriptInterface.addCallback("set_tracked_indices", (marks: number[], colors?: number[]): void => { - for (let ii: number = 0; ii < this.numPoseFields; ii++) { + this._scriptInterface.addCallback('set_tracked_indices', (marks: number[], colors?: number[]): void => { + for (let ii = 0; ii < this.numPoseFields; ii++) { let pose: Pose2D = this.getPose(ii); pose.clearTracking(); let baseColors: number[] = []; if (colors) { - if (colors.length == marks.length) { + if (colors.length === marks.length) { baseColors = colors; } else { - console.error("Mark array is not the same length as color array for set_tracked_indices - leaving as black"); + log.error( + 'Mark array is not the same length as color array in set_tracked_indices - leaving as black' + ); } } - if (baseColors.length == 0) { + if (baseColors.length === 0) { baseColors = marks.map(idx => 0x000000); } - for (let k: number = 0; k < marks.length; k++) { + for (let k = 0; k < marks.length; k++) { pose.addBaseMark(marks[k], baseColors[k]); } } }); - this._scriptInterface.addCallback("set_design_title", (design_title: string): void => { - log.info("TODO: set_design_title"); + this._scriptInterface.addCallback('set_design_title', (designTitle: string): void => { + log.info('TODO: set_design_title'); // Application.instance.get_application_gui("Design Name").set_text(design_title); // Application.instance.get_application_gui("Design Name").visible = true; this.clearUndoStack(); @@ -956,22 +991,22 @@ export default class PoseEditMode extends GameMode { }); } - public on_click_run(): void { + public onClickRun(): void { let nid: string = this._nidField.text; if (nid.length === 0) { return; } this._runStatus.style.fill = 0xC0C0C0; - this._runStatus.text = "running..."; + this._runStatus.text = 'running...'; - const LOCK_NAME = "RunScript"; + const LOCK_NAME = 'RunScript'; this.pushUILock(LOCK_NAME); ExternalInterface.runScript(nid) - .then(ret => { + .then((ret) => { log.info(ret); - if (typeof(ret['cause']) === "string") { + if (typeof (ret['cause']) === 'string') { this._runStatus.style.fill = (ret['result'] ? 0x00FF00 : 0xFF0000); this._runStatus.text = ret['cause']; } @@ -982,21 +1017,21 @@ export default class PoseEditMode extends GameMode { } public layoutConstraints(): void { - let min_x: number = this._constraintsOffset + 17; - let rel_x: number; + let minX: number = this._constraintsOffset + 17; + let relX: number; if (this._targetPairs == null) return; let n: number = this._targetPairs.length; if (n < 2) return; - for (let ii: number = 1; ii < n; ii++) { - rel_x = (ii / n) * Flashbang.stageWidth + 17; - if (rel_x < min_x) rel_x = min_x; + for (let ii = 1; ii < n; ii++) { + relX = (ii / n) * Flashbang.stageWidth + 17; + if (relX < minX) relX = minX; if (this._constraintShapeBoxes[ii]) { - this._constraintShapeBoxes[ii].display.position = new Point(rel_x, 35); - min_x = rel_x + 77; + this._constraintShapeBoxes[ii].display.position = new Point(relX, 35); + minX = relX + 77; } if (this._constraintAntishapeBoxes[ii]) { - this._constraintAntishapeBoxes[ii].display.position = new Point(rel_x + 77, 35); - min_x = rel_x + 2 * 77; + this._constraintAntishapeBoxes[ii].display.position = new Point(relX + 77, 35); + minX = relX + 2 * 77; } } } @@ -1035,13 +1070,12 @@ export default class PoseEditMode extends GameMode { } private showNextSolution(indexOffset: number): void { - if (this._params.solutions == null || this._params.solutions.length == 0) { + if (this._params.solutions == null || this._params.solutions.length === 0) { return; } const curSolutionIdx = this._params.solutions.indexOf(this._curSolution); - let nextSolutionIdx = - (curSolutionIdx >= 0 ? curSolutionIdx + indexOffset : 0) % this._params.solutions.length; + let nextSolutionIdx = (curSolutionIdx >= 0 ? curSolutionIdx + indexOffset : 0) % this._params.solutions.length; if (nextSolutionIdx < 0) { nextSolutionIdx = this._params.solutions.length + nextSolutionIdx; } @@ -1051,11 +1085,11 @@ export default class PoseEditMode extends GameMode { this.showSolution(solution); } - /*override*/ + /* override */ public update(dt: number): void { // process queued asynchronous operations (folding) const startTime = new Date().getTime(); - let elapsed: number = 0; + let elapsed = 0; while (this._opQueue.length > 0 && elapsed < 50) { // FIXME: arbitrary let op: PoseOp = this._opQueue.shift(); op.fn(); @@ -1079,12 +1113,12 @@ export default class PoseEditMode extends GameMode { return this._isPlaying; } - public showMissionScreen(do_show: boolean): void { - this._showMissionScreen = do_show; + public showMissionScreen(doShow: boolean): void { + this._showMissionScreen = doShow; } - public showConstraints(do_show: boolean): void { - this._overrideShowConstraints = do_show; + public showConstraints(doShow: boolean): void { + this._overrideShowConstraints = doShow; if (this._constraintsLayer != null) { this._constraintsLayer.visible = this._constraintsLayer.visible && this._overrideShowConstraints; } @@ -1098,7 +1132,7 @@ export default class PoseEditMode extends GameMode { return this._constraintBoxes[this._constraintBoxes.length - i - 1]; } - public get_shape_box(i: number): ConstraintBox { + public getShapeBox(i: number): ConstraintBox { return this._constraintBoxes[i]; } @@ -1106,11 +1140,11 @@ export default class PoseEditMode extends GameMode { this._ancestorId = id; } - /*override*/ - protected onSetPip(pip_mode: boolean): void { - Eterna.settings.pipEnabled.value = pip_mode; + /* override */ + protected onSetPip(pipMode: boolean): void { + Eterna.settings.pipEnabled.value = pipMode; - if (pip_mode) { + if (pipMode) { this._toolbar.stateToggle.display.visible = false; this._targetName.visible = false; @@ -1128,15 +1162,14 @@ export default class PoseEditMode extends GameMode { this.setToFrozenMode(); } - let min_zoom: number = -1; + let minZoom = -1; for (let pose of this._poses) { - min_zoom = Math.max(min_zoom, pose.computeDefaultZoomLevel()); + minZoom = Math.max(minZoom, pose.computeDefaultZoomLevel()); } for (let pose of this._poses) { - pose.setZoomLevel(min_zoom); + pose.setZoomLevel(minZoom); } - } else { this._toolbar.stateToggle.display.visible = true; this._targetName.visible = true; @@ -1146,7 +1179,7 @@ export default class PoseEditMode extends GameMode { } } - /*override*/ + /* override */ protected createContextMenu(): ContextMenu { if (this.isDialogOrNotifShowing || this.hasUILock) { return null; @@ -1154,27 +1187,27 @@ export default class PoseEditMode extends GameMode { let menu = new ContextMenu(); - menu.addItem("Preferences").clicked.connect(() => this.showViewOptionsDialog()); - if (this._puzzle.puzzleType == PuzzleType.EXPERIMENTAL) { - menu.addItem("Design Browser").clicked.connect(() => this.openDesignBrowserForOurPuzzle()); - menu.addItem("Submit").clicked.connect(() => this.submitCurrentPose()); - menu.addItem("Specs").clicked.connect(() => this.showSpec()); + menu.addItem('Preferences').clicked.connect(() => this.showViewOptionsDialog()); + if (this._puzzle.puzzleType === PuzzleType.EXPERIMENTAL) { + menu.addItem('Design Browser').clicked.connect(() => this.openDesignBrowserForOurPuzzle()); + menu.addItem('Submit').clicked.connect(() => this.submitCurrentPose()); + menu.addItem('Specs').clicked.connect(() => this.showSpec()); } - menu.addItem("Reset").clicked.connect(() => this.showResetPrompt()); - menu.addItem("Copy Sequence").clicked.connect(() => this.showCopySequenceDialog()); - menu.addItem("Paste Sequence").clicked.connect(() => this.showPasteSequenceDialog()); - menu.addItem("Beam to PuzzleMaker").clicked.connect(() => this.transferToPuzzlemaker()); + menu.addItem('Reset').clicked.connect(() => this.showResetPrompt()); + menu.addItem('Copy Sequence').clicked.connect(() => this.showCopySequenceDialog()); + menu.addItem('Paste Sequence').clicked.connect(() => this.showPasteSequenceDialog()); + menu.addItem('Beam to PuzzleMaker').clicked.connect(() => this.transferToPuzzlemaker()); return menu; } private openDesignBrowserForOurPuzzle(): void { - if (this._puzzle.puzzleType == PuzzleType.EXPERIMENTAL) { + if (this._puzzle.puzzleType === PuzzleType.EXPERIMENTAL) { this.pushUILock(); Eterna.app.switchToDesignBrowser(this._puzzle) .then(() => this.popUILock()) - .catch(e => { + .catch((e) => { log.error(e); this.popUILock(); }); @@ -1203,11 +1236,10 @@ export default class PoseEditMode extends GameMode { let tempBG = DisplayUtil.fillStageRect(0x061A34); this.container.addChildAt(tempBG, 0); - let info = - `Player: ${Eterna.playerName}\n` + - `Puzzle ID: ${this._puzzle.nodeID}\n` + - `Puzzle Title: ${this._puzzle.getName()}\n` + - `Mode: ${this.toolbar.naturalButton.isSelected ? "NativeMode" : "TargetMode"}`; + let info = `Player: ${Eterna.playerName}\n` + + `Puzzle ID: ${this._puzzle.nodeID}\n` + + `Puzzle Title: ${this._puzzle.getName()}\n` + + `Mode: ${this.toolbar.naturalButton.isSelected ? 'NativeMode' : 'TargetMode'}`; let infoText = Fonts.arial(info).color(0xffffff).build(); this.container.addChild(infoText); @@ -1229,14 +1261,14 @@ export default class PoseEditMode extends GameMode { private exitPuzzle(): void { if (this._submitSolutionRspData == null) { - throw new Error("exit_puzzle was called before we submitted a solution"); + throw new Error('exit_puzzle was called before we submitted a solution'); } this.showMissionClearedPanel(this._submitSolutionRspData); } private showResetPrompt(): void { - const PROMPT = "Do you really want to reset?\nResetting will clear your undo stack."; - this.showConfirmDialog(PROMPT).closed.then(confirmed => { + const PROMPT = 'Do you really want to reset?\nResetting will clear your undo stack.'; + this.showConfirmDialog(PROMPT).closed.then((confirmed) => { if (confirmed) { this.resetAutosaveData(); this._puzzle.temporaryConstraints = null; @@ -1245,8 +1277,8 @@ export default class PoseEditMode extends GameMode { }); } - private changeTarget(target_index: number): void { - this._curTargetIndex = target_index; + private changeTarget(targetIndex: number): void { + this._curTargetIndex = targetIndex; if (this._targetConditions && this._targetConditions[this._curTargetIndex]) { if (this._targetConditions[this._curTargetIndex]['state_name'] != null) { @@ -1262,23 +1294,23 @@ export default class PoseEditMode extends GameMode { } } - private getForcedHighlights(target_index: number): number[] { + private getForcedHighlights(targetIndex: number): number[] { let elems: number[] = null; if (this._targetConditions) { - let max_len: number = this._poses[target_index].sequence.length; - for (let ii: number = 0; ii < this._poses.length; ii++) { - if (ii === target_index || this._targetConditions[ii]['force_struct'] == null) { + let maxLen: number = this._poses[targetIndex].sequence.length; + for (let ii = 0; ii < this._poses.length; ii++) { + if (ii === targetIndex || this._targetConditions[ii]['force_struct'] == null) { continue; } if (elems == null) { elems = []; } - let curr: number = 1; + let curr = 1; let forced: number[] = EPars.parenthesisToForcedArray(this._targetConditions[ii]['force_struct']); let jj; - for (jj = 0; jj < max_len && jj < forced.length; jj++) { + for (jj = 0; jj < maxLen && jj < forced.length; jj++) { let _stat: number = (forced[jj] === EPars.FORCE_IGNORE ? 1 : 0); if ((curr ^ _stat) !== 0) { elems.push(jj - _stat); @@ -1294,64 +1326,72 @@ export default class PoseEditMode extends GameMode { return elems; } - private setPoseTarget(pose_index: number, target_index: number): void { - if (this._targetConditions[target_index] != null) { - this._poses[pose_index].sequence = this._puzzle.transformSequence(this._poses[target_index].sequence, target_index); - let tc_type: string = this._targetConditions[target_index]['type']; + private setPoseTarget(poseIndex: number, targetIndex: number): void { + if (this._targetConditions[targetIndex] != null) { + this._poses[poseIndex].sequence = this._puzzle.transformSequence( + this._poses[targetIndex].sequence, targetIndex + ); + let tcType: string = this._targetConditions[targetIndex]['type']; - if (tc_type === "multistrand") { - let odefs: OligoDef[] = this._targetConditions[target_index]['oligos']; + if (tcType === 'multistrand') { + let odefs: OligoDef[] = this._targetConditions[targetIndex]['oligos']; let ndefs: Oligo[] = []; - for (let ii: number = 0; ii < odefs.length; ii++) { + for (let ii = 0; ii < odefs.length; ii++) { ndefs.push({ sequence: EPars.stringToSequence(odefs[ii].sequence), malus: odefs[ii].malus, name: odefs[ii]['name'] }); } - this._poses[pose_index].setOligos(ndefs, this._targetOligosOrder[target_index]); + this._poses[poseIndex].setOligos(ndefs, this._targetOligosOrder[targetIndex]); } else { - this._poses[pose_index].setOligos(null); - } - - if (Puzzle.isOligoType(tc_type)) { - let fold_mode: number = this._targetConditions[target_index]["fold_mode"] == null ? - Pose2D.OLIGO_MODE_DIMER : - Number(this._targetConditions[target_index]["fold_mode"]); - this._poses[pose_index].setOligo(EPars.stringToSequence(this._targetConditions[target_index]['oligo_sequence']), fold_mode, - this._targetConditions[target_index]['oligo_name']); - this._poses[pose_index].oligoMalus = this._targetConditions[target_index]["malus"]; + this._poses[poseIndex].setOligos(null); + } + + if (Puzzle.isOligoType(tcType)) { + let foldMode: number = this._targetConditions[targetIndex]['fold_mode'] == null + ? Pose2D.OLIGO_MODE_DIMER + : Number(this._targetConditions[targetIndex]['fold_mode']); + this._poses[poseIndex].setOligo( + EPars.stringToSequence(this._targetConditions[targetIndex]['oligo_sequence']), + foldMode, + this._targetConditions[targetIndex]['oligo_name'] + ); + this._poses[poseIndex].oligoMalus = this._targetConditions[targetIndex]['malus']; } else { - this._poses[pose_index].setOligo(null); + this._poses[poseIndex].setOligo(null); } - if (Puzzle.isAptamerType(tc_type)) { - this._poses[pose_index].setMolecularBinding(this._targetConditions[target_index]['site'], this._targetConditions[target_index]['binding_pairs'], this._targetConditions[target_index]['bonus'] / 100.0); + if (Puzzle.isAptamerType(tcType)) { + this._poses[poseIndex].setMolecularBinding( + this._targetConditions[targetIndex]['site'], + this._targetConditions[targetIndex]['binding_pairs'], + this._targetConditions[targetIndex]['bonus'] / 100.0 + ); } else { - this._poses[pose_index].setMolecularBinding(null, null, null); + this._poses[poseIndex].setMolecularBinding(null, null, null); } - let forced_struct: number[] = null; - if (this._targetConditions[target_index]['force_struct'] != null) { - forced_struct = EPars.parenthesisToForcedArray(this._targetConditions[target_index]['force_struct']); + let forcedStruct: number[] = null; + if (this._targetConditions[targetIndex]['force_struct'] != null) { + forcedStruct = EPars.parenthesisToForcedArray(this._targetConditions[targetIndex]['force_struct']); } - this._poses[pose_index].forcedStruct = forced_struct; - this._poses[pose_index].structConstraints = this._targetConditions[target_index]['structure_constraints']; - + this._poses[poseIndex].forcedStruct = forcedStruct; + this._poses[poseIndex].structConstraints = this._targetConditions[targetIndex]['structure_constraints']; } else { - this._poses[pose_index].setMolecularBinding(null, null, 0); - this._poses[pose_index].forcedStruct = null; - this._poses[pose_index].structConstraints = null; - this._poses[pose_index].setOligos(null); - this._poses[pose_index].setOligo(null); + this._poses[poseIndex].setMolecularBinding(null, null, 0); + this._poses[poseIndex].forcedStruct = null; + this._poses[poseIndex].structConstraints = null; + this._poses[poseIndex].setOligos(null); + this._poses[poseIndex].setOligo(null); } - this._poses[pose_index].forcedHighlights = this.getForcedHighlights(target_index); + this._poses[poseIndex].forcedHighlights = this.getForcedHighlights(targetIndex); if (this._puzzle.nodeID === 2390140) { - if (target_index === 1) { - this._poses[pose_index].auxInfo(null); + if (targetIndex === 1) { + this._poses[poseIndex].auxInfo(null); } else { - this._poses[pose_index].auxInfo({cleaving_site: 28}); + this._poses[poseIndex].auxInfo({cleavingSite: 28}); } } } @@ -1402,11 +1442,18 @@ export default class PoseEditMode extends GameMode { } } } else { - this._poses[0].setOligos(this._targetOligos[this._curTargetIndex], this._targetOligosOrder[this._curTargetIndex]); - this._poses[0].setOligo(this._targetOligo[this._curTargetIndex], this._oligoMode[this._curTargetIndex], this._oligoName[this._curTargetIndex]); + this._poses[0].setOligos( + this._targetOligos[this._curTargetIndex], this._targetOligosOrder[this._curTargetIndex] + ); + this._poses[0].setOligo( + this._targetOligo[this._curTargetIndex], + this._oligoMode[this._curTargetIndex], + this._oligoName[this._curTargetIndex] + ); this._poses[0].pairs = this._targetPairs[this._curTargetIndex]; if (this._targetConditions != null && this._targetConditions[this._curTargetIndex] != null) { - this._poses[0].structConstraints = this._targetConditions[this._curTargetIndex]['structure_constraints']; + let newConstraints = this._targetConditions[this._curTargetIndex]['structure_constraints']; + this._poses[0].structConstraints = newConstraints; } } @@ -1421,7 +1468,7 @@ export default class PoseEditMode extends GameMode { } else if (this._poseState === PoseState.NATIVE) { this.setToTargetMode(); } else { - throw new Error("Invalid pose state"); + throw new Error('Invalid pose state'); } } @@ -1442,7 +1489,7 @@ export default class PoseEditMode extends GameMode { this._background.freezeBackground(this._isFrozen); } - /// This mode is strictly for internal use, not to be used by users + // / This mode is strictly for internal use, not to be used by users private setToFrozenMode(): void { this._poseState = PoseState.FROZEN; this._paused = true; @@ -1476,9 +1523,11 @@ export default class PoseEditMode extends GameMode { } private changeFolder(): void { - let curr_f: string = this._folder.name; - this._folder = FolderManager.instance.getNextFolder(curr_f, (folder: Folder) => !this._puzzle.canUseFolder(folder)); - if (this._folder.name === curr_f) return; + let currF: string = this._folder.name; + this._folder = FolderManager.instance.getNextFolder( + currF, (folder: Folder) => !this._puzzle.canUseFolder(folder) + ); + if (this._folder.name === currF) return; this.onFolderUpdated(); } @@ -1490,7 +1539,7 @@ export default class PoseEditMode extends GameMode { let puzzleState = this.getCurrentUndoBlock(); let dialog = this.showDialog(new SpecBoxDialog(puzzleState)); - dialog.closed.then(showDocked => { + dialog.closed.then((showDocked) => { if (showDocked) { this._dockedSpecBox.setSpec(puzzleState); this._dockedSpecBox.display.visible = true; @@ -1515,25 +1564,22 @@ export default class PoseEditMode extends GameMode { private submitCurrentPose(): void { if (this._puzzle.puzzleType !== PuzzleType.EXPERIMENTAL) { - /// Always submit the sequence in the first state - let sol_to_submit: UndoBlock = this.getCurrentUndoBlock(0); - this.submitSolution({title: "Cleared Solution", comment: "No comment"}, sol_to_submit); - + // / Always submit the sequence in the first state + let solToSubmit: UndoBlock = this.getCurrentUndoBlock(0); + this.submitSolution({title: 'Cleared Solution', comment: 'No comment'}, solToSubmit); } else { - const NOT_SATISFIED_PROMPT = - "Puzzle constraints are not satisfied.\n" + - "You can still submit the sequence, but please note that there is a risk of not getting\n" + - "synthesized properly"; + const NOT_SATISFIED_PROMPT = 'Puzzle constraints are not satisfied.\n' + + 'You can still submit the sequence, but please note that there is a risk of not getting\n' + + 'synthesized properly'; if (!this.checkConstraints(false)) { if (this._puzzle.isSoftConstraint || Eterna.DEV_MODE) { this.showConfirmDialog(NOT_SATISFIED_PROMPT).closed - .then(confirmed => { + .then((confirmed) => { if (confirmed) { - this.promptForExperimentalPuzzleSubmission() + this.promptForExperimentalPuzzleSubmission(); } }); - } else { this.showNotification("You didn't satisfy all requirements!"); } @@ -1544,21 +1590,21 @@ export default class PoseEditMode extends GameMode { } private promptForExperimentalPuzzleSubmission(): void { - /// Generate dot and melting plot data + // / Generate dot and melting plot data this.updateCurrentBlockWithDotAndMeltingPlot(); - /// Generate dot and melting plot data + // / Generate dot and melting plot data let datablock: UndoBlock = this.getCurrentUndoBlock(); if (datablock.getParam(UndoBlockParam.DOTPLOT_BITMAP) == null) { this.updateCurrentBlockWithDotAndMeltingPlot(); } - let init_score: number = datablock.getParam(UndoBlockParam.PROB_SCORE, 37); + let initScore: number = datablock.getParam(UndoBlockParam.PROB_SCORE, 37); - let meltpoint: number = 107; - for (let ii: number = 47; ii < 100; ii += 10) { - let current_score: number = datablock.getParam(UndoBlockParam.PROB_SCORE, ii); - if (current_score < init_score * 0.5) { + let meltpoint = 107; + for (let ii = 47; ii < 100; ii += 10) { + let currentScore: number = datablock.getParam(UndoBlockParam.PROB_SCORE, ii); + if (currentScore < initScore * 0.5) { meltpoint = ii; break; } @@ -1566,12 +1612,12 @@ export default class PoseEditMode extends GameMode { datablock.setParam(UndoBlockParam.MELTING_POINT, meltpoint, 37); - this.showDialog(new SubmitPoseDialog()).closed.then(submitDetails => { + this.showDialog(new SubmitPoseDialog()).closed.then((submitDetails) => { if (submitDetails != null) { - /// Always submit the sequence in the first state + // / Always submit the sequence in the first state this.updateCurrentBlockWithDotAndMeltingPlot(0); - let sol_to_submit: UndoBlock = this.getCurrentUndoBlock(0); - this.submitSolution(submitDetails, sol_to_submit); + let solToSubmit: UndoBlock = this.getCurrentUndoBlock(0); + this.submitSolution(submitDetails, solToSubmit); } }); } @@ -1579,72 +1625,71 @@ export default class PoseEditMode extends GameMode { /** Creates solution-submission data for shipping off to the server */ private createSubmitData(details: SubmitPoseDetails, undoBlock: UndoBlock): any { if (details.title.length === 0) { - details.title = "Default title"; + details.title = 'Default title'; } if (details.comment.length === 0) { - details.comment = "No comment"; + details.comment = 'No comment'; } - let post_data: any = {}; + let postData: any = {}; if (this._puzzle.puzzleType !== PuzzleType.EXPERIMENTAL) { - let next_puzzle: number = this._puzzle.nextPuzzleID; + let nextPuzzle: number = this._puzzle.nextPuzzleID; - if (next_puzzle > 0) { - post_data["next-puzzle"] = next_puzzle; + if (nextPuzzle > 0) { + postData['next-puzzle'] = nextPuzzle; } else { - post_data["recommend-puzzle"] = true; + postData['recommend-puzzle'] = true; } - post_data["pointsrank"] = true; - } else { // is experimental - if (this._ancestorId > 0) { - post_data["ancestor-id"] = this._ancestorId; - } + postData['pointsrank'] = true; + } else if (this._ancestorId > 0) { + // is experimental + postData['ancestor-id'] = this._ancestorId; } let elapsed: number = (new Date().getTime() - this._startSolvingTime) / 1000; - let move_history: any = { - begin_from: this._startingPoint, - num_moves: this._moveCount, + let moveHistory: any = { + beginFrom: this._startingPoint, + numMoves: this._moveCount, moves: this._moves.slice(), elapsed: elapsed.toFixed(0) }; - post_data["move-history"] = JSON.stringify(move_history); + postData['move-history'] = JSON.stringify(moveHistory); - let newlinereg: RegExp = new RegExp("/\"/g"); + let newlinereg = new RegExp('/"/g'); details.comment = details.comment.replace(newlinereg, "'"); details.title = details.title.replace(newlinereg, "'"); - let seq_string: string = EPars.sequenceToString(this._puzzle.transformSequence(undoBlock.sequence, 0)); + let seqString: string = EPars.sequenceToString(this._puzzle.transformSequence(undoBlock.sequence, 0)); - post_data["title"] = details.title; - post_data["energy"] = undoBlock.getParam(UndoBlockParam.FE) / 100.0; - post_data["puznid"] = this._puzzle.nodeID; - post_data["sequence"] = seq_string; - post_data["repetition"] = undoBlock.getParam(UndoBlockParam.REPETITION); - post_data["gu"] = undoBlock.getParam(UndoBlockParam.GU); - post_data["gc"] = undoBlock.getParam(UndoBlockParam.GC); - post_data["ua"] = undoBlock.getParam(UndoBlockParam.AU); - post_data["body"] = details.comment; + postData['title'] = details.title; + postData['energy'] = undoBlock.getParam(UndoBlockParam.FE) / 100.0; + postData['puznid'] = this._puzzle.nodeID; + postData['sequence'] = seqString; + postData['repetition'] = undoBlock.getParam(UndoBlockParam.REPETITION); + postData['gu'] = undoBlock.getParam(UndoBlockParam.GU); + postData['gc'] = undoBlock.getParam(UndoBlockParam.GC); + postData['ua'] = undoBlock.getParam(UndoBlockParam.AU); + postData['body'] = details.comment; if (this._puzzle.puzzleType === PuzzleType.EXPERIMENTAL) { - post_data["melt"] = undoBlock.getParam(UndoBlockParam.MELTING_POINT); + postData['melt'] = undoBlock.getParam(UndoBlockParam.MELTING_POINT); if (this._foldTotalTime >= 1000.0) { let fd: any[] = []; - for (let ii: number = 0; ii < this._poses.length; ii++) { + for (let ii = 0; ii < this._poses.length; ii++) { fd.push(this.getCurrentUndoBlock(ii).toJSON()); } - post_data["fold-data"] = JSON.stringify(fd); + postData['fold-data'] = JSON.stringify(fd); } } - return post_data; + return postData; } - private submitSolution(details: SubmitPoseDetails, undoBlock: UndoBlock): void { + private async submitSolution(details: SubmitPoseDetails, undoBlock: UndoBlock): Promise { this._rscript.finishLevel(); if (this._puzzle.nodeID < 0) { @@ -1658,7 +1703,6 @@ export default class PoseEditMode extends GameMode { // Show a "Submitting now!" dialog submittingRef = this.showDialog(new SubmittingDialog()).ref; fxComplete = Promise.resolve(); - } else { // Kick off a BubbleSweep animation let bubbles = new BubbleSweep(800); @@ -1681,9 +1725,9 @@ export default class PoseEditMode extends GameMode { new SelfDestructTask() )); - for (let pose of this._poses) { - pose.showTotalEnergy = false; - pose.clearExplosion(); + for (let poseToClear of this._poses) { + poseToClear.showTotalEnergy = false; + poseToClear.clearExplosion(); } this._constraintsLayer.visible = false; @@ -1693,72 +1737,68 @@ export default class PoseEditMode extends GameMode { } // submit our solution to the server - log.debug("Submitting solution..."); + log.debug('Submitting solution...'); let submissionPromise = Eterna.client.submitSolution(this.createSubmitData(details, undoBlock)); // Wait for explosion completion - fxComplete.then(() => { - // Wait for the submission to the server, and for the mode to be active. - // 'waitTillActive' is probably not necessary in practice, but if another mode is pushed onto this one - // during submission, we want to wait till we're the top-most mode before executing more view logic. - return Promise.all([submissionPromise, this.waitTillActive()]); - }) - .then(allResults => { - // 'allResults' contains the results of our submission, and the "waitTillActive" void promise - let submissionResponse = allResults[0]; - - // show achievements, if we were awarded any - let cheevs: any = submissionResponse['new_achievements']; - if (cheevs != null) { - return this._achievements.awardAchievements(cheevs).then(() => submissionResponse); - } else { - return Promise.resolve(submissionResponse); - } - }) - .then(submissionResponse => { - submittingRef.destroyObject(); + await fxComplete; + + // Wait for the submission to the server, and for the mode to be active. + // 'waitTillActive' is probably not necessary in practice, but if another mode is pushed onto this one + // during submission, we want to wait till we're the top-most mode before executing more view logic. + let allResults = await Promise.all([submissionPromise, this.waitTillActive()]); + + // 'allResults' contains the results of our submission, and the "waitTillActive" void promise + let submissionResponse = allResults[0]; + + // show achievements, if we were awarded any + let cheevs: any = submissionResponse['new_achievements']; + if (cheevs != null) { + await this._achievements.awardAchievements(cheevs); + } - let data: any = submissionResponse['data']; + submittingRef.destroyObject(); - if (this._puzzle.puzzleType !== PuzzleType.EXPERIMENTAL) { - this.showMissionClearedPanel(data); + let data: any = submissionResponse['data']; + + if (this._puzzle.puzzleType !== PuzzleType.EXPERIMENTAL) { + this.showMissionClearedPanel(data); + } + + const seqString = EPars.sequenceToString( + this._puzzle.transformSequence(undoBlock.sequence, 0) + ); + + if (data['error'] != null) { + log.debug(`Got solution submission error: ${data['error']}`); + if (data['error'].indexOf('barcode') >= 0) { + let dialog = this.showNotification(data['error'], 'More Information'); + dialog.extraButton.clicked.connect(() => window.open(EternaURL.BARCODE_HELP, '_blank')); + let hairpin: string = EPars.getBarcodeHairpin(seqString); + if (hairpin != null) { + SolutionManager.instance.addHairpins([hairpin]); + this.checkConstraints(); + } + } else { + this.showNotification(data['error']); } + } else { + log.debug('Solution submitted'); - const seqString = EPars.sequenceToString( - this._puzzle.transformSequence(undoBlock.sequence, 0)); + if (data['solution-id'] != null) { + this.setAncestorId(data['solution-id']); + } - if (data['error'] != null) { - log.debug(`Got solution submission error: ${data["error"]}`); - if (data['error'].indexOf('barcode') >= 0) { - let dialog = this.showNotification(data['error'], "More Information"); - dialog.extraButton.clicked.connect(() => window.open(EternaURL.BARCODE_HELP, "_blank")); + if (this._puzzle.puzzleType === PuzzleType.EXPERIMENTAL) { + if (this._puzzle.useBarcode) { let hairpin: string = EPars.getBarcodeHairpin(seqString); if (hairpin != null) { SolutionManager.instance.addHairpins([hairpin]); this.checkConstraints(); } - } else { - this.showNotification(data['error']); - } - - } else { - log.debug("Solution submitted"); - - if (data['solution-id'] != null) { - this.setAncestorId(data['solution-id']); - } - - if (this._puzzle.puzzleType === PuzzleType.EXPERIMENTAL) { - if (this._puzzle.useBarcode) { - let hairpin: string = EPars.getBarcodeHairpin(seqString); - if (hairpin != null) { - SolutionManager.instance.addHairpins([hairpin]); - this.checkConstraints(); - } - } } } - }); + } } private showMissionClearedPanel(submitSolutionRspData: any): void { @@ -1779,8 +1819,8 @@ export default class PoseEditMode extends GameMode { let moreText: string = null; let boostersData = this._puzzle.boosters; if (boostersData != null && boostersData.mission_cleared != null) { - infoText = boostersData.mission_cleared["info"]; - moreText = boostersData.mission_cleared["more"]; + infoText = boostersData.mission_cleared['info']; + moreText = boostersData.mission_cleared['more']; } let nextPuzzleData: any = submitSolutionRspData['next-puzzle']; @@ -1790,7 +1830,7 @@ export default class PoseEditMode extends GameMode { nextPuzzle = PuzzleManager.instance.parsePuzzle(nextPuzzleData); log.info(`Loaded next puzzle [id=${nextPuzzle.nodeID}]`); } catch (err) { - log.error(`Failed to load next puzzle`, err); + log.error('Failed to load next puzzle', err); } } @@ -1831,7 +1871,7 @@ export default class PoseEditMode extends GameMode { } else { missionClearedPanel.nextButton.clicked.connect(() => { keepPlaying(); - window.open(EternaURL.getFeedURL(), "_self"); + window.open(EternaURL.getFeedURL(), '_self'); }); } @@ -1877,7 +1917,7 @@ export default class PoseEditMode extends GameMode { } private displayConstraintBoxes(animate: boolean, display: boolean): void { - let num_constraints: number = 0; + let numConstraints = 0; let constraints: string[] = this._puzzle.constraints; if (this._puzzle.temporaryConstraints != null) { @@ -1885,54 +1925,56 @@ export default class PoseEditMode extends GameMode { } if (constraints != null) { - num_constraints = constraints.length; + numConstraints = constraints.length; } - let w_walker: number = 17; + let wWalker = 17; for (let xx = 0; xx < this._targetPairs.length; xx++) { if (xx === 0) { // scan for non-(ANTI)SHAPE - for (let ii = 0; ii < num_constraints / 2; ii++) { + for (let ii = 0; ii < numConstraints / 2; ii++) { const box = this._constraintBoxes[ii]; - if (box.constraintType === ConstraintType.SHAPE || box.constraintType === ConstraintType.ANTISHAPE) { + if ( + box.constraintType === ConstraintType.SHAPE || box.constraintType === ConstraintType.ANTISHAPE + ) { continue; } - let cpos = new Point(w_walker, 35); - w_walker += 119; + let cpos = new Point(wWalker, 35); + wWalker += 119; box.setLocation(cpos, animate); box.showBigText = false; box.display.visible = display; } - if (w_walker > 17) { - w_walker += 25; + if (wWalker > 17) { + wWalker += 25; } } else if (xx === 1) { // save the offset for later use (avoid overlaps in PIP mode) - this._constraintsOffset = w_walker; + this._constraintsOffset = wWalker; } // scan for SHAPE - for (let ii = 0; ii < num_constraints / 2; ii++) { + for (let ii = 0; ii < numConstraints / 2; ii++) { const box = this._constraintBoxes[ii]; if (box.constraintType !== ConstraintType.SHAPE || int(constraints[2 * ii + 1]) !== xx) { continue; } - let cpos = new Point(w_walker, 35); - w_walker += 77; + let cpos = new Point(wWalker, 35); + wWalker += 77; box.setLocation(cpos, animate); box.showBigText = false; box.display.visible = (xx === 0 || !this._isPipMode) ? display : false; } // scan for ANTISHAPE - for (let ii = 0; ii < num_constraints / 2; ii++) { + for (let ii = 0; ii < numConstraints / 2; ii++) { const box = this._constraintBoxes[ii]; if (box.constraintType !== ConstraintType.ANTISHAPE || int(constraints[2 * ii + 1]) !== xx) { continue; } - let cpos = new Point(w_walker, 35); - w_walker += 77; + let cpos = new Point(wWalker, 35); + wWalker += 77; box.setLocation(cpos, animate); box.showBigText = false; box.display.visible = (xx === 0 || !this._isPipMode) ? display : false; @@ -1948,7 +1990,6 @@ export default class PoseEditMode extends GameMode { const constraints: string[] = this._puzzle.curConstraints; if (constraints == null || constraints.length === 0 || !this._showMissionScreen) { this.startPlaying(); - } else { this.setPuzzleState(PuzzleState.COUNTDOWN); @@ -1962,7 +2003,8 @@ export default class PoseEditMode extends GameMode { box.setLocation(new Point( (Flashbang.stageWidth * 0.3), - (Flashbang.stageHeight * 0.4) + (ii * 77))); + (Flashbang.stageHeight * 0.4) + (ii * 77) + )); } this._startSolvingTime = new Date().getTime(); @@ -1985,11 +2027,11 @@ export default class PoseEditMode extends GameMode { // though uglier - to do things this way. let dummyInfo: ConstraintInfo = { - wrong_pairs: null, - restricted_local: null, - max_allowed_adenine: -1, - max_allowed_cytosine: -1, - max_allowed_guanine: -1, + wrongPairs: null, + restrictedLocal: null, + maxAllowedAdenine: -1, + maxAllowedCytosine: -1, + maxAllowedGuanine: -1 }; let introConstraintBoxes: ConstraintBox[] = []; let constraints = this._puzzle.constraints; @@ -2013,7 +2055,8 @@ export default class PoseEditMode extends GameMode { this._puzzle.getName(true), missionText, this._targetPairs, - introConstraintBoxes)); + introConstraintBoxes + )); }); } @@ -2039,11 +2082,11 @@ export default class PoseEditMode extends GameMode { } let objs: any[] = []; - let msecs: number = 0; + let msecs = 0; objs.push(msecs); objs.push(this._seqStacks[this._stackLevel][0].sequence); - for (let ii: number = 0; ii < this._poses.length; ++ii) { + for (let ii = 0; ii < this._poses.length; ++ii) { objs.push(JSON.stringify(this._seqStacks[this._stackLevel][ii].toJSON())); } @@ -2051,7 +2094,7 @@ export default class PoseEditMode extends GameMode { } public static savedDataTokenName(puzzleID: number): string { - return "puz_" + puzzleID; + return `puz_${puzzleID}`; } private get savedDataTokenName(): string { @@ -2081,21 +2124,24 @@ export default class PoseEditMode extends GameMode { // return false; // } - let beginning_sequence: number[] = this._puzzle.getBeginningSequence(); + let beginningSequence: number[] = this._puzzle.getBeginningSequence(); let locks: boolean[] = this._puzzle.puzzleLocks; - let oligo_len: number = 0; + let oligoLen = 0; if (this._targetConditions[0] && Puzzle.isOligoType(this._targetConditions[0]['type'])) { - oligo_len = this._targetConditions[0]['oligo_sequence'].length; - if (Number(this._targetConditions[0]["fold_mode"]) === Pose2D.OLIGO_MODE_DIMER) oligo_len++; - } else if (this._targetConditions[0] && this._targetConditions[0]['type'] === "multistrand") { + oligoLen = this._targetConditions[0]['oligo_sequence'].length; + if (Number(this._targetConditions[0]['fold_mode']) === Pose2D.OLIGO_MODE_DIMER) oligoLen++; + } else if (this._targetConditions[0] && this._targetConditions[0]['type'] === 'multistrand') { let oligos: OligoDef[] = this._targetConditions[0]['oligos']; for (let ii = 0; ii < oligos.length; ii++) { - oligo_len += (oligos[ii]['sequence'].length + 1); + oligoLen += (oligos[ii]['sequence'].length + 1); } } - if (beginning_sequence.length !== locks.length || (beginning_sequence.length + oligo_len) !== this._targetPairs[0].length) { + if ( + beginningSequence.length !== locks.length + || (beginningSequence.length + oligoLen) !== this._targetPairs[0].length + ) { return false; } this.clearUndoStack(); @@ -2114,35 +2160,35 @@ export default class PoseEditMode extends GameMode { let a: number[] = json[1]; for (let ii = 0; ii < this._poses.length; ++ii) { if (json[ii + 2] != null) { - let undo_block: UndoBlock = new UndoBlock([]); + let undoBlock: UndoBlock = new UndoBlock([]); try { - undo_block.fromJSON(JSON.parse(json[ii + 2])); + undoBlock.fromJSON(JSON.parse(json[ii + 2])); } catch (e) { - log.error("Error loading saved puzzle data", e); + log.error('Error loading saved puzzle data', e); return false; } - /// JEEFIX : Don't override secstruct from autoload without checking whther the puzzle can vary length. - /// KWSFIX : Only allow when shiftable mode (=> shift_limit = 0) + // / JEEFIX : Don't override secstruct from autoload without checking whther the puzzle can vary length. + // / KWSFIX : Only allow when shiftable mode (=> shift_limit = 0) - if (this._puzzle.shiftLimit === 0 && undo_block.targetPairs.length !== this._targetPairs[ii].length) { + if (this._puzzle.shiftLimit === 0 && undoBlock.targetPairs.length !== this._targetPairs[ii].length) { return false; } - this._targetPairs[ii] = undo_block.targetPairs; - this._targetOligosOrder[ii] = undo_block.targetOligoOrder; + this._targetPairs[ii] = undoBlock.targetPairs; + this._targetOligosOrder[ii] = undoBlock.targetOligoOrder; - this.setPosesWithUndoBlock(ii, undo_block); + this.setPosesWithUndoBlock(ii, undoBlock); } } - if ((a.length + oligo_len) !== this._targetPairs[0].length) { + if ((a.length + oligoLen) !== this._targetPairs[0].length) { return false; } for (let ii = 0; ii < this._targetPairs[0].length; ii++) { if (locks[ii]) { - a[ii] = beginning_sequence[ii]; + a[ii] = beginningSequence[ii]; } } @@ -2161,7 +2207,7 @@ export default class PoseEditMode extends GameMode { this._moves = []; } - private set_default_visibilities(): void { + private setDefaultVisibilities(): void { this._exitButton.display.visible = false; this._showMissionScreen = true; @@ -2173,7 +2219,7 @@ export default class PoseEditMode extends GameMode { private moveHistoryAddMutations(before: number[], after: number[]): void { let muts: any[] = []; - for (let ii: number = 0; ii < after.length; ii++) { + for (let ii = 0; ii < after.length; ii++) { if (after[ii] !== before[ii]) { muts.push({pos: ii + 1, base: EPars.sequenceToString([after[ii]])}); } @@ -2183,33 +2229,33 @@ export default class PoseEditMode extends GameMode { this._moves.push(muts.slice()); } - private moveHistoryAddSequence(change_type: string, seq: string): void { + private moveHistoryAddSequence(changeType: string, seq: string): void { let muts: any[] = []; - muts.push({"type": change_type, "sequence": seq}); + muts.push({type: changeType, sequence: seq}); this._moveCount++; this._moves.push(muts.slice()); } - private setPuzzleEpilog(init_seq: number[], is_reset: boolean): void { - if (is_reset) { - let new_seq: number[] = this._puzzle.transformSequence(this.getCurrentUndoBlock(0).sequence, 0); - this.moveHistoryAddSequence("reset", EPars.sequenceToString(new_seq)); + private setPuzzleEpilog(initSeq: number[], isReset: boolean): void { + if (isReset) { + let newSeq: number[] = this._puzzle.transformSequence(this.getCurrentUndoBlock(0).sequence, 0); + this.moveHistoryAddSequence('reset', EPars.sequenceToString(newSeq)); } else { this._startSolvingTime = new Date().getTime(); - this._startingPoint = EPars.sequenceToString(this._puzzle.transformSequence(this.getCurrentUndoBlock(0).sequence, 0)); + this._startingPoint = EPars.sequenceToString( + this._puzzle.transformSequence(this.getCurrentUndoBlock(0).sequence, 0) + ); } - if (is_reset || this._isDatabrowserMode) { + if (isReset || this._isDatabrowserMode) { this.startPlaying(); - } else if (init_seq == null) { + } else if (initSeq == null) { this.startCountdown(); + } else if (this._puzzle.puzzleType === PuzzleType.EXPERIMENTAL) { + // / Given init sequence (solution) in the lab, don't show mission animation - go straight to game + this.startPlaying(); } else { - /// Given init sequence (solution) in the lab, don't show mission animation - go straight to game - if (this._puzzle.puzzleType === PuzzleType.EXPERIMENTAL) { - this.startPlaying(); - } else { - this.startCountdown(); - } + this.startCountdown(); } this.setPip(Eterna.settings.pipEnabled.value); @@ -2217,7 +2263,10 @@ export default class PoseEditMode extends GameMode { this.ropPresets(); } - private updateConstraint(type: ConstraintType, value: string, constraintIdx: number, box: ConstraintBox, render: boolean, outInfo: ConstraintInfo): ConstraintStatus { + private updateConstraint( + type: ConstraintType, value: string, constraintIdx: number, + box: ConstraintBox, render: boolean, outInfo: ConstraintInfo + ): ConstraintStatus { let isSatisfied = true; let isPending = false; @@ -2234,7 +2283,7 @@ export default class PoseEditMode extends GameMode { const count: number = undoBlock.getParam(UndoBlockParam.AU); isSatisfied = (count >= Number(value)); if (render) { - box.setContent(ConstraintType.AU, value, isSatisfied, count) + box.setContent(ConstraintType.AU, value, isSatisfied, count); } } else if (type === ConstraintType.GC) { const count: number = undoBlock.getParam(UndoBlockParam.GC); @@ -2243,146 +2292,155 @@ export default class PoseEditMode extends GameMode { box.setContent(ConstraintType.GC, value, isSatisfied, count); } } else if (type === ConstraintType.MUTATION) { - const sequence_diff: number = EPars.sequenceDiff(this._puzzle.getSubsequenceWithoutBarcode(sequence), this._puzzle.getSubsequenceWithoutBarcode(this._puzzle.getBeginningSequence())); - isSatisfied = sequence_diff <= Number(value); + const sequenceDiff: number = EPars.sequenceDiff( + this._puzzle.getSubsequenceWithoutBarcode(sequence), + this._puzzle.getSubsequenceWithoutBarcode(this._puzzle.getBeginningSequence()) + ); + isSatisfied = sequenceDiff <= Number(value); if (render) { - box.setContent(ConstraintType.MUTATION, value, isSatisfied, sequence_diff); + box.setContent(ConstraintType.MUTATION, value, isSatisfied, sequenceDiff); } } else if (type === ConstraintType.SHAPE) { - const target_index = Number(value); - const ublk: UndoBlock = this.getCurrentUndoBlock(target_index); - let native_pairs = ublk.getPairs(); - let structure_constraints: any[] = null; - if (this._targetConditions != null && this._targetConditions[target_index] != null) { - structure_constraints = this._targetConditions[target_index]['structure_constraints']; + const targetIndex = Number(value); + const ublk: UndoBlock = this.getCurrentUndoBlock(targetIndex); + let nativePairs = ublk.getPairs(); + let structureConstraints: any[] = null; + if (this._targetConditions != null && this._targetConditions[targetIndex] != null) { + structureConstraints = this._targetConditions[targetIndex]['structure_constraints']; if (ublk.oligoOrder != null) { - let np_map: number[] = ublk.reorderedOligosIndexMap(ublk.oligoOrder); - let tp_map: number[] = ublk.reorderedOligosIndexMap(ublk.targetOligoOrder); - if (np_map != null) { - let new_pairs: number[] = []; - let new_sc: number[] = []; - for (let jj = 0; jj < native_pairs.length; jj++) { - let kk: number = tp_map.indexOf(jj); - new_sc[jj] = structure_constraints[kk]; - let pp: number = native_pairs[np_map[kk]]; - new_pairs[jj] = pp < 0 ? pp : tp_map[np_map.indexOf(pp)]; + let npMap: number[] = ublk.reorderedOligosIndexMap(ublk.oligoOrder); + let tpMap: number[] = ublk.reorderedOligosIndexMap(ublk.targetOligoOrder); + if (npMap != null) { + let newPairs: number[] = []; + let newSC: number[] = []; + for (let jj = 0; jj < nativePairs.length; jj++) { + let kk: number = tpMap.indexOf(jj); + newSC[jj] = structureConstraints[kk]; + let pp: number = nativePairs[npMap[kk]]; + newPairs[jj] = pp < 0 ? pp : tpMap[npMap.indexOf(pp)]; } - native_pairs = new_pairs; - structure_constraints = new_sc; + nativePairs = newPairs; + structureConstraints = newSC; } } } - isSatisfied = EPars.arePairsSame(native_pairs, this._targetPairs[target_index], structure_constraints); + isSatisfied = EPars.arePairsSame(nativePairs, this._targetPairs[targetIndex], structureConstraints); - let input_index: number = undefined; + let inputIndex: number; if (this._targetPairs.length > 1) { - input_index = target_index; + inputIndex = targetIndex; } if (render) { box.setContent(ConstraintType.SHAPE, { - target: this._targetPairs[target_index], - index: input_index, - native: native_pairs, - structure_constraints: structure_constraints + target: this._targetPairs[targetIndex], + index: inputIndex, + native: nativePairs, + structureConstraints }, isSatisfied, 0); box.flagged = this._unstableShapeConstraintIdx === constraintIdx; if (this._unstableShapeConstraintIdx === constraintIdx) { - outInfo.wrong_pairs = box.getWrongPairs(native_pairs, this._targetPairs[target_index], structure_constraints, isSatisfied); + outInfo.wrongPairs = box.getWrongPairs( + nativePairs, this._targetPairs[targetIndex], structureConstraints, isSatisfied + ); } } - if (target_index > 0) { + if (targetIndex > 0) { if (this._constraintShapeBoxes != null) { - if (this._constraintShapeBoxes[target_index] != null) { - this._constraintShapeBoxes[target_index].setContent(ConstraintType.SHAPE, { - target: this._targetPairs[target_index], - index: input_index, - native: native_pairs, - structure_constraints: structure_constraints + if (this._constraintShapeBoxes[targetIndex] != null) { + this._constraintShapeBoxes[targetIndex].setContent(ConstraintType.SHAPE, { + target: this._targetPairs[targetIndex], + index: inputIndex, + native: nativePairs, + structureConstraints }, isSatisfied, 0); - this._constraintShapeBoxes[target_index].flagged = this._unstableShapeConstraintIdx === constraintIdx; - this._constraintShapeBoxes[target_index].display.visible = this._isPipMode; + + let flag = this._unstableShapeConstraintIdx === constraintIdx; + this._constraintShapeBoxes[targetIndex].flagged = flag; + this._constraintShapeBoxes[targetIndex].display.visible = this._isPipMode; } } } - } else if (type === ConstraintType.ANTISHAPE) { - let target_index = Number(value); - let native_pairs = this.getCurrentUndoBlock(target_index).getPairs(); + let targetIndex = Number(value); + let nativePairs = this.getCurrentUndoBlock(targetIndex).getPairs(); if (this._targetConditions == null) { - throw new Error("Target object not available for ANTISHAPE constraint"); + throw new Error('Target object not available for ANTISHAPE constraint'); } - if (this._targetConditions[target_index] == null) { - throw new Error("Target condition not available for ANTISHAPE constraint"); + if (this._targetConditions[targetIndex] == null) { + throw new Error('Target condition not available for ANTISHAPE constraint'); } - let anti_structure_string: string = this._targetConditions[target_index]['anti_secstruct']; + let antiStructureString: string = this._targetConditions[targetIndex]['anti_secstruct']; - if (anti_structure_string == null) { - throw new Error("Target structure not available for ANTISHAPE constraint"); + if (antiStructureString == null) { + throw new Error('Target structure not available for ANTISHAPE constraint'); } - let anti_structure_constraints: any[] = this._targetConditions[target_index]['anti_structure_constraints']; - let anti_pairs: number[] = EPars.parenthesisToPairs(anti_structure_string); - isSatisfied = !EPars.arePairsSame(native_pairs, anti_pairs, anti_structure_constraints); + let antiStructureConstraints: any[] = this._targetConditions[targetIndex]['anti_structure_constraints']; + let antiPairs: number[] = EPars.parenthesisToPairs(antiStructureString); + isSatisfied = !EPars.arePairsSame(nativePairs, antiPairs, antiStructureConstraints); - let input_index: number = undefined; + let inputIndex: number; if (this._targetPairs.length > 1) { - input_index = target_index; + inputIndex = targetIndex; } if (render) { box.setContent(ConstraintType.ANTISHAPE, { - target: anti_pairs, - native: native_pairs, - index: input_index, - structure_constraints: anti_structure_constraints + target: antiPairs, + native: nativePairs, + index: inputIndex, + structureConstraints: antiStructureConstraints }, isSatisfied, 0); box.flagged = this._unstableShapeConstraintIdx === constraintIdx; if (this._unstableShapeConstraintIdx === constraintIdx) { - outInfo.wrong_pairs = box.getWrongPairs(native_pairs, anti_pairs, anti_structure_constraints, isSatisfied); + outInfo.wrongPairs = box.getWrongPairs( + nativePairs, antiPairs, antiStructureConstraints, isSatisfied + ); } } - if (target_index > 0) { + if (targetIndex > 0) { if (this._constraintAntishapeBoxes != null) { - if (this._constraintAntishapeBoxes[target_index] != null) { - this._constraintAntishapeBoxes[target_index].setContent(ConstraintType.ANTISHAPE, { - target: anti_pairs, - native: native_pairs, - index: input_index, - structure_constraints: anti_structure_constraints + if (this._constraintAntishapeBoxes[targetIndex] != null) { + this._constraintAntishapeBoxes[targetIndex].setContent(ConstraintType.ANTISHAPE, { + target: antiPairs, + native: nativePairs, + index: inputIndex, + structureConstraints: antiStructureConstraints }, isSatisfied, 0); - this._constraintAntishapeBoxes[target_index].flagged = this._unstableShapeConstraintIdx === constraintIdx; - this._constraintAntishapeBoxes[target_index].display.visible = this._isPipMode; + let flag = this._unstableShapeConstraintIdx === constraintIdx; + this._constraintAntishapeBoxes[targetIndex].flagged = flag; + + this._constraintAntishapeBoxes[targetIndex].display.visible = this._isPipMode; } } } - } else if (type === ConstraintType.BINDINGS) { - const target_index = Number(value); - const undoblk: UndoBlock = this.getCurrentUndoBlock(target_index); + const targetIndex = Number(value); + const undoblk: UndoBlock = this.getCurrentUndoBlock(targetIndex); if (this._targetConditions == null) { - throw new Error("Target object not available for BINDINGS constraint"); + throw new Error('Target object not available for BINDINGS constraint'); } - if (this._targetConditions[target_index] == null) { - throw new Error("Target condition not available for BINDINGS constraint"); + if (this._targetConditions[targetIndex] == null) { + throw new Error('Target condition not available for BINDINGS constraint'); } - const oligos: OligoDef[] = this._targetConditions[target_index]['oligos']; + const oligos: OligoDef[] = this._targetConditions[targetIndex]['oligos']; if (oligos == null) { - throw new Error("Target condition not available for BINDINGS constraint"); + throw new Error('Target condition not available for BINDINGS constraint'); } - let o_names: string[] = []; + let oNames: string[] = []; let bind: boolean[] = []; let label: string[] = []; let bmap: boolean[] = []; @@ -2399,253 +2457,242 @@ export default class PoseEditMode extends GameMode { isSatisfied = true; for (let jj = 0; jj < oligos.length; jj++) { if (oligos[jj]['bind'] == null) continue; - let o_name: string = oligos[jj]['name']; - if (o_name == null) o_name = "Oligo " + (jj + 1).toString(); - o_names.push(o_name); - let expected: boolean = Boolean(oligos[jj]['bind']); + let oName: string = oligos[jj]['name']; + if (oName == null) oName = `Oligo ${(jj + 1).toString()}`; + oNames.push(oName); + let expected = Boolean(oligos[jj]['bind']); bind.push(expected); - let lbl: string = oligos[jj]['label'] != null ? String(oligos[jj]['label']) : String.fromCharCode(65 + jj); + let lbl: string = oligos[jj]['label'] != null + ? String(oligos[jj]['label']) : String.fromCharCode(65 + jj); label.push(lbl); if (bmap[jj] !== expected) { isSatisfied = false; - if (outInfo.restricted_local == null) { - outInfo.restricted_local = []; + if (outInfo.restrictedLocal == null) { + outInfo.restrictedLocal = []; } - if (outInfo.restricted_local[target_index] == null) { - outInfo.restricted_local[target_index] = []; + if (outInfo.restrictedLocal[targetIndex] == null) { + outInfo.restrictedLocal[targetIndex] = []; } - outInfo.restricted_local[target_index].push(offsets[jj]); - outInfo.restricted_local[target_index].push(offsets[jj] + oligos[jj]['sequence'].length - 1); + outInfo.restrictedLocal[targetIndex].push(offsets[jj]); + outInfo.restrictedLocal[targetIndex].push(offsets[jj] + oligos[jj]['sequence'].length - 1); } } if (render) { box.setContent(ConstraintType.BINDINGS, { - index: target_index, - bind: bind, - label: label, - oligo_name: o_names + index: targetIndex, + bind, + label, + oligoNames: oNames }, isSatisfied, 0); } - } else if (type === ConstraintType.G) { const count: number = Constraints.count(sequence, EPars.RNABASE_GUANINE); isSatisfied = (count >= Number(value)); if (render) { box.setContent(ConstraintType.G, value, isSatisfied, count); } - } else if (type === ConstraintType.GMAX) { const count = Constraints.count(sequence, EPars.RNABASE_GUANINE); isSatisfied = (count <= Number(value)); if (render) { box.setContent(ConstraintType.GMAX, value, isSatisfied, count); } - } else if (type === ConstraintType.A) { const count: number = Constraints.count(sequence, EPars.RNABASE_ADENINE); isSatisfied = (count >= Number(value)); if (render) { box.setContent(ConstraintType.A, value, isSatisfied, count); } - } else if (type === ConstraintType.AMAX) { const count = Constraints.count(sequence, EPars.RNABASE_ADENINE); isSatisfied = (count <= Number(value)); if (render) { box.setContent(ConstraintType.AMAX, value, isSatisfied, count); } - } else if (type === ConstraintType.U) { const count: number = Constraints.count(sequence, EPars.RNABASE_URACIL); isSatisfied = (count >= Number(value)); if (render) { box.setContent(ConstraintType.U, value, isSatisfied, count); } - } else if (type === ConstraintType.UMAX) { const count = Constraints.count(sequence, EPars.RNABASE_URACIL); isSatisfied = (count <= Number(value)); if (render) { box.setContent(ConstraintType.UMAX, value, isSatisfied, count); } - } else if (type === ConstraintType.C) { const count: number = Constraints.count(sequence, EPars.RNABASE_CYTOSINE); isSatisfied = (count >= Number(value)); if (render) { box.setContent(ConstraintType.C, value, isSatisfied, count); } - } else if (type === ConstraintType.CMAX) { const count = Constraints.count(sequence, EPars.RNABASE_CYTOSINE); isSatisfied = (count <= Number(value)); if (render) { box.setContent(ConstraintType.CMAX, value, isSatisfied, count); } - } else if (type === ConstraintType.PAIRS) { - let num_gu: number = undoBlock.getParam(UndoBlockParam.GU); - let num_gc: number = undoBlock.getParam(UndoBlockParam.GC); - let num_ua: number = undoBlock.getParam(UndoBlockParam.AU); - isSatisfied = (num_gc + num_gu + num_ua >= Number(value)); + let numGU: number = undoBlock.getParam(UndoBlockParam.GU); + let numGC: number = undoBlock.getParam(UndoBlockParam.GC); + let numUA: number = undoBlock.getParam(UndoBlockParam.AU); + isSatisfied = (numGC + numGU + numUA >= Number(value)); if (render) { - box.setContent(ConstraintType.PAIRS, value, isSatisfied, num_gc + num_gu + num_ua); + box.setContent(ConstraintType.PAIRS, value, isSatisfied, numGC + numGU + numUA); } - } else if (type === ConstraintType.STACK) { - const stack_len: number = undoBlock.getParam(UndoBlockParam.STACK); - isSatisfied = (stack_len >= Number(value)); + const stackLen: number = undoBlock.getParam(UndoBlockParam.STACK); + isSatisfied = (stackLen >= Number(value)); if (render) { - box.setContent(ConstraintType.STACK, value, isSatisfied, stack_len); + box.setContent(ConstraintType.STACK, value, isSatisfied, stackLen); } } else if (type === ConstraintType.CONSECUTIVE_G) { - let consecutive_g_count: number = EPars.countConsecutive(sequence, EPars.RNABASE_GUANINE); - isSatisfied = (consecutive_g_count < Number(value)); + let consecutiveGCount: number = EPars.countConsecutive(sequence, EPars.RNABASE_GUANINE); + isSatisfied = (consecutiveGCount < Number(value)); if (render) { - box.setContent(ConstraintType.CONSECUTIVE_G, value, isSatisfied, consecutive_g_count); + box.setContent(ConstraintType.CONSECUTIVE_G, value, isSatisfied, consecutiveGCount); } - outInfo.max_allowed_guanine = Number(value); - + outInfo.maxAllowedGuanine = Number(value); } else if (type === ConstraintType.CONSECUTIVE_C) { - let consecutive_c_count: number = EPars.countConsecutive(sequence, EPars.RNABASE_CYTOSINE); - isSatisfied = (consecutive_c_count < Number(value)); + let consecutiveCCount: number = EPars.countConsecutive(sequence, EPars.RNABASE_CYTOSINE); + isSatisfied = (consecutiveCCount < Number(value)); if (render) { - box.setContent(ConstraintType.CONSECUTIVE_C, value, isSatisfied, consecutive_c_count); + box.setContent(ConstraintType.CONSECUTIVE_C, value, isSatisfied, consecutiveCCount); } - outInfo.max_allowed_cytosine = Number(value); - + outInfo.maxAllowedCytosine = Number(value); } else if (type === ConstraintType.CONSECUTIVE_A) { - let consecutive_a_count: number = EPars.countConsecutive(sequence, EPars.RNABASE_ADENINE); - isSatisfied = (consecutive_a_count < Number(value)); + let consecutiveACount: number = EPars.countConsecutive(sequence, EPars.RNABASE_ADENINE); + isSatisfied = (consecutiveACount < Number(value)); if (render) { - box.setContent(ConstraintType.CONSECUTIVE_A, value, isSatisfied, consecutive_a_count); + box.setContent(ConstraintType.CONSECUTIVE_A, value, isSatisfied, consecutiveACount); } - outInfo.max_allowed_adenine = Number(value); - + outInfo.maxAllowedAdenine = Number(value); } else if (type === ConstraintType.LAB_REQUIREMENTS) { let locks: boolean[] = undoBlock.puzzleLocks; - let consecutive_g_count: number = EPars.countConsecutive(sequence, EPars.RNABASE_GUANINE, locks); - let consecutive_c_count: number = EPars.countConsecutive(sequence, EPars.RNABASE_CYTOSINE, locks); - let consecutive_a_count: number = EPars.countConsecutive(sequence, EPars.RNABASE_ADENINE, locks); - outInfo.max_allowed_guanine = 4; - outInfo.max_allowed_cytosine = 4; - outInfo.max_allowed_adenine = 5; - isSatisfied = (consecutive_g_count < outInfo.max_allowed_guanine); - isSatisfied = isSatisfied && (consecutive_c_count < outInfo.max_allowed_cytosine); - isSatisfied = isSatisfied && (consecutive_a_count < outInfo.max_allowed_adenine); + let consecutiveGCount: number = EPars.countConsecutive(sequence, EPars.RNABASE_GUANINE, locks); + let consecutiveCCount: number = EPars.countConsecutive(sequence, EPars.RNABASE_CYTOSINE, locks); + let consecutiveACount: number = EPars.countConsecutive(sequence, EPars.RNABASE_ADENINE, locks); + outInfo.maxAllowedGuanine = 4; + outInfo.maxAllowedCytosine = 4; + outInfo.maxAllowedAdenine = 5; + isSatisfied = (consecutiveGCount < outInfo.maxAllowedGuanine); + isSatisfied = isSatisfied && (consecutiveCCount < outInfo.maxAllowedCytosine); + isSatisfied = isSatisfied && (consecutiveACount < outInfo.maxAllowedAdenine); if (render) { box.setContent(ConstraintType.LAB_REQUIREMENTS, { - "g_count": consecutive_g_count, "g_max": outInfo.max_allowed_guanine, - "c_count": consecutive_c_count, "c_max": outInfo.max_allowed_cytosine, - "a_count": consecutive_a_count, "a_max": outInfo.max_allowed_adenine + gCount: consecutiveGCount, + gMax: outInfo.maxAllowedGuanine, + cCount: consecutiveCCount, + cMax: outInfo.maxAllowedCytosine, + aCount: consecutiveACount, + aMax: outInfo.maxAllowedAdenine }, isSatisfied, 0); } - } else if (type === ConstraintType.BARCODE) { isSatisfied = !SolutionManager.instance.checkRedundancyByHairpin(EPars.sequenceToString(sequence)); if (render) { box.setContent(ConstraintType.BARCODE, 0, isSatisfied, 0); } - } else if (type === ConstraintType.OLIGO_BOUND) { - let target_index = Number(value); - let nnfe: number[] = this.getCurrentUndoBlock(target_index).getParam(UndoBlockParam.NNFE_ARRAY, EPars.DEFAULT_TEMPERATURE); + let targetIndex = Number(value); + let nnfe: number[] = this.getCurrentUndoBlock(targetIndex) + .getParam(UndoBlockParam.NNFE_ARRAY, EPars.DEFAULT_TEMPERATURE); isSatisfied = (nnfe != null && nnfe[0] === -2); if (this._targetConditions == null) { - throw new Error("Target object not available for BINDINGS constraint"); + throw new Error('Target object not available for BINDINGS constraint'); } - if (this._targetConditions[target_index] == null) { - throw new Error("Target condition not available for BINDINGS constraint"); + if (this._targetConditions[targetIndex] == null) { + throw new Error('Target condition not available for BINDINGS constraint'); } - let o_names: string[] = []; - let o_name: string = this._targetConditions[target_index]['oligo_name']; + let oNames: string[] = []; + let oName: string = this._targetConditions[targetIndex]['oligo_name']; // TSC: not sure what this value should be. It's not guaranteed to be initialized in the original Flash code let jj = 0; - if (o_name == null) o_name = "Oligo " + (jj + 1).toString(); - o_names.push(o_name); + if (oName == null) oName = `Oligo ${(jj + 1).toString()}`; + oNames.push(oName); let bind: boolean[] = []; bind.push(true); let label: string[] = []; - let lbl: string = this._targetConditions[target_index]['oligo_label']; + let lbl: string = this._targetConditions[targetIndex]['oligo_label']; if (lbl == null) lbl = String.fromCharCode(65 + jj); label.push(lbl); if (render) { box.setContent(ConstraintType.BINDINGS, { - index: target_index, - bind: bind, - label: label, - oligo_name: o_names + index: targetIndex, + bind, + label, + oligoNames: oNames }, isSatisfied, 0); } - } else if (type === ConstraintType.OLIGO_UNBOUND) { - let target_index = Number(value); - let nnfe: number[] = this.getCurrentUndoBlock(target_index).getParam(UndoBlockParam.NNFE_ARRAY, EPars.DEFAULT_TEMPERATURE); + let targetIndex = Number(value); + let nnfe: number[] = this.getCurrentUndoBlock(targetIndex) + .getParam(UndoBlockParam.NNFE_ARRAY, EPars.DEFAULT_TEMPERATURE); isSatisfied = (nnfe == null || nnfe[0] !== -2); if (this._targetConditions == null) { - throw new Error("Target object not available for BINDINGS constraint"); + throw new Error('Target object not available for BINDINGS constraint'); } - if (this._targetConditions[target_index] == null) { - throw new Error("Target condition not available for BINDINGS constraint"); + if (this._targetConditions[targetIndex] == null) { + throw new Error('Target condition not available for BINDINGS constraint'); } // TSC: not sure what this value should be. It's not guaranteed to be initialized in the original Flash code let jj = 0; - let o_names: string[] = []; - let o_name: string = this._targetConditions[target_index]['oligo_name']; - if (o_name == null) o_name = "Oligo " + (jj + 1).toString(); - o_names.push(o_name); + let oNames: string[] = []; + let oName: string = this._targetConditions[targetIndex]['oligo_name']; + if (oName == null) oName = `Oligo ${(jj + 1).toString()}`; + oNames.push(oName); let bind: boolean[] = []; bind.push(false); let label: string[] = []; - let lbl: string = this._targetConditions[target_index]['oligo_label']; + let lbl: string = this._targetConditions[targetIndex]['oligo_label']; if (lbl == null) lbl = String.fromCharCode(65 + jj); label.push(lbl); if (render) { box.setContent(ConstraintType.BINDINGS, { - index: target_index, - bind: bind, - label: label, - oligo_name: o_names + index: targetIndex, + bind, + label, + oligoNames: oNames }, isSatisfied, 0); } - } else if (type === ConstraintType.SCRIPT) { isSatisfied = false; const scriptID = value; const scriptCompleted = ExternalInterface.runScriptMaybeSynchronously(scriptID, - { params: { puzzleInfo: this._puzzle.toJSON() } }, - scriptResult => { - let goal = ""; - let name = "..."; - let resultValue = ""; + {params: {puzzleInfo: this._puzzle.toJSON()}}, + (scriptResult) => { + let goal = ''; + let name = '...'; + let resultValue = ''; let index = null; - let dataPNG = ""; + let dataPNG = ''; if (scriptResult && scriptResult.cause) { if (scriptResult.cause.satisfied) isSatisfied = scriptResult.cause.satisfied; if (scriptResult.cause.goal != null) goal = scriptResult.cause.goal; @@ -2653,9 +2700,13 @@ export default class PoseEditMode extends GameMode { if (scriptResult.cause.value != null) resultValue = scriptResult.cause.value; if (scriptResult.cause.index != null) { index = (scriptResult.cause.index + 1).toString(); - let ll: number = this._isPipMode ? - scriptResult.cause.index : - (scriptResult.cause.index === this._curTargetIndex ? 0 : -1); + let ll: number; + if (this._isPipMode) { + ll = scriptResult.cause.index; + } else { + ll = (scriptResult.cause.index === this._curTargetIndex ? 0 : -1); + } + if (ll >= 0) { if (scriptResult.cause.highlight != null) { this._poses[ll].highlightUserDefinedSequence(scriptResult.cause.highlight); @@ -2672,16 +2723,15 @@ export default class PoseEditMode extends GameMode { if (render) { box.setContent(ConstraintType.SCRIPT, { - "nid": scriptID, - "goal": goal, - "name": name, - "value": resultValue, - "index": index, - "data_png": dataPNG + nid: scriptID, + goal, + name, + value: resultValue, + index, + dataPNG }, isSatisfied, 0); } - } - ); + }); if (!scriptCompleted) { log.warn(`Constraint script wasn't able to run synchronously [scriptID=${scriptID}]`); @@ -2706,11 +2756,11 @@ export default class PoseEditMode extends GameMode { } let constraintsInfo: ConstraintInfo = { - wrong_pairs: null, - restricted_local: null, - max_allowed_adenine: -1, - max_allowed_cytosine: -1, - max_allowed_guanine: -1, + wrongPairs: null, + restrictedLocal: null, + maxAllowedAdenine: -1, + maxAllowedCytosine: -1, + maxAllowedGuanine: -1 }; let allAreSatisfied = true; @@ -2733,14 +2783,14 @@ export default class PoseEditMode extends GameMode { hasPendingConstraints = hasPendingConstraints || status === ConstraintStatus.PENDING; if (type === ConstraintType.SHAPE || type === ConstraintType.ANTISHAPE) { - const target_index = Number(value); + const targetIndex = Number(value); if (!this._isPipMode) { - box.display.alpha = (target_index === this._curTargetIndex) ? 1.0 : 0.3; + box.display.alpha = (targetIndex === this._curTargetIndex) ? 1.0 : 0.3; } else { box.display.alpha = 1.0; } - if (this._isPipMode && target_index > 0) { + if (this._isPipMode && targetIndex > 0) { box.display.visible = false; } else if (this._puzState === PuzzleState.GAME || this._puzState === PuzzleState.CLEARED) { box.display.visible = true; @@ -2759,11 +2809,11 @@ export default class PoseEditMode extends GameMode { } let unstable: number[] = []; - if (constraintsInfo.wrong_pairs) { - let curr: number = 0; + if (constraintsInfo.wrongPairs) { + let curr = 0; let jj: number; - for (jj = 0; jj < constraintsInfo.wrong_pairs.length; jj++) { - let stat: number = (constraintsInfo.wrong_pairs[jj] === 1 ? 1 : 0); + for (jj = 0; jj < constraintsInfo.wrongPairs.length; jj++) { + let stat: number = (constraintsInfo.wrongPairs[jj] === 1 ? 1 : 0); if ((curr ^ stat) !== 0) { unstable.push(jj - curr); curr = stat; @@ -2774,23 +2824,30 @@ export default class PoseEditMode extends GameMode { } } - const undo_block: UndoBlock = this.getCurrentUndoBlock(); - const sequence: number[] = undo_block.sequence; - const locks: boolean[] = undo_block.puzzleLocks; + const undoBlock: UndoBlock = this.getCurrentUndoBlock(); + const sequence: number[] = undoBlock.sequence; + const locks: boolean[] = undoBlock.puzzleLocks; - const restricted_guanine = EPars.getRestrictedConsecutive(sequence, EPars.RNABASE_GUANINE, constraintsInfo.max_allowed_guanine - 1, locks); - const restricted_cytosine = EPars.getRestrictedConsecutive(sequence, EPars.RNABASE_CYTOSINE, constraintsInfo.max_allowed_cytosine - 1, locks); - const restricted_adenine = EPars.getRestrictedConsecutive(sequence, EPars.RNABASE_ADENINE, constraintsInfo.max_allowed_adenine - 1, locks); + const restrictedGuanine = EPars.getRestrictedConsecutive( + sequence, EPars.RNABASE_GUANINE, constraintsInfo.maxAllowedGuanine - 1, locks + ); + const restrictedCytosine = EPars.getRestrictedConsecutive( + sequence, EPars.RNABASE_CYTOSINE, constraintsInfo.maxAllowedCytosine - 1, locks + ); + const restrictedAdenine = EPars.getRestrictedConsecutive( + sequence, EPars.RNABASE_ADENINE, constraintsInfo.maxAllowedAdenine - 1, locks + ); - const restricted_global: number[] = restricted_guanine.concat(restricted_cytosine).concat(restricted_adenine); + const restrictedGlobal: number[] = restrictedGuanine.concat(restrictedCytosine).concat(restrictedAdenine); for (let ii = 0; ii < this._poses.length; ii++) { - let jj = this._isPipMode ? ii : (ii === 0 ? this._curTargetIndex : ii); + let jj = (this._isPipMode || ii !== 0) ? ii : this._curTargetIndex; + let restricted: number[]; - if (constraintsInfo.restricted_local && constraintsInfo.restricted_local[jj]) { - restricted = restricted_global.concat(constraintsInfo.restricted_local[jj]); + if (constraintsInfo.restrictedLocal && constraintsInfo.restrictedLocal[jj]) { + restricted = restrictedGlobal.concat(constraintsInfo.restrictedLocal[jj]); } else { - restricted = restricted_global; + restricted = restrictedGlobal; } this._poses[ii].highlightRestrictedSequence(restricted); this._poses[ii].highlightUnstableSequence(unstable); @@ -2816,9 +2873,9 @@ export default class PoseEditMode extends GameMode { // let dn: GameObject = (Application.instance.get_application_gui("Design Name")); // if (dn != null) dn.visible = (this._stack_level === 0); - let undo_block: UndoBlock = this.getCurrentUndoBlock(); - let sequence: number[] = undo_block.sequence; - let best_pairs: number[] = undo_block.getPairs(EPars.DEFAULT_TEMPERATURE); + let undoBlock: UndoBlock = this.getCurrentUndoBlock(); + let sequence: number[] = undoBlock.sequence; + let bestPairs: number[] = undoBlock.getPairs(EPars.DEFAULT_TEMPERATURE); let nnfe: number[]; if (!this._paused) { @@ -2832,7 +2889,8 @@ export default class PoseEditMode extends GameMode { this.getCurrentUndoBlock().oligoName); this._poses[0].pairs = this.getCurrentUndoBlock().getPairs(); if (this._targetConditions != null && this._targetConditions[this._curTargetIndex] != null) { - this._poses[0].structConstraints = this._targetConditions[this._curTargetIndex]['structure_constraints']; + let newConstraints = this._targetConditions[this._curTargetIndex]['structure_constraints']; + this._poses[0].structConstraints = newConstraints; } continue; } @@ -2847,7 +2905,6 @@ export default class PoseEditMode extends GameMode { this._poses[ii].structConstraints = this._targetConditions[ii]['structure_constraints']; } } - } else { for (let ii = 0; ii < this._poses.length; ++ii) { if (ii === 0 && this._poseState === PoseState.TARGET && !this._isPipMode) { @@ -2859,7 +2916,8 @@ export default class PoseEditMode extends GameMode { this.getCurrentUndoBlock().oligoName); this._poses[0].pairs = this.getCurrentUndoBlock().targetPairs; if (this._targetConditions != null && this._targetConditions[this._curTargetIndex] != null) { - this._poses[0].structConstraints = this._targetConditions[this._curTargetIndex]['structure_constraints']; + let newConstraints = this._targetConditions[this._curTargetIndex]['structure_constraints']; + this._poses[0].structConstraints = newConstraints; } this._targetOligos[0] = this.getCurrentUndoBlock(0).targetOligos; this._targetOligosOrder[0] = this.getCurrentUndoBlock(0).targetOligoOrder; @@ -2882,7 +2940,6 @@ export default class PoseEditMode extends GameMode { this._poses[ii].structConstraints = this._targetConditions[ii]['structure_constraints']; } } - } for (let ii = 0; ii < this._poses.length; ii++) { @@ -2899,12 +2956,16 @@ export default class PoseEditMode extends GameMode { } if (Puzzle.isAptamerType(this._targetConditions[jj]['type'])) { - this._poses[ii].setMolecularBinding(this._targetConditions[jj]['site'], this._targetConditions[jj]['binding_pairs'], this._targetConditions[jj]['bonus'] / 100.0); + this._poses[ii].setMolecularBinding( + this._targetConditions[jj]['site'], + this._targetConditions[jj]['binding_pairs'], + this._targetConditions[jj]['bonus'] / 100.0 + ); } else { this._poses[ii].setMolecularBinding(null, null, 0); } if (Puzzle.isOligoType(this._targetConditions[jj]['type'])) { - this._poses[ii].oligoMalus = this._targetConditions[jj]["malus"]; + this._poses[ii].oligoMalus = this._targetConditions[jj]['malus']; nnfe = this.getCurrentUndoBlock(jj).getParam(UndoBlockParam.NNFE_ARRAY, EPars.DEFAULT_TEMPERATURE); if (nnfe != null && nnfe[0] === -2) { this._poses[ii].oligoPaired = true; @@ -2913,7 +2974,7 @@ export default class PoseEditMode extends GameMode { this._poses[ii].oligoPaired = false; } } - if (this._targetConditions[jj]['type'] === "multistrand") { + if (this._targetConditions[jj]['type'] === 'multistrand') { nnfe = this.getCurrentUndoBlock(jj).getParam(UndoBlockParam.NNFE_ARRAY, EPars.DEFAULT_TEMPERATURE); if (nnfe != null && nnfe[0] === -2) { this._poses[ii].duplexCost = nnfe[1] * 0.01; @@ -2921,10 +2982,10 @@ export default class PoseEditMode extends GameMode { } } - let num_AU: number = undo_block.getParam(UndoBlockParam.AU); - let num_GU: number = undo_block.getParam(UndoBlockParam.GU); - let num_GC: number = undo_block.getParam(UndoBlockParam.GC); - this._toolbar.palette.setPairCounts(num_AU, num_GU, num_GC); + let numAU: number = undoBlock.getParam(UndoBlockParam.AU); + let numGU: number = undoBlock.getParam(UndoBlockParam.GU); + let numGC: number = undoBlock.getParam(UndoBlockParam.GC); + this._toolbar.palette.setPairCounts(numAU, numGU, numGC); if (!this._isFrozen) { if (this._toolbar.undoButton.display.visible) { @@ -2935,40 +2996,40 @@ export default class PoseEditMode extends GameMode { } } - let was_satisfied: boolean = true; + let wasSatisfied = true; for (let ii = 0; ii < this._puzzle.constraints.length; ii += 2) { - was_satisfied = was_satisfied && this._constraintBoxes[ii / 2].isSatisfied; + wasSatisfied = wasSatisfied && this._constraintBoxes[ii / 2].isSatisfied; } - let constraints_satisfied: boolean = this.checkConstraints(); + let constraintsSatisfied: boolean = this.checkConstraints(); for (let ii = 0; ii < this._poses.length; ii++) { - this.getCurrentUndoBlock(ii).stable = constraints_satisfied; + this.getCurrentUndoBlock(ii).stable = constraintsSatisfied; } - /// Update spec thumbnail if it is open + // / Update spec thumbnail if it is open this.updateDockedSpecBox(); let isThereTempConstraints: boolean = (this._puzzle.temporaryConstraints != null); - if (constraints_satisfied && !isThereTempConstraints) { + if (constraintsSatisfied && !isThereTempConstraints) { if (this._puzzle.puzzleType !== PuzzleType.EXPERIMENTAL && this._puzState === PuzzleState.GAME) { this.submitCurrentPose(); } } } - private flashConstraintForTarget(target_index: number): void { + private flashConstraintForTarget(targetIndex: number): void { let box: ConstraintBox = null; - if (target_index === 0 || !this._isPipMode) { + if (targetIndex === 0 || !this._isPipMode) { let constraints: string[] = this._puzzle.constraints; - for (let ii: number = 0; ii < constraints.length; ii += 2) { - if (constraints[ii] === ConstraintType.SHAPE && Number(constraints[ii + 1]) === target_index) { + for (let ii = 0; ii < constraints.length; ii += 2) { + if (constraints[ii] === ConstraintType.SHAPE && Number(constraints[ii + 1]) === targetIndex) { box = this._constraintBoxes[ii / 2]; break; } } } else { - box = this._constraintShapeBoxes[target_index]; + box = this._constraintShapeBoxes[targetIndex]; } if (box != null) { @@ -2976,62 +3037,62 @@ export default class PoseEditMode extends GameMode { } } - private poseEditByTarget(target_index: number): void { + private poseEditByTarget(targetIndex: number): void { this.savePosesMarkersContexts(); - let xx: number = this._isPipMode ? target_index : this._curTargetIndex; - let segments: number[] = this._poses[target_index].designSegments; - let idx_map: number[] = this._poses[target_index].getOrderMap(this._targetOligosOrder[xx]); - let structure_constraints: boolean[] = null; + let xx: number = this._isPipMode ? targetIndex : this._curTargetIndex; + let segments: number[] = this._poses[targetIndex].designSegments; + let idxMap: number[] = this._poses[targetIndex].getOrderMap(this._targetOligosOrder[xx]); + let structureConstraints: boolean[] = null; - if (idx_map != null) { + if (idxMap != null) { for (let jj = 0; jj < segments.length; jj++) { - segments[jj] = idx_map.indexOf(segments[jj]); + segments[jj] = idxMap.indexOf(segments[jj]); } } // we want 2 blocks (2x2) && same length && separated by at least 3 bases if (segments.length === 4 && segments[1] - segments[0] === segments[3] - segments[2] && (segments[2] - segments[1] > 3 - || EPars.hasCut(this._poses[target_index].fullSequence, segments[1], segments[2]))) { + || EPars.hasCut(this._poses[targetIndex].fullSequence, segments[1], segments[2]))) { /* - - get design_segments - - if (2 groups) and (all paired/unpaired in _target_pairs) and (all as dontcare) - set _target_pairs - clear design - */ + - get design_segments + - if (2 groups) and (all paired/unpaired in _target_pairs) and (all as dontcare) + set _target_pairs + clear design + */ if (this._targetConditions[xx] != null) { - structure_constraints = this._targetConditions[xx]['structure_constraints']; + structureConstraints = this._targetConditions[xx]['structure_constraints']; } - if (structure_constraints != null) { - let num_unpaired: number = 0; - let num_wrong: number = 0; - let dontcare_ok: boolean = true; - for (let jj = segments[0]; jj <= segments[1] && dontcare_ok; jj++) { - if (structure_constraints[jj]) { - dontcare_ok = false; + if (structureConstraints != null) { + let numUnpaired = 0; + let numWrong = 0; + let dontcareOk = true; + for (let jj = segments[0]; jj <= segments[1] && dontcareOk; jj++) { + if (structureConstraints[jj]) { + dontcareOk = false; continue; } if (this._targetPairs[xx][jj] < 0) { - num_unpaired++; + numUnpaired++; } else if (this._targetPairs[xx][jj] < segments[2] || this._targetPairs[xx][jj] > segments[3]) { - num_wrong++; + numWrong++; } } - for (let jj = segments[2]; jj <= segments[3] && dontcare_ok; jj++) { - if (structure_constraints[jj]) { - dontcare_ok = false; + for (let jj = segments[2]; jj <= segments[3] && dontcareOk; jj++) { + if (structureConstraints[jj]) { + dontcareOk = false; continue; } if (this._targetPairs[xx][jj] < 0) { - num_unpaired++; + numUnpaired++; } else if (this._targetPairs[xx][jj] < segments[0] || this._targetPairs[xx][jj] > segments[1]) { - num_wrong++; + numWrong++; } } - if (dontcare_ok && num_wrong === 0) { - if (num_unpaired === 0) { + if (dontcareOk && numWrong === 0) { + if (numUnpaired === 0) { for (let jj = segments[0]; jj <= segments[1]; jj++) { this._targetPairs[xx][jj] = -1; } @@ -3040,38 +3101,51 @@ export default class PoseEditMode extends GameMode { } Eterna.sound.playSound(Sounds.SoundRY); this.flashConstraintForTarget(xx); - this._poses[target_index].clearDesignStruct(); - } else if (num_unpaired === segments[1] - segments[0] + segments[3] - segments[2] + 2) { + this._poses[targetIndex].clearDesignStruct(); + } else if (numUnpaired === segments[1] - segments[0] + segments[3] - segments[2] + 2) { // breaking pairs is safe, but adding them may not always be - if (EPars.validateParenthesis(EPars.pairsToParenthesis(this._targetPairs[xx]).slice(segments[1] + 1, segments[2]), false) == null) { - for (let jj = segments[0]; jj <= segments[1]; jj++) this._targetPairs[xx][jj] = segments[3] - (jj - segments[0]); - for (let jj = segments[2]; jj <= segments[3]; jj++) this._targetPairs[xx][jj] = segments[1] - (jj - segments[2]); + if ( + EPars.validateParenthesis( + EPars.pairsToParenthesis(this._targetPairs[xx]).slice(segments[1] + 1, segments[2]), + false + ) == null + ) { + for (let jj = segments[0]; jj <= segments[1]; jj++) { + this._targetPairs[xx][jj] = segments[3] - (jj - segments[0]); + } + for (let jj = segments[2]; jj <= segments[3]; jj++) { + this._targetPairs[xx][jj] = segments[1] - (jj - segments[2]); + } Eterna.sound.playSound(Sounds.SoundGB); this.flashConstraintForTarget(xx); - this._poses[target_index].clearDesignStruct(); + this._poses[targetIndex].clearDesignStruct(); // if the above fails, and we have multi-oligos, there may be a permutation where it works } else if (this._targetOligos[xx] != null && this._targetOligos[xx].length > 1) { - let new_order: number[] = []; - for (let jj = 0; jj < this._targetOligos[xx].length; jj++) new_order.push(jj); + let newOrder: number[] = []; + for (let jj = 0; jj < this._targetOligos[xx].length; jj++) newOrder.push(jj); let more: boolean; do { - segments = this._poses[target_index].designSegments; - let new_map: number[] = this._poses[target_index].getOrderMap(new_order); - let new_pairs: number[] = []; - if (new_map != null) { + segments = this._poses[targetIndex].designSegments; + let newMap: number[] = this._poses[targetIndex].getOrderMap(newOrder); + let newPairs: number[] = []; + if (newMap != null) { for (let jj = 0; jj < segments.length; jj++) { - segments[jj] = new_map.indexOf(segments[jj]); + segments[jj] = newMap.indexOf(segments[jj]); } for (let jj = 0; jj < this._targetPairs[xx].length; jj++) { - let kk: number = idx_map.indexOf(new_map[jj]); + let kk: number = idxMap.indexOf(newMap[jj]); let pp: number = this._targetPairs[xx][kk]; - new_pairs[jj] = pp < 0 ? pp : new_map.indexOf(idx_map[pp]); + newPairs[jj] = pp < 0 ? pp : newMap.indexOf(idxMap[pp]); } } - if (EPars.validateParenthesis(EPars.pairsToParenthesis(new_pairs).slice(segments[1] + 1, segments[2]), false) == null) { + if ( + EPars.validateParenthesis( + EPars.pairsToParenthesis(newPairs).slice(segments[1] + 1, segments[2]), false + ) == null + ) { // compatible permutation - this._targetPairs[xx] = new_pairs; - this._targetOligosOrder[xx] = new_order; + this._targetPairs[xx] = newPairs; + this._targetOligosOrder[xx] = newOrder; for (let jj = segments[0]; jj <= segments[1]; jj++) { this._targetPairs[xx][jj] = segments[3] - (jj - segments[0]); } @@ -3080,10 +3154,10 @@ export default class PoseEditMode extends GameMode { } Eterna.sound.playSound(Sounds.SoundGB); this.flashConstraintForTarget(xx); - this._poses[target_index].clearDesignStruct(); + this._poses[targetIndex].clearDesignStruct(); more = false; } else { - more = FoldUtil.nextPerm(new_order); + more = FoldUtil.nextPerm(newOrder); } } while (more); } @@ -3092,86 +3166,94 @@ export default class PoseEditMode extends GameMode { } } - let last_shifted_index: number = this._poses[target_index].lastShiftedIndex; - let last_shifted_command: number = this._poses[target_index].lastShiftedCommand; - for (let ii: number = 0; ii < this._poses.length; ii++) { - if (last_shifted_index > 0 && last_shifted_command >= 0) { - if (ii !== target_index) { - this._poses[ii].baseShiftWithCommand(last_shifted_command, last_shifted_index); + let lastShiftedIndex: number = this._poses[targetIndex].lastShiftedIndex; + let lastShiftedCommand: number = this._poses[targetIndex].lastShiftedCommand; + for (let ii = 0; ii < this._poses.length; ii++) { + if (lastShiftedIndex > 0 && lastShiftedCommand >= 0) { + if (ii !== targetIndex) { + this._poses[ii].baseShiftWithCommand(lastShiftedCommand, lastShiftedIndex); } - let results: any = this._poses[ii].parseCommandWithPairs(last_shifted_command, last_shifted_index, this._targetPairs[ii]); + let results: any = this._poses[ii].parseCommandWithPairs( + lastShiftedCommand, lastShiftedIndex, this._targetPairs[ii] + ); if (results != null) { let parenthesis: string = results[0]; let mode: number = results[1]; this._targetPairs[ii] = EPars.parenthesisToPairs(parenthesis); } - let anti_structure_constraints: any[] = this._targetConditions[ii]['anti_structure_constraints']; - if (anti_structure_constraints != null) { - if (last_shifted_command === EPars.RNABASE_ADD_BASE) { - let anti_structure_constraint: boolean = anti_structure_constraints[last_shifted_index]; - anti_structure_constraints.splice(last_shifted_index, 0, anti_structure_constraint); - } else if (last_shifted_command === EPars.RNABASE_DELETE) { - anti_structure_constraints.splice(last_shifted_index, 1); + let antiStructureConstraints: any[] = this._targetConditions[ii]['anti_structure_constraints']; + if (antiStructureConstraints != null) { + if (lastShiftedCommand === EPars.RNABASE_ADD_BASE) { + let antiStructureConstraint: boolean = antiStructureConstraints[lastShiftedIndex]; + antiStructureConstraints.splice(lastShiftedIndex, 0, antiStructureConstraint); + } else if (lastShiftedCommand === EPars.RNABASE_DELETE) { + antiStructureConstraints.splice(lastShiftedIndex, 1); } } - structure_constraints = this._targetConditions[ii]['structure_constraints']; - if (structure_constraints != null) { - let constraint_val: boolean = structure_constraints[last_shifted_index]; - let new_constraints: any[]; + structureConstraints = this._targetConditions[ii]['structure_constraints']; + if (structureConstraints != null) { + let constraintVal: boolean = structureConstraints[lastShiftedIndex]; + let newConstraints: any[]; - if (last_shifted_command === EPars.RNABASE_ADD_BASE) { - new_constraints = structure_constraints.slice(0, last_shifted_index); - new_constraints.push(constraint_val); - new_constraints = new_constraints.concat(structure_constraints.slice(last_shifted_index, structure_constraints.length)); + if (lastShiftedCommand === EPars.RNABASE_ADD_BASE) { + newConstraints = structureConstraints.slice(0, lastShiftedIndex); + newConstraints.push(constraintVal); + newConstraints = newConstraints.concat( + structureConstraints.slice(lastShiftedIndex, structureConstraints.length) + ); } else { - new_constraints = structure_constraints.slice(0, last_shifted_index); - new_constraints = new_constraints.concat(structure_constraints.slice(last_shifted_index + 1, structure_constraints.length)); + newConstraints = structureConstraints.slice(0, lastShiftedIndex); + newConstraints = newConstraints.concat( + structureConstraints.slice(lastShiftedIndex + 1, structureConstraints.length) + ); } - this._targetConditions[ii]['structure_constraints'] = new_constraints; + this._targetConditions[ii]['structure_constraints'] = newConstraints; } - let anti_secstruct: string = this._targetConditions[ii]['anti_secstruct']; - if (anti_secstruct != null) { - let anti_pairs: number[] = EPars.parenthesisToPairs(anti_secstruct); - let antiResult: any[] = this._poses[ii].parseCommandWithPairs(last_shifted_command, last_shifted_index, anti_pairs); + let antiSecstruct: string = this._targetConditions[ii]['anti_secstruct']; + if (antiSecstruct != null) { + let antiPairs: number[] = EPars.parenthesisToPairs(antiSecstruct); + let antiResult: any[] = this._poses[ii].parseCommandWithPairs( + lastShiftedCommand, lastShiftedIndex, antiPairs + ); this._targetConditions[ii]['anti_secstruct'] = antiResult[0]; } - if (this._targetConditions[ii]['type'] === "aptamer") { - let binding_site: number[] = this._targetConditions[ii]['site'].slice(0); - let binding_pairs: number[] = []; - if (last_shifted_command === EPars.RNABASE_ADD_BASE) { - for (let ss: number = 0; ss < binding_site.length; ss++) { - if (binding_site[ss] >= last_shifted_index) { - binding_site[ss]++; + if (this._targetConditions[ii]['type'] === 'aptamer') { + let bindingSite: number[] = this._targetConditions[ii]['site'].slice(0); + let bindingPairs: number[] = []; + if (lastShiftedCommand === EPars.RNABASE_ADD_BASE) { + for (let ss = 0; ss < bindingSite.length; ss++) { + if (bindingSite[ss] >= lastShiftedIndex) { + bindingSite[ss]++; } } - for (let jj = 0; jj < binding_site.length; jj++) { - binding_pairs.push(this._targetPairs[ii][binding_site[jj]]); + for (let jj = 0; jj < bindingSite.length; jj++) { + bindingPairs.push(this._targetPairs[ii][bindingSite[jj]]); } } else { - for (let ss = 0; ss < binding_site.length; ss++) { - if (binding_site[ss] >= last_shifted_index) { - binding_site[ss]--; + for (let ss = 0; ss < bindingSite.length; ss++) { + if (bindingSite[ss] >= lastShiftedIndex) { + bindingSite[ss]--; } } - for (let jj = 0; jj < binding_site.length; jj++) { - binding_pairs.push(this._targetPairs[ii][binding_site[jj]]); + for (let jj = 0; jj < bindingSite.length; jj++) { + bindingPairs.push(this._targetPairs[ii][bindingSite[jj]]); } } - this._targetConditions[ii]['site'] = binding_site; - this._targetConditions[ii]['binding_pairs'] = binding_pairs; + this._targetConditions[ii]['site'] = bindingSite; + this._targetConditions[ii]['binding_pairs'] = bindingPairs; } } - this._poses[ii].sequence = this._poses[target_index].sequence; - this._poses[ii].puzzleLocks = this._poses[target_index].puzzleLocks; + this._poses[ii].sequence = this._poses[targetIndex].sequence; + this._poses[ii].puzzleLocks = this._poses[targetIndex].puzzleLocks; } this._foldTotalTime = 0; @@ -3180,9 +3262,9 @@ export default class PoseEditMode extends GameMode { return; } - const LOCK_NAME = "ExecFold"; + const LOCK_NAME = 'ExecFold'; - let execfold_cb = (fd: any[]) => { + let execfoldCB = (fd: any[]) => { this.hideAsyncText(); this.popUILock(LOCK_NAME); @@ -3192,9 +3274,9 @@ export default class PoseEditMode extends GameMode { this._seqStacks[this._stackLevel] = []; for (let ii = 0; ii < this._poses.length; ii++) { - let undo_block: UndoBlock = new UndoBlock([]); - undo_block.fromJSON(fd[ii]); - this._seqStacks[this._stackLevel][ii] = undo_block; + let undoBlock: UndoBlock = new UndoBlock([]); + undoBlock.fromJSON(fd[ii]); + this._seqStacks[this._stackLevel][ii] = undoBlock; } this.savePosesMarkersContexts(); @@ -3208,38 +3290,40 @@ export default class PoseEditMode extends GameMode { return; } - this.poseEditByTargetDoFold(target_index); + this.poseEditByTargetDoFold(targetIndex); }; this.pushUILock(LOCK_NAME); - let sol: Solution = SolutionManager.instance.getSolutionBySequence(this._poses[target_index].getSequenceString()); - if (sol != null && this._puzzle.hasTargetType("multistrand")) { - this.showAsyncText("retrieving..."); - sol.queryFoldData().then((result) => execfold_cb(result)); + let sol: Solution = SolutionManager.instance.getSolutionBySequence( + this._poses[targetIndex].getSequenceString() + ); + if (sol != null && this._puzzle.hasTargetType('multistrand')) { + this.showAsyncText('retrieving...'); + sol.queryFoldData().then(result => execfoldCB(result)); } else { - execfold_cb(null); + execfoldCB(null); } } - private poseEditByTargetDoFold(target_index: number): void { + private poseEditByTargetDoFold(targetIndex: number): void { this._foldStartTime = new Date().getTime(); - this.showAsyncText("folding..."); + this.showAsyncText('folding...'); this.pushUILock(PoseEditMode.FOLDING_LOCK); if (this.forceSync) { - for (let ii: number = 0; ii < this._targetPairs.length; ii++) { + for (let ii = 0; ii < this._targetPairs.length; ii++) { this.poseEditByTargetFoldTarget(ii); } - this.poseEditByTargetEpilog(target_index); - + this.poseEditByTargetEpilog(targetIndex); } else { for (let ii = 0; ii < this._targetPairs.length; ii++) { this._opQueue.push(new PoseOp(ii + 1, () => this.poseEditByTargetFoldTarget(ii))); } - this._opQueue.push(new PoseOp(this._targetPairs.length + 1, () => this.poseEditByTargetEpilog(target_index))); - + this._opQueue.push( + new PoseOp(this._targetPairs.length + 1, () => this.poseEditByTargetEpilog(targetIndex)) + ); } if (this._poseEditByTargetCb != null) { @@ -3248,89 +3332,94 @@ export default class PoseEditMode extends GameMode { } private poseEditByTargetFoldTarget(ii: number): void { - let best_pairs: number[]; - let oligo_order: number[] = null; - let oligos_paired: number = 0; - let force_struct: string = null; - let fold_mode: number; - let full_seq: number[]; + let bestPairs: number[]; + let oligoOrder: number[] = null; + let oligosPaired = 0; + let forceStruct: string = null; + let foldMode: number; + let fullSeq: number[]; let malus: number; let bonus: number; let sites: number[]; if (ii === 0) { - /// Pushing undo block + // / Pushing undo block this._stackLevel++; this._seqStacks[this._stackLevel] = []; } // a "trick" used by the 'multifold' branch below, in order to // re-queue itself without triggering the stack push coded above - ii = ii % this._targetPairs.length; + ii %= this._targetPairs.length; let seq: number[] = this._poses[ii].sequence; - if (this._targetConditions[ii]) force_struct = this._targetConditions[ii]['force_struct']; - - if (this._targetConditions[ii] == null || this._targetConditions[ii]['type'] === "single") { - best_pairs = this._folder.foldSequence(this._puzzle.transformSequence(seq, ii), null, force_struct); + if (this._targetConditions[ii]) forceStruct = this._targetConditions[ii]['force_struct']; - } else if (this._targetConditions[ii]['type'] === "aptamer") { + if (this._targetConditions[ii] == null || this._targetConditions[ii]['type'] === 'single') { + bestPairs = this._folder.foldSequence(this._puzzle.transformSequence(seq, ii), null, forceStruct); + } else if (this._targetConditions[ii]['type'] === 'aptamer') { bonus = this._targetConditions[ii]['bonus']; sites = this._targetConditions[ii]['site']; - best_pairs = this._folder.foldSequenceWithBindingSite(this._puzzle.transformSequence(seq, ii), this._targetPairs[ii], sites, Number(bonus), this._targetConditions[ii]['fold_version']); - - } else if (this._targetConditions[ii]['type'] === "oligo") { - fold_mode = this._targetConditions[ii]["fold_mode"] == null ? - Pose2D.OLIGO_MODE_DIMER : - Number(this._targetConditions[ii]["fold_mode"]); - if (fold_mode === Pose2D.OLIGO_MODE_DIMER) { - log.debug("cofold"); - full_seq = seq.concat(EPars.stringToSequence("&" + this._targetConditions[ii]['oligo_sequence'])); - malus = int(this._targetConditions[ii]["malus"] * 100); - best_pairs = this._folder.cofoldSequence(full_seq, null, malus, force_struct); - } else if (fold_mode === Pose2D.OLIGO_MODE_EXT5P) { - full_seq = EPars.stringToSequence(this._targetConditions[ii]['oligo_sequence']).concat(seq); - best_pairs = this._folder.foldSequence(full_seq, null, force_struct); + bestPairs = this._folder.foldSequenceWithBindingSite( + this._puzzle.transformSequence(seq, ii), + this._targetPairs[ii], + sites, Number(bonus), + this._targetConditions[ii]['fold_version'] + ); + } else if (this._targetConditions[ii]['type'] === 'oligo') { + foldMode = this._targetConditions[ii]['fold_mode'] == null + ? Pose2D.OLIGO_MODE_DIMER + : Number(this._targetConditions[ii]['fold_mode']); + if (foldMode === Pose2D.OLIGO_MODE_DIMER) { + log.debug('cofold'); + fullSeq = seq.concat(EPars.stringToSequence(`&${this._targetConditions[ii]['oligo_sequence']}`)); + malus = int(this._targetConditions[ii]['malus'] * 100); + bestPairs = this._folder.cofoldSequence(fullSeq, null, malus, forceStruct); + } else if (foldMode === Pose2D.OLIGO_MODE_EXT5P) { + fullSeq = EPars.stringToSequence(this._targetConditions[ii]['oligo_sequence']).concat(seq); + bestPairs = this._folder.foldSequence(fullSeq, null, forceStruct); } else { - full_seq = seq.concat(EPars.stringToSequence(this._targetConditions[ii]['oligo_sequence'])); - best_pairs = this._folder.foldSequence(full_seq, null, force_struct); + fullSeq = seq.concat(EPars.stringToSequence(this._targetConditions[ii]['oligo_sequence'])); + bestPairs = this._folder.foldSequence(fullSeq, null, forceStruct); } - - } else if (this._targetConditions[ii]['type'] === "aptamer+oligo") { + } else if (this._targetConditions[ii]['type'] === 'aptamer+oligo') { bonus = this._targetConditions[ii]['bonus']; sites = this._targetConditions[ii]['site']; - fold_mode = this._targetConditions[ii]["fold_mode"] == null ? - Pose2D.OLIGO_MODE_DIMER : - Number(this._targetConditions[ii]["fold_mode"]); - if (fold_mode === Pose2D.OLIGO_MODE_DIMER) { - log.debug("cofold"); - full_seq = seq.concat(EPars.stringToSequence("&" + this._targetConditions[ii]['oligo_sequence'])); - malus = int(this._targetConditions[ii]["malus"] * 100); - best_pairs = this._folder.cofoldSequenceWithBindingSite(full_seq, sites, bonus, force_struct, malus); - } else if (fold_mode === Pose2D.OLIGO_MODE_EXT5P) { - full_seq = EPars.stringToSequence(this._targetConditions[ii]['oligo_sequence']).concat(seq); - best_pairs = this._folder.foldSequenceWithBindingSite(full_seq, this._targetPairs[ii], sites, Number(bonus), this._targetConditions[ii]['fold_version']); + foldMode = this._targetConditions[ii]['fold_mode'] == null + ? Pose2D.OLIGO_MODE_DIMER + : Number(this._targetConditions[ii]['fold_mode']); + if (foldMode === Pose2D.OLIGO_MODE_DIMER) { + log.debug('cofold'); + fullSeq = seq.concat(EPars.stringToSequence(`&${this._targetConditions[ii]['oligo_sequence']}`)); + malus = int(this._targetConditions[ii]['malus'] * 100); + bestPairs = this._folder.cofoldSequenceWithBindingSite(fullSeq, sites, bonus, forceStruct, malus); + } else if (foldMode === Pose2D.OLIGO_MODE_EXT5P) { + fullSeq = EPars.stringToSequence(this._targetConditions[ii]['oligo_sequence']).concat(seq); + bestPairs = this._folder.foldSequenceWithBindingSite( + fullSeq, this._targetPairs[ii], sites, Number(bonus), this._targetConditions[ii]['fold_version'] + ); } else { - full_seq = seq.concat(EPars.stringToSequence(this._targetConditions[ii]['oligo_sequence'])); - best_pairs = this._folder.foldSequenceWithBindingSite(full_seq, this._targetPairs[ii], sites, Number(bonus), this._targetConditions[ii]['fold_version']); + fullSeq = seq.concat(EPars.stringToSequence(this._targetConditions[ii]['oligo_sequence'])); + bestPairs = this._folder.foldSequenceWithBindingSite( + fullSeq, this._targetPairs[ii], sites, Number(bonus), this._targetConditions[ii]['fold_version'] + ); } - - } else if (this._targetConditions[ii]['type'] === "multistrand") { + } else if (this._targetConditions[ii]['type'] === 'multistrand') { let oligos: any[] = []; - for (let jj: number = 0; jj < this._targetConditions[ii]['oligos'].length; jj++) { + for (let jj = 0; jj < this._targetConditions[ii]['oligos'].length; jj++) { oligos.push({ seq: EPars.stringToSequence(this._targetConditions[ii]['oligos'][jj]['sequence']), - malus: int(this._targetConditions[ii]['oligos'][jj]["malus"] * 100.0) + malus: int(this._targetConditions[ii]['oligos'][jj]['malus'] * 100.0) }); } - log.debug("multifold"); + log.debug('multifold'); let key: any = { - primitive: "multifold", + primitive: 'multifold', seq: this._puzzle.transformSequence(seq, ii), - second_best_pairs: null, - oligos: oligos, - desired_pairs: null, + secondBestPairs: null, + oligos, + desiredPairs: null, temp: 37 }; let mfold: any = this._folder.getCache(key); @@ -3341,42 +3430,43 @@ export default class PoseEditMode extends GameMode { let ops: PoseOp[] = this._folder.multifoldUnroll(this._puzzle.transformSequence(seq, ii), null, oligos); this._opQueue.unshift(new PoseOp( ii + 1, - () => this.poseEditByTargetFoldTarget(ii + this._targetPairs.length))); + () => this.poseEditByTargetFoldTarget(ii + this._targetPairs.length) + )); while (ops.length > 0) { let o: PoseOp = ops.pop(); o.sn = ii + 1; this._opQueue.unshift(o); } return; - } else { let best: any = this._folder.multifold(this._puzzle.transformSequence(seq, ii), null, oligos); - best_pairs = best.pairs.slice(); - oligo_order = best.order.slice(); - oligos_paired = best.count; + bestPairs = best.pairs.slice(); + oligoOrder = best.order.slice(); + oligosPaired = best.count; } } - let undo_block: UndoBlock = new UndoBlock(this._puzzle.transformSequence(seq, ii)); - undo_block.setPairs(best_pairs); - undo_block.targetOligos = this._targetOligos[ii]; - undo_block.targetOligo = this._targetOligo[ii]; - undo_block.oligoOrder = oligo_order; - undo_block.oligosPaired = oligos_paired; - undo_block.targetPairs = this._targetPairs[ii]; - undo_block.targetOligoOrder = this._targetOligosOrder[ii]; - undo_block.puzzleLocks = this._poses[ii].puzzleLocks; - undo_block.targetConditions = this._targetConditions[ii]; - undo_block.setBasics(this._folder); - this._seqStacks[this._stackLevel][ii] = undo_block; + let undoBlock: UndoBlock = new UndoBlock(this._puzzle.transformSequence(seq, ii)); + undoBlock.setPairs(bestPairs); + undoBlock.targetOligos = this._targetOligos[ii]; + undoBlock.targetOligo = this._targetOligo[ii]; + undoBlock.oligoOrder = oligoOrder; + undoBlock.oligosPaired = oligosPaired; + undoBlock.targetPairs = this._targetPairs[ii]; + undoBlock.targetOligoOrder = this._targetOligosOrder[ii]; + undoBlock.puzzleLocks = this._poses[ii].puzzleLocks; + undoBlock.targetConditions = this._targetConditions[ii]; + undoBlock.setBasics(this._folder); + this._seqStacks[this._stackLevel][ii] = undoBlock; } - private poseEditByTargetEpilog(target_index: number): void { + private poseEditByTargetEpilog(targetIndex: number): void { this.hideAsyncText(); this.popUILock(PoseEditMode.FOLDING_LOCK); // this._fold_total_time = new Date().getTime() - this._fold_start_time; - // if (!this._tools_container.contains(this._freeze_button) && this._fold_total_time >= 1000.0) { // FIXME: a bit arbitrary... + // if (!this._tools_container.contains(this._freeze_button) && this._fold_total_time >= 1000.0) { + // // FIXME: a bit arbitrary... // this._tools_container.addObject(this._freeze_button); // this.layout_bars(); // } @@ -3385,16 +3475,17 @@ export default class PoseEditMode extends GameMode { this.updateScore(); this.transformPosesMarkers(); - /// JEEFIX + // / JEEFIX + + let lastBestPairs: number[] = this._seqStacks[this._stackLevel][targetIndex].getPairs(); + let bestPairs: number[] = lastBestPairs; - let last_best_pairs: number[] = null; - let best_pairs: number[] = last_best_pairs = this._seqStacks[this._stackLevel][target_index].getPairs(); if (this._stackLevel > 0) { - last_best_pairs = this._seqStacks[this._stackLevel - 1][target_index].getPairs(); + lastBestPairs = this._seqStacks[this._stackLevel - 1][targetIndex].getPairs(); } - if (last_best_pairs != null) { - let is_shape_constrained: boolean = false; + if (lastBestPairs != null) { + let isShapeConstrained = false; let constraints: string[] = this._puzzle.constraints; if (this._puzzle.temporaryConstraints != null) { @@ -3404,59 +3495,64 @@ export default class PoseEditMode extends GameMode { if (constraints != null) { for (let ii = 0; ii < constraints.length; ii += 2) { if (constraints[ii] === ConstraintType.SHAPE) { - is_shape_constrained = true; + isShapeConstrained = true; } } } - let pairs_diff: number[] = []; + let pairsDiff: number[] = []; - for (let ii = 0; ii < best_pairs.length; ii++) { - if (last_best_pairs[ii] === best_pairs[ii]) { - pairs_diff[ii] = 0; - } else if (best_pairs[ii] < 0 && last_best_pairs[ii] >= 0) { - pairs_diff[ii] = -1; - } else if (best_pairs[ii] > ii) { - if (last_best_pairs[ii] >= 0) { - pairs_diff[ii] = 1; + for (let ii = 0; ii < bestPairs.length; ii++) { + if (lastBestPairs[ii] === bestPairs[ii]) { + pairsDiff[ii] = 0; + } else if (bestPairs[ii] < 0 && lastBestPairs[ii] >= 0) { + pairsDiff[ii] = -1; + } else if (bestPairs[ii] > ii) { + if (lastBestPairs[ii] >= 0) { + pairsDiff[ii] = 1; } else { - pairs_diff[ii] = 2; + pairsDiff[ii] = 2; } } else { - pairs_diff[ii] = 0; - } - } - - if (!this._poses[target_index].useSimpleGraphics) { - let stack_start: number = -1; - let last_other_stack: number = -1; - for (let ii = 0; ii < best_pairs.length; ii++) { - if (pairs_diff[ii] > 0 && ((!is_shape_constrained && this._poseState === PoseState.NATIVE) || (best_pairs[ii] === this._targetPairs[target_index][ii]))) { - if (stack_start < 0) { - stack_start = ii; - last_other_stack = best_pairs[ii]; + pairsDiff[ii] = 0; + } + } + + if (!this._poses[targetIndex].useSimpleGraphics) { + let stackStart = -1; + let lastOtherStack = -1; + for (let ii = 0; ii < bestPairs.length; ii++) { + if ( + pairsDiff[ii] > 0 + && ( + (!isShapeConstrained && this._poseState === PoseState.NATIVE) + || (bestPairs[ii] === this._targetPairs[targetIndex][ii]) + ) + ) { + if (stackStart < 0) { + stackStart = ii; + lastOtherStack = bestPairs[ii]; } else { - if (best_pairs[ii] !== last_other_stack - 1) { - this._poses[target_index].praiseStack(stack_start, ii - 1); - stack_start = ii; + if (bestPairs[ii] !== lastOtherStack - 1) { + this._poses[targetIndex].praiseStack(stackStart, ii - 1); + stackStart = ii; } - last_other_stack = best_pairs[ii]; - } - } else { - if (stack_start >= 0) { - this._poses[target_index].praiseStack(stack_start, ii - 1); - stack_start = -1; - last_other_stack = -1; + lastOtherStack = bestPairs[ii]; } - + } else if (stackStart >= 0) { + this._poses[targetIndex].praiseStack(stackStart, ii - 1); + stackStart = -1; + lastOtherStack = -1; } } } } - if (this._foldTotalTime >= 1000.0 && this._puzzle.hasTargetType("multistrand")) { - let sol: Solution = SolutionManager.instance.getSolutionBySequence(this._poses[target_index].getSequenceString()); + if (this._foldTotalTime >= 1000.0 && this._puzzle.hasTargetType('multistrand')) { + let sol: Solution = SolutionManager.instance.getSolutionBySequence( + this._poses[targetIndex].getSequenceString() + ); if (sol != null && !sol.hasFoldData) { let fd: any[] = []; for (let ii = 0; ii < this._poses.length; ii++) { @@ -3471,21 +3567,21 @@ export default class PoseEditMode extends GameMode { } } - protected getCurrentUndoBlock(target_index: number = -1): UndoBlock { - if (target_index < 0) { + protected getCurrentUndoBlock(targetIndex: number = -1): UndoBlock { + if (targetIndex < 0) { return this._seqStacks[this._stackLevel][this._curTargetIndex]; } else { - return this._seqStacks[this._stackLevel][target_index]; + return this._seqStacks[this._stackLevel][targetIndex]; } } - private setPosesWithUndoBlock(ii: number, undo_block: UndoBlock): void { - this._poses[ii].sequence = this._puzzle.transformSequence(undo_block.sequence, ii); - this._poses[ii].puzzleLocks = undo_block.puzzleLocks; + private setPosesWithUndoBlock(ii: number, undoBlock: UndoBlock): void { + this._poses[ii].sequence = this._puzzle.transformSequence(undoBlock.sequence, ii); + this._poses[ii].puzzleLocks = undoBlock.puzzleLocks; } private moveUndoStack(): void { - for (let ii: number = 0; ii < this._poses.length; ii++) { + for (let ii = 0; ii < this._poses.length; ii++) { this.setPosesWithUndoBlock(ii, this._seqStacks[this._stackLevel][ii]); this._targetPairs[ii] = this._seqStacks[this._stackLevel][ii].targetPairs; this._targetConditions[ii] = this._seqStacks[this._stackLevel][ii].targetConditions; @@ -3537,9 +3633,8 @@ export default class PoseEditMode extends GameMode { this.savePosesMarkersContexts(); let before: number[] = this._puzzle.transformSequence(this.getCurrentUndoBlock(0).sequence, 0); - let stack_level: number = this._stackLevel; + let stackLevel: number = this._stackLevel; while (this._stackLevel >= 1) { - if (this.getCurrentUndoBlock(0).stable) { this.moveUndoStack(); @@ -3553,7 +3648,7 @@ export default class PoseEditMode extends GameMode { this._stackLevel--; } - this._stackLevel = stack_level; + this._stackLevel = stackLevel; } private hideEndCurtain(): void { @@ -3575,8 +3670,11 @@ export default class PoseEditMode extends GameMode { * The _unstableShapeConstraintIdx indicates which constraint's misfolded bases should be hilited. */ private onConstraintBoxClicked(idx: number): void { - if (this._puzzle.curConstraints[idx] == ConstraintType.SHAPE || this._puzzle.curConstraints[idx] == ConstraintType.ANTISHAPE) { - this._unstableShapeConstraintIdx = (this._unstableShapeConstraintIdx == idx ? -1 : idx); + if ( + this._puzzle.curConstraints[idx] === ConstraintType.SHAPE + || this._puzzle.curConstraints[idx] === ConstraintType.ANTISHAPE + ) { + this._unstableShapeConstraintIdx = (this._unstableShapeConstraintIdx === idx ? -1 : idx); this.checkConstraints(); } } @@ -3592,14 +3690,14 @@ export default class PoseEditMode extends GameMode { private _toolbar: Toolbar; - protected _folder: Folder; - /// Asynch folding + protected _folder: Folder; + // / Asynch folding private _opQueue: PoseOp[] = []; private _poseEditByTargetCb: () => void = null; private _asynchText: Text; private _foldStartTime: number; private _foldTotalTime: number; - /// Undo stack + // / Undo stack private _seqStacks: UndoBlock[][]; private _stackLevel: number; private _stackSize: number; @@ -3626,7 +3724,7 @@ export default class PoseEditMode extends GameMode { private _hintBoxRef: GameObjectRef = GameObjectRef.NULL; - /// constraints && scoring display + // / constraints && scoring display private _constraintBoxes: ConstraintBox[]; private _constraintShapeBoxes: ConstraintBox[]; private _constraintAntishapeBoxes: ConstraintBox[]; @@ -3663,26 +3761,5 @@ export default class PoseEditMode extends GameMode { // Will be non-null after we submit our solution to the server private _submitSolutionRspData: any; - private static readonly FOLDING_LOCK = "Folding"; -} - -interface ConstraintInfo { - wrong_pairs: number[]; - restricted_local: number[][]; - max_allowed_guanine: number; - max_allowed_cytosine: number; - max_allowed_adenine: number; -} - -interface OligoDef { - sequence: string; - malus: number; - name: string; - bind?: boolean; - concentration?: string; - label?: string; -} - -enum ConstraintStatus { - SATISFIED = "satisfied", UNSATISFIED = "unsatisfied", PENDING = "pending" + private static readonly FOLDING_LOCK = 'Folding'; } diff --git a/src/eterna/mode/PoseEdit/SubmitPoseDialog.ts b/src/eterna/mode/PoseEdit/SubmitPoseDialog.ts index 91be38a8d..e622f281e 100644 --- a/src/eterna/mode/PoseEdit/SubmitPoseDialog.ts +++ b/src/eterna/mode/PoseEdit/SubmitPoseDialog.ts @@ -1,18 +1,18 @@ -import {Flashbang} from "flashbang/core"; -import {KeyCode} from "flashbang/input"; -import {Dialog, TextInputPanel} from "eterna/ui"; -import SubmitPoseDetails from "./SubmitPoseDetails"; +import {Flashbang} from 'flashbang/core'; +import {KeyCode} from 'flashbang/input'; +import {Dialog, TextInputPanel} from 'eterna/ui'; +import SubmitPoseDetails from './SubmitPoseDetails'; /** Prompts the player for a title and comment */ export default class SubmitPoseDialog extends Dialog { protected added(): void { super.added(); - const TITLE = "Title"; - const COMMENT = "Comment"; + const TITLE = 'Title'; + const COMMENT = 'Comment'; let inputPanel = new TextInputPanel(); - inputPanel.title = "Submit your design"; + inputPanel.title = 'Submit your design'; let title = inputPanel.addField(TITLE, 200); inputPanel.addField(COMMENT, 200, true); this.addObject(inputPanel, this.container); diff --git a/src/eterna/mode/PoseEdit/SubmittingDialog.ts b/src/eterna/mode/PoseEdit/SubmittingDialog.ts index 9752b809d..0037ed50a 100644 --- a/src/eterna/mode/PoseEdit/SubmittingDialog.ts +++ b/src/eterna/mode/PoseEdit/SubmittingDialog.ts @@ -1,15 +1,15 @@ -import {Point} from "pixi.js"; -import {Flashbang} from "flashbang/core"; -import {AlphaTask, RepeatingTask, SerialTask} from "flashbang/tasks"; -import {Easing} from "flashbang/util"; -import {Dialog} from "eterna/ui"; -import {Fonts} from "eterna/util"; +import {Point} from 'pixi.js'; +import {Flashbang} from 'flashbang/core'; +import {AlphaTask, RepeatingTask, SerialTask} from 'flashbang/tasks'; +import {Easing} from 'flashbang/util'; +import {Dialog} from 'eterna/ui'; +import {Fonts} from 'eterna/util'; export default class SubmittingDialog extends Dialog { protected added(): void { super.added(); - let text = Fonts.arial("Submitting...", 20).color(0xffffff).bold().build(); + let text = Fonts.arial('Submitting...', 20).color(0xffffff).bold().build(); this.container.addChild(text); text.alpha = 0; diff --git a/src/eterna/mode/PoseEdit/index.ts b/src/eterna/mode/PoseEdit/index.ts index f5ba3f742..483e2adcd 100644 --- a/src/eterna/mode/PoseEdit/index.ts +++ b/src/eterna/mode/PoseEdit/index.ts @@ -1,7 +1,7 @@ -export {default as Booster, BoosterType} from "./Booster"; -export {default as MissionClearedPanel} from "./MissionClearedPanel"; -export {default as MissionIntroMode} from "./MissionIntroMode"; -export {default as PoseEditMode, PuzzleState, PoseEditParams} from "./PoseEditMode"; -export {default as SubmitPoseDetails} from "./SubmitPoseDetails"; -export {default as SubmitPoseDialog} from "./SubmitPoseDialog"; -export {default as SubmittingDialog} from "./SubmittingDialog"; +export {default as Booster, BoosterType} from './Booster'; +export {default as MissionClearedPanel} from './MissionClearedPanel'; +export {default as MissionIntroMode} from './MissionIntroMode'; +export {default as PoseEditMode, PuzzleState, PoseEditParams} from './PoseEditMode'; +export {default as SubmitPoseDetails} from './SubmitPoseDetails'; +export {default as SubmitPoseDialog} from './SubmitPoseDialog'; +export {default as SubmittingDialog} from './SubmittingDialog'; diff --git a/src/eterna/mode/PuzzleEdit/PuzzleEditMode.ts b/src/eterna/mode/PuzzleEdit/PuzzleEditMode.ts index 9d4228695..4dc2f4362 100644 --- a/src/eterna/mode/PuzzleEdit/PuzzleEditMode.ts +++ b/src/eterna/mode/PuzzleEdit/PuzzleEditMode.ts @@ -1,28 +1,28 @@ -import {DisplayObject, Point} from "pixi.js"; -import {HAlign, VAlign} from "flashbang/core"; -import {KeyCode} from "flashbang/input"; -import {Base64, DisplayUtil} from "flashbang/util"; -import EPars from "eterna/EPars"; -import Eterna from "eterna/Eterna"; +import {DisplayObject, Point} from 'pixi.js'; +import {HAlign, VAlign} from 'flashbang/core'; +import {KeyCode} from 'flashbang/input'; +import {Base64, DisplayUtil} from 'flashbang/util'; +import EPars from 'eterna/EPars'; +import Eterna from 'eterna/Eterna'; import { Folder, FolderManager, LinearFoldC, LinearFoldV, NuPACK, Vienna, Vienna2 -} from "eterna/folding"; +} from 'eterna/folding'; import { Molecule, Pose2D, PoseField, PuzzleEditOp -} from "eterna/pose2D"; -import {ConstraintType} from "eterna/puzzle"; -import {Bitmaps} from "eterna/resources"; +} from 'eterna/pose2D'; +import {ConstraintType} from 'eterna/puzzle'; +import {Bitmaps} from 'eterna/resources'; import { AsyncProcessDialog, ConstraintBox, DialogCanceledError, EternaViewOptionsDialog, EternaViewOptionsMode, GameButton, GetPaletteTargetBaseType, PaletteTargetType, PasteSequenceDialog, PoseThumbnail, PoseThumbnailType, URLButton, Toolbar, ToolbarType -} from "eterna/ui"; -import {default as UndoBlock, UndoBlockParam} from "eterna/UndoBlock"; -import {ExternalInterfaceCtx, Fonts} from "eterna/util"; -import {Background, BaseGlow} from "eterna/vfx"; -import {CopyTextDialogMode, GameMode} from "eterna/mode"; -import StructureInput from "./StructureInput"; -import SubmitPuzzleDialog, {SubmitPuzzleDetails} from "./SubmitPuzzleDialog"; +} from 'eterna/ui'; +import UndoBlock, {UndoBlockParam} from 'eterna/UndoBlock'; +import {ExternalInterfaceCtx, Fonts} from 'eterna/util'; +import {Background, BaseGlow} from 'eterna/vfx'; +import {CopyTextDialogMode, GameMode} from 'eterna/mode'; +import StructureInput from './StructureInput'; +import SubmitPuzzleDialog, {SubmitPuzzleDetails} from './SubmitPuzzleDialog'; type InteractionEvent = PIXI.interaction.InteractionEvent; @@ -66,7 +66,7 @@ export default class PuzzleEditMode extends GameMode { this._folderButton = new GameButton() .allStates(Bitmaps.ShapeImg) .label(this._folder.name, 22) - .tooltip("Select the folding engine"); + .tooltip('Select the folding engine'); this._folderButton.display.scale = new Point(0.5, 0.5); this._folderButton.display.position = new Point(17, 160); this.addObject(this._folderButton, this.uiLayer); @@ -114,7 +114,7 @@ export default class PuzzleEditMode extends GameMode { this._toolbar.copyButton.clicked.connect(() => { this.modeStack.pushMode(new CopyTextDialogMode( EPars.sequenceToString(this._poses[0].sequence), - "Current Sequence" + 'Current Sequence' )); }); @@ -139,19 +139,19 @@ export default class PuzzleEditMode extends GameMode { this._toolbar.palette.targetClicked.connect(type => this.onPaletteTargetSelected(type)); if (this._embedded) { - this._scriptInterface.addCallback("get_secstruct", () => this.structure); - this._scriptInterface.addCallback("get_sequence", () => this.sequence); - this._scriptInterface.addCallback("get_locks", () => this.getLockString()); - this._scriptInterface.addCallback("get_thumbnail", () => this.getThumbnailBase64); - this._scriptInterface.addCallback("get_shift_limit", () => this.shiftLimitString); + this._scriptInterface.addCallback('get_secstruct', () => this.structure); + this._scriptInterface.addCallback('get_sequence', () => this.sequence); + this._scriptInterface.addCallback('get_locks', () => this.getLockString()); + this._scriptInterface.addCallback('get_thumbnail', () => this.getThumbnailBase64); + this._scriptInterface.addCallback('get_shift_limit', () => this.shiftLimitString); } this.clearUndoStack(); - let pose_fields: PoseField[] = []; + let poseFields: PoseField[] = []; this._structureInputs = []; - let set_cb = (kk: number): void => { + let setCB = (kk: number): void => { this._poses[kk].addBaseCallback = (parenthesis: string, op: PuzzleEditOp, index: number): void => { let secInput: StructureInput = this._structureInputs[kk]; secInput.structureString = parenthesis; @@ -159,19 +159,19 @@ export default class PuzzleEditMode extends GameMode { }; }; - let pose_edit_setter = (index: number, pose_to_set: Pose2D): void => { - pose_to_set.poseEditCallback = () => this.poseEditByTarget(index); + let poseEditSetter = (index: number, poseToSet: Pose2D): void => { + poseToSet.poseEditCallback = () => this.poseEditByTarget(index); }; - let bind_mousedown_event = (pose: Pose2D, index: number): void => { - pose.startMousedownCallback = (e: InteractionEvent, closest_dist: number, closest_index: number): void => { + let bindMousedownEvent = (pose: Pose2D, index: number): void => { + pose.startMousedownCallback = (e: InteractionEvent, closestDist: number, closestIndex: number): void => { for (let ii = 0; ii < this._numTargets; ++ii) { - let pose_field: PoseField = pose_fields[ii]; - let {pose} = pose_field; - if (ii == index) { - pose.onPoseMouseDown(e, closest_index); + let poseField: PoseField = poseFields[ii]; + let poseToNotify = poseField.pose; + if (ii === index) { + poseToNotify.onPoseMouseDown(e, closestIndex); } else { - pose.onPoseMouseDownPropagate(e, closest_index); + poseToNotify.onPoseMouseDownPropagate(e, closestIndex); } } }; @@ -179,17 +179,18 @@ export default class PuzzleEditMode extends GameMode { let initialPoseData = this._initialPoseData; for (let ii = 0; ii < this._numTargets; ii++) { - let defaultStructure = ".....((((((((....))))))))....."; + let defaultStructure = '.....((((((((....)))))))).....'; let defaultPairs: number[] = EPars.parenthesisToPairs(defaultStructure); - let defaultSequence = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; + let defaultSequence = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'; if (initialPoseData != null && initialPoseData[ii] != null - && initialPoseData[ii]["sequence"] != null - && initialPoseData[ii]["structure"] != null - && initialPoseData[ii]["structure"] != "") { - defaultStructure = initialPoseData[ii]["structure"]; - defaultSequence = initialPoseData[ii]["sequence"]; + && initialPoseData[ii]['sequence'] != null + && initialPoseData[ii]['structure'] != null + && initialPoseData[ii]['structure'] !== '' + ) { + defaultStructure = initialPoseData[ii]['structure']; + defaultSequence = initialPoseData[ii]['sequence']; defaultPairs = EPars.parenthesisToPairs(defaultStructure); } @@ -200,7 +201,7 @@ export default class PuzzleEditMode extends GameMode { pose.molecularStructure = defaultPairs; pose.molecularBindingBonus = -4.86; pose.sequence = EPars.stringToSequence(defaultSequence); - pose_fields.push(poseField); + poseFields.push(poseField); let structureInput = new StructureInput(pose); poseField.addObject(structureInput, poseField.container); @@ -213,28 +214,28 @@ export default class PuzzleEditMode extends GameMode { structureInput.structureString = defaultStructure; this._structureInputs.push(structureInput); - let constraint_box = new ConstraintBox(); - constraint_box.display.position = new Point(17, 35); - poseField.addObject(constraint_box, poseField.container); + let constraintBox = new ConstraintBox(); + constraintBox.display.position = new Point(17, 35); + poseField.addObject(constraintBox, poseField.container); if (this._embedded) { - constraint_box.display.visible = false; + constraintBox.display.visible = false; } - this._constraintBoxes.push(constraint_box); + this._constraintBoxes.push(constraintBox); } - this.setPoseFields(pose_fields); + this.setPoseFields(poseFields); this.poseEditByTarget(0); for (let ii = 0; ii < this._numTargets; ii++) { - set_cb(ii); - pose_edit_setter(ii, this._poses[ii]); + setCB(ii); + poseEditSetter(ii, this._poses[ii]); if (this._embedded) { this._poses[ii].setZoomLevel(2, true, true); } - bind_mousedown_event(this._poses[ii], ii); + bindMousedownEvent(this._poses[ii], ii); } this.setToTargetMode(); @@ -270,8 +271,8 @@ export default class PuzzleEditMode extends GameMode { return `puzedit_${numTargets}`; } - public setFolder(engine_name: string): void { - let newFolder: Folder = FolderManager.instance.getFolder(engine_name); + public setFolder(engineName: string): void { + let newFolder: Folder = FolderManager.instance.getFolder(engineName); if (newFolder) { this._folder = newFolder; } @@ -288,20 +289,20 @@ export default class PuzzleEditMode extends GameMode { public getLockString(): string { let locks: boolean[] = this.getCurrentLock(0); let len: number = this._poses[0].sequence.length; - let lock_string = ""; + let lockString = ''; for (let ii = 0; ii < len; ii++) { if (locks[ii]) { - lock_string += "x"; + lockString += 'x'; } else { - lock_string += "o"; + lockString += 'o'; } } - return lock_string; + return lockString; } public get shiftLimitString(): string { - return ""; + return ''; } public getThumbnailBase64(): string { @@ -383,7 +384,7 @@ export default class PuzzleEditMode extends GameMode { this.container.addChildAt(tempBG, 0); let info = `Player: ${Eterna.playerName}\n` - + "Player Puzzle Designer"; + + 'Player Puzzle Designer'; let infoText = Fonts.arial(info, 12).color(0xffffff).build(); this.container.addChild(infoText); @@ -406,7 +407,7 @@ export default class PuzzleEditMode extends GameMode { } private promptForReset(): void { - const PROMPT = "Do you really want to reset?"; + const PROMPT = 'Do you really want to reset?'; this.showConfirmDialog(PROMPT).closed.then((confirmed) => { if (confirmed) { @@ -428,40 +429,45 @@ export default class PuzzleEditMode extends GameMode { } private onSubmitPuzzle(): void { - let first_secstruct: string = this._structureInputs[0].structureString; + let firstSecstruct: string = this._structureInputs[0].structureString; for (let ii = 0; ii < this._poses.length; ii++) { let secstruct: string = this._structureInputs[ii].structureString; - let length_limit = 400; + let lengthLimit = 400; if (Eterna.DEV_MODE) { - length_limit = -1; + lengthLimit = -1; } - let error: string = EPars.validateParenthesis(secstruct, false, length_limit); + let error: string = EPars.validateParenthesis(secstruct, false, lengthLimit); if (error != null) { this.showNotification(error); return; } - if (secstruct.length != first_secstruct.length) { + if (secstruct.length !== firstSecstruct.length) { this.showNotification("Structure lengths don't match"); return; } - if (!EPars.arePairsSame(this.getCurrentTargetPairs(ii), this.getCurrentUndoBlock(ii).getPairs(EPars.DEFAULT_TEMPERATURE)) && !Eterna.DEV_MODE) { - this.showNotification("You should first solve your puzzle before submitting it!"); + if ( + !EPars.arePairsSame( + this.getCurrentTargetPairs(ii), + this.getCurrentUndoBlock(ii).getPairs(EPars.DEFAULT_TEMPERATURE) + ) && !Eterna.DEV_MODE + ) { + this.showNotification('You should first solve your puzzle before submitting it!'); return; } if (this._poses[ii].checkOverlap() && !Eterna.DEV_MODE) { - this.showNotification("Some bases overlapped too much!"); + this.showNotification('Some bases overlapped too much!'); return; } } let puzzleState = this.getCurrentUndoBlock(0); - const PROMPT = "You can only submit 3 puzzles per 24 hours.\nAre you sure you want to submit?"; + const PROMPT = 'You can only submit 3 puzzles per 24 hours.\nAre you sure you want to submit?'; this.showConfirmDialog(PROMPT).confirmed .then(() => this.showDialog(new SubmitPuzzleDialog(this._poses.length, puzzleState)).confirmed) .then(details => this.submitPuzzle(details)) @@ -473,10 +479,10 @@ export default class PuzzleEditMode extends GameMode { } private submitPuzzle(details: SubmitPuzzleDetails): void { - let constraints = ""; + let constraints = ''; for (let ii = 0; ii < this._poses.length; ii++) { if (ii > 0) { - constraints += ","; + constraints += ','; } constraints += `SHAPE,${ii}`; } @@ -484,37 +490,37 @@ export default class PuzzleEditMode extends GameMode { let len: number = this._poses[0].sequence.length; let locks = this.getCurrentLock(0); - let lock_string = ""; + let lockString = ''; for (let ii = 0; ii < len; ii++) { if (locks[ii]) { - lock_string += "x"; + lockString += 'x'; } else { - lock_string += "o"; + lockString += 'o'; } } let sequence: string = EPars.sequenceToString(this._poses[0].sequence); - let beginning_sequence = ""; + let beginningSequence = ''; for (let ii = 0; ii < len; ii++) { if (locks[ii]) { - beginning_sequence += sequence.substr(ii, 1); + beginningSequence += sequence.substr(ii, 1); } else { - beginning_sequence += "A"; + beginningSequence += 'A'; } } - if (this._poses.length == 1) { - let num_pairs: number = EPars.numPairs(this.getCurrentTargetPairs(0)); + if (this._poses.length === 1) { + let numPairs: number = EPars.numPairs(this.getCurrentTargetPairs(0)); - if (details.minGU != undefined && details.minGU > 0) { + if (details.minGU !== undefined && details.minGU > 0) { constraints += `,GU,${details.minGU.toString()}`; } - if (details.maxGC != undefined && details.maxGC <= num_pairs) { + if (details.maxGC !== undefined && details.maxGC <= numPairs) { constraints += `,GC,${details.maxGC.toString()}`; } - if (details.minAU != undefined && details.minAU > 0) { + if (details.minAU !== undefined && details.minAU > 0) { constraints += `,AU,${details.minAU.toString()}`; } } @@ -522,47 +528,47 @@ export default class PuzzleEditMode extends GameMode { let objectives: any[] = []; for (let ii = 0; ii < this._poses.length; ii++) { let objective: any = {}; - let binding_site: any[] = this.getCurrentBindingSite(ii); - let binding_bases: any[] = []; - for (let bb = 0; bb < binding_site.length; bb++) { - if (binding_site[bb]) { - binding_bases.push(bb); + let bindingSite: any[] = this.getCurrentBindingSite(ii); + let bindingBases: any[] = []; + for (let bb = 0; bb < bindingSite.length; bb++) { + if (bindingSite[bb]) { + bindingBases.push(bb); } } - objective["secstruct"] = this._structureInputs[ii].structureString; + objective['secstruct'] = this._structureInputs[ii].structureString; - if (binding_bases.length > 0) { - objective["type"] = "aptamer"; - objective["site"] = binding_bases; - objective["concentration"] = 10000; - objective["fold_version"] = 2.0; + if (bindingBases.length > 0) { + objective['type'] = 'aptamer'; + objective['site'] = bindingBases; + objective['concentration'] = 10000; + objective['fold_version'] = 2.0; } else { - objective["type"] = "single"; + objective['type'] = 'single'; } objectives.push(objective); } - let post_params: any = {}; + let postParams: any = {}; - post_params["folder"] = this._folder.name; - let params_title: string; - if (this._folder.name == Vienna2.NAME) { - params_title = "[VRNA_2]"; - } else if (this._folder.name == NuPACK.NAME) { - params_title = "[NuPACK]"; - } else if (this._folder.name == LinearFoldC.NAME) { - params_title = "[LFC]"; - } else if (this._folder.name == LinearFoldV.NAME) { - params_title = "[LFV]"; + postParams['folder'] = this._folder.name; + let paramsTitle: string; + if (this._folder.name === Vienna2.NAME) { + paramsTitle = '[VRNA_2]'; + } else if (this._folder.name === NuPACK.NAME) { + paramsTitle = '[NuPACK]'; + } else if (this._folder.name === LinearFoldC.NAME) { + paramsTitle = '[LFC]'; + } else if (this._folder.name === LinearFoldV.NAME) { + paramsTitle = '[LFV]'; } else { - params_title = ""; + paramsTitle = ''; } if (this._poses.length > 1) { - params_title += `[switch2.5][${this._poses.length} states] ${details.title}`; + paramsTitle += `[switch2.5][${this._poses.length} states] ${details.title}`; } else { - params_title += details.title; + paramsTitle += details.title; } // Render pose thumbnail images @@ -574,21 +580,21 @@ export default class PuzzleEditMode extends GameMode { PoseThumbnail.createFramedBitmap(this._poses[0].sequence, this._poses[0].pairs, 2, PoseThumbnailType.WHITE) ); - post_params["title"] = params_title; - post_params["secstruct"] = EPars.pairsToParenthesis(this.getCurrentTargetPairs(0)); - post_params["constraints"] = constraints; - post_params["body"] = details.description; - post_params["midimgdata"] = midImageString; - post_params["bigimgdata"] = bigImageString; - post_params["lock"] = lock_string; - post_params["begin_sequence"] = beginning_sequence; - post_params["objectives"] = JSON.stringify(objectives); - - let submitText = this.showDialog(new AsyncProcessDialog("Submitting...")).ref; - Eterna.client.submitPuzzle(post_params) + postParams['title'] = paramsTitle; + postParams['secstruct'] = EPars.pairsToParenthesis(this.getCurrentTargetPairs(0)); + postParams['constraints'] = constraints; + postParams['body'] = details.description; + postParams['midimgdata'] = midImageString; + postParams['bigimgdata'] = bigImageString; + postParams['lock'] = lockString; + postParams['begin_sequence'] = beginningSequence; + postParams['objectives'] = JSON.stringify(objectives); + + let submitText = this.showDialog(new AsyncProcessDialog('Submitting...')).ref; + Eterna.client.submitPuzzle(postParams) .then(() => { submitText.destroyObject(); - this.showNotification("Your puzzle has been successfully published.\n"); + this.showNotification('Your puzzle has been successfully published.\n'); }) .catch((err) => { submitText.destroyObject(); @@ -623,9 +629,9 @@ export default class PuzzleEditMode extends GameMode { } private changeFolder(): void { - let curr_f: string = this._folder.name; - this._folder = FolderManager.instance.getNextFolder(curr_f, () => false); - if (this._folder.name == curr_f) { + let currF: string = this._folder.name; + this._folder = FolderManager.instance.getNextFolder(currF, () => false); + if (this._folder.name === currF) { return; } @@ -676,7 +682,9 @@ export default class PuzzleEditMode extends GameMode { this._poses[ii].puzzleLocks = this._lockStack[this._stackLevel][ii]; this._poses[ii].molecularStructure = this._targetPairsStack[this._stackLevel][ii]; this._poses[ii].molecularBindingSite = this._bindingSiteStack[this._stackLevel][ii]; - this._structureInputs[ii].structureString = EPars.pairsToParenthesis(this._targetPairsStack[this._stackLevel][ii]); + this._structureInputs[ii].structureString = EPars.pairsToParenthesis( + this._targetPairsStack[this._stackLevel][ii] + ); } this.updateScore(); @@ -693,7 +701,9 @@ export default class PuzzleEditMode extends GameMode { this._poses[ii].puzzleLocks = this._lockStack[this._stackLevel][ii]; this._poses[ii].molecularStructure = this._targetPairsStack[this._stackLevel][ii]; this._poses[ii].molecularBindingSite = this._bindingSiteStack[this._stackLevel][ii]; - this._structureInputs[ii].structureString = EPars.pairsToParenthesis(this._targetPairsStack[this._stackLevel][ii]); + this._structureInputs[ii].structureString = EPars.pairsToParenthesis( + this._targetPairsStack[this._stackLevel][ii] + ); } this.updateScore(); } @@ -703,33 +713,33 @@ export default class PuzzleEditMode extends GameMode { for (let ii = 0; ii < this._poses.length; ii++) { let undoblock: UndoBlock = this.getCurrentUndoBlock(ii); - let target_pairs = this.getCurrentTargetPairs(ii); - let best_pairs = undoblock.getPairs(EPars.DEFAULT_TEMPERATURE); + let targetPairs = this.getCurrentTargetPairs(ii); + let bestPairs = undoblock.getPairs(EPars.DEFAULT_TEMPERATURE); let {sequence} = this._poses[ii]; - if (sequence.length != target_pairs.length) { + if (sequence.length !== targetPairs.length) { throw new Error("sequence and design pairs lengths don't match"); } if (this._paused) { - this._poses[ii].pairs = target_pairs; + this._poses[ii].pairs = targetPairs; } else { - this._poses[ii].pairs = best_pairs; + this._poses[ii].pairs = bestPairs; } this._constraintBoxes[ii].setContent(ConstraintType.SHAPE, { - target: target_pairs, - native: best_pairs - }, EPars.arePairsSame(best_pairs, target_pairs), 0); + target: targetPairs, + native: bestPairs + }, EPars.arePairsSame(bestPairs, targetPairs), 0); this._constraintBoxes[ii].display.scale.x = 1; this._constraintBoxes[ii].display.scale.y = 1; } let undoblock: UndoBlock = this.getCurrentUndoBlock(this._poses.length - 1); - let num_AU: number = undoblock.getParam(UndoBlockParam.AU); - let num_GU: number = undoblock.getParam(UndoBlockParam.GU); - let num_GC: number = undoblock.getParam(UndoBlockParam.GC); + let numAU: number = undoblock.getParam(UndoBlockParam.AU); + let numGU: number = undoblock.getParam(UndoBlockParam.GU); + let numGC: number = undoblock.getParam(UndoBlockParam.GC); - this._toolbar.palette.setPairCounts(num_AU, num_GU, num_GC); + this._toolbar.palette.setPairCounts(numAU, numGU, numGC); } private onPaletteTargetSelected(type: PaletteTargetType): void { @@ -746,84 +756,88 @@ export default class PuzzleEditMode extends GameMode { } private poseEditByTarget(index: number): void { - let no_change = true; - let current_undo_blocks: UndoBlock[] = []; - let current_target_pairs: number[][] = []; - let current_lock: boolean[][] = []; - let current_binding_sites: boolean[][] = []; + let noChange = true; + let currentUndoBlocks: UndoBlock[] = []; + let currentTargetPairs: number[][] = []; + let currentLock: boolean[][] = []; + let currentBindingSites: boolean[][] = []; - let force_sequence = this._poses[index].sequence; - let force_lock = this._poses[index].puzzleLocks; + let forceSequence = this._poses[index].sequence; + let forceLock = this._poses[index].puzzleLocks; - let different_structures = false; + let differentStructures = false; for (let ii = 0; ii < this._poses.length; ii++) { - if (ii != index) { - if (this._poses[ii].sequence.length == force_sequence.length) { - this._poses[ii].sequence = force_sequence; - this._poses[ii].puzzleLocks = force_lock; + if (ii !== index) { + if (this._poses[ii].sequence.length === forceSequence.length) { + this._poses[ii].sequence = forceSequence; + this._poses[ii].puzzleLocks = forceLock; } else { - different_structures = true; + differentStructures = true; } } } - if (different_structures) { - let lengths = "["; + if (differentStructures) { + let lengths = '['; for (let ii = 0; ii < this._poses.length; ii++) { if (ii > 0) { - lengths += ","; + lengths += ','; } lengths += this._poses[ii].sequence.length.toString(); } - lengths += "]"; + lengths += ']'; for (let ii = 0; ii < this._poses.length; ii++) { - this._structureInputs[ii].setWarning(`Structure lengths don't match ${lengths}.\nSequences won't be synced.`); + this._structureInputs[ii].setWarning( + `Structure lengths don't match ${lengths}.\nSequences won't be synced.` + ); } } else { for (let ii = 0; ii < this._poses.length; ii++) { - this._structureInputs[ii].setWarning(""); + this._structureInputs[ii].setWarning(''); } } for (let ii = 0; ii < this._poses.length; ii++) { - let target_pairs: number[] = EPars.parenthesisToPairs(this._structureInputs[ii].structureString); + let targetPairs: number[] = EPars.parenthesisToPairs(this._structureInputs[ii].structureString); let seq = this._poses[ii].sequence; let lock = this._poses[ii].puzzleLocks; - let binding_site = this._poses[ii].molecularBindingSite; + let bindingSite = this._poses[ii].molecularBindingSite; if (this._stackLevel >= 0) { - if (this._structureInputs[ii].structureString != EPars.pairsToParenthesis(this._targetPairsStack[this._stackLevel][ii])) { - no_change = false; - } - if (EPars.sequenceToString(seq) != EPars.sequenceToString(this._seqStack[this._stackLevel][ii].sequence)) { - no_change = false; + if ( + this._structureInputs[ii].structureString + !== EPars.pairsToParenthesis(this._targetPairsStack[this._stackLevel][ii]) + || EPars.sequenceToString(seq) + !== EPars.sequenceToString(this._seqStack[this._stackLevel][ii].sequence) + ) { + noChange = false; } - let last_lock: boolean[] = this._lockStack[this._stackLevel][ii]; - if (last_lock.length != lock.length) { - no_change = false; + let lastLock: boolean[] = this._lockStack[this._stackLevel][ii]; + if (lastLock.length !== lock.length) { + noChange = false; } else { for (let ll = 0; ll < lock.length; ll++) { - if (lock[ll] != last_lock[ll]) { - no_change = false; + if (lock[ll] !== lastLock[ll]) { + noChange = false; break; } } } - let last_binding_site: boolean[] = this._bindingSiteStack[this._stackLevel][ii]; - if (last_binding_site == null && binding_site != null) { - no_change = false; - } else if (last_binding_site != null && binding_site == null) { - no_change = false; - } else if (last_binding_site != null && binding_site != null) { - if (last_binding_site.length != binding_site.length) { - no_change = false; + let lastBindingSite: boolean[] = this._bindingSiteStack[this._stackLevel][ii]; + if (lastBindingSite == null && bindingSite != null) { + noChange = false; + } else if (lastBindingSite != null && bindingSite == null) { + noChange = false; + } else if (lastBindingSite != null && bindingSite != null) { + if (lastBindingSite.length !== bindingSite.length) { + noChange = false; } else { - for (let ll = 0; ll < binding_site.length; ll++) { - if (binding_site[ll] != last_binding_site[ll]) { - no_change = false; + for (let ll = 0; ll < bindingSite.length; ll++) { + if (bindingSite[ll] !== lastBindingSite[ll]) { + noChange = false; break; } } @@ -831,49 +845,49 @@ export default class PuzzleEditMode extends GameMode { } } - let is_there_molecule = false; - if (binding_site != null) { - for (let bb = 0; bb < binding_site.length; bb++) { - if (binding_site[bb]) { - is_there_molecule = true; + let isThereMolecule = false; + if (bindingSite != null) { + for (let bb = 0; bb < bindingSite.length; bb++) { + if (bindingSite[bb]) { + isThereMolecule = true; break; } } } - let best_pairs: number[]; - if (!is_there_molecule) { - best_pairs = this._folder.foldSequence(seq, null, null, EPars.DEFAULT_TEMPERATURE); + let bestPairs: number[]; + if (!isThereMolecule) { + bestPairs = this._folder.foldSequence(seq, null, null, EPars.DEFAULT_TEMPERATURE); } else { let bonus = -486; let site: number[] = []; - for (let bb = 0; bb < binding_site.length; bb++) { - if (binding_site[bb]) { + for (let bb = 0; bb < bindingSite.length; bb++) { + if (bindingSite[bb]) { site.push(bb); } } - best_pairs = this._folder.foldSequenceWithBindingSite(seq, target_pairs, site, Number(bonus), 2.0); + bestPairs = this._folder.foldSequenceWithBindingSite(seq, targetPairs, site, Number(bonus), 2.0); } - let undo_block = new UndoBlock(seq); - undo_block.setPairs(best_pairs); - undo_block.setBasics(this._folder); - current_undo_blocks.push(undo_block); - current_lock.push(lock); - current_binding_sites.push(binding_site); - current_target_pairs.push(target_pairs); + let undoBlock = new UndoBlock(seq); + undoBlock.setPairs(bestPairs); + undoBlock.setBasics(this._folder); + currentUndoBlocks.push(undoBlock); + currentLock.push(lock); + currentBindingSites.push(bindingSite); + currentTargetPairs.push(targetPairs); } - if (no_change && this._stackLevel >= 0) { + if (noChange && this._stackLevel >= 0) { return; } // / Pushing undo block this._stackLevel++; - this._seqStack[this._stackLevel] = current_undo_blocks; - this._targetPairsStack[this._stackLevel] = current_target_pairs; - this._lockStack[this._stackLevel] = current_lock; - this._bindingSiteStack[this._stackLevel] = current_binding_sites; + this._seqStack[this._stackLevel] = currentUndoBlocks; + this._targetPairsStack[this._stackLevel] = currentTargetPairs; + this._lockStack[this._stackLevel] = currentLock; + this._bindingSiteStack[this._stackLevel] = currentBindingSites; this._stackSize = this._stackLevel + 1; this.updateScore(); diff --git a/src/eterna/mode/PuzzleEdit/StructureInput.ts b/src/eterna/mode/PuzzleEdit/StructureInput.ts index 5522d590a..25b7bdec1 100644 --- a/src/eterna/mode/PuzzleEdit/StructureInput.ts +++ b/src/eterna/mode/PuzzleEdit/StructureInput.ts @@ -1,12 +1,12 @@ -import {Rectangle} from "pixi.js"; -import {HAlign, VAlign, Updatable} from "flashbang/core"; -import {KeyCode} from "flashbang/input"; -import {DisplayUtil} from "flashbang/util"; -import EPars from "eterna/EPars"; -import Eterna from "eterna/Eterna"; -import {Pose2D, PuzzleEditOp} from "eterna/pose2D"; -import {GamePanel, TextInputObject, TextBalloon} from "eterna/ui"; -import {Fonts} from "eterna/util"; +import {Rectangle} from 'pixi.js'; +import {HAlign, VAlign, Updatable} from 'flashbang/core'; +import {KeyCode} from 'flashbang/input'; +import {DisplayUtil} from 'flashbang/util'; +import EPars from 'eterna/EPars'; +import Eterna from 'eterna/Eterna'; +import {Pose2D, PuzzleEditOp} from 'eterna/pose2D'; +import {GamePanel, TextInputObject, TextBalloon} from 'eterna/ui'; +import {Fonts} from 'eterna/util'; function IsArrowKey(keyCode: string): boolean { @@ -17,7 +17,7 @@ function IsArrowKey(keyCode: string): boolean { } export default class StructureInput extends GamePanel implements Updatable { - public constructor(pose: Pose2D) { + constructor(pose: Pose2D) { super(); this._pose = pose; } @@ -27,12 +27,12 @@ export default class StructureInput extends GamePanel implements Updatable { this._textInput = new TextInputObject(20) .font(Fonts.ARIAL) - .disallow(/[^\.\(\)]/g) + .disallow(/[^.()]/g) .bold(); this._textInput.showFakeTextInputWhenNotFocused(); this.addObject(this._textInput, this.container); - this._errorText = new TextBalloon("", 0x0, 0.8); + this._errorText = new TextBalloon('', 0x0, 0.8); this._errorText.display.visible = false; this._errorText.display.position.y = -60; this.addObject(this._errorText, this.container); @@ -48,7 +48,7 @@ export default class StructureInput extends GamePanel implements Updatable { }; let showError = () => { - if (this._errorText.text.text !== " ") this._errorText.display.visible = true; + if (this._errorText.text.text !== ' ') this._errorText.display.visible = true; }; let hideError = () => { @@ -66,7 +66,7 @@ export default class StructureInput extends GamePanel implements Updatable { public update(dt: number): void { // Update the cursor highlight when our caret position changes - if (this._prevCaretPostion != this._textInput.caretPosition) { + if (this._prevCaretPostion !== this._textInput.caretPosition) { this._prevCaretPostion = this._textInput.caretPosition; this._pose.trackCursor(this._textInput.caretPosition); } @@ -85,49 +85,49 @@ export default class StructureInput extends GamePanel implements Updatable { public setPose(op: PuzzleEditOp = null, index: number = -1): void { let input = this._textInput.text; - input = input.replace(/[^\.\(\)]/g, ""); + input = input.replace(/[^.()]/g, ''); // Replace () with (.) -- () is illegal and causes an error - input = input.replace(/\(\)/g, "(.)"); + input = input.replace(/\(\)/g, '(.)'); let error: string = EPars.validateParenthesis(input, false, Eterna.MAX_PUZZLE_EDIT_LENGTH); - this.setWarning(error || ""); + this.setWarning(error || ''); this._textInput.text = input; let {sequence} = this._pose; let locks = this._pose.puzzleLocks; - let binding_site = this._pose.molecularBindingSite; - let sequence_backup = this._pose.sequence; - let locks_backup = this._pose.puzzleLocks; - let binding_site_backup = this._pose.molecularBindingSite; + let bindingSite = this._pose.molecularBindingSite; + let sequenceBackup = this._pose.sequence; + let locksBackup = this._pose.puzzleLocks; + let bindingSiteBackup = this._pose.molecularBindingSite; if (sequence.length > input.length) { sequence = sequence.slice(0, input.length); locks = locks.slice(0, input.length); - binding_site = binding_site.slice(0, input.length); + bindingSite = bindingSite.slice(0, input.length); } for (let ii: number = sequence.length; ii < input.length; ii++) { sequence.push(EPars.RNABASE_ADENINE); locks.push(false); - binding_site.push(false); + bindingSite.push(false); } // BASE SHIFTING MODIFIED HERE. Delete comments to apply the changes - if (op == PuzzleEditOp.ADD_BASE) { + if (op === PuzzleEditOp.ADD_BASE) { // Add a base - let after_index = sequence.slice(index); - let after_lock_index = locks.slice(index); - let after_binding_site_index = binding_site.slice(index); + let afterIndex = sequence.slice(index); + let afterLockIndex = locks.slice(index); + let afterBindingSiteIndex = bindingSite.slice(index); sequence[index] = EPars.RNABASE_ADENINE; locks[index] = false; - binding_site[index] = false; + bindingSite[index] = false; - for (let ii = 0; ii < after_index.length - 1; ii++) { - sequence[ii + index + 1] = after_index[ii]; - locks[ii + index + 1] = after_lock_index[ii]; - binding_site[ii + index + 1] = after_binding_site_index[ii]; + for (let ii = 0; ii < afterIndex.length - 1; ii++) { + sequence[ii + index + 1] = afterIndex[ii]; + locks[ii + index + 1] = afterLockIndex[ii]; + bindingSite[ii + index + 1] = afterBindingSiteIndex[ii]; } - } else if (op == PuzzleEditOp.ADD_PAIR) { + } else if (op === PuzzleEditOp.ADD_PAIR) { // Add a pair let pindex: number = (this._pose.pairs)[index]; if (index > pindex) { @@ -135,33 +135,33 @@ export default class StructureInput extends GamePanel implements Updatable { index = pindex; pindex = temp; } - let after_index = sequence.slice(index); - let after_lock_index = locks.slice(index); - let after_binding_site_index = binding_site.slice(index); + let afterIndex = sequence.slice(index); + let afterLockIndex = locks.slice(index); + let afterBindingSiteIndex = bindingSite.slice(index); sequence[index] = EPars.RNABASE_ADENINE; sequence[pindex + 2] = EPars.RNABASE_ADENINE; locks[index] = false; locks[pindex + 2] = false; - binding_site[index] = false; - binding_site[pindex + 2] = false; + bindingSite[index] = false; + bindingSite[pindex + 2] = false; - for (let ii = 0; ii < after_index.length - 2; ii++) { + for (let ii = 0; ii < afterIndex.length - 2; ii++) { if (ii + index > pindex) { - sequence[ii + index + 2] = after_index[ii]; - locks[ii + index + 2] = after_lock_index[ii]; - binding_site[ii + index + 2] = after_binding_site_index[ii]; + sequence[ii + index + 2] = afterIndex[ii]; + locks[ii + index + 2] = afterLockIndex[ii]; + bindingSite[ii + index + 2] = afterBindingSiteIndex[ii]; } else { - sequence[ii + index + 1] = after_index[ii]; - locks[ii + index + 1] = after_lock_index[ii]; - binding_site[ii + index + 1] = after_binding_site_index[ii]; + sequence[ii + index + 1] = afterIndex[ii]; + locks[ii + index + 1] = afterLockIndex[ii]; + bindingSite[ii + index + 1] = afterBindingSiteIndex[ii]; } } - } else if (op == PuzzleEditOp.ADD_CYCLE) { + } else if (op === PuzzleEditOp.ADD_CYCLE) { // Add a cycle of length 3 - let after_index = sequence.slice(index); - let after_lock_index = locks.slice(index); - let after_binding_site_index = binding_site.slice(index); + let afterIndex = sequence.slice(index); + let afterLockIndex = locks.slice(index); + let afterBindingSiteIndex = bindingSite.slice(index); sequence[index] = EPars.RNABASE_ADENINE; sequence[index + 1] = EPars.RNABASE_ADENINE; @@ -175,18 +175,18 @@ export default class StructureInput extends GamePanel implements Updatable { locks[index + 3] = false; locks[index + 4] = false; - binding_site[index] = false; - binding_site[index + 1] = false; - binding_site[index + 2] = false; - binding_site[index + 3] = false; - binding_site[index + 4] = false; + bindingSite[index] = false; + bindingSite[index + 1] = false; + bindingSite[index + 2] = false; + bindingSite[index + 3] = false; + bindingSite[index + 4] = false; - for (let ii = 0; ii < after_index.length - 5; ii++) { - sequence[ii + index + 5] = after_index[ii]; - locks[ii + index + 5] = after_lock_index[ii]; - binding_site[ii + index + 5] = after_binding_site_index[ii]; + for (let ii = 0; ii < afterIndex.length - 5; ii++) { + sequence[ii + index + 5] = afterIndex[ii]; + locks[ii + index + 5] = afterLockIndex[ii]; + bindingSite[ii + index + 5] = afterBindingSiteIndex[ii]; } - } else if (op == PuzzleEditOp.DELETE_PAIR) { + } else if (op === PuzzleEditOp.DELETE_PAIR) { // Delete a pair let pindex = (this._pose.pairs)[index]; if (index > pindex) { @@ -194,36 +194,36 @@ export default class StructureInput extends GamePanel implements Updatable { index = pindex; pindex = temp; } - let after_index = sequence_backup.slice(index + 1); - let after_lock_index = locks_backup.slice(index + 1); - let after_binding_site_index = binding_site_backup.slice(index + 1); + let afterIndex = sequenceBackup.slice(index + 1); + let afterLockIndex = locksBackup.slice(index + 1); + let afterBindingSiteIndex = bindingSiteBackup.slice(index + 1); - for (let ii = 0; ii < after_index.length - 1; ii++) { + for (let ii = 0; ii < afterIndex.length - 1; ii++) { if (ii + index >= pindex - 1) { - sequence[ii + index] = after_index[ii + 1]; - locks[ii + index] = after_lock_index[ii + 1]; - binding_site[ii + index] = after_binding_site_index[ii + 1]; + sequence[ii + index] = afterIndex[ii + 1]; + locks[ii + index] = afterLockIndex[ii + 1]; + bindingSite[ii + index] = afterBindingSiteIndex[ii + 1]; } else { - sequence[ii + index] = after_index[ii]; - locks[ii + index] = after_lock_index[ii]; - binding_site[ii + index] = after_binding_site_index[ii]; + sequence[ii + index] = afterIndex[ii]; + locks[ii + index] = afterLockIndex[ii]; + bindingSite[ii + index] = afterBindingSiteIndex[ii]; } } - } else if (op == PuzzleEditOp.DELETE_BASE) { + } else if (op === PuzzleEditOp.DELETE_BASE) { // Delete a base - let after_index = sequence_backup.slice(index + 1); - let after_lock_index = locks_backup.slice(index + 1); - let after_binding_site_index = binding_site_backup.slice(index + 1); - - for (let ii = 0; ii < after_index.length; ii++) { - sequence[ii + index] = after_index[ii]; - locks[ii + index] = after_lock_index[ii]; - binding_site[ii + index] = after_binding_site_index[ii]; + let afterIndex = sequenceBackup.slice(index + 1); + let afterLockIndex = locksBackup.slice(index + 1); + let afterBindingSiteIndex = bindingSiteBackup.slice(index + 1); + + for (let ii = 0; ii < afterIndex.length; ii++) { + sequence[ii + index] = afterIndex[ii]; + locks[ii + index] = afterLockIndex[ii]; + bindingSite[ii + index] = afterBindingSiteIndex[ii]; } } this._pose.sequence = sequence; this._pose.puzzleLocks = locks; - this._pose.molecularBindingSite = binding_site; + this._pose.molecularBindingSite = bindingSite; this._pose.trackCursor(this._textInput.caretPosition); try { this._pose.molecularStructure = EPars.parenthesisToPairs(this.structureString); @@ -237,12 +237,12 @@ export default class StructureInput extends GamePanel implements Updatable { public get structureString(): string { let secstruct: string = this._textInput.text; - return secstruct.replace(/[^\.\(\)]/g, ""); + return secstruct.replace(/[^.()]/g, ''); } public set structureString(struct: string) { this._textInput.text = struct; - this.setWarning(""); + this.setWarning(''); } public setWarning(warning: string): void { @@ -251,7 +251,7 @@ export default class StructureInput extends GamePanel implements Updatable { this._errorText.setText(warning); } else { this.setup(0, 0.07, 0xFFFFFF, 0.0, 0); - this._errorText.setText(""); + this._errorText.setText(''); } } diff --git a/src/eterna/mode/PuzzleEdit/SubmitPuzzleDialog.ts b/src/eterna/mode/PuzzleEdit/SubmitPuzzleDialog.ts index 008c76a08..5f1645654 100644 --- a/src/eterna/mode/PuzzleEdit/SubmitPuzzleDialog.ts +++ b/src/eterna/mode/PuzzleEdit/SubmitPuzzleDialog.ts @@ -1,9 +1,17 @@ -import {Flashbang} from "flashbang/core"; -import {KeyCode} from "flashbang/input"; -import EPars from "eterna/EPars"; -import {Dialog, DialogCanceledError, TextInputPanel} from "eterna/ui"; -import {default as UndoBlock, UndoBlockParam} from "eterna/UndoBlock"; -import {GameMode} from "eterna/mode"; +import {Flashbang} from 'flashbang/core'; +import {KeyCode} from 'flashbang/input'; +import EPars from 'eterna/EPars'; +import {Dialog, DialogCanceledError, TextInputPanel} from 'eterna/ui'; +import UndoBlock, {UndoBlockParam} from 'eterna/UndoBlock'; +import {GameMode} from 'eterna/mode'; + +function GetNumber(dict: Map, name: string): number | undefined { + if (!dict.has(name)) { + return undefined; + } + let value = dict.get(name); + return value != null && value.length > 0 ? Number(value) : undefined; +} export interface SubmitPuzzleDetails { title: string; @@ -15,7 +23,7 @@ export interface SubmitPuzzleDetails { } export default class SubmitPuzzleDialog extends Dialog { - public constructor(numPoses: number, puzzleState: UndoBlock) { + constructor(numPoses: number, puzzleState: UndoBlock) { super(); this._numPoses = numPoses; this._puzzleState = puzzleState; @@ -40,19 +48,19 @@ export default class SubmitPuzzleDialog extends Dialog { protected added(): void { super.added(); - const TITLE = "Title"; - const MIN_GU = "Min G-U pairs required"; - const MAX_GC = "Max G-C pairs allowed"; - const MIN_AU = "Min A-U pairs required"; - const DESCRIPTION = "Description"; + const TITLE = 'Title'; + const MIN_GU = 'Min G-U pairs required'; + const MAX_GC = 'Max G-C pairs allowed'; + const MIN_AU = 'Min A-U pairs required'; + const DESCRIPTION = 'Description'; const FIELD_WIDTH = 200; let inputPanel = new TextInputPanel(); - inputPanel.title = "Publish your puzzle"; + inputPanel.title = 'Publish your puzzle'; let title = inputPanel.addField(TITLE, FIELD_WIDTH); - if (this._numPoses == 1) { + if (this._numPoses === 1) { inputPanel.addField(MIN_GU, FIELD_WIDTH); inputPanel.addField(MAX_GC, FIELD_WIDTH); inputPanel.addField(MIN_AU, FIELD_WIDTH); @@ -92,34 +100,34 @@ export default class SubmitPuzzleDialog extends Dialog { } private validate(details: SubmitPuzzleDetails): string { - if (details.title.length == 0) { - return "You must enter a title for your puzzle"; - } else if (details.description.length == 0) { - return "You must write a description of your puzzle"; + if (details.title.length === 0) { + return 'You must enter a title for your puzzle'; + } else if (details.description.length === 0) { + return 'You must write a description of your puzzle'; } - if (this._numPoses == 1) { + if (this._numPoses === 1) { let numAU: number = this._puzzleState.getParam(UndoBlockParam.AU, EPars.DEFAULT_TEMPERATURE); let numGU: number = this._puzzleState.getParam(UndoBlockParam.GU, EPars.DEFAULT_TEMPERATURE); let numGC: number = this._puzzleState.getParam(UndoBlockParam.GC, EPars.DEFAULT_TEMPERATURE); if (details.minGU) { - let max_GU = (numAU + numGU + numGC) / 3; - if (details.minGU < 0 || details.minGU > numGU || details.minGU > max_GU) { - return `${"Number of G-U pairs should be either blank or " - + "an integer between 0 and "}${numGU} (number of GUs in your current solution) ` - + `and at most ${max_GU} (a third of total number of pairs)`; + let maxGU = (numAU + numGU + numGC) / 3; + if (details.minGU < 0 || details.minGU > numGU || details.minGU > maxGU) { + return `${'Number of G-U pairs should be either blank or ' + + 'an integer between 0 and '}${numGU} (number of GUs in your current solution) ` + + `and at most ${maxGU} (a third of total number of pairs)`; } } if (details.maxGC && details.maxGC < numGC) { - return `${"Number of G-C pairs should be either blank or " - + "at least "}${numGC} (number GCs in your current solution)`; + return `${'Number of G-C pairs should be either blank or ' + + 'at least '}${numGC} (number GCs in your current solution)`; } if (details.minAU && (details.minAU < 0 || details.minAU > numAU)) { - return `${"Number of A-U pairs should be either blank or " - + "an integer between 0 and "}${numAU} (number of AUs in your current solution)`; + return `${'Number of A-U pairs should be either blank or ' + + 'an integer between 0 and '}${numAU} (number of AUs in your current solution)`; } } @@ -129,11 +137,3 @@ export default class SubmitPuzzleDialog extends Dialog { private readonly _numPoses: number; private readonly _puzzleState: UndoBlock; } - -function GetNumber(dict: Map, name: string): number | undefined { - if (!dict.has(name)) { - return undefined; - } - let value = dict.get(name); - return value != null && value.length > 0 ? Number(value) : undefined; -} diff --git a/src/eterna/mode/PuzzleEdit/index.ts b/src/eterna/mode/PuzzleEdit/index.ts index 9b8e48acf..7b11f3148 100644 --- a/src/eterna/mode/PuzzleEdit/index.ts +++ b/src/eterna/mode/PuzzleEdit/index.ts @@ -1,3 +1,3 @@ -export {default as PuzzleEditMode, PuzzleEditPoseData} from "./PuzzleEditMode"; -export {default as StructureInput} from "./StructureInput"; -export {default as SubmitPuzzleDialog, SubmitPuzzleDetails} from "./SubmitPuzzleDialog"; +export {default as PuzzleEditMode, PuzzleEditPoseData} from './PuzzleEditMode'; +export {default as StructureInput} from './StructureInput'; +export {default as SubmitPuzzleDialog, SubmitPuzzleDetails} from './SubmitPuzzleDialog'; diff --git a/src/eterna/mode/index.ts b/src/eterna/mode/index.ts index 07ccc4f02..041405d67 100644 --- a/src/eterna/mode/index.ts +++ b/src/eterna/mode/index.ts @@ -1,8 +1,8 @@ -export {default as CopyTextDialogMode} from "./CopyTextDialogMode"; -export {default as ErrorDialogMode} from "./ErrorDialogMode"; -export {default as GameMode} from "./GameMode"; -export {default as LoadingMode} from "./LoadingMode"; -export {DesignBrowserMode, DesignBrowserFilter} from "./DesignBrowser"; -export {default as FeedbackViewMode} from "./FeedbackViewMode"; -export {PoseEditMode, PoseEditParams} from "./PoseEdit"; -export {PuzzleEditMode, PuzzleEditPoseData} from "./PuzzleEdit"; +export {default as CopyTextDialogMode} from './CopyTextDialogMode'; +export {default as ErrorDialogMode} from './ErrorDialogMode'; +export {default as GameMode} from './GameMode'; +export {default as LoadingMode} from './LoadingMode'; +export {DesignBrowserMode, DesignBrowserFilter} from './DesignBrowser'; +export {default as FeedbackViewMode} from './FeedbackViewMode'; +export {PoseEditMode, PoseEditParams} from './PoseEdit'; +export {PuzzleEditMode, PuzzleEditPoseData} from './PuzzleEdit'; diff --git a/src/eterna/net/EternaURL.ts b/src/eterna/net/EternaURL.ts index 97688d5a5..1561b48e6 100644 --- a/src/eterna/net/EternaURL.ts +++ b/src/eterna/net/EternaURL.ts @@ -1,14 +1,15 @@ -import Eterna from "eterna/Eterna"; -import {Utility} from "eterna/util"; +import Eterna from 'eterna/Eterna'; +import {Utility} from 'eterna/util'; export default class EternaURL { - public static readonly BARCODE_HELP: string = "/web/lab/manual/#barcode"; - public static readonly STRATEGY_GUIDE: string = "http://getsatisfaction.com/eternagame/topics/the_strategy_guide_to_solve_eterna_puzzles"; + public static readonly BARCODE_HELP: string = '/web/lab/manual/#barcode'; + public static readonly STRATEGY_GUIDE: string = + 'http://getsatisfaction.com/eternagame/topics/the_strategy_guide_to_solve_eterna_puzzles'; public static getFeedURL(): string { return Eterna.playerID === 0 - ? EternaURL.createURL({page: "register"}) - : EternaURL.createURL({page: "me"}); + ? EternaURL.createURL({page: 'register'}) + : EternaURL.createURL({page: 'me'}); } public static createURL(params: any): string { @@ -16,63 +17,63 @@ export default class EternaURL { params = {}; } - if (params["page"] === "player") { - return `/web/player/${params["uid"]}/`; - } else if (params["page"] === "lab_bench") { - return "/web/"; - } else if (params["page"] === "me") { - return "/web/"; - } else if (params["page"] === "roadmap") { - return "/web/roadmap/"; - } else if (params["page"] === "about") { - return "/web/about/"; - } else if (params["page"] === "tutorials") { - return "/web/tutorials/"; - } else if (params["page"] === "challenges") { - return "/web/challenges/"; - } else if (params["page"] === "playerpuzzles") { - return "/web/playerpuzzles/"; - } else if (params["page"] === "currentlabs") { - return "/web/labs/"; - } else if (params["page"] === "proposedlabs") { - return "/web/labs/proposed/"; - } else if (params["page"] === "waitinglabs") { - return "/web/labs/waiting/"; - } else if (params["page"] === "pastlabs") { - return "/web/labs/past/"; - } else if (params["page"] === "strategymarket") { - return "/web/strategymarket/"; - } else if (params["page"] === "scripts") { - return "/web/script/"; - } else if (params["page"] === "manual") { - return "/web/lab/manual/"; - } else if (params["page"] === "newslist") { - return "/web/news/"; - } else if (params["page"] === "players") { - return "/web/players/"; - } else if (params["page"] === "register") { - return "/web/register/"; - } else if (params["page"] === "puzzle") { - return `/web/puzzle/${params["nid"]}/`; - } else if (params["page"] === "strategy_guides") { - return "/web/strategy_guides/"; - } else if (params["page"] === "blog") { - return "/web/blog/"; - } else if (params["page"] === "lab_browser") { - return `/web/browse/${params["nid"]}/`; - } else if (params["page"] === "browse_solution" || params["page"] === "browse_player") { - let url = `/game/browse/${params["puznid"]}/?`; - delete params["page"]; - delete params["puznid"]; + if (params['page'] === 'player') { + return `/web/player/${params['uid']}/`; + } else if (params['page'] === 'lab_bench') { + return '/web/'; + } else if (params['page'] === 'me') { + return '/web/'; + } else if (params['page'] === 'roadmap') { + return '/web/roadmap/'; + } else if (params['page'] === 'about') { + return '/web/about/'; + } else if (params['page'] === 'tutorials') { + return '/web/tutorials/'; + } else if (params['page'] === 'challenges') { + return '/web/challenges/'; + } else if (params['page'] === 'playerpuzzles') { + return '/web/playerpuzzles/'; + } else if (params['page'] === 'currentlabs') { + return '/web/labs/'; + } else if (params['page'] === 'proposedlabs') { + return '/web/labs/proposed/'; + } else if (params['page'] === 'waitinglabs') { + return '/web/labs/waiting/'; + } else if (params['page'] === 'pastlabs') { + return '/web/labs/past/'; + } else if (params['page'] === 'strategymarket') { + return '/web/strategymarket/'; + } else if (params['page'] === 'scripts') { + return '/web/script/'; + } else if (params['page'] === 'manual') { + return '/web/lab/manual/'; + } else if (params['page'] === 'newslist') { + return '/web/news/'; + } else if (params['page'] === 'players') { + return '/web/players/'; + } else if (params['page'] === 'register') { + return '/web/register/'; + } else if (params['page'] === 'puzzle') { + return `/web/puzzle/${params['nid']}/`; + } else if (params['page'] === 'strategy_guides') { + return '/web/strategy_guides/'; + } else if (params['page'] === 'blog') { + return '/web/blog/'; + } else if (params['page'] === 'lab_browser') { + return `/web/browse/${params['nid']}/`; + } else if (params['page'] === 'browse_solution' || params['page'] === 'browse_player') { + let url = `/game/browse/${params['puznid']}/?`; + delete params['page']; + delete params['puznid']; return url + Utility.generateParameterString(params); - } else if (params["page"] === "script") { - return "/web/script/"; - } else if (params["page"] === "group") { - return "/web/group/"; - } else if (params["page"] === "conduct") { - return "/web/conduct/"; + } else if (params['page'] === 'script') { + return '/web/script/'; + } else if (params['page'] === 'group') { + return '/web/group/'; + } else if (params['page'] === 'conduct') { + return '/web/conduct/'; } - return "/web/"; + return '/web/'; } } diff --git a/src/eterna/net/GameClient.ts b/src/eterna/net/GameClient.ts index 7f7da04f4..b8bdccd08 100644 --- a/src/eterna/net/GameClient.ts +++ b/src/eterna/net/GameClient.ts @@ -1,12 +1,12 @@ -import * as log from "loglevel"; -import {Base64} from "flashbang/util"; +import * as log from 'loglevel'; +import {Base64} from 'flashbang/util'; type JSONData = any; export default class GameClient { public readonly baseURL: string; - public constructor(baseURL: string) { + constructor(baseURL: string) { log.info(`GameClient baseURL=${baseURL}`); this.baseURL = baseURL; } @@ -15,17 +15,17 @@ export default class GameClient { /** Authenticates the logged-in player. */ public authenticate(): Promise<[string, number]> { - return this.get("/eterna_authenticate.php") + return this.get('/eterna_authenticate.php') .then(rsp => rsp.text()) .then((res) => { - if (res === "NOT LOGGED IN") { - return Promise.resolve<[string, number]>(["Anonymous", 0]); + if (res === 'NOT LOGGED IN') { + return Promise.resolve<[string, number]>(['Anonymous', 0]); } else { try { let [match, username, uid] = res.match(/^(.+)\s(\d+)$/); return Promise.resolve<[string, number]>([username, Number(uid)]); } catch (e) { - throw new Error("Authentication response malformed"); + throw new Error('Authentication response malformed'); } } }); @@ -33,121 +33,121 @@ export default class GameClient { /** Logs the player in. Resolves with the player's UID if successful. */ public login(name: string, password: string): Promise { - return this.post("/login/", {name, pass: password, type: "login"}) + return this.post('/login/', {name, pass: password, type: 'login'}) .then(rsp => rsp.json()) .then((json) => { - if (json["error"] != null) { - throw new Error(`Failed to log in as ${name}: ${json["error"]}`); - } else if (json["data"] == null || json["data"]["uid"] == null) { - throw new Error("Failed to log in (bad response data)"); + if (json['error'] != null) { + throw new Error(`Failed to log in as ${name}: ${json['error']}`); + } else if (json['data'] == null || json['data']['uid'] == null) { + throw new Error('Failed to log in (bad response data)'); } - return Number(json["data"]["uid"]); + return Number(json['data']['uid']); }); } public logout(): Promise { - return this.get("/eterna_logout.php", {noredirect: true}) + return this.get('/eterna_logout.php', {noredirect: true}) .then(rsp => rsp.text()).then(() => {}); } public getBannedList(): Promise { - return this.get("/banned.list").then(rsp => rsp.json()); + return this.get('/banned.list').then(rsp => rsp.json()); } // / PUZZLES public getPuzzle(puznid: number, scriptid: number): Promise { - return this.get(GameClient.GET_URI, {type: "puzzle", nid: puznid, script: scriptid}) + return this.get(GameClient.GET_URI, {type: 'puzzle', nid: puznid, script: scriptid}) .then((rsp: Response) => rsp.json()); } public getPuzzleVotes(puznid: number, round: number): Promise { - return this.get(GameClient.GET_URI, {type: "votes", puznid, round}) + return this.get(GameClient.GET_URI, {type: 'votes', puznid, round}) .then(rsp => rsp.json()); } public submitSolution(params: any): Promise { - params["type"] = "post_solution"; + params['type'] = 'post_solution'; return this.post(GameClient.POST_URI, params).then(rsp => rsp.json()); } public submitPuzzle(params: any): Promise { - params["type"] = "puzzle"; + params['type'] = 'puzzle'; return this.post(GameClient.POST_URI, params) .then(rsp => rsp.json()) .then((json) => { - let data = json["data"]; - if (data["success"]) { + let data = json['data']; + if (data['success']) { return Promise.resolve(); } else { - return Promise.reject(data["error"]); + return Promise.reject(data['error']); } }); } public getSolutions(puzzleID: number): Promise { - return this.get(GameClient.GET_URI, {type: "solutions", puznid: puzzleID}) + return this.get(GameClient.GET_URI, {type: 'solutions', puznid: puzzleID}) .then(rsp => rsp.json()); } public getSolutionInfo(solutionID: number): Promise { - return this.get(GameClient.GET_URI, {type: "solution_info", solid: solutionID, round: "1"}) + return this.get(GameClient.GET_URI, {type: 'solution_info', solid: solutionID, round: '1'}) .then(rsp => rsp.json()); } public getSolutionComments(solutionID: number): Promise { - return this.get(GameClient.GET_URI, {nid: solutionID, type: "comments"}) + return this.get(GameClient.GET_URI, {nid: solutionID, type: 'comments'}) .then(rsp => rsp.json()); } public submitSolutionComment(solutionID: number, body: string): Promise { - return this.post(GameClient.POST_URI, {type: "post_comment", nid: solutionID, body}) + return this.post(GameClient.POST_URI, {type: 'post_comment', nid: solutionID, body}) .then(rsp => rsp.json()); } /** Deletes a solution. Returns nothing on success, and an error string if there was a problem. */ public deleteSolution(solutionID: number): Promise { - return this.post(GameClient.POST_URI, {type: "delete_solution", nid: solutionID}) + return this.post(GameClient.POST_URI, {type: 'delete_solution', nid: solutionID}) .then(rsp => rsp.json()) .then((json) => { - let data = json["data"]; - if (data["success"]) { + let data = json['data']; + if (data['success']) { return Promise.resolve(); } else { - return Promise.reject(data["error"]); + return Promise.reject(data['error']); } }); } public toggleSolutionVote(solutionID: number, puznid: number, myVotes: number): Promise { - let post_params: any = {solnid: solutionID, puznid}; + let postParams: any = {solnid: solutionID, puznid}; if (myVotes === 1) { - post_params["type"] = "unvote"; + postParams['type'] = 'unvote'; } else if (myVotes === 0) { - post_params["type"] = "vote"; + postParams['type'] = 'vote'; } else { throw new Error("Wrong vote value - can't submit"); } - return this.post(GameClient.POST_URI, post_params) + return this.post(GameClient.POST_URI, postParams) .then(rsp => rsp.json()) .then((json) => { - let data = json["data"]; - if (data["success"]) { + let data = json['data']; + if (data['success']) { return data; } else { - return Promise.reject(data["error"]); + return Promise.reject(data['error']); } }); } - public updateSolutionFoldData(solutionID: number, fold_data: any): Promise { - let dataString: string = JSON.stringify(fold_data); + public updateSolutionFoldData(solutionID: number, foldData: any): Promise { + let dataString: string = JSON.stringify(foldData); return this.post(GameClient.POST_URI, { - type: "update_solution_fold_data", + type: 'update_solution_fold_data', nid: solutionID, - "fold-data": dataString + 'fold-data': dataString }).then(rsp => rsp.text()); } @@ -155,16 +155,16 @@ export default class GameClient { public postScreenshot(imgBytes: ArrayBuffer): Promise { let encoded = Base64.encodeBytes(imgBytes); return this.post(GameClient.POST_URI, { - type: "screenshot", + type: 'screenshot', data: encoded }) .then(rsp => rsp.json()) .then((jsonData) => { - let data = jsonData["data"]; - if (data["success"]) { - return data["filename"]; + let data = jsonData['data']; + if (data['success']) { + return data['filename']; } else { - throw new Error(`Failed to post screenshot: ${data["error"]}`); + throw new Error(`Failed to post screenshot: ${data['error']}`); } }); } @@ -178,8 +178,8 @@ export default class GameClient { } return fetch(url.toString(), { - headers: new Headers({"Content-Type": "text/plain"}), - credentials: "include" + headers: new Headers({'Content-Type': 'text/plain'}), + credentials: 'include' }).then((rsp) => { if (!rsp.ok) { throw new Error(`HTTP status code: ${rsp.status}`); @@ -200,10 +200,10 @@ export default class GameClient { } return fetch(url.toString(), { - method: "POST", + method: 'POST', body: postParams.toString(), - headers: new Headers({"Content-Type": "application/x-www-form-urlencoded"}), - credentials: "include" + headers: new Headers({'Content-Type': 'application/x-www-form-urlencoded'}), + credentials: 'include' }).then((rsp) => { if (!rsp.ok) { throw new Error(`HTTP status code: ${rsp.status}`); @@ -239,6 +239,6 @@ export default class GameClient { return new URL(urlString, this.baseURL); } - private static GET_URI: string = "/get/"; - private static POST_URI: string = "/post/"; + private static GET_URI: string = '/get/'; + private static POST_URI: string = '/post/'; } diff --git a/src/eterna/net/index.ts b/src/eterna/net/index.ts index 47165f57f..e3ec118b7 100644 --- a/src/eterna/net/index.ts +++ b/src/eterna/net/index.ts @@ -1,2 +1,2 @@ -export {default as EternaURL} from "./EternaURL"; -export {default as GameClient} from "./GameClient"; +export {default as EternaURL} from './EternaURL'; +export {default as GameClient} from './GameClient'; diff --git a/src/eterna/pose2D/Base.ts b/src/eterna/pose2D/Base.ts index 5822d2680..8b1a78038 100644 --- a/src/eterna/pose2D/Base.ts +++ b/src/eterna/pose2D/Base.ts @@ -1,14 +1,14 @@ -import * as log from "loglevel"; -import {Point, Sprite, Texture} from "pixi.js"; -import {LateUpdatable} from "flashbang/core"; -import {ContainerObject} from "flashbang/objects"; -import Constants from "eterna/Constants"; -import EPars from "eterna/EPars"; -import Eterna from "eterna/Eterna"; -import {ROPWait} from "eterna/rscript"; -import BaseAssets from "./BaseAssets"; -import BaseDrawFlags from "./BaseDrawFlags"; -import Pose2D, {RNAHighlightState} from "./Pose2D"; +import * as log from 'loglevel'; +import {Point, Sprite, Texture} from 'pixi.js'; +import {LateUpdatable} from 'flashbang/core'; +import {ContainerObject} from 'flashbang/objects'; +import Constants from 'eterna/Constants'; +import EPars from 'eterna/EPars'; +import Eterna from 'eterna/Eterna'; +import {ROPWait} from 'eterna/rscript'; +import BaseAssets from './BaseAssets'; +import BaseDrawFlags from './BaseDrawFlags'; +import Pose2D, {RNAHighlightState} from './Pose2D'; type ColorMatrixFilter = PIXI.filters.ColorMatrixFilter; @@ -45,30 +45,30 @@ export default class Base extends ContainerObject implements LateUpdatable { this._sparking = true; this._sparkStartTime = -1; - let rand_angle: number = Math.random() * Math.PI * 2; - this._sparkDir = new Point(Math.cos(rand_angle), Math.sin(rand_angle)); + let randAngle: number = Math.random() * Math.PI * 2; + this._sparkDir = new Point(Math.cos(randAngle), Math.sin(randAngle)); } - public setGoDir(go_x: number, go_y: number): void { - if (Math.abs(go_x - this._goX) > Constants.EPSILON) { - this._goX = go_x; + public setGoDir(goX: number, goY: number): void { + if (Math.abs(goX - this._goX) > Constants.EPSILON) { + this._goX = goX; this._needsRedraw = true; } - if (Math.abs(go_y - this._goY) > Constants.EPSILON) { - this._goY = go_y; + if (Math.abs(goY - this._goY) > Constants.EPSILON) { + this._goY = goY; this._needsRedraw = true; } } - public setOutDir(out_x: number, out_y: number): void { - if (Math.abs(out_x - this._outX) > Constants.EPSILON) { - this._outX = out_x; + public setOutDir(outX: number, outY: number): void { + if (Math.abs(outX - this._outX) > Constants.EPSILON) { + this._outX = outX; this._needsRedraw = true; } - if (Math.abs(out_y - this._outY) > Constants.EPSILON) { - this._outY = out_y; + if (Math.abs(outY - this._outY) > Constants.EPSILON) { + this._outY = outY; this._needsRedraw = true; } } @@ -128,29 +128,29 @@ export default class Base extends ContainerObject implements LateUpdatable { this._forceUnpaired = force; } - public needRedraw(is_static: boolean): boolean { + public needRedraw(isStatic: boolean): boolean { if (!this.display.visible || this._baseType === EPars.RNABASE_CUT) { return false; } - return this._needsRedraw || - (this._animate && !is_static) || - (this._pairing && !is_static) || - (this._unpairing && !is_static) || - this._sparking; + return this._needsRedraw + || (this._animate && !isStatic) + || (this._pairing && !isStatic) + || (this._unpairing && !isStatic) + || this._sparking; } public setDirty(): void { this._needsRedraw = true; } - public setColorLevel(use_color: boolean, color_level: number): void { - if (!use_color) { + public setColorLevel(useColor: boolean, colorLevel: number): void { + if (!useColor) { this._colorLevel = -1; return; } - this._colorLevel = color_level; + this._colorLevel = colorLevel; } public setLast(lastbase: boolean): void { @@ -167,8 +167,8 @@ export default class Base extends ContainerObject implements LateUpdatable { } } - public setPairing(pairing: boolean, go_x: number, go_y: number, duration: number, pair_type: number): void { - let target_angle: number = Math.atan2(go_y, go_x) * 180.0 / Math.PI; + public setPairing(pairing: boolean, goX: number, goY: number, duration: number, pairType: number): void { + let targetAngle: number = Math.atan2(goY, goX) * 180.0 / Math.PI; if (this._pairing && !pairing) { this._unpairing = true; @@ -179,7 +179,7 @@ export default class Base extends ContainerObject implements LateUpdatable { this._needsRedraw = true; } - if (this._pairType !== pair_type) { + if (this._pairType !== pairType) { this._needsRedraw = true; } @@ -193,9 +193,9 @@ export default class Base extends ContainerObject implements LateUpdatable { this._pairingCompleteTime = -1; this._pairingDuration = duration; this._pairingStartDegree = this._lastSatellite1AbsDegree; - this._pairingTargetDegree = target_angle; + this._pairingTargetDegree = targetAngle; this._pairingStartRadius = this._lastSatellite1Radius; - this._pairType = pair_type; + this._pairType = pairType; if (Math.abs(this._pairingTargetDegree - this._pairingStartDegree) > 180) { if (this._pairingTargetDegree > this._pairingStartDegree) { @@ -207,43 +207,53 @@ export default class Base extends ContainerObject implements LateUpdatable { } public isClicked(x: number, y: number, zoomlev: number, lenient: boolean): number { - let diffx: number, diffy: number; + let diffx: number; let + diffy: number; diffx = this.x - x; diffy = this.y - y; - let sq_dist: number = diffx * diffx + diffy * diffy; + let sqDist: number = diffx * diffx + diffy * diffy; if (!lenient) { let threshold: number = BaseAssets.getHitTestDistanceThreshold(zoomlev); - if (sq_dist < threshold * threshold) { - return sq_dist; + if (sqDist < threshold * threshold) { + return sqDist; } - } else if (sq_dist < 225) { - return sq_dist; + } else if (sqDist < 225) { + return sqDist; } return -1; } - public setDrawParams(zoom_level: number, off_x: number, off_y: number, current_time: number, drawFlags: number, numberTexture: Texture, highlight_state: RNAHighlightState = null) { - this._zoomLevel = zoom_level; - this._offX = off_x; - this._offY = off_y; - this._currentTime = current_time; + public setDrawParams( + zoomLevel: number, offX: number, offY: number, currentTime: number, drawFlags: number, + numberTexture: Texture, highlightState: RNAHighlightState = null + ) { + this._zoomLevel = zoomLevel; + this._offX = offX; + this._offY = offY; + this._currentTime = currentTime; this._drawFlags = drawFlags; - this._highlightState = highlight_state; + this._highlightState = highlightState; this._numberTexture = numberTexture; this._needsRedraw = true; } public lateUpdate(dt: number): void { if (this._needsRedraw && this.display.visible && this._baseType !== EPars.RNABASE_CUT) { - this.redraw(this._zoomLevel, this._offX, this._offY, this._currentTime, this._drawFlags, this._numberTexture, this._highlightState); + this.redraw( + this._zoomLevel, this._offX, this._offY, + this._currentTime, this._drawFlags, this._numberTexture, this._highlightState + ); this._needsRedraw = false; } } - private redraw(zoomLevel: number, offX: number, offY: number, currentTime: number, drawFlags: number, numberTexture: Texture, highlight_state: RNAHighlightState = null): void { + private redraw( + zoomLevel: number, offX: number, offY: number, currentTime: number, drawFlags: number, + numberTexture: Texture, highlightState: RNAHighlightState = null + ): void { this._body.visible = false; this._backbone.visible = false; this._barcode.visible = false; @@ -258,12 +268,12 @@ export default class Base extends ContainerObject implements LateUpdatable { const lowperform: boolean = (drawFlags & BaseDrawFlags.LOW_PERFORM) !== 0; - let body_data: Texture = BaseAssets.getBodyTexture(this._baseType, this._colorLevel, zoomLevel, drawFlags); - const barcode_data: Texture = BaseAssets.getBarcodeTexture(zoomLevel, drawFlags); + let bodyData: Texture = BaseAssets.getBodyTexture(this._baseType, this._colorLevel, zoomLevel, drawFlags); + const barcodeData: Texture = BaseAssets.getBarcodeTexture(zoomLevel, drawFlags); - let random_x: number = 0; - let random_y: number = 0; - let angle_rand: number = 0; + let randomX = 0; + let randomY = 0; + let angleRand = 0; if (this._animate) { if (this._animStartTime < 0) { @@ -277,13 +287,13 @@ export default class Base extends ContainerObject implements LateUpdatable { } let progsin: number = Math.sin(prog); - angle_rand = Math.PI / 12.0 * progsin; + angleRand = Math.PI / 12.0 * progsin; - random_x = this._goY * progsin * 0.07; - random_y = -this._goX * progsin * 0.07; + randomX = this._goY * progsin * 0.07; + randomY = -this._goX * progsin * 0.07; } - let pairing_prog: number = 0; + let pairingProg = 0; if (this._pairing || this._unpairing) { if (this._pairingStartTime < 0) { @@ -291,12 +301,12 @@ export default class Base extends ContainerObject implements LateUpdatable { } if (this._pairingDuration === 0) { - pairing_prog = 1; + pairingProg = 1; this._pairingCompleteTime = currentTime; } else { - pairing_prog = (currentTime - this._pairingStartTime) / (this._pairingDuration); - if (pairing_prog >= 1) { - pairing_prog = 1; + pairingProg = (currentTime - this._pairingStartTime) / (this._pairingDuration); + if (pairingProg >= 1) { + pairingProg = 1; if (this._pairingCompleteTime < 0) { this._pairingCompleteTime = currentTime; } @@ -304,18 +314,18 @@ export default class Base extends ContainerObject implements LateUpdatable { } } - let draw_body: boolean = false; - if (body_data) { - draw_body = true; + let drawBody = false; + if (bodyData) { + drawBody = true; - this._lastCenterX = this.display.x + random_x + offX; - this._lastCenterY = this.display.y + random_y + offY; + this._lastCenterX = this.display.x + randomX + offX; + this._lastCenterY = this.display.y + randomY + offY; - if (draw_body) { - if (barcode_data != null) { - Base.showSprite(this._barcode, barcode_data); - this._barcode.x = random_x + offX; - this._barcode.y = random_y + offY; + if (drawBody) { + if (barcodeData != null) { + Base.showSprite(this._barcode, barcodeData); + this._barcode.x = randomX + offX; + this._barcode.y = randomY + offY; } if (this._isForced) { @@ -325,146 +335,154 @@ export default class Base extends ContainerObject implements LateUpdatable { // body_data = temp_bd; } - Base.showSprite(this._body, body_data); - Base.showHighlightState(this._body, this._baseIdx, highlight_state); + Base.showSprite(this._body, bodyData); + Base.showHighlightState(this._body, this._baseIdx, highlightState); - this._body.x = random_x + offX; - this._body.y = random_y + offY; + this._body.x = randomX + offX; + this._body.y = randomY + offY; let letterdata: Texture = BaseAssets.getLetterTexture(this._baseType, zoomLevel, drawFlags); if (letterdata != null) { Base.showSprite(this._letter, letterdata); - this._letter.x = random_x + offX; - this._letter.y = random_y + offY; + this._letter.x = randomX + offX; + this._letter.y = randomY + offY; } } } if (Math.abs(this._goX) > 0 || Math.abs(this._goY) > 0) { if (zoomLevel < 2 * Base.NUM_ZOOM_LEVELS && !this._isLast && !lowperform) { - const backbone_data: Texture = BaseAssets.getBackboneTexture(zoomLevel); - Base.showSprite(this._backbone, backbone_data); - this._backbone.x = random_x + offX + this._goX / 2; - this._backbone.y = random_y + offY + this._goY / 2; + const backboneData: Texture = BaseAssets.getBackboneTexture(zoomLevel); + Base.showSprite(this._backbone, backboneData); + this._backbone.x = randomX + offX + this._goX / 2; + this._backbone.y = randomY + offY + this._goY / 2; } - let go_radian: number = Math.atan2(this._goY, this._goX); - let satellite_body_data: Texture; + let goRadian: number = Math.atan2(this._goY, this._goX); + let satelliteBodyData: Texture; if (zoomLevel < Base.NUM_ZOOM_LEVELS && !lowperform) { - const reference_base_size: number = BaseAssets.getSatelliteReferenceBaseSize(zoomLevel); + const referenceBaseSize: number = BaseAssets.getSatelliteReferenceBaseSize(zoomLevel); - let st0_diff_degree: number; - let st0_angle: number = Math.PI / 5.2 + angle_rand; - st0_diff_degree = (go_radian + st0_angle) * 180 / Math.PI - 90.0; - st0_diff_degree = Base.toCanonicalRange(st0_diff_degree); + let st0DiffDegree: number; + let st0Angle: number = Math.PI / 5.2 + angleRand; + st0DiffDegree = (goRadian + st0Angle) * 180 / Math.PI - 90.0; + st0DiffDegree = Base.toCanonicalRange(st0DiffDegree); - if (Math.trunc(st0_diff_degree / 5) < 0 || Math.trunc(st0_diff_degree / 5) > 71) { - if (Math.trunc(st0_diff_degree / 5) < -1 || Math.trunc(st0_diff_degree / 5) > 72) { - log.debug(st0_diff_degree); - throw new Error("WHAT0"); + if (Math.trunc(st0DiffDegree / 5) < 0 || Math.trunc(st0DiffDegree / 5) > 71) { + if (Math.trunc(st0DiffDegree / 5) < -1 || Math.trunc(st0DiffDegree / 5) > 72) { + log.debug(st0DiffDegree); + throw new Error('WHAT0'); } - st0_diff_degree = 0; + st0DiffDegree = 0; } - satellite_body_data = BaseAssets.getSatellite0Texture(zoomLevel, st0_diff_degree); - if (satellite_body_data == null) { - satellite_body_data = BaseAssets.getSatellite0Texture(zoomLevel, st0_diff_degree); + satelliteBodyData = BaseAssets.getSatellite0Texture(zoomLevel, st0DiffDegree); + if (satelliteBodyData == null) { + satelliteBodyData = BaseAssets.getSatellite0Texture(zoomLevel, st0DiffDegree); } - let draw_st0: boolean = !this._forceUnpaired; + let drawSt0 = !this._forceUnpaired; - if (draw_st0) { - let st0_cos: number = Math.cos(st0_angle); - let st0_sin: number = Math.sin(st0_angle); - let st0_x: number = this._goX / 2.5 * st0_cos - this._goY / 2.5 * st0_sin + offX + random_x; - let st0_y: number = this._goX / 2.5 * st0_sin + this._goY / 2.5 * st0_cos + offY + random_y; + if (drawSt0) { + let st0Cos: number = Math.cos(st0Angle); + let st0Sin: number = Math.sin(st0Angle); + let st0X: number = this._goX / 2.5 * st0Cos - this._goY / 2.5 * st0Sin + offX + randomX; + let st0Y: number = this._goX / 2.5 * st0Sin + this._goY / 2.5 * st0Cos + offY + randomY; - Base.showSprite(this._sat0, satellite_body_data); - Base.showHighlightState(this._sat0, this._baseIdx, highlight_state); - this._sat0.x = st0_x; - this._sat0.y = st0_y; + Base.showSprite(this._sat0, satelliteBodyData); + Base.showHighlightState(this._sat0, this._baseIdx, highlightState); + this._sat0.x = st0X; + this._sat0.y = st0Y; } - let draw_st1: boolean = !this._forceUnpaired; - let st1_diff_degree: number; - let st1_x: number; - let st1_y: number; + let drawSt1 = !this._forceUnpaired; + let st1DiffDegree: number; + let st1X: number; + let st1Y: number; - let current_radian: number; + let currentRadian: number; if (!this._pairing) { if (!this._unpairing) { - let st1_angle: number = -Math.PI / 5.2 - angle_rand; - st1_diff_degree = (go_radian + st1_angle) * 180 / Math.PI - 90.0; - st1_diff_degree = Base.toCanonicalRange(st1_diff_degree); - let st1_cos: number = Math.cos(st1_angle); - let st1_sin: number = Math.sin(st1_angle); - st1_x = this._goX / 2.5 * st1_cos - this._goY / 2.5 * st1_sin + offX + random_x; - st1_y = this._goX / 2.5 * st1_sin + this._goY / 2.5 * st1_cos + offY + random_y; - - this._lastSatellite1Radius = reference_base_size * 0.45; + let st1Angle: number = -Math.PI / 5.2 - angleRand; + st1DiffDegree = (goRadian + st1Angle) * 180 / Math.PI - 90.0; + st1DiffDegree = Base.toCanonicalRange(st1DiffDegree); + let st1Cos: number = Math.cos(st1Angle); + let st1Sin: number = Math.sin(st1Angle); + st1X = this._goX / 2.5 * st1Cos - this._goY / 2.5 * st1Sin + offX + randomX; + st1Y = this._goX / 2.5 * st1Sin + this._goY / 2.5 * st1Cos + offY + randomY; + + this._lastSatellite1Radius = referenceBaseSize * 0.45; } else { - let target_angle: number = (go_radian - Math.PI / 5.2) * 180 / Math.PI; + let targetAngle: number = (goRadian - Math.PI / 5.2) * 180 / Math.PI; - if (Math.abs(target_angle - this._pairingStartDegree) > 180) { - if (target_angle > this._pairingStartDegree) { - target_angle -= 360; + if (Math.abs(targetAngle - this._pairingStartDegree) > 180) { + if (targetAngle > this._pairingStartDegree) { + targetAngle -= 360; } else { - target_angle += 360; + targetAngle += 360; } } - let current_angle: number = this._pairingStartDegree * (1 - pairing_prog) + target_angle * pairing_prog; - current_radian = current_angle * Math.PI / 180.0; - st1_diff_degree = Base.toCanonicalRange(current_angle - 90.0); - let current_radius: number = this._pairingStartRadius * (1 - pairing_prog) + (reference_base_size * 0.45) * pairing_prog; - st1_x = Math.cos(current_radian) * current_radius + offX; - st1_y = Math.sin(current_radian) * current_radius + offY; - this._lastSatellite1Radius = current_radius; + let currentAngle: number = ( + this._pairingStartDegree * (1 - pairingProg) + targetAngle * pairingProg + ); + currentRadian = currentAngle * Math.PI / 180.0; + st1DiffDegree = Base.toCanonicalRange(currentAngle - 90.0); + let currentRadius: number = ( + this._pairingStartRadius * (1 - pairingProg) + (referenceBaseSize * 0.45) * pairingProg + ); + st1X = Math.cos(currentRadian) * currentRadius + offX; + st1Y = Math.sin(currentRadian) * currentRadius + offY; + this._lastSatellite1Radius = currentRadius; } - } else { - let current_degree: number = this._pairingTargetDegree * pairing_prog + this._pairingStartDegree * (1 - pairing_prog); - current_radian = current_degree * Math.PI / 180.0; + let currentDegree: number = ( + this._pairingTargetDegree * pairingProg + this._pairingStartDegree * (1 - pairingProg) + ); + currentRadian = currentDegree * Math.PI / 180.0; - st1_diff_degree = current_degree - 90.0; - st1_diff_degree = Base.toCanonicalRange(st1_diff_degree); + st1DiffDegree = currentDegree - 90.0; + st1DiffDegree = Base.toCanonicalRange(st1DiffDegree); - let pair_r: number = 0; + let pairR = 0; if (this._pairingCompleteTime >= 0) { - pair_r = (Math.cos((currentTime - this._pairingCompleteTime) / 250.0 + Math.PI / 2)) * 2 + reference_base_size * 0.45; + pairR = ( + (Math.cos((currentTime - this._pairingCompleteTime) / 250.0 + Math.PI / 2)) * 2 + + referenceBaseSize * 0.45 + ); } else { - pair_r = pairing_prog * (reference_base_size * 0.45) + (1 - pairing_prog) * this._pairingStartRadius; + pairR = pairingProg * (referenceBaseSize * 0.45) + (1 - pairingProg) * this._pairingStartRadius; } - st1_x = Math.cos(current_radian) * pair_r + offX; - st1_y = Math.sin(current_radian) * pair_r + offY; + st1X = Math.cos(currentRadian) * pairR + offX; + st1Y = Math.sin(currentRadian) * pairR + offY; - this._lastSatellite1Radius = pair_r; + this._lastSatellite1Radius = pairR; } - if (Math.trunc(st1_diff_degree / 5) < 0 || Math.trunc(st1_diff_degree / 5) > 71) { - if (Math.trunc(st1_diff_degree / 5) < -1 || Math.trunc(st1_diff_degree / 5) > 72) { - log.debug(st1_diff_degree); - throw new Error("WHAT1"); + if (Math.trunc(st1DiffDegree / 5) < 0 || Math.trunc(st1DiffDegree / 5) > 71) { + if (Math.trunc(st1DiffDegree / 5) < -1 || Math.trunc(st1DiffDegree / 5) > 72) { + log.debug(st1DiffDegree); + throw new Error('WHAT1'); } - st1_diff_degree = 0; + st1DiffDegree = 0; } - satellite_body_data = BaseAssets.getSatellite1Texture(zoomLevel, st1_diff_degree, this._pairType); + satelliteBodyData = BaseAssets.getSatellite1Texture(zoomLevel, st1DiffDegree, this._pairType); - this._lastSatellite1AbsDegree = st1_diff_degree + 90.0; + this._lastSatellite1AbsDegree = st1DiffDegree + 90.0; - if (draw_st1) { - Base.showSprite(this._sat1, satellite_body_data); - Base.showHighlightState(this._sat1, this._baseIdx, highlight_state); - this._sat1.x = st1_x; - this._sat1.y = st1_y; + if (drawSt1) { + Base.showSprite(this._sat1, satelliteBodyData); + Base.showHighlightState(this._sat1, this._baseIdx, highlightState); + this._sat1.x = st1X; + this._sat1.y = st1Y; } } } @@ -473,14 +491,19 @@ export default class Base extends ContainerObject implements LateUpdatable { this._unpairing = false; } - if (numberTexture != null && body_data != null && draw_body) { - let desired_dist: number = Math.sqrt((numberTexture.width / 2) * (numberTexture.width / 2) + (numberTexture.height / 2) * (numberTexture.height / 2)); - desired_dist += Math.sqrt((this._outX / 2) * (this._outX / 2) + (this._outY / 2) * (this._outY / 2)); - desired_dist *= 0.8; + if (numberTexture != null && bodyData != null && drawBody) { + let desiredDist: number = Math.sqrt( + (numberTexture.width / 2) * (numberTexture.width / 2) + + (numberTexture.height / 2) * (numberTexture.height / 2) + ); + desiredDist += Math.sqrt((this._outX / 2) * (this._outX / 2) + (this._outY / 2) * (this._outY / 2)); + desiredDist *= 0.8; - let out_dist: number = Math.sqrt(this._outX * this._outX + this._outY * this._outY); - if (out_dist > Constants.EPSILON) { - let numberPos: Point = new Point(offX + this._outX * desired_dist / out_dist, offY + this._outY * desired_dist / out_dist); + let outDist: number = Math.sqrt(this._outX * this._outX + this._outY * this._outY); + if (outDist > Constants.EPSILON) { + let numberPos = new Point( + offX + this._outX * desiredDist / outDist, offY + this._outY * desiredDist / outDist + ); Base.showSprite(this._number, numberTexture); this._number.x = numberPos.x; this._number.y = numberPos.y; @@ -502,7 +525,7 @@ export default class Base extends ContainerObject implements LateUpdatable { this._sparkStartTime = currentTime; } - const DURATION: number = 1; + const DURATION = 1; let animProgress = (currentTime - this._sparkStartTime) / DURATION; if (animProgress >= 1) { @@ -517,30 +540,32 @@ export default class Base extends ContainerObject implements LateUpdatable { Base.showSprite(this._spark1, tex); Base.showSprite(this._spark2, tex); - let flying_dist: number = 70; + let flyingDist = 70; if (zoomLevel < Base.NUM_ZOOM_LEVELS) { - flying_dist = 100; + flyingDist = 100; } this._spark1.position = new Point( - offX + this._sparkDir.x * flying_dist * animProgress, - offY + this._sparkDir.y * flying_dist * animProgress); + offX + this._sparkDir.x * flyingDist * animProgress, + offY + this._sparkDir.y * flyingDist * animProgress + ); this._spark2.position = new Point( - offX - this._sparkDir.x * flying_dist * animProgress, - offY - this._sparkDir.y * flying_dist * animProgress); + offX - this._sparkDir.x * flyingDist * animProgress, + offY - this._sparkDir.y * flyingDist * animProgress + ); } public getLastDrawnPos(): Point { return new Point(this._lastCenterX, this._lastCenterY); } - private static showHighlightState (sprite: Sprite, baseIdx: number, highlight_state?: RNAHighlightState) { + private static showHighlightState(sprite: Sprite, baseIdx: number, highlightState?: RNAHighlightState) { sprite.filters = null; sprite.alpha = 1; - if (highlight_state != null && highlight_state.isOn) { - if (highlight_state.nuc.indexOf(baseIdx) === -1) { + if (highlightState != null && highlightState.isOn) { + if (highlightState.nuc.indexOf(baseIdx) === -1) { sprite.alpha = 0.55; } else { sprite.filters = [this.multiplyAlphaFilter(1.33)]; @@ -570,7 +595,7 @@ export default class Base extends ContainerObject implements LateUpdatable { private static toCanonicalRange(deg: number): number { if (deg > 0) { - deg = deg - (Math.trunc(deg / 360.0) * 360); + deg -= (Math.trunc(deg / 360.0) * 360); if (deg >= 360) { deg = 359; } diff --git a/src/eterna/pose2D/BaseAssets.ts b/src/eterna/pose2D/BaseAssets.ts index 0e28ec44d..392932a5c 100644 --- a/src/eterna/pose2D/BaseAssets.ts +++ b/src/eterna/pose2D/BaseAssets.ts @@ -1,12 +1,14 @@ -import {Container, Graphics, Sprite, Texture} from "pixi.js"; -import {ColorUtil, TextureUtil} from "flashbang/util"; -import EPars from "eterna/EPars"; -import ExpPainter from "eterna/ExpPainter"; -import {BitmapManager, Bitmaps, Sounds} from "eterna/resources"; -import {EternaTextureUtil} from "eterna/util"; -import Base from "./Base"; -import BaseDrawFlags from "./BaseDrawFlags"; -import BaseTextures from "./BaseTextures"; +import { + Container, Graphics, Sprite, Texture +} from 'pixi.js'; +import {ColorUtil, TextureUtil} from 'flashbang/util'; +import EPars from 'eterna/EPars'; +import ExpPainter from 'eterna/ExpPainter'; +import {BitmapManager, Bitmaps, Sounds} from 'eterna/resources'; +import {EternaTextureUtil} from 'eterna/util'; +import Base from './Base'; +import BaseDrawFlags from './BaseDrawFlags'; +import BaseTextures from './BaseTextures'; /** Handles initialization and management of Base-related assets */ export default class BaseAssets { @@ -16,7 +18,9 @@ export default class BaseAssets { if (zoomLevel < Base.NUM_ZOOM_LEVELS) { bitmapWidth = BaseAssets.textureForSize(BaseAssets._baseUBitmaps.bodyData, 0, zoomLevel).width; } else if (zoomLevel < 2 * Base.NUM_ZOOM_LEVELS) { - bitmapWidth = BaseAssets.textureForSize(BaseAssets._baseUBitmaps.midData, 0, zoomLevel - Base.NUM_ZOOM_LEVELS).width; + bitmapWidth = BaseAssets.textureForSize( + BaseAssets._baseUBitmaps.midData, 0, zoomLevel - Base.NUM_ZOOM_LEVELS + ).width; } else { bitmapWidth = BaseAssets._baseUBitmaps.minData.width; } @@ -24,30 +28,29 @@ export default class BaseAssets { return bitmapWidth / 2.0; } - public static getBodyTexture(base_type: number, color_level: number, zoom_level: number, flags: number): Texture { - if (BaseAssets.isBaseType(base_type) && color_level < 0) { - return BaseAssets.getBaseBitmaps(base_type).getBodyTexture(zoom_level, flags); - - } else if (base_type === EPars.RNABASE_LOCK) { - return BaseAssets.textureForSize(BaseAssets._backboneBodyData, 0, zoom_level); - - } else if (color_level < 0) { - if (zoom_level < Base.NUM_ZOOM_LEVELS) { - return BaseAssets.textureForSize(BaseAssets._sphereData, ExpPainter.NUM_COLORS, zoom_level); - } else if (zoom_level < Base.NUM_ZOOM_LEVELS * 2) { - return BaseAssets.textureForSize(BaseAssets._sphereMidData, ExpPainter.NUM_COLORS, zoom_level - Base.NUM_ZOOM_LEVELS); + public static getBodyTexture(baseType: number, colorLevel: number, zoomLevel: number, flags: number): Texture { + if (BaseAssets.isBaseType(baseType) && colorLevel < 0) { + return BaseAssets.getBaseBitmaps(baseType).getBodyTexture(zoomLevel, flags); + } else if (baseType === EPars.RNABASE_LOCK) { + return BaseAssets.textureForSize(BaseAssets._backboneBodyData, 0, zoomLevel); + } else if (colorLevel < 0) { + if (zoomLevel < Base.NUM_ZOOM_LEVELS) { + return BaseAssets.textureForSize(BaseAssets._sphereData, ExpPainter.NUM_COLORS, zoomLevel); + } else if (zoomLevel < Base.NUM_ZOOM_LEVELS * 2) { + return BaseAssets.textureForSize( + BaseAssets._sphereMidData, ExpPainter.NUM_COLORS, zoomLevel - Base.NUM_ZOOM_LEVELS + ); } else { - return BaseAssets.textureForSize(BaseAssets._sphereMinData, ExpPainter.NUM_COLORS, zoom_level - Base.NUM_ZOOM_LEVELS); + return BaseAssets.textureForSize( + BaseAssets._sphereMinData, ExpPainter.NUM_COLORS, zoomLevel - Base.NUM_ZOOM_LEVELS + ); } - + } else if (zoomLevel < Base.NUM_ZOOM_LEVELS) { + return BaseAssets.textureForSize(BaseAssets._sphereData, colorLevel, zoomLevel); + } else if (zoomLevel < Base.NUM_ZOOM_LEVELS * 2) { + return BaseAssets.textureForSize(BaseAssets._sphereMidData, colorLevel, zoomLevel - Base.NUM_ZOOM_LEVELS); } else { - if (zoom_level < Base.NUM_ZOOM_LEVELS) { - return BaseAssets.textureForSize(BaseAssets._sphereData, color_level, zoom_level); - } else if (zoom_level < Base.NUM_ZOOM_LEVELS * 2) { - return BaseAssets.textureForSize(BaseAssets._sphereMidData, color_level, zoom_level - Base.NUM_ZOOM_LEVELS); - } else { - return BaseAssets._sphereMinData[color_level]; - } + return BaseAssets._sphereMinData[colorLevel]; } } @@ -65,31 +68,33 @@ export default class BaseAssets { return null; } - public static getLetterTexture(base_type: number, zoom_level: number, drawFlags: number): Texture | null { - return BaseAssets.isBaseType(base_type) ? - BaseAssets.getBaseBitmaps(base_type).getLetterTexture(zoom_level, drawFlags) : - null; + public static getLetterTexture(baseType: number, zoomLevel: number, drawFlags: number): Texture | null { + return BaseAssets.isBaseType(baseType) + ? BaseAssets.getBaseBitmaps(baseType).getLetterTexture(zoomLevel, drawFlags) + : null; } - public static getBackboneTexture(zoom_level: number): Texture { - if (zoom_level < Base.NUM_ZOOM_LEVELS) { - return BaseAssets.textureForSize(BaseAssets._backboneBodyData, 0, zoom_level); + public static getBackboneTexture(zoomLevel: number): Texture { + if (zoomLevel < Base.NUM_ZOOM_LEVELS) { + return BaseAssets.textureForSize(BaseAssets._backboneBodyData, 0, zoomLevel); } else { - return BaseAssets.textureForSize(BaseAssets._backboneMidData, 0, zoom_level - Base.NUM_ZOOM_LEVELS); + return BaseAssets.textureForSize(BaseAssets._backboneMidData, 0, zoomLevel - Base.NUM_ZOOM_LEVELS); } } - public static getSatellite0Texture(zoom_level: number, st0_diff_degree: number): Texture { - return BaseAssets.textureForSize(BaseAssets._satelliteData, Math.trunc(st0_diff_degree / 5), zoom_level); + public static getSatellite0Texture(zoomLevel: number, st0DiffDegree: number): Texture { + return BaseAssets.textureForSize(BaseAssets._satelliteData, Math.trunc(st0DiffDegree / 5), zoomLevel); } - public static getSatellite1Texture(zoom_level: number, st1_diff_degree: number, pair_type: number): Texture { - if (pair_type === -1 || pair_type === 2) { - return BaseAssets.textureForSize(BaseAssets._satelliteData, Math.trunc(st1_diff_degree / 5), zoom_level); - } else if (pair_type === 1) { - return BaseAssets.textureForSize(BaseAssets._satelliteWeakerData, Math.trunc(st1_diff_degree / 5), zoom_level); + public static getSatellite1Texture(zoomLevel: number, st1DiffDegree: number, pairType: number): Texture { + if (pairType === -1 || pairType === 2) { + return BaseAssets.textureForSize(BaseAssets._satelliteData, Math.trunc(st1DiffDegree / 5), zoomLevel); + } else if (pairType === 1) { + return BaseAssets.textureForSize(BaseAssets._satelliteWeakerData, Math.trunc(st1DiffDegree / 5), zoomLevel); } else { - return BaseAssets.textureForSize(BaseAssets._satelliteStrongerData, Math.trunc(st1_diff_degree / 5), zoom_level); + return BaseAssets.textureForSize( + BaseAssets._satelliteStrongerData, Math.trunc(st1DiffDegree / 5), zoomLevel + ); } } @@ -97,60 +102,57 @@ export default class BaseAssets { progress = (1 - progress) * (1 - progress); progress = 1 - progress; - let prog_index: number = Math.trunc(progress * 10); + let progIndex: number = Math.trunc(progress * 10); - if (prog_index >= 10) - prog_index = 9; - else if (prog_index < 0) - prog_index = 0; + if (progIndex >= 10) progIndex = 9; + else if (progIndex < 0) progIndex = 0; - return BaseAssets._sparkBitmaps[prog_index]; + return BaseAssets._sparkBitmaps[progIndex]; } - public static getSatelliteReferenceBaseSize(zoom_level: number): number { - return BaseAssets.textureForSize(BaseAssets._baseABitmaps.bodyData, 0, zoom_level).width; + public static getSatelliteReferenceBaseSize(zoomLevel: number): number { + return BaseAssets.textureForSize(BaseAssets._baseABitmaps.bodyData, 0, zoomLevel).width; } public static getBaseTypeSound(type: number): string | null { switch (type) { - case EPars.RNABASE_ADENINE: return Sounds.SoundY; - case EPars.RNABASE_URACIL: return Sounds.SoundB; - case EPars.RNABASE_GUANINE: return Sounds.SoundR; - case EPars.RNABASE_CYTOSINE: return Sounds.SoundG; + case EPars.RNABASE_ADENINE: return Sounds.SoundY; + case EPars.RNABASE_URACIL: return Sounds.SoundB; + case EPars.RNABASE_GUANINE: return Sounds.SoundR; + case EPars.RNABASE_CYTOSINE: return Sounds.SoundG; + default: return null; } - - return null; } - private static getBaseBitmaps(base_type: number): BaseTextures { - switch (base_type) { - case EPars.RNABASE_URACIL: - return BaseAssets._baseUBitmaps; - case EPars.RNABASE_ADENINE: - return BaseAssets._baseABitmaps; - case EPars.RNABASE_GUANINE: - return BaseAssets._baseGBitmaps; - case EPars.RNABASE_CYTOSINE: - return BaseAssets._baseCBitmaps; - default: - throw new Error("Bad base type: " + base_type); + private static getBaseBitmaps(baseType: number): BaseTextures { + switch (baseType) { + case EPars.RNABASE_URACIL: + return BaseAssets._baseUBitmaps; + case EPars.RNABASE_ADENINE: + return BaseAssets._baseABitmaps; + case EPars.RNABASE_GUANINE: + return BaseAssets._baseGBitmaps; + case EPars.RNABASE_CYTOSINE: + return BaseAssets._baseCBitmaps; + default: + throw new Error(`Bad base type: ${baseType}`); } } - private static isBaseType(base_type: number): boolean { - switch (base_type) { - case EPars.RNABASE_URACIL: - case EPars.RNABASE_ADENINE: - case EPars.RNABASE_GUANINE: - case EPars.RNABASE_CYTOSINE: - return true; - default: - return false; + private static isBaseType(baseType: number): boolean { + switch (baseType) { + case EPars.RNABASE_URACIL: + case EPars.RNABASE_ADENINE: + case EPars.RNABASE_GUANINE: + case EPars.RNABASE_CYTOSINE: + return true; + default: + return false; } } - /*internal*/ - static init(): void { + /* internal */ + public static init(): void { if (BaseAssets._inited) { return; } @@ -183,7 +185,7 @@ export default class BaseAssets { pattern.filters = [colorTransform]; sphereBitmap.addChild(pattern); BaseAssets._sphereData.push(TextureUtil.renderToTexture(sphereBitmap)); - } while(0); + } while (0); do { const sphereBitmapMid: Container = new Container(); @@ -192,7 +194,7 @@ export default class BaseAssets { pattern.filters = [colorTransform]; sphereBitmapMid.addChild(pattern); BaseAssets._sphereMidData.push(TextureUtil.renderToTexture(sphereBitmapMid)); - } while(0); + } while (0); do { const sphereBitmapMin: Container = new Container(); @@ -200,8 +202,7 @@ export default class BaseAssets { pattern.filters = [colorTransform]; sphereBitmapMin.addChild(pattern); BaseAssets._sphereMinData.push(TextureUtil.renderToTexture(sphereBitmapMin)); - - } while(0); + } while (0); } EternaTextureUtil.createScaled(BaseAssets._sphereData, 0.75, Base.NUM_ZOOM_LEVELS); @@ -220,20 +221,28 @@ export default class BaseAssets { EternaTextureUtil.createScaled(BaseAssets._backboneMidData, 0.75, Base.NUM_ZOOM_LEVELS); // BARCODE TEXTURES - BaseAssets._barcodeData = [BaseAssets.drawCircularBarcode(16, 6, /*0.5*/ 1)]; - BaseAssets._barcodeMidData = [BaseAssets.drawCircularBarcode(12, 3, /*0.5*/ 1)]; - BaseAssets._barcodeMinData = [BaseAssets.drawCircularBarcode(6, 2, /*0.5*/ 1)]; + BaseAssets._barcodeData = [BaseAssets.drawCircularBarcode(16, 6, /* 0.5 */ 1)]; + BaseAssets._barcodeMidData = [BaseAssets.drawCircularBarcode(12, 3, /* 0.5 */ 1)]; + BaseAssets._barcodeMinData = [BaseAssets.drawCircularBarcode(6, 2, /* 0.5 */ 1)]; EternaTextureUtil.createScaled(BaseAssets._barcodeData, 0.75, Base.NUM_ZOOM_LEVELS); EternaTextureUtil.createScaled(BaseAssets._barcodeMidData, 0.75, Base.NUM_ZOOM_LEVELS); // SATELLITE TEXTURES - BaseAssets._satelliteData = BaseAssets.createSatelliteBitmaps(ColorUtil.colorTransform(1, 1, 1, 1, 0, 0, 0, 0)); - BaseAssets._satelliteWeakerData = BaseAssets.createSatelliteBitmaps(ColorUtil.colorTransform(1, 1, 1, 0.5, 0, 0, 0, 0)); - BaseAssets._satelliteStrongerData = BaseAssets.createSatelliteBitmaps(ColorUtil.colorTransform(3, 3, 3, 3, 0, 0, 0, 0)); + BaseAssets._satelliteData = BaseAssets.createSatelliteBitmaps( + ColorUtil.colorTransform(1, 1, 1, 1, 0, 0, 0, 0) + ); + BaseAssets._satelliteWeakerData = BaseAssets.createSatelliteBitmaps( + ColorUtil.colorTransform(1, 1, 1, 0.5, 0, 0, 0, 0) + ); + BaseAssets._satelliteStrongerData = BaseAssets.createSatelliteBitmaps( + ColorUtil.colorTransform(3, 3, 3, 3, 0, 0, 0, 0) + ); // SPARK TEXTURES - BaseAssets._sparkBitmaps = EternaTextureUtil.createTransparent(BitmapManager.getBitmap(Bitmaps.BonusSymbol), 10); + BaseAssets._sparkBitmaps = EternaTextureUtil.createTransparent( + BitmapManager.getBitmap(Bitmaps.BonusSymbol), 10 + ); // SOUNDS // log.debug("INIT SOUND"); @@ -255,10 +264,10 @@ export default class BaseAssets { scratch.moveTo(xx, yy); - let steps: number = 360; + let steps = 360; - for (let i: number = 1; i <= steps; i++) { - let color: number = 0x0; + for (let i = 1; i <= steps; i++) { + let color = 0x0; if (i % 32 < 16) { color = 0xFFFFFF; } @@ -284,13 +293,13 @@ export default class BaseAssets { return textures; } - private static textureForSize(textures: Texture[], ii: number, size_num: number): Texture { + private static textureForSize(textures: Texture[], ii: number, sizeNum: number): Texture { if (textures.length % Base.NUM_ZOOM_LEVELS !== 0) { - throw new Error("Invalid textures array length " + textures.length); + throw new Error(`Invalid textures array length ${textures.length}`); } - let orig_length: number = textures.length / Base.NUM_ZOOM_LEVELS; - return textures[(orig_length * size_num + ii)]; + let origLength: number = textures.length / Base.NUM_ZOOM_LEVELS; + return textures[(origLength * sizeNum + ii)]; } private static _inited: boolean; @@ -300,21 +309,21 @@ export default class BaseAssets { private static _baseGBitmaps: BaseTextures; private static _baseCBitmaps: BaseTextures; - /// Backbone textures + // / Backbone textures private static _backboneBodyData: Texture[]; private static _backboneMidData: Texture[]; - /// Satellites for the max zoom + // / Satellites for the max zoom private static _satelliteData: Texture[]; private static _satelliteWeakerData: Texture[]; private static _satelliteStrongerData: Texture[]; - /// Barcode outline data + // / Barcode outline data private static _barcodeData: Texture[]; private static _barcodeMidData: Texture[]; private static _barcodeMinData: Texture[]; - /// Bitmaps for blank bases + // / Bitmaps for blank bases private static _sphereData: Texture[]; private static _sphereMidData: Texture[]; private static _sphereMinData: Texture[]; diff --git a/src/eterna/pose2D/BaseTextures.ts b/src/eterna/pose2D/BaseTextures.ts index 4a31f0f56..8c520a14a 100644 --- a/src/eterna/pose2D/BaseTextures.ts +++ b/src/eterna/pose2D/BaseTextures.ts @@ -1,28 +1,28 @@ -import {Text, Texture} from "pixi.js"; -import {TextureUtil} from "flashbang/util"; -import EPars from "eterna/EPars"; -import {BitmapManager} from "eterna/resources"; -import {EternaTextureUtil, Fonts} from "eterna/util"; -import Base from "./Base"; -import BaseDrawFlags from "./BaseDrawFlags"; +import {Text, Texture} from 'pixi.js'; +import {TextureUtil} from 'flashbang/util'; +import EPars from 'eterna/EPars'; +import {BitmapManager} from 'eterna/resources'; +import {EternaTextureUtil, Fonts} from 'eterna/util'; +import Base from './Base'; +import BaseDrawFlags from './BaseDrawFlags'; /** Encapsulates textures for a Base type */ export default class BaseTextures { public baseType: number; - public letterData: Texture[]; // letters + public letterData: Texture[]; // letters - public bodyData: Texture[]; // max-size - public fBodyData: Texture[]; // "dontcare" + public bodyData: Texture[]; // max-size + public fBodyData: Texture[]; // "dontcare" - public lBodyData: Texture[]; // max-size, letter mode - public lfBodyData: Texture[]; // "dontcare" + public lBodyData: Texture[]; // max-size, letter mode + public lfBodyData: Texture[]; // "dontcare" - public lockData: Texture[]; // max-size, locked - public fLockData: Texture[]; // "dontcare" + public lockData: Texture[]; // max-size, locked + public fLockData: Texture[]; // "dontcare" - public midData: Texture[]; // mid-size - public fMidData: Texture[]; // "dontcare" + public midData: Texture[]; // mid-size + public fMidData: Texture[]; // "dontcare" public midLockData: Texture[]; // mid-size, locked public fMidLockData: Texture[]; // "dontcare" @@ -33,37 +33,41 @@ export default class BaseTextures { this.baseType = baseType; this.letterData = BaseTextures.createLetterTextures(baseType, Base.ZOOM_SCALE_FACTOR); - this.bodyData = BaseTextures.createBodyTextures("LBase*", baseType); - this.fBodyData = BaseTextures.createBodyTextures("LBase*f", baseType); - this.lBodyData = BaseTextures.createBodyTextures("LBase*", baseType); - this.lfBodyData = BaseTextures.createBodyTextures("LBase*f", baseType); - this.lockData = BaseTextures.createBodyTextures("Base*Lock", baseType); - this.fLockData = BaseTextures.createBodyTextures("Base*fLock", baseType); - this.midData = BaseTextures.createBodyTextures("Base*Mid", baseType); - this.fMidData = BaseTextures.createBodyTextures("Base*fMid", baseType); - this.midLockData = BaseTextures.createBodyTextures("Base*MidLock", baseType); - this.fMidLockData = BaseTextures.createBodyTextures("Base*fMidLock", baseType); - this.minData = BitmapManager.getBitmapNamed(BaseTextures.getTexName("Base*Min", baseType)); + this.bodyData = BaseTextures.createBodyTextures('LBase*', baseType); + this.fBodyData = BaseTextures.createBodyTextures('LBase*f', baseType); + this.lBodyData = BaseTextures.createBodyTextures('LBase*', baseType); + this.lfBodyData = BaseTextures.createBodyTextures('LBase*f', baseType); + this.lockData = BaseTextures.createBodyTextures('Base*Lock', baseType); + this.fLockData = BaseTextures.createBodyTextures('Base*fLock', baseType); + this.midData = BaseTextures.createBodyTextures('Base*Mid', baseType); + this.fMidData = BaseTextures.createBodyTextures('Base*fMid', baseType); + this.midLockData = BaseTextures.createBodyTextures('Base*MidLock', baseType); + this.fMidLockData = BaseTextures.createBodyTextures('Base*fMidLock', baseType); + this.minData = BitmapManager.getBitmapNamed(BaseTextures.getTexName('Base*Min', baseType)); } public getBodyTexture(zoomLevel: number, flags: number): Texture { const locked: boolean = (flags & BaseDrawFlags.LOCKED) !== 0; const lettermode: boolean = (flags & BaseDrawFlags.LETTER_MODE) !== 0; - const is_dontcare: boolean = (flags & BaseDrawFlags.IS_DONTCARE) !== 0; + const isDontcare: boolean = (flags & BaseDrawFlags.IS_DONTCARE) !== 0; if (zoomLevel < Base.NUM_ZOOM_LEVELS) { if (!locked && !lettermode) { - return BaseTextures.textureForSize(is_dontcare ? this.fBodyData : this.bodyData, 0, zoomLevel); + return BaseTextures.textureForSize(isDontcare ? this.fBodyData : this.bodyData, 0, zoomLevel); } else if (!locked) { - return BaseTextures.textureForSize(is_dontcare ? this.lfBodyData : this.lBodyData, 0, zoomLevel); + return BaseTextures.textureForSize(isDontcare ? this.lfBodyData : this.lBodyData, 0, zoomLevel); } else { - return BaseTextures.textureForSize(is_dontcare ? this.fLockData : this.lockData, 0, zoomLevel); + return BaseTextures.textureForSize(isDontcare ? this.fLockData : this.lockData, 0, zoomLevel); } } else if (zoomLevel < Base.NUM_ZOOM_LEVELS * 2) { if (!locked) { - return BaseTextures.textureForSize(is_dontcare ? this.fMidData : this.midData, 0, zoomLevel - Base.NUM_ZOOM_LEVELS); + return BaseTextures.textureForSize( + isDontcare ? this.fMidData : this.midData, 0, zoomLevel - Base.NUM_ZOOM_LEVELS + ); } else { - return BaseTextures.textureForSize(is_dontcare ? this.fMidLockData : this.midLockData, 0, zoomLevel - Base.NUM_ZOOM_LEVELS); + return BaseTextures.textureForSize( + isDontcare ? this.fMidLockData : this.midLockData, 0, zoomLevel - Base.NUM_ZOOM_LEVELS + ); } } else { return this.minData; @@ -82,8 +86,9 @@ export default class BaseTextures { } private static createLetterTextures(baseType: number, zoomScalar: number): Texture[] { - let big_letter: Text = Fonts.arial(BaseTextures.type2Letter(baseType)).fontSize(18).bold().color(0x0).build(); - let textures: Texture[] = [TextureUtil.renderToTexture(big_letter)]; + let bigLetter: Text = Fonts.arial(BaseTextures.type2Letter(baseType)).fontSize(18).bold().color(0x0) + .build(); + let textures: Texture[] = [TextureUtil.renderToTexture(bigLetter)]; EternaTextureUtil.createScaled(textures, zoomScalar, Base.NUM_ZOOM_LEVELS); return textures; } @@ -101,25 +106,25 @@ export default class BaseTextures { private static type2Letter(baseType: number): string { switch (baseType) { - case EPars.RNABASE_URACIL: - return "U"; - case EPars.RNABASE_ADENINE: - return "A"; - case EPars.RNABASE_GUANINE: - return "G"; - case EPars.RNABASE_CYTOSINE: - return "C"; - default: - throw new Error("Bad baseType: " + baseType); + case EPars.RNABASE_URACIL: + return 'U'; + case EPars.RNABASE_ADENINE: + return 'A'; + case EPars.RNABASE_GUANINE: + return 'G'; + case EPars.RNABASE_CYTOSINE: + return 'C'; + default: + throw new Error(`Bad baseType: ${baseType}`); } } - private static textureForSize(textures: Texture[], ii: number, size_num: number): Texture { + private static textureForSize(textures: Texture[], ii: number, sizeNum: number): Texture { if (textures.length % Base.NUM_ZOOM_LEVELS !== 0) { - throw new Error("Invalid textures array length " + textures.length); + throw new Error(`Invalid textures array length ${textures.length}`); } let origLength: number = textures.length / Base.NUM_ZOOM_LEVELS; - return textures[(origLength * size_num + ii)]; + return textures[(origLength * sizeNum + ii)]; } } diff --git a/src/eterna/pose2D/EnergyScoreDisplay.ts b/src/eterna/pose2D/EnergyScoreDisplay.ts index 833822976..cc6857ce0 100644 --- a/src/eterna/pose2D/EnergyScoreDisplay.ts +++ b/src/eterna/pose2D/EnergyScoreDisplay.ts @@ -1,8 +1,8 @@ -import MultiStyleText from "pixi-multistyle-text"; -import {Container, Graphics, Point} from "pixi.js"; -import {HAlign} from "flashbang/core"; -import {VLayoutContainer} from "flashbang/layout"; -import {Fonts} from "eterna/util"; +import MultiStyleText from 'pixi-multistyle-text'; +import {Container, Graphics, Point} from 'pixi.js'; +import {HAlign} from 'flashbang/core'; +import {VLayoutContainer} from 'flashbang/layout'; +import {Fonts} from 'eterna/util'; export default class EnergyScoreDisplay extends Container { public static grey(text: string): string { @@ -17,7 +17,7 @@ export default class EnergyScoreDisplay extends Container { return `${text}`; } - public constructor(width: number, height: number) { + constructor(width: number, height: number) { super(); this._width = width; @@ -29,27 +29,27 @@ export default class EnergyScoreDisplay extends Container { let textLayout: VLayoutContainer = new VLayoutContainer(2, HAlign.LEFT); - this._labelText = new MultiStyleText("Total", { - "default": { + this._labelText = new MultiStyleText('Total', { + default: { fontFamily: Fonts.STDFONT_REGULAR, fontSize: 11, - fill: 0xffffff, + fill: 0xffffff }, - "grey": { fill: 0x777777 }, - "green": { fill: 0x33AA33 }, - "red": { fill: 0xFF4747 } + grey: {fill: 0x777777}, + green: {fill: 0x33AA33}, + red: {fill: 0xFF4747} }); textLayout.addChild(this._labelText); - this._energyText = new MultiStyleText("5.2 kcal", { - "default": { + this._energyText = new MultiStyleText('5.2 kcal', { + default: { fontFamily: Fonts.STDFONT_MEDIUM, fontSize: 13, - fill: 0xffffff, + fill: 0xffffff }, - "grey": { fill: 0x777777 }, - "green": { fill: 0x33AA33 }, - "red": { fill: 0xFF4747 } + grey: {fill: 0x777777}, + green: {fill: 0x33AA33}, + red: {fill: 0xFF4747} }); textLayout.addChild(this._energyText); @@ -57,12 +57,12 @@ export default class EnergyScoreDisplay extends Container { textLayout.position = new Point(5, 4); this.addChild(textLayout); - this.setEnergyText("", ""); + this.setEnergyText('', ''); } public get hasText(): boolean { - return (this._labelText.text.length > 0 && this._labelText.text != " ") || - (this._energyText.text.length > 0 && this._energyText.text != " "); + return (this._labelText.text.length > 0 && this._labelText.text !== ' ') + || (this._energyText.text.length > 0 && this._energyText.text !== ' '); } public setEnergyText(label: string, energy: string): void { @@ -91,5 +91,5 @@ export default class EnergyScoreDisplay extends Container { private readonly _bg: Graphics; private _width: number; - private _height :number; + private _height: number; } diff --git a/src/eterna/pose2D/ExplosionFactorPanel.ts b/src/eterna/pose2D/ExplosionFactorPanel.ts index fddff58d6..f746b5925 100644 --- a/src/eterna/pose2D/ExplosionFactorPanel.ts +++ b/src/eterna/pose2D/ExplosionFactorPanel.ts @@ -1,13 +1,13 @@ -import {Point, Text} from "pixi.js"; -import {Signal} from "signals"; -import {KeyCode} from "flashbang/input"; -import {GameButton, GamePanel, TextInputObject} from "eterna/ui"; -import {Fonts} from "eterna/util"; +import {Point, Text} from 'pixi.js'; +import {Signal} from 'signals'; +import {KeyCode} from 'flashbang/input'; +import {GameButton, GamePanel, TextInputObject} from 'eterna/ui'; +import {Fonts} from 'eterna/util'; export default class ExplosionFactorPanel extends GamePanel { public readonly factorUpdated: Signal = new Signal(); - public constructor() { + constructor() { super(); this.setup(0, 1.0, 0x152843, 0.27, 0xC0DCE7); @@ -30,45 +30,45 @@ export default class ExplosionFactorPanel extends GamePanel { input.text = '1'; input.display.position = new Point(widthWalker, heightWalker); this.addObject(input, this.container); - input.valueChanged.connect(val => { + input.valueChanged.connect((val) => { let factor = parseFloat(val); - if (isNaN(factor)) return; + if (Number.isNaN(factor)) return; if (factor < 0) return; this.factorUpdated.emit(factor); }); - widthWalker += /*input.width*/ 50 + 5; + widthWalker += /* input.width */ 50 + 5; let decreaseButton: GameButton = new GameButton().label('-', 16); decreaseButton.display.position = new Point(widthWalker, heightWalker); this.addObject(decreaseButton, this.container); decreaseButton.clicked.connect(() => { - let factor = Math.max(0, Math.round((parseFloat(input.text) - 0.25)*1000)/1000); - input.text = (isNaN(factor) ? 1 : factor).toString(); + let factor = Math.max(0, Math.round((parseFloat(input.text) - 0.25) * 1000) / 1000); + input.text = (Number.isNaN(factor) ? 1 : factor).toString(); this.factorUpdated.emit(parseFloat(input.text)); }); decreaseButton.hotkey(KeyCode.BracketLeft); decreaseButton.tooltip('Decrease space between paired bases ([)'); - widthWalker += /*decreaseButton.container.width*/20 + 5; + widthWalker += /* decreaseButton.container.width */20 + 5; let increaseButton: GameButton = new GameButton().label('+', 16); increaseButton.display.position = new Point(widthWalker, heightWalker); this.addObject(increaseButton, this.container); increaseButton.clicked.connect(() => { - let factor = Math.max(0, Math.round((parseFloat(input.text)+ 0.25)*1000)/1000); - input.text = (isNaN(factor) ? 1 : factor).toString(); + let factor = Math.max(0, Math.round((parseFloat(input.text) + 0.25) * 1000) / 1000); + input.text = (Number.isNaN(factor) ? 1 : factor).toString(); this.factorUpdated.emit(parseFloat(input.text)); }); increaseButton.hotkey(KeyCode.BracketRight); increaseButton.tooltip('Increase space between paired bases (])'); // Prevent PoseField from adding a drag surface over our buttons when we're trying to click, not drag - decreaseButton.pointerDown.connect((e) => e.stopPropagation()); - increaseButton.pointerDown.connect((e) => e.stopPropagation()); + decreaseButton.pointerDown.connect(e => e.stopPropagation()); + increaseButton.pointerDown.connect(e => e.stopPropagation()); - widthWalker += /*increaseButton.container.width*/20; - heightWalker += /*increaseButton.container.height*/26; + widthWalker += /* increaseButton.container.width */20; + heightWalker += /* increaseButton.container.height */26; this.setSize( Math.max(label.width, widthWalker + ExplosionFactorPanel.WMARGIN), diff --git a/src/eterna/pose2D/HighlightBox.ts b/src/eterna/pose2D/HighlightBox.ts index 72371a45b..6ac99807f 100644 --- a/src/eterna/pose2D/HighlightBox.ts +++ b/src/eterna/pose2D/HighlightBox.ts @@ -1,8 +1,9 @@ -import {DisplayObject, Graphics, Point} from "pixi.js"; -import {GameObject, LateUpdatable, ObjectTask} from "flashbang/core"; -import {Vector2} from "flashbang/geom"; -import {AlphaTask, RepeatingTask, SerialTask} from "flashbang/tasks"; -import Pose2D from "./Pose2D"; +import {DisplayObject, Graphics, Point} from 'pixi.js'; +import {GameObject, LateUpdatable, ObjectTask} from 'flashbang/core'; +import {Vector2} from 'flashbang/geom'; +import {AlphaTask, RepeatingTask, SerialTask} from 'flashbang/tasks'; +import {Assert} from 'flashbang/util'; +import Pose2D from './Pose2D'; export enum HighlightType { STACK = 0, @@ -18,7 +19,7 @@ export enum HighlightType { /** A class for highlighting groups of bases in a Pose2D */ export default class HighlightBox extends GameObject implements LateUpdatable { - public constructor(pose: Pose2D) { + constructor(pose: Pose2D) { super(); this._pose = pose; this._graphics = new Graphics(); @@ -45,12 +46,12 @@ export default class HighlightBox extends GameObject implements LateUpdatable { this._on = on; } - public get enabled() :boolean { + public get enabled(): boolean { return this._enabled; } public set enabled(value: boolean) { - if (value === this._enabled){ + if (value === this._enabled) { return; } @@ -87,9 +88,8 @@ export default class HighlightBox extends GameObject implements LateUpdatable { public isInQueue(basenum: number): boolean { if (this._queue == null) return false; - for (let ii: number = 1; ii < this._queue.length; ii += 2) { - if (basenum >= this._queue[ii] && basenum <= this._queue[ii + 1]) - return true; + for (let ii = 1; ii < this._queue.length; ii += 2) { + if (basenum >= this._queue[ii] && basenum <= this._queue[ii + 1]) return true; } return false; } @@ -98,8 +98,7 @@ export default class HighlightBox extends GameObject implements LateUpdatable { if (this._pose.isAnimating || !this.enabled) { // Hide when we're disabled or the Pose is animating this.display.visible = false; - - } else { + } else { // Redraw when we're dirty or the zoom level has changed this.display.visible = true; if (this._dirty || this._pose.zoomLevel !== this._prevZoomLevel || this.basePositionChanged) { @@ -116,15 +115,15 @@ export default class HighlightBox extends GameObject implements LateUpdatable { return false; } - let pos: Point = this._pose.getBaseXY(this._queue[1], HighlightBox.P); + let pos: Point = this._pose.getBaseLoc(this._queue[1], HighlightBox.P); return this._prevPosition.x !== pos.x || this._prevPosition.y !== pos.y; } private redraw(): void { let color: number; - let base_size: number; - let fadeTime: number = 0.85; - let zoom_level: number = this._pose.zoomLevel; + let baseSize: number; + let fadeTime = 0.85; + let zoomLevel: number = this._pose.zoomLevel; this.display.alpha = 0; this.display.visible = true; @@ -134,65 +133,65 @@ export default class HighlightBox extends GameObject implements LateUpdatable { return; } - this._prevPosition = this._pose.getBaseXY(this._queue[1], this._prevPosition); + this._prevPosition = this._pose.getBaseLoc(this._queue[1], this._prevPosition); this._lastKnownQueue = this._queue; let type: HighlightType = this._queue[0]; if (type === HighlightType.STACK) { - base_size = 25; - } else if (zoom_level === 0) { - base_size = 18; - } else if (zoom_level === 1) { - base_size = 14; - } else if (zoom_level === 2) { - base_size = 10; - } else if (zoom_level === 3) { - base_size = 7; + baseSize = 25; + } else if (zoomLevel === 0) { + baseSize = 18; + } else if (zoomLevel === 1) { + baseSize = 14; + } else if (zoomLevel === 2) { + baseSize = 10; + } else if (zoomLevel === 3) { + baseSize = 7; } else { - base_size = 4; + baseSize = 4; } switch (type) { - case HighlightType.STACK: - color = 0xFFFFFF; - break; - case HighlightType.LOOP: - color = 0xFF0000; - break; - case HighlightType.RESTRICTED: - color = 0xFFFF7E; - break; - case HighlightType.FORCED: - color = 0x00FF00; - break; - case HighlightType.DESIGN: - color = 0x7EFFFF; - break; - case HighlightType.UNSTABLE: - color = 0xFF0000; - break; - case HighlightType.SHIFT: - color = 0xC0C0C0; - break; - case HighlightType.USER_DEFINED: - color = 0x32CD32; - fadeTime = 1.0; - break; + case HighlightType.STACK: + color = 0xFFFFFF; + break; + case HighlightType.LOOP: + color = 0xFF0000; + break; + case HighlightType.RESTRICTED: + color = 0xFFFF7E; + break; + case HighlightType.FORCED: + color = 0x00FF00; + break; + case HighlightType.DESIGN: + color = 0x7EFFFF; + break; + case HighlightType.UNSTABLE: + color = 0xFF0000; + break; + case HighlightType.SHIFT: + color = 0xC0C0C0; + break; + case HighlightType.USER_DEFINED: + color = 0x32CD32; + fadeTime = 1.0; + break; + default: + Assert.unreachable(type); } if (type === HighlightType.STACK) { - this.renderStack(color, base_size); + this.renderStack(color, baseSize); } else { - this.renderLoop(color, base_size); + this.renderLoop(color, baseSize); } - this.replaceNamedObject(HighlightBox.ANIM, new RepeatingTask((): ObjectTask => { - return new SerialTask( - new AlphaTask(1, fadeTime), - new AlphaTask(0.2, fadeTime) - ); - })); + this.replaceNamedObject(HighlightBox.ANIM, new RepeatingTask((): ObjectTask => new SerialTask( + new AlphaTask(1, fadeTime), + new AlphaTask(0.2, fadeTime) + ))); this._on = true; } @@ -200,126 +199,146 @@ export default class HighlightBox extends GameObject implements LateUpdatable { private renderStack(color: number, baseSize: number): void { let pairs: number[] = this._pose.pairs; - for (let ii: number = 1; ii < this._queue.length; ii += 2) { - let stack_start: number = this._queue[ii]; - let stack_end: number = this._queue[ii + 1]; + for (let ii = 1; ii < this._queue.length; ii += 2) { + let stackStart: number = this._queue[ii]; + let stackEnd: number = this._queue[ii + 1]; - if (pairs[stack_start] < 0 || pairs[stack_end] < 0) { - throw new Error("Invalid stack highlight from " + stack_start.toString() + " to " + stack_end.toString()); + if (pairs[stackStart] < 0 || pairs[stackEnd] < 0) { + throw new Error(`Invalid stack highlight from ${stackStart.toString()} to ${stackEnd.toString()}`); } - let p0: Point = this._pose.getBaseXY(stack_start); - let p1: Point = this._pose.getBaseXY(pairs[stack_end]); + let p0: Point = this._pose.getBaseLoc(stackStart); + let p1: Point = this._pose.getBaseLoc(pairs[stackEnd]); - let max_x: number = Math.max(p0.x, p1.x); - let min_x: number = Math.min(p0.x, p1.x); + let maxX = Math.max(p0.x, p1.x); + let minX = Math.min(p0.x, p1.x); - let max_y: number = Math.max(p0.y, p1.y); - let min_y: number = Math.min(p0.y, p1.y); + let maxY = Math.max(p0.y, p1.y); + let minY = Math.min(p0.y, p1.y); this._graphics.lineStyle(5, color, 0.7); this._graphics.drawRoundedRect( - min_x - baseSize, - min_y - baseSize, - max_x - min_x + 2 * baseSize, - max_y - min_y + 2 * baseSize, 10); + minX - baseSize, + minY - baseSize, + maxX - minX + 2 * baseSize, + maxY - minY + 2 * baseSize, 10 + ); } } - private renderLoop(_color: number, base_size: number): void { + private renderLoop(_color: number, baseSize: number): void { let pairs: number[] = this._pose.pairs; - let full_len: number = this._pose.fullSequence.length; + let fullLen: number = this._pose.fullSequence.length; let strict: boolean = (this._queue[0] === HighlightType.LOOP); - for (let i: number = 1; i < this._queue.length; i += 2) { - let loop_start: number = this._queue[i]; - let loop_end: number = this._queue[i + 1]; + for (let i = 1; i < this._queue.length; i += 2) { + let loopStart: number = this._queue[i]; + let loopEnd: number = this._queue[i + 1]; - if (strict && (pairs[loop_start] >= 0 || pairs[loop_end] >= 0)) { - throw new Error("Invalid loop highlight from " + loop_start.toString() + " to " + loop_end.toString()); + if (strict && (pairs[loopStart] >= 0 || pairs[loopEnd] >= 0)) { + throw new Error(`Invalid loop highlight from ${loopStart.toString()} to ${loopEnd.toString()}`); } let axes: Point[] = []; - let base_xy: Point; + let baseLoc: Point; - let start_from: Point = new Point; - let end_to: Point = new Point; + let startFrom: Point = new Point(); + let endTo: Point = new Point(); - for (let ii: number = loop_start; ii <= loop_end; ii++) { - let num_gos: number = 0; + for (let ii: number = loopStart; ii <= loopEnd; ii++) { + let numGos = 0; let axis: Vector2 = new Vector2(0, 0); - base_xy = this._pose.getBaseXY(ii); + baseLoc = this._pose.getBaseLoc(ii); if (ii > 0) { - let prev_base_xy: Point = this._pose.getBaseXY(ii - 1); - let from_prev: Vector2 = new Vector2((base_xy.x - prev_base_xy.x), (base_xy.y - prev_base_xy.y)); - from_prev.normalizeLocal(); - axis.x += from_prev.x; - axis.y += from_prev.y; - num_gos++; - - if (ii === loop_start) { - start_from.x = from_prev.x; - start_from.y = from_prev.y; + let prevBaseLoc: Point = this._pose.getBaseLoc(ii - 1); + let fromPrev: Vector2 = new Vector2((baseLoc.x - prevBaseLoc.x), (baseLoc.y - prevBaseLoc.y)); + fromPrev.normalizeLocal(); + axis.x += fromPrev.x; + axis.y += fromPrev.y; + numGos++; + + if (ii === loopStart) { + startFrom.x = fromPrev.x; + startFrom.y = fromPrev.y; } - if (ii === loop_end && ii === full_len - 1) { - end_to.x = from_prev.x; - end_to.y = from_prev.y; + if (ii === loopEnd && ii === fullLen - 1) { + endTo.x = fromPrev.x; + endTo.y = fromPrev.y; } } - if (ii < full_len - 1) { - let next_base_xy: Point = this._pose.getBaseXY(ii + 1); - let to_next: Vector2 = new Vector2((next_base_xy.x - base_xy.x), (next_base_xy.y - base_xy.y)); - to_next.normalizeLocal(); - axis.x += to_next.x; - axis.y += to_next.y; - num_gos++; - - if (ii === loop_start) { - start_from.x = to_next.x; - start_from.y = to_next.y; + if (ii < fullLen - 1) { + let nextBaseLoc: Point = this._pose.getBaseLoc(ii + 1); + let toNext = new Vector2((nextBaseLoc.x - baseLoc.x), (nextBaseLoc.y - baseLoc.y)); + toNext.normalizeLocal(); + axis.x += toNext.x; + axis.y += toNext.y; + numGos++; + + if (ii === loopStart) { + startFrom.x = toNext.x; + startFrom.y = toNext.y; } - if (ii === loop_end) { - end_to.x = to_next.x; - end_to.y = to_next.y; + if (ii === loopEnd) { + endTo.x = toNext.x; + endTo.y = toNext.y; } } - if (num_gos === 0) { - throw new Error("Something wrong with loop highlight!"); + if (numGos === 0) { + throw new Error('Something wrong with loop highlight!'); } axis.normalizeLocal(); axes.push(new Point(axis.y, -axis.x)); } - let loop_start_xy: Point = this._pose.getBaseXY(loop_start); - let loop_end_xy: Point = this._pose.getBaseXY(loop_end); - let loop_start_axis: Point = axes[0]; - let loop_end_axis: Point = axes[loop_end - loop_start]; + let loopStartLoc: Point = this._pose.getBaseLoc(loopStart); + let loopEndLoc: Point = this._pose.getBaseLoc(loopEnd); + let loopStartAxis: Point = axes[0]; + let loopEndAxis: Point = axes[loopEnd - loopStart]; this._graphics.lineStyle(5, _color, 0.7); - this._graphics.moveTo(loop_start_xy.x + loop_start_axis.x * base_size - start_from.x * base_size, loop_start_xy.y + loop_start_axis.y * base_size - start_from.y * base_size); + this._graphics.moveTo( + loopStartLoc.x + loopStartAxis.x * baseSize - startFrom.x * baseSize, + loopStartLoc.y + loopStartAxis.y * baseSize - startFrom.y * baseSize + ); - for (let ii = loop_start; ii <= loop_end; ii++) { - base_xy = this._pose.getBaseXY(ii); - this._graphics.lineTo(base_xy.x + axes[ii - loop_start].x * base_size, base_xy.y + axes[ii - loop_start].y * base_size); + for (let ii = loopStart; ii <= loopEnd; ii++) { + baseLoc = this._pose.getBaseLoc(ii); + this._graphics.lineTo( + baseLoc.x + axes[ii - loopStart].x * baseSize, baseLoc.y + axes[ii - loopStart].y * baseSize + ); } if (this._queue[0] !== HighlightType.USER_DEFINED) { - this._graphics.lineTo(loop_end_xy.x + loop_end_axis.x * base_size + end_to.x * base_size, loop_end_xy.y + loop_end_axis.y * base_size + end_to.y * base_size); - this._graphics.lineTo(loop_end_xy.x - loop_end_axis.x * base_size + end_to.x * base_size, loop_end_xy.y - loop_end_axis.y * base_size + end_to.y * base_size); - - for (let ii = loop_end; ii >= loop_start; ii--) { - base_xy = this._pose.getBaseXY(ii); - this._graphics.lineTo(base_xy.x - axes[ii - loop_start].x * base_size, base_xy.y - axes[ii - loop_start].y * base_size); + this._graphics.lineTo( + loopEndLoc.x + loopEndAxis.x * baseSize + endTo.x * baseSize, + loopEndLoc.y + loopEndAxis.y * baseSize + endTo.y * baseSize + ); + this._graphics.lineTo( + loopEndLoc.x - loopEndAxis.x * baseSize + endTo.x * baseSize, + loopEndLoc.y - loopEndAxis.y * baseSize + endTo.y * baseSize + ); + + for (let ii = loopEnd; ii >= loopStart; ii--) { + baseLoc = this._pose.getBaseLoc(ii); + this._graphics.lineTo( + baseLoc.x - axes[ii - loopStart].x * baseSize, baseLoc.y - axes[ii - loopStart].y * baseSize + ); } - this._graphics.lineTo(loop_start_xy.x - loop_start_axis.x * base_size - start_from.x * base_size, loop_start_xy.y - loop_start_axis.y * base_size - start_from.y * base_size); - this._graphics.lineTo(loop_start_xy.x + loop_start_axis.x * base_size - start_from.x * base_size, loop_start_xy.y + loop_start_axis.y * base_size - start_from.y * base_size); + this._graphics.lineTo( + loopStartLoc.x - loopStartAxis.x * baseSize - startFrom.x * baseSize, + loopStartLoc.y - loopStartAxis.y * baseSize - startFrom.y * baseSize + ); + this._graphics.lineTo( + loopStartLoc.x + loopStartAxis.x * baseSize - startFrom.x * baseSize, + loopStartLoc.y + loopStartAxis.y * baseSize - startFrom.y * baseSize + ); } } } @@ -335,5 +354,5 @@ export default class HighlightBox extends GameObject implements LateUpdatable { private _prevPosition: Point; private _prevZoomLevel: number = -1; - private static readonly ANIM = "anim"; + private static readonly ANIM = 'anim'; } diff --git a/src/eterna/pose2D/Molecule.ts b/src/eterna/pose2D/Molecule.ts index 5e0fbfaea..382fa1c30 100644 --- a/src/eterna/pose2D/Molecule.ts +++ b/src/eterna/pose2D/Molecule.ts @@ -1,9 +1,11 @@ -import {Container, Point, Sprite, Texture} from "pixi.js"; -import {BitmapManager, Bitmaps} from "eterna/resources"; -import {EternaTextureUtil, int} from "eterna/util"; +import { + Container, Point, Sprite, Texture +} from 'pixi.js'; +import {BitmapManager, Bitmaps} from 'eterna/resources'; +import {EternaTextureUtil, int} from 'eterna/util'; export default class Molecule extends Container { - public constructor() { + constructor() { super(); Molecule.initTextures(); @@ -29,15 +31,19 @@ export default class Molecule extends Container { prog = Math.max(0, prog); let progInd = int(int(prog / 2.0 * Molecule.NUM_ANIMATION_STEPS) % Molecule.NUM_ANIMATION_STEPS); - let glowTex = this._isWrong ? - Molecule._glowWrongTex[zoomLevel][progInd] : - Molecule._glowTex[zoomLevel][progInd]; + let glowTex = this._isWrong + ? Molecule._glowWrongTex[zoomLevel][progInd] + : Molecule._glowTex[zoomLevel][progInd]; this._glow.texture = glowTex; this._glow.pivot.x = glowTex.width * 0.5; this._glow.pivot.y = glowTex.height * 0.5; - progInd = int(int(elapsedTime / Molecule.BODY_ANIMATION_SPAN * Molecule.NUM_ANIMATION_STEPS) % Molecule.NUM_ANIMATION_STEPS); + progInd = int( + int( + elapsedTime / Molecule.BODY_ANIMATION_SPAN * Molecule.NUM_ANIMATION_STEPS + ) % Molecule.NUM_ANIMATION_STEPS + ); let bodyTex = Molecule._bodyTex[zoomLevel][progInd]; this._body.texture = bodyTex; @@ -74,7 +80,8 @@ export default class Molecule extends Container { for (let ii = 0; ii < Molecule.NUM_ANIMATION_STEPS; ii++) { let glowTex = EternaTextureUtil.colorTransformAlpha( - scaledGlowTex, 255, 255, 255, 1.0 - (ii / Molecule.NUM_ANIMATION_STEPS) * 0.5, 0, 0, 0, 0); + scaledGlowTex, 255, 255, 255, 1.0 - (ii / Molecule.NUM_ANIMATION_STEPS) * 0.5, 0, 0, 0, 0 + ); texturesInZoom.push(glowTex); let wrongGlowTex = EternaTextureUtil.colorTransform(glowTex, 255, 0, 0, 0, 0, 0); @@ -105,5 +112,4 @@ export default class Molecule extends Container { private static readonly NUM_ANIMATION_STEPS: number = 60; private static readonly ANIMATION_SPAN: number = 1.1; private static readonly BODY_ANIMATION_SPAN: number = 2.2; - } diff --git a/src/eterna/pose2D/PaintCursor.ts b/src/eterna/pose2D/PaintCursor.ts index 5f45cce12..d4c606d27 100644 --- a/src/eterna/pose2D/PaintCursor.ts +++ b/src/eterna/pose2D/PaintCursor.ts @@ -1,16 +1,16 @@ -import {Graphics, DisplayObject} from "pixi.js"; -import {Flashbang, GameObject, Updatable} from "flashbang/core"; -import EPars from "eterna/EPars"; +import {Graphics, DisplayObject} from 'pixi.js'; +import {Flashbang, GameObject, Updatable} from 'flashbang/core'; +import EPars from 'eterna/EPars'; export default class PaintCursor extends GameObject implements Updatable { - public constructor() { + constructor() { super(); this._graphics = new Graphics(); this._color = PaintCursor.WHITE; this._outColor = PaintCursor.NULL; } - /*override*/ + /* override */ public get display(): DisplayObject { return this._graphics; } @@ -21,55 +21,55 @@ export default class PaintCursor extends GameObject implements Updatable { public setShape(shape: number): void { switch (shape) { - case EPars.RNABASE_ADENINE: - this._color = PaintCursor.YELLOW; - this._outColor = PaintCursor.NULL; - break; - - case EPars.RNABASE_URACIL: - this._color = PaintCursor.BLUE; - this._outColor = PaintCursor.NULL; - break; - - case EPars.RNABASE_DELETE: - case EPars.RNABASE_GUANINE: - this._color = PaintCursor.RED; - this._outColor = PaintCursor.NULL; - break; - - case EPars.RNABASE_CYTOSINE: - this._color = PaintCursor.GREEN; - this._outColor = PaintCursor.NULL; - break; - - case EPars.RNABASE_AU_PAIR: - this._color = PaintCursor.YELLOW; - this._outColor = PaintCursor.BLUE; - break; - - case EPars.RNABASE_GU_PAIR: - this._color = PaintCursor.BLUE; - this._outColor = PaintCursor.RED; - break; - - case EPars.RNABASE_GC_PAIR: - this._color = PaintCursor.RED; - this._outColor = PaintCursor.GREEN; - break; - - case EPars.RNABASE_ADD_BASE: - case EPars.RNABASE_ADD_PAIR: - this._color = PaintCursor.YELLOW; - this._outColor = PaintCursor.NULL; - break; - - default: - this._color = PaintCursor.WHITE; - this._outColor = PaintCursor.NULL; + case EPars.RNABASE_ADENINE: + this._color = PaintCursor.YELLOW; + this._outColor = PaintCursor.NULL; + break; + + case EPars.RNABASE_URACIL: + this._color = PaintCursor.BLUE; + this._outColor = PaintCursor.NULL; + break; + + case EPars.RNABASE_DELETE: + case EPars.RNABASE_GUANINE: + this._color = PaintCursor.RED; + this._outColor = PaintCursor.NULL; + break; + + case EPars.RNABASE_CYTOSINE: + this._color = PaintCursor.GREEN; + this._outColor = PaintCursor.NULL; + break; + + case EPars.RNABASE_AU_PAIR: + this._color = PaintCursor.YELLOW; + this._outColor = PaintCursor.BLUE; + break; + + case EPars.RNABASE_GU_PAIR: + this._color = PaintCursor.BLUE; + this._outColor = PaintCursor.RED; + break; + + case EPars.RNABASE_GC_PAIR: + this._color = PaintCursor.RED; + this._outColor = PaintCursor.GREEN; + break; + + case EPars.RNABASE_ADD_BASE: + case EPars.RNABASE_ADD_PAIR: + this._color = PaintCursor.YELLOW; + this._outColor = PaintCursor.NULL; + break; + + default: + this._color = PaintCursor.WHITE; + this._outColor = PaintCursor.NULL; } } - /*override*/ + /* override */ public update(dt: number): void { this._graphics.clear(); @@ -114,4 +114,3 @@ export default class PaintCursor extends GameObject implements Updatable { private static readonly GREY = 0xC0C0C0; private static readonly NULL = 0x0; } - diff --git a/src/eterna/pose2D/Pose2D.ts b/src/eterna/pose2D/Pose2D.ts index bc54ebda4..dbf286239 100644 --- a/src/eterna/pose2D/Pose2D.ts +++ b/src/eterna/pose2D/Pose2D.ts @@ -1,42 +1,44 @@ -import * as log from "loglevel"; -import {Container, Graphics, Point, Sprite, Texture, Rectangle} from "pixi.js"; -import {Flashbang, Updatable} from "flashbang/core"; -import {Vector2} from "flashbang/geom"; -import {InputUtil} from "flashbang/input"; -import {ContainerObject, SceneObject, Dragger} from "flashbang/objects"; +import * as log from 'loglevel'; +import { + Container, Graphics, Point, Sprite, Texture, Rectangle +} from 'pixi.js'; +import {Flashbang, Updatable} from 'flashbang/core'; +import {Vector2} from 'flashbang/geom'; +import {InputUtil} from 'flashbang/input'; +import {ContainerObject, SceneObject, Dragger} from 'flashbang/objects'; import { AlphaTask, DelayTask, LocationTask, ParallelTask, RepeatingTask, SelfDestructTask, SerialTask -} from "flashbang/tasks"; -import {Arrays, DisplayUtil, Easing} from "flashbang/util"; -import {Registration} from "signals"; -import EPars from "eterna/EPars"; -import Eterna from "eterna/Eterna"; -import ExpPainter from "eterna/ExpPainter"; -import {Folder} from "eterna/folding"; -import {GameMode} from "eterna/mode"; -import {Booster} from "eterna/mode/PoseEdit"; -import {BitmapManager, Sounds} from "eterna/resources"; -import {ROPWait} from "eterna/rscript"; -import {TextBalloon} from "eterna/ui"; -import {Fonts, Utility} from "eterna/util"; -import {BaseGlow, LightRay} from "eterna/vfx"; -import Base from "./Base"; -import BaseDrawFlags from "./BaseDrawFlags"; -import EnergyScoreDisplay from "./EnergyScoreDisplay"; -import HighlightBox, {HighlightType} from "./HighlightBox"; -import Molecule from "./Molecule"; -import PaintCursor from "./PaintCursor"; -import PoseField from "./PoseField"; -import PoseUtil from "./PoseUtil"; -import PuzzleEditOp from "./PuzzleEditOp"; -import RNAAnchorObject from "./RNAAnchorObject"; -import RNALayout, {RNATreeNode} from "./RNALayout"; -import ScoreDisplayNode, {ScoreDisplayNodeType} from "./ScoreDisplayNode"; -import ExplosionFactorPanel from "./ExplosionFactorPanel"; +} from 'flashbang/tasks'; +import {Arrays, DisplayUtil, Easing} from 'flashbang/util'; +import {Registration} from 'signals'; +import EPars from 'eterna/EPars'; +import Eterna from 'eterna/Eterna'; +import ExpPainter from 'eterna/ExpPainter'; +import {Folder} from 'eterna/folding'; +import {GameMode} from 'eterna/mode'; +import {Booster} from 'eterna/mode/PoseEdit'; +import {BitmapManager, Sounds} from 'eterna/resources'; +import {ROPWait} from 'eterna/rscript'; +import {TextBalloon} from 'eterna/ui'; +import {Fonts, Utility} from 'eterna/util'; +import {BaseGlow, LightRay} from 'eterna/vfx'; +import Base from './Base'; +import BaseDrawFlags from './BaseDrawFlags'; +import EnergyScoreDisplay from './EnergyScoreDisplay'; +import HighlightBox, {HighlightType} from './HighlightBox'; +import Molecule from './Molecule'; +import PaintCursor from './PaintCursor'; +import PoseField from './PoseField'; +import PoseUtil from './PoseUtil'; +import PuzzleEditOp from './PuzzleEditOp'; +import RNAAnchorObject from './RNAAnchorObject'; +import RNALayout, {RNATreeNode} from './RNALayout'; +import ScoreDisplayNode, {ScoreDisplayNodeType} from './ScoreDisplayNode'; +import ExplosionFactorPanel from './ExplosionFactorPanel'; type InteractionEvent = PIXI.interaction.InteractionEvent; -export type PoseMouseDownCallback = (e: InteractionEvent, closest_dist: number, closest_index: number) => void; +export type PoseMouseDownCallback = (e: InteractionEvent, closestDist: number, closestIndex: number) => void; export default class Pose2D extends ContainerObject implements Updatable { public static readonly COLOR_CURSOR: number = 0xFFC0CB; @@ -71,7 +73,7 @@ export default class Pose2D extends ContainerObject implements Updatable { this.container.addChild(this._deltaScoreEnergyDisplay); this._secondaryScoreEnergyDisplay = new EnergyScoreDisplay(111, 40); - this._secondaryScoreEnergyDisplay.position = new Point(17 + 119*2, 118); + this._secondaryScoreEnergyDisplay.position = new Point(17 + 119 * 2, 118); this._secondaryScoreEnergyDisplay.visible = false; this.container.addChild(this._secondaryScoreEnergyDisplay); @@ -95,7 +97,7 @@ export default class Pose2D extends ContainerObject implements Updatable { this.addObject(this._paintCursor, this.container); this._explosionRays = []; - for (let ii: number = 0; ii < 10; ii++) { + for (let ii = 0; ii < 10; ii++) { let ray = new LightRay(); this._explosionRays.push(ray); this.addObject(ray, this.container); @@ -127,11 +129,11 @@ export default class Pose2D extends ContainerObject implements Updatable { this._auxInfoCanvas.visible = false; this.container.addChild(this._auxInfoCanvas); - this._auxTextballoon = new TextBalloon("", 0x0, 0.9); + this._auxTextballoon = new TextBalloon('', 0x0, 0.9); this._auxTextballoon.display.visible = false; this.addObject(this._auxTextballoon, this._auxInfoCanvas); - this._strandLabel = new TextBalloon("", 0x0, 0.8); + this._strandLabel = new TextBalloon('', 0x0, 0.8); this._strandLabel.display.visible = false; this.addObject(this._strandLabel, this.container); @@ -140,14 +142,20 @@ export default class Pose2D extends ContainerObject implements Updatable { this.pointerOut.connect(() => this.onMouseOut()); // handle view settings - this.regs.add(Eterna.settings.showNumbers.connectNotify(value => this.showNumbering = value)); - this.regs.add(Eterna.settings.showLetters.connectNotify(value => this.lettermode = value)); - this.regs.add(Eterna.settings.useContinuousColors.connectNotify(value => this.useContinuousExpColors = value)); - this.regs.add(Eterna.settings.useExtendedColors.connectNotify(value => this.useExtendedScale = value)); - this.regs.add(Eterna.settings.displayFreeEnergies.connectNotify(value => this.displayScoreTexts = value)); - this.regs.add(Eterna.settings.highlightRestricted.connectNotify(value => this.highlightRestricted = value)); - this.regs.add(Eterna.settings.displayAuxInfo.connectNotify(value => this.displayAuxInfo = value)); - this.regs.add(Eterna.settings.simpleGraphics.connectNotify(value => this.useSimpleGraphics = value)) + this.regs.add(Eterna.settings.showNumbers.connectNotify((value) => { this.showNumbering = value; })); + this.regs.add(Eterna.settings.showLetters.connectNotify((value) => { this.lettermode = value; })); + this.regs.add( + Eterna.settings.useContinuousColors.connectNotify((value) => { this.useContinuousExpColors = value; }) + ); + this.regs.add(Eterna.settings.useExtendedColors.connectNotify((value) => { this.useExtendedScale = value; })); + this.regs.add( + Eterna.settings.displayFreeEnergies.connectNotify((value) => { this.displayScoreTexts = value; }) + ); + this.regs.add( + Eterna.settings.highlightRestricted.connectNotify((value) => { this.highlightRestricted = value; }) + ); + this.regs.add(Eterna.settings.displayAuxInfo.connectNotify((value) => { this.displayAuxInfo = value; })); + this.regs.add(Eterna.settings.simpleGraphics.connectNotify((value) => { this.useSimpleGraphics = value; })); } public setSize(width: number, height: number): void { @@ -170,7 +178,7 @@ export default class Pose2D extends ContainerObject implements Updatable { } public removeAnchoredObject(obj: RNAAnchorObject): void { - for (let ii: number = 0; ii < this._anchoredObjects.length; ++ii) { + for (let ii = 0; ii < this._anchoredObjects.length; ++ii) { if (obj === this._anchoredObjects[ii]) { this._anchoredObjects.splice(ii, 1); break; @@ -186,21 +194,21 @@ export default class Pose2D extends ContainerObject implements Updatable { return (this.lastSampledTime - this._foldStartTime < this._foldDuration); } - public visualizeFeedback(dat: number[], mid: number, lo: number, hi: number, start_index: number): void { + public visualizeFeedback(dat: number[], mid: number, lo: number, hi: number, startIndex: number): void { // coloring let newdat: number[] = ExpPainter.transformData(dat, hi, lo); - this._expPainter = new ExpPainter(newdat, start_index); + this._expPainter = new ExpPainter(newdat, startIndex); this._expMid = mid; this._expHi = hi; this.paintFeedback(); // print feedback score - for (let ii: number = 0; ii < this._feedbackObjs.length; ii++) { + for (let ii = 0; ii < this._feedbackObjs.length; ii++) { this.removeObject(this._feedbackObjs[ii]); } this._feedbackObjsNum = dat.length; - this._feedbackObjsStartInd = start_index; + this._feedbackObjsStartInd = startIndex; this.printFeedback(dat); this.updatePrintFeedback(); } @@ -213,14 +221,16 @@ export default class Pose2D extends ContainerObject implements Updatable { this._expPainter.continuous = this._expContinuous; this._expPainter.extendedScale = this._expExtendedScale; - for (let ii: number = 0; ii < this._sequence.length; ii++) { - this._bases[ii].setColorLevel(true, this._expPainter.getColorLevelWithMidpoint(ii, this._expMid, this._expHi)); + for (let ii = 0; ii < this._sequence.length; ii++) { + this._bases[ii].setColorLevel( + true, this._expPainter.getColorLevelWithMidpoint(ii, this._expMid, this._expHi) + ); } this._redraw = true; } public clearFeedback(): void { - for (let ii: number = 0; ii < this._sequence.length; ii++) { + for (let ii = 0; ii < this._sequence.length; ii++) { this._bases[ii].setColorLevel(false, -1); } this._redraw = true; @@ -230,9 +240,9 @@ export default class Pose2D extends ContainerObject implements Updatable { return this._zoomLevel; } - public setZoomLevel(zoom_level: number, animate: boolean = true, center: boolean = false): void { - if ((this._zoomLevel !== zoom_level || center) && animate) { - if (this._zoomLevel === zoom_level && center) { + public setZoomLevel(zoomLevel: number, animate: boolean = true, center: boolean = false): void { + if ((this._zoomLevel !== zoomLevel || center) && animate) { + if (this._zoomLevel === zoomLevel && center) { if (Math.abs(this._width / 2 - this._offX) + Math.abs(this._height / 2 - this._offY) < 50) { return; } @@ -241,9 +251,9 @@ export default class Pose2D extends ContainerObject implements Updatable { this._startOffsetX = this._offX; this._startOffsetY = this._offY; - let scaler: number = 1; - if (zoom_level > this._zoomLevel) { - scaler = Pose2D.ZOOM_SPACINGS[zoom_level] / Pose2D.ZOOM_SPACINGS[this._zoomLevel]; + let scaler = 1; + if (zoomLevel > this._zoomLevel) { + scaler = Pose2D.ZOOM_SPACINGS[zoomLevel] / Pose2D.ZOOM_SPACINGS[this._zoomLevel]; } if (!this._offsetTranslating && !center) { @@ -259,12 +269,11 @@ export default class Pose2D extends ContainerObject implements Updatable { this._offsetTranslating = true; - this._zoomLevel = zoom_level; + this._zoomLevel = zoomLevel; this.computeLayout(true); this._redraw = true; - - } else if (this._zoomLevel !== zoom_level) { - this._zoomLevel = zoom_level; + } else if (this._zoomLevel !== zoomLevel) { + this._zoomLevel = zoomLevel; this.computeLayout(true); this._redraw = true; } @@ -275,18 +284,18 @@ export default class Pose2D extends ContainerObject implements Updatable { let xarray: number[] = new Array(n); let yarray: number[] = new Array(n); - let rna_coords: RNALayout; - rna_coords = new RNALayout(Pose2D.ZOOM_SPACINGS[0], Pose2D.ZOOM_SPACINGS[0]); - rna_coords.setupTree(this._pairs); - rna_coords.drawTree(); - rna_coords.getCoords(xarray, yarray); + let rnaCoords: RNALayout; + rnaCoords = new RNALayout(Pose2D.ZOOM_SPACINGS[0], Pose2D.ZOOM_SPACINGS[0]); + rnaCoords.setupTree(this._pairs); + rnaCoords.drawTree(); + rnaCoords.getCoords(xarray, yarray); let xmin: number = xarray[0]; let xmax: number = xarray[0]; let ymin: number = yarray[0]; let ymax: number = yarray[0]; - for (let ii: number = 0; ii < n; ii++) { + for (let ii = 0; ii < n; ii++) { if (xarray[ii] < xmin) { xmin = xarray[ii]; } @@ -334,7 +343,7 @@ export default class Pose2D extends ContainerObject implements Updatable { public doneColoring(): void { this._coloring = false; - let need_update: boolean = false; + let needUpdate = false; if (this._mutatedSequence == null) { return; @@ -344,14 +353,13 @@ export default class Pose2D extends ContainerObject implements Updatable { throw new Error("Mutated sequence and original sequence lengths don't match"); } - let num_mut: number = 0; + let numMut = 0; let muts: any[] = []; - let div: number = 1; + let div = 1; if (this._currentColor === EPars.RNABASE_PAIR || this._currentColor === EPars.RNABASE_GC_PAIR || this._currentColor === EPars.RNABASE_AU_PAIR || this._currentColor === EPars.RNABASE_GU_PAIR) { - div = 2; } @@ -359,17 +367,17 @@ export default class Pose2D extends ContainerObject implements Updatable { let ii: number; for (ii = 0; ii < this._sequence.length; ii++) { if (this._sequence[ii] !== this._mutatedSequence[ii + ofs]) { - num_mut++; + numMut++; this._sequence[ii] = this._mutatedSequence[ii + ofs]; muts.push({pos: ii + 1, base: EPars.sequenceToString([this._sequence[ii]])}); - need_update = true; + needUpdate = true; } } - if (need_update) { - this.callTrackMovesCallback(num_mut / div, muts); + if (needUpdate) { + this.callTrackMovesCallback(numMut / div, muts); } - if (need_update || this._lockUpdated || this._bindingSiteUpdated || this._designStructUpdated) { + if (needUpdate || this._lockUpdated || this._bindingSiteUpdated || this._designStructUpdated) { this.checkPairs(); this.updateMolecule(); this.generateScoreNodes(); @@ -382,14 +390,14 @@ export default class Pose2D extends ContainerObject implements Updatable { this._designStructUpdated = false; } - public setMutated(seq_arr: number[]): void { - let n: number = Math.min(this._mutatedSequence.length, seq_arr.length); + public setMutated(seqArr: number[]): void { + let n: number = Math.min(this._mutatedSequence.length, seqArr.length); let ofs: number = (this._oligo != null && this._oligoMode === Pose2D.OLIGO_MODE_EXT5P ? this._oligo.length : 0); - for (let ii: number = 0; ii < n; ii++) { - if (this._mutatedSequence[ii] !== seq_arr[ii] && !this.isLocked(ofs + ii)) { - this._mutatedSequence[ii] = seq_arr[ii]; - this._bases[ofs + ii].setType(seq_arr[ii]); + for (let ii = 0; ii < n; ii++) { + if (this._mutatedSequence[ii] !== seqArr[ii] && !this.isLocked(ofs + ii)) { + this._mutatedSequence[ii] = seqArr[ii]; + this._bases[ofs + ii].setType(seqArr[ii]); } } } @@ -399,25 +407,25 @@ export default class Pose2D extends ContainerObject implements Updatable { return; } - let num_mut: number = 0; + let numMut = 0; let muts: any[] = []; let n: number = Math.min(sequence.length, this._sequence.length); - let need_update: boolean = false; + let needUpdate = false; let ofs: number = (this._oligo != null && this._oligoMode === Pose2D.OLIGO_MODE_EXT5P ? this._oligo.length : 0); - for (let ii: number = 0; ii < n; ii++) { + for (let ii = 0; ii < n; ii++) { if (this._sequence[ii] !== sequence[ii] && !this.isLocked(ofs + ii)) { - num_mut++; + numMut++; this._sequence[ii] = sequence[ii]; muts.push({pos: ii + 1, base: EPars.sequenceToString([this._sequence[ii]])}); this._bases[ofs + ii].setType(sequence[ii]); - need_update = true; + needUpdate = true; } } - if (need_update) { - this.callTrackMovesCallback(num_mut, muts); + if (needUpdate) { + this.callTrackMovesCallback(numMut, muts); this.checkPairs(); this.updateMolecule(); @@ -426,7 +434,7 @@ export default class Pose2D extends ContainerObject implements Updatable { } } - public getBaseXY(seq: number, out: Point = null): Point { + public getBaseLoc(seq: number, out: Point = null): Point { if (out == null) { out = new Point(); } @@ -443,67 +451,67 @@ export default class Pose2D extends ContainerObject implements Updatable { } public clearMouse(): void { - //document.getElementById(Eterna.PIXI_CONTAINER_ID).style.cursor = ''; + // document.getElementById(Eterna.PIXI_CONTAINER_ID).style.cursor = ''; this._paintCursor.display.visible = false; this._strandLabel.display.visible = false; } - public parseCommand(command: number, closest_index: number): any[] { + public parseCommand(command: number, closestIndex: number): any[] { switch (command) { - case EPars.RNABASE_ADD_BASE: - return PoseUtil.addBaseWithIndex(closest_index, this._pairs); + case EPars.RNABASE_ADD_BASE: + return PoseUtil.addBaseWithIndex(closestIndex, this._pairs); - case EPars.RNABASE_ADD_PAIR: - return PoseUtil.addPairWithIndex(closest_index, this._pairs); + case EPars.RNABASE_ADD_PAIR: + return PoseUtil.addPairWithIndex(closestIndex, this._pairs); - case EPars.RNABASE_DELETE: - return this.deleteBaseWithIndex(closest_index); + case EPars.RNABASE_DELETE: + return this.deleteBaseWithIndex(closestIndex); - default: - return null; + default: + return null; } } - public parseCommandWithPairs(command: number, closest_index: number, pairs: number[]): any[] { + public parseCommandWithPairs(command: number, closestIndex: number, pairs: number[]): any[] { switch (command) { - case EPars.RNABASE_ADD_BASE: - return PoseUtil.addBaseWithIndex(closest_index, pairs); + case EPars.RNABASE_ADD_BASE: + return PoseUtil.addBaseWithIndex(closestIndex, pairs); - case EPars.RNABASE_DELETE: - return this.deleteBaseWithIndexPairs(closest_index, pairs); + case EPars.RNABASE_DELETE: + return this.deleteBaseWithIndexPairs(closestIndex, pairs); - default: - return null; + default: + return null; } } - public onPoseMouseDownPropagate(e: InteractionEvent, closest_index: number): void { + public onPoseMouseDownPropagate(e: InteractionEvent, closestIndex: number): void { let altDown: boolean = Flashbang.app.isAltKeyDown; let ctrlDown: boolean = Flashbang.app.isControlKeyDown || Flashbang.app.isMetaKeyDown; if ((this._coloring && !altDown) || ctrlDown) { - if (ctrlDown && closest_index >= this.sequence.length) { + if (ctrlDown && closestIndex >= this.sequence.length) { return; } - this.onPoseMouseDown(e, closest_index); + this.onPoseMouseDown(e, closestIndex); } } - public onPoseMouseDown(e: InteractionEvent, closest_index: number): void { + public onPoseMouseDown(e: InteractionEvent, closestIndex: number): void { let altDown: boolean = Flashbang.app.isAltKeyDown; let shiftDown: boolean = Flashbang.app.isShiftKeyDown; let ctrlDown: boolean = Flashbang.app.isControlKeyDown || Flashbang.app.isMetaKeyDown; - if (closest_index >= 0) { + if (closestIndex >= 0) { this._mouseDownAltKey = altDown; - if (ctrlDown && closest_index < this.fullSequenceLength) { - this.toggleBlackMark(closest_index); + if (ctrlDown && closestIndex < this.fullSequenceLength) { + this.toggleBlackMark(closestIndex); return; } if (shiftDown) { - if (closest_index < this.sequenceLength) { - this._shiftStart = closest_index; - this._shiftEnd = closest_index; + if (closestIndex < this.sequenceLength) { + this._shiftStart = closestIndex; + this._shiftEnd = closestIndex; this.updateShiftHighlight(); let reg: Registration = null; @@ -518,28 +526,26 @@ export default class Pose2D extends ContainerObject implements Updatable { } this._lastShiftedCommand = -1; this._lastShiftedIndex = -1; - let cmd: any[] = this.parseCommand(this._currentColor, closest_index); + let cmd: any[] = this.parseCommand(this._currentColor, closestIndex); if (cmd == null) { let dragger = new Dragger(); this.addObject(dragger); dragger.dragged.connect(() => this.onMouseMoved()); dragger.dragComplete.connect(() => this.onMouseUp()); - this.onBaseMouseDown(closest_index, ctrlDown); + this.onBaseMouseDown(closestIndex, ctrlDown); } else { this._lastShiftedCommand = this._currentColor; - this._lastShiftedIndex = closest_index; + this._lastShiftedIndex = closestIndex; - this.callAddBaseCallback(cmd[0], cmd[1], closest_index); + this.callAddBaseCallback(cmd[0], cmd[1], closestIndex); } e.stopPropagation(); - } else { - if (shiftDown) { - this._shiftStart = -1; - this._shiftEnd = -1; - this.updateShiftHighlight(); - } + } else if (shiftDown) { + this._shiftStart = -1; + this._shiftEnd = -1; + this.updateShiftHighlight(); } } @@ -552,18 +558,18 @@ export default class Pose2D extends ContainerObject implements Updatable { } } - public addBaseMark(closestIndex: number, color:number = 0x000000): void { + public addBaseMark(closestIndex: number, color: number = 0x000000): void { let index: number = this._trackedIndices.indexOf(closestIndex); if (index === -1) { this._trackedIndices.push(closestIndex); ROPWait.notifyBlackMark(closestIndex, true); - let base_box: Graphics = new Graphics(); - this._baseBoxes.push(base_box); - this.container.addChild(base_box); + let baseBox: Graphics = new Graphics(); + this._baseBoxes.push(baseBox); + this.container.addChild(baseBox); let n: number = this._trackedIndices.length; - let center: Point = this.getBaseXY(this._trackedIndices[n - 1]); + let center: Point = this.getBaseLoc(this._trackedIndices[n - 1]); this._baseBoxes[n - 1].x = center.x; this._baseBoxes[n - 1].y = center.y; this._baseBoxes[n - 1].visible = true; @@ -573,13 +579,13 @@ export default class Pose2D extends ContainerObject implements Updatable { } } - public removeBlackMark(closest_index: number): void { - let index: number = this._trackedIndices.indexOf(closest_index); + public removeBlackMark(closestIndex: number): void { + let index: number = this._trackedIndices.indexOf(closestIndex); if (index !== -1) { this._baseBoxes[index].visible = false; this._trackedIndices.splice(index, 1); this._baseBoxes.splice(index, 1); - ROPWait.notifyBlackMark(closest_index, false); + ROPWait.notifyBlackMark(closestIndex, false); } } @@ -604,37 +610,39 @@ export default class Pose2D extends ContainerObject implements Updatable { this._paintCursor.display.x = mouseX; this._paintCursor.display.y = mouseY; - let closest_dist: number = -1; - let closest_index: number = -1; + let closestDist = -1; + let closestIndex = -1; for (let ii = 0; ii < this.fullSequenceLength; ii++) { - let mouseDist: number = this._bases[ii].isClicked(mouseX - this._offX, mouseY - this._offY, this._zoomLevel, this._coloring); + let mouseDist: number = this._bases[ii].isClicked( + mouseX - this._offX, mouseY - this._offY, this._zoomLevel, this._coloring + ); if (mouseDist >= 0) { - if (closest_index < 0 || mouseDist < closest_dist) { - closest_index = ii; - closest_dist = mouseDist; + if (closestIndex < 0 || mouseDist < closestDist) { + closestIndex = ii; + closestDist = mouseDist; } } } - if (closest_index >= 0 && this._currentColor >= 0) { - this.onBaseMouseMove(closest_index); - //document.getElementById(Eterna.PIXI_CONTAINER_ID).style.cursor = 'none'; + if (closestIndex >= 0 && this._currentColor >= 0) { + this.onBaseMouseMove(closestIndex); + // document.getElementById(Eterna.PIXI_CONTAINER_ID).style.cursor = 'none'; this._paintCursor.display.visible = true; this._paintCursor.setShape(this._currentColor); - let strandName: string = this.getStrandName(closest_index); + let strandName: string = this.getStrandName(closestIndex); if (strandName != null) { this._strandLabel.setText(strandName); if (mouseX + 16 + this._strandLabel.width > this._width) { this._strandLabel.display.position = new Point( mouseX - 16 - this._strandLabel.width, - mouseY + 16); + mouseY + 16 + ); } else { this._strandLabel.display.position = new Point(mouseX + 16, mouseY + 16); } this._strandLabel.display.visible = true; } - } else { this._lastColoredIndex = -1; } @@ -643,13 +651,13 @@ export default class Pose2D extends ContainerObject implements Updatable { this.updateScoreNodeGui(); if (this._feedbackObjs.length > 0) { for (let ii = 0; ii < this._feedbackObjs.length; ii++) { - if (ii === closest_index) { + if (ii === closestIndex) { continue; } this._feedbackObjs[ii].display.visible = false; } - if (closest_index >= 0) { - this._feedbackObjs[closest_index].display.visible = true; + if (closestIndex >= 0) { + this._feedbackObjs[closestIndex].display.visible = true; } } } @@ -694,9 +702,9 @@ export default class Pose2D extends ContainerObject implements Updatable { return this._offY; } - public setOffset(off_x: number, off_y: number): void { - this._offX = off_x; - this._offY = off_y; + public setOffset(offX: number, offY: number): void { + this._offX = offX; + this._offY = offY; this._redraw = true; } @@ -747,13 +755,13 @@ export default class Pose2D extends ContainerObject implements Updatable { this._forcedStruct = null; } else { if (forced.length !== len) { - throw new Error("Forced structure length does not match sequence length " + forced.length + " " + this._sequence.length + " " + this._pairs.length); + throw new Error(`Forced structure length does not match sequence length ${forced.length} ${this._sequence.length} ${this._pairs.length}`); } this._forcedStruct = forced.slice(); } - for (let ii: number = 0; ii < len; ii++) { + for (let ii = 0; ii < len; ii++) { this._bases[ii].forced = this._forcedStruct != null && this._forcedStruct[ii] !== EPars.FORCE_IGNORE; } } @@ -764,7 +772,7 @@ export default class Pose2D extends ContainerObject implements Updatable { } let temp: number[] = []; - for (let ii: number = 0; ii < this.fullSequenceLength; ii++) { + for (let ii = 0; ii < this.fullSequenceLength; ii++) { temp.push(EPars.FORCE_IGNORE); } @@ -779,14 +787,14 @@ export default class Pose2D extends ContainerObject implements Updatable { } } - public set structConstraints(do_care: boolean[]) { + public set structConstraints(doCare: boolean[]) { let ii: number; let len: number = this.fullSequenceLength; - let dc: boolean[] = (do_care == null ? null : do_care.slice()); + let dc: boolean[] = (doCare == null ? null : doCare.slice()); if (dc != null && this._oligosOrder != null) { - let idx_map: number[] = this.getOrderMap(null); + let idxMap: number[] = this.getOrderMap(null); for (ii = 0; ii < len; ii++) { - dc[ii] = do_care[idx_map.indexOf(ii)]; + dc[ii] = doCare[idxMap.indexOf(ii)]; } } for (ii = 0; ii < len; ii++) { @@ -795,7 +803,7 @@ export default class Pose2D extends ContainerObject implements Updatable { } public clearDesignStruct(): void { - for (let jj: number = 0; jj < this.fullSequenceLength; jj++) { + for (let jj = 0; jj < this.fullSequenceLength; jj++) { this._designStruct[jj] = false; } this.updateDesignHighlight(); @@ -818,8 +826,8 @@ export default class Pose2D extends ContainerObject implements Updatable { public get designSegments(): number[] { let elems: number[] = []; - let curr: number = 0; - for (let jj: number = 0; jj < this.fullSequenceLength; jj++) { + let curr = 0; + for (let jj = 0; jj < this.fullSequenceLength; jj++) { let stat: number = this._designStruct[jj] ? 1 : 0; if ((curr ^ stat) !== 0) { elems.push(jj - curr); @@ -849,7 +857,7 @@ export default class Pose2D extends ContainerObject implements Updatable { } } // find the next acceptable spot - let ofs: number = 1; + let ofs = 1; let len: number = this.sequenceLength; while (last + ofs < len) { for (ii = first + ofs; ii <= last + ofs; ii++) { @@ -906,7 +914,7 @@ export default class Pose2D extends ContainerObject implements Updatable { } } // find the next acceptable spot - let ofs: number = -1; + let ofs = -1; while (first + ofs >= 0) { for (ii = first + ofs; ii <= last + ofs; ii++) { if (this._locks[ii]) { @@ -955,7 +963,7 @@ export default class Pose2D extends ContainerObject implements Updatable { } public get satisfied(): boolean { - for (let ii: number = 0; ii < this._pairs.length; ii++) { + for (let ii = 0; ii < this._pairs.length; ii++) { if (this._pairs[ii] > ii && !this.isPairSatisfied(ii, this._pairs[ii])) { return false; } @@ -1041,7 +1049,7 @@ export default class Pose2D extends ContainerObject implements Updatable { this._selectionHighlightBox.setHighlight(HighlightType.LOOP, action.slice(1)); } - /// For restricted queue + // / For restricted queue public clearRestrictedHighlight(): void { this._restrictedHighlightBox.clear(); } @@ -1062,96 +1070,95 @@ export default class Pose2D extends ContainerObject implements Updatable { this._userDefinedHighlightBox.clear(); } - public highlightUserDefinedSequence(user_defined: number[]): void { - this._userDefinedHighlightBox.setHighlight(HighlightType.USER_DEFINED, user_defined); + public highlightUserDefinedSequence(userDefined: number[]): void { + this._userDefinedHighlightBox.setHighlight(HighlightType.USER_DEFINED, userDefined); } public clearShiftHighlight(): void { this._shiftHighlightBox.clear(); } - public praiseStack(stack_start: number, stack_end: number): void { - this._praiseQueue.push(stack_start); - this._praiseQueue.push(stack_end); + public praiseStack(stackStart: number, stackEnd: number): void { + this._praiseQueue.push(stackStart); + this._praiseQueue.push(stackEnd); } - public praiseSequence(seq_start: number, seq_end: number): void { - this._praiseSeq.push(seq_start); - this._praiseSeq.push(seq_end); + public praiseSequence(seqStart: number, seqEnd: number): void { + this._praiseSeq.push(seqStart); + this._praiseSeq.push(seqEnd); } - private onPraiseStack(stack_start: number, stack_end: number, play_sound: boolean): void { - let x_pos: number = 0; - let y_pos: number = 0; + private onPraiseStack(stackStart: number, stackEnd: number, playSound: boolean): void { + let xPos = 0; + let yPos = 0; - let play_ua: boolean = false; - let play_gc: boolean = false; - let play_gu: boolean = false; + let playUA = false; + let playGC = false; + let playGU = false; - for (let kk: number = stack_start; kk <= stack_end; kk++) { + for (let kk: number = stackStart; kk <= stackEnd; kk++) { if (this._pairs[kk] < 0) { return; } } - for (let ii: number = stack_start; ii <= stack_end; ii++) { - + for (let ii: number = stackStart; ii <= stackEnd; ii++) { let aa: number = ii; let bb: number = this._pairs[ii]; - if ((this._sequence[aa] === EPars.RNABASE_ADENINE && this._sequence[bb] === EPars.RNABASE_URACIL) || - (this._sequence[bb] === EPars.RNABASE_ADENINE && this._sequence[aa] === EPars.RNABASE_URACIL)) { - play_ua = true; - } else if ((this._sequence[aa] === EPars.RNABASE_GUANINE && this._sequence[bb] === EPars.RNABASE_CYTOSINE) || - (this._sequence[bb] === EPars.RNABASE_GUANINE && this._sequence[aa] === EPars.RNABASE_CYTOSINE)) { - play_gc = true; - } else if ((this._sequence[aa] === EPars.RNABASE_GUANINE && this._sequence[bb] === EPars.RNABASE_URACIL) || - (this._sequence[bb] === EPars.RNABASE_GUANINE && this._sequence[aa] === EPars.RNABASE_URACIL)) { - play_gu = true; + if ((this._sequence[aa] === EPars.RNABASE_ADENINE && this._sequence[bb] === EPars.RNABASE_URACIL) + || (this._sequence[bb] === EPars.RNABASE_ADENINE && this._sequence[aa] === EPars.RNABASE_URACIL)) { + playUA = true; + } else if ((this._sequence[aa] === EPars.RNABASE_GUANINE && this._sequence[bb] === EPars.RNABASE_CYTOSINE) + || (this._sequence[bb] === EPars.RNABASE_GUANINE && this._sequence[aa] === EPars.RNABASE_CYTOSINE)) { + playGC = true; + } else if ((this._sequence[aa] === EPars.RNABASE_GUANINE && this._sequence[bb] === EPars.RNABASE_URACIL) + || (this._sequence[bb] === EPars.RNABASE_GUANINE && this._sequence[aa] === EPars.RNABASE_URACIL)) { + playGU = true; } this._bases[ii].startSparking(); this._bases[this._pairs[ii]].startSparking(); - let p: Point = this.getBaseXY(ii); - let p2: Point = this.getBaseXY(this._pairs[ii]); + let p: Point = this.getBaseLoc(ii); + let p2: Point = this.getBaseLoc(this._pairs[ii]); - x_pos += p.x; - y_pos += p.y; + xPos += p.x; + yPos += p.y; - x_pos += p2.x; - y_pos += p2.y; + xPos += p2.x; + yPos += p2.y; } - let stack_len: number = (stack_end - stack_start) + 1; + let stackLen: number = (stackEnd - stackStart) + 1; - x_pos /= stack_len * 2; - y_pos /= stack_len * 2; + xPos /= stackLen * 2; + yPos /= stackLen * 2; - let praiseText = stack_len > 1 ? "Great Pairings!" : "Great Pairing!"; - let praise_obj = new SceneObject(Fonts.arial(praiseText, 20).bold().color(0xffffff).build()); - praise_obj.display.position = new Point(x_pos - DisplayUtil.width(praise_obj.display) * 0.5, y_pos); - this.addObject(praise_obj, this.container); + let praiseText = stackLen > 1 ? 'Great Pairings!' : 'Great Pairing!'; + let praiseObj = new SceneObject(Fonts.arial(praiseText, 20).bold().color(0xffffff).build()); + praiseObj.display.position = new Point(xPos - DisplayUtil.width(praiseObj.display) * 0.5, yPos); + this.addObject(praiseObj, this.container); - praise_obj.display.alpha = 0; - praise_obj.addObject(new SerialTask( + praiseObj.display.alpha = 0; + praiseObj.addObject(new SerialTask( new ParallelTask( new AlphaTask(0.85, 0.33, Easing.easeOut), - new LocationTask(praise_obj.display.x, praise_obj.display.y - 80, 0.33, Easing.easeOut) + new LocationTask(praiseObj.display.x, praiseObj.display.y - 80, 0.33, Easing.easeOut) ), new DelayTask(1), new ParallelTask( new AlphaTask(0, 0.33, Easing.easeOut), - new LocationTask(praise_obj.display.x, praise_obj.display.y - 120, 0.33, Easing.easeOut) + new LocationTask(praiseObj.display.x, praiseObj.display.y - 120, 0.33, Easing.easeOut) ), new SelfDestructTask() )); - if (play_sound) { - if (play_gc) { + if (playSound) { + if (playGC) { Eterna.sound.playSound(Sounds.SoundRG); - } else if (play_ua) { + } else if (playUA) { Eterna.sound.playSound(Sounds.SoundYB); - } else if (play_gu) { + } else if (playGU) { Eterna.sound.playSound(Sounds.SoundRB); } } @@ -1162,7 +1169,7 @@ export default class Pose2D extends ContainerObject implements Updatable { // If any of the nucleotides are part of a stack, highlight its pair as well. let addition: number[] = []; - for (let i: number = 0; i < nucleotides.length; ++i) { + for (let i = 0; i < nucleotides.length; ++i) { if (this._pairs[nucleotides[i]] !== -1) { addition.push(this._pairs[nucleotides[i]]); } @@ -1184,8 +1191,8 @@ export default class Pose2D extends ContainerObject implements Updatable { } } - private onPraiseSeq(seq_start: number, seq_end: number): void { - for (let ii: number = seq_start; ii <= seq_end; ii++) { + private onPraiseSeq(seqStart: number, seqEnd: number): void { + for (let ii: number = seqStart; ii <= seqEnd; ii++) { if (ii >= 0 && ii < this.fullSequenceLength) { this._bases[ii].startSparking(); } @@ -1197,12 +1204,12 @@ export default class Pose2D extends ContainerObject implements Updatable { this._auxInfoCanvas.visible = display; } - public set auxInfo(aux_info: any) { - this._auxInfo = aux_info; + public set auxInfo(auxInfo: any) { + this._auxInfo = auxInfo; if (this._auxInfo != null && this._auxInfo[Pose2D.CLEAVING_SITE] != null) { this._auxTextballoon.display.visible = true; - this._auxTextballoon.setText("Ribozyme cleaving site"); + this._auxTextballoon.setText('Ribozyme cleaving site'); } } @@ -1211,36 +1218,36 @@ export default class Pose2D extends ContainerObject implements Updatable { this._explosionStartTime = -1; if (this._explosionRays.length >= this._sequence.length) { - for (let ii: number = 0; ii < this._sequence.length; ii++) { + for (let ii = 0; ii < this._sequence.length; ii++) { const ray = this._explosionRays[ii]; ray.display.visible = false; ray.draw( Vector2.fromPolar(Math.max(this._width, this._height), Math.random() * 2 * Math.PI), - this._sequence[ii]); - + this._sequence[ii] + ); } } else { let diff: number = (this._sequence.length - this._explosionRays.length) / this._explosionRays.length; - let diff_walker: number = 0; - let ray_walker: number = 0; + let diffWalker = 0; + let rayWalker = 0; for (let ii = 0; ii < this._sequence.length; ii++) { - if (diff_walker < 1) { - if (ray_walker >= this._explosionRays.length) { + if (diffWalker < 1) { + if (rayWalker >= this._explosionRays.length) { continue; } - const ray = this._explosionRays[ray_walker]; + const ray = this._explosionRays[rayWalker]; ray.display.visible = false; ray.draw( Vector2.fromPolar(Math.max(this._width, this._height), Math.random() * 2 * Math.PI), - this._sequence[ii]); - - ray_walker++; - diff_walker += diff; + this._sequence[ii] + ); + rayWalker++; + diffWalker += diff; } else { - diff_walker -= 1; + diffWalker -= 1; } } } @@ -1250,7 +1257,7 @@ export default class Pose2D extends ContainerObject implements Updatable { this.callExplosionCompleteCallback(); } - return new Promise((resolve) => this._onExplosionComplete = resolve); + return new Promise((resolve) => { this._onExplosionComplete = resolve; }); } private callExplosionCompleteCallback(): void { @@ -1315,22 +1322,24 @@ export default class Pose2D extends ContainerObject implements Updatable { let mouseX: number = Pose2D.P.x; let mouseY: number = Pose2D.P.y; - let closest_dist: number = -1; - let closest_index: number = -1; + let closestDist = -1; + let closestIndex = -1; if (this._startMousedownCallback != null) { - for (let ii: number = 0; ii < this.fullSequenceLength; ii++) { - let mouseDist: number = this._bases[ii].isClicked(mouseX - this._offX, mouseY - this._offY, this._zoomLevel, false); + for (let ii = 0; ii < this.fullSequenceLength; ii++) { + let mouseDist: number = this._bases[ii].isClicked( + mouseX - this._offX, mouseY - this._offY, this._zoomLevel, false + ); if (mouseDist >= 0) { - if (closest_index < 0 || mouseDist < closest_dist) { - closest_index = ii; - closest_dist = mouseDist; + if (closestIndex < 0 || mouseDist < closestDist) { + closestIndex = ii; + closestDist = mouseDist; } } } - this._startMousedownCallback(e, closest_dist, closest_index); + this._startMousedownCallback(e, closestDist, closestIndex); } else { - this.onPoseMouseDown(e, closest_index); + this.onPoseMouseDown(e, closestIndex); } } @@ -1338,44 +1347,6 @@ export default class Pose2D extends ContainerObject implements Updatable { return EPars.getSatisfiedPairs(this._pairs, this.fullSequence); } - public set sequence(sequence: number[]) { - if (Arrays.shallowEqual(this._sequence, sequence)) { - return; - } - - if (this._locks == null) { - this._locks = Pose2D.createDefaultLocks(this._sequence.length); - } - - this._sequence = sequence.slice(); - if (this._sequence.length > this._bases.length) { - let diff: number = (this._sequence.length - this._bases.length); - for (let ii: number = 0; ii < diff; ii++) { - this.createBase(); - this._locks.push(false); - } - - } else if (this._sequence.length < this._bases.length) { - for (let ii: number = this._sequence.length; ii < this._bases.length; ii++) { - if (this.isTrackedIndex(ii)) { - this.removeBlackMark(ii); - } - } - } - - let n: number = this.fullSequenceLength; - for (let ii: number = 0; ii < n; ii++) { - if (ii < this._sequence.length) { - this._bases[ii].setType(this._sequence[ii]); - } - this._bases[ii].baseIndex = ii; - } - - this.checkPairs(); - this.updateMolecule(); - this.generateScoreNodes(); - } - public set molecularBindingBonus(bonus: number) { this._molecularBindingBonus = bonus; } @@ -1401,20 +1372,20 @@ export default class Pose2D extends ContainerObject implements Updatable { return; } - let target_pairs: number[] = this._moleculeTargetPairs.slice(); - if (!target_pairs) { + let targetPairs: number[] = this._moleculeTargetPairs.slice(); + if (!targetPairs) { throw new Error("Can't find molecular target structure"); } - let binding_bases: number[] = []; - let binding_pairs: number[] = []; - for (let ii: number = 0; ii < bindingSite.length; ii++) { + let bindingBases: number[] = []; + let bindingPairs: number[] = []; + for (let ii = 0; ii < bindingSite.length; ii++) { if (bindingSite[ii]) { - binding_bases.push(ii); - binding_pairs.push(target_pairs[ii]); + bindingBases.push(ii); + bindingPairs.push(targetPairs[ii]); } } - this.setMolecularBinding(binding_bases, binding_pairs, this._molecularBindingBonus); + this.setMolecularBinding(bindingBases, bindingPairs, this._molecularBindingBonus); } public get molecularBindingSite(): boolean[] { @@ -1423,13 +1394,13 @@ export default class Pose2D extends ContainerObject implements Updatable { } let temp: boolean[] = []; - for (let ii: number = 0; ii < this._sequence.length; ii++) { + for (let ii = 0; ii < this._sequence.length; ii++) { temp.push(false); } return temp; } - public setMolecularBinding(binding_sites: number[], binding_pairs: number[], binding_bonus: number): void { + public setMolecularBinding(bindingSites: number[], bindingPairs: number[], bindingBonus: number): void { if (this._molecule != null) { this._molecule.destroy({children: true}); this._molecule = null; @@ -1446,24 +1417,24 @@ export default class Pose2D extends ContainerObject implements Updatable { this._molecularBindingPairs = null; - if (binding_sites == null || binding_sites.length === 0) { + if (bindingSites == null || bindingSites.length === 0) { return; } this._molecularBindingBases = new Array(this._sequence.length); this._molecularBindingPairs = new Array(this._sequence.length); - this._molecularBindingBonus = binding_bonus; + this._molecularBindingBonus = bindingBonus; this._molecule = new Molecule(); this._moleculeLayer.addChild(this._molecule); - for (let ii: number = 0; ii < binding_sites.length; ii++) { - let idx = binding_sites[ii]; + for (let ii = 0; ii < bindingSites.length; ii++) { + let idx = bindingSites[ii]; let baseGlow = new BaseGlow(); this._moleculeLayer.addChild(baseGlow); this._molecularBindingBases[idx] = baseGlow; - this._molecularBindingPairs[idx] = binding_pairs[ii]; + this._molecularBindingPairs[idx] = bindingPairs[ii]; } this.updateMolecule(); @@ -1474,31 +1445,31 @@ export default class Pose2D extends ContainerObject implements Updatable { return; } - let bound_render: boolean = true; - let bound_real: boolean = true; - let satisfied_pairs: number[] = this.satisfiedPairs; + let boundRender = true; + let boundReal = true; + let satisfiedPairs: number[] = this.satisfiedPairs; - for (let ii: number = 0; ii < this._molecularBindingPairs.length; ii++) { + for (let ii = 0; ii < this._molecularBindingPairs.length; ii++) { if (this._molecularBindingBases[ii] == null) { continue; } if (this._molecularBindingPairs[ii] !== this._pairs[ii]) { - bound_render = false; + boundRender = false; } - if (this._molecularBindingPairs[ii] !== satisfied_pairs[ii]) { - bound_real = false; + if (this._molecularBindingPairs[ii] !== satisfiedPairs[ii]) { + boundReal = false; this._molecularBindingBases[ii].isWrong = true; } else { this._molecularBindingBases[ii].isWrong = false; } } - this._molecule.isWrong = !bound_real; - this._moleculeIsBound = bound_render; - this._moleculeIsBoundReal = bound_real; + this._molecule.isWrong = !boundReal; + this._moleculeIsBound = boundRender; + this._moleculeIsBoundReal = boundReal; } - public setOligos(oligos: Oligo[], order: number[] = null, num_paired: number = 0): void { + public setOligos(oligos: Oligo[], order: number[] = null, numPaired: number = 0): void { if (oligos == null) { this._oligos = null; this._oligosOrder = null; @@ -1516,7 +1487,7 @@ export default class Pose2D extends ContainerObject implements Updatable { } } - let prev_order: number[] = this._oligosOrder; + let prevOrder: number[] = this._oligosOrder; this._oligos = JSON.parse(JSON.stringify(oligos)); if (order == null) { this._oligosOrder = []; @@ -1526,7 +1497,7 @@ export default class Pose2D extends ContainerObject implements Updatable { } else { this._oligosOrder = order.slice(); } - this._oligosPaired = num_paired; + this._oligosPaired = numPaired; let seq: number[] = this.fullSequence; if (seq.length > this._bases.length) { @@ -1544,16 +1515,16 @@ export default class Pose2D extends ContainerObject implements Updatable { // if possible, maintain visual consistency // (strands "fly" from their previous location in the previous oligo order) - if (same && JSON.stringify(prev_order) !== JSON.stringify(this._oligosOrder)) { - let old_x: number[] = []; - let old_y: number[] = []; - let idx_map: number[] = this.getOrderMap(prev_order); + if (same && JSON.stringify(prevOrder) !== JSON.stringify(this._oligosOrder)) { + let oldX: number[] = []; + let oldY: number[] = []; + let idxMap: number[] = this.getOrderMap(prevOrder); for (let k = 0; k < seq.length; k++) { - old_x[k] = this._bases[k].x; - old_y[k] = this._bases[k].y; + oldX[k] = this._bases[k].x; + oldY[k] = this._bases[k].y; } for (let k = 0; k < seq.length; k++) { - this._bases[idx_map[k]].setXY(old_x[k], old_y[k]); + this._bases[idxMap[k]].setXY(oldX[k], oldY[k]); } } } @@ -1562,12 +1533,12 @@ export default class Pose2D extends ContainerObject implements Updatable { return (this._oligos != null ? JSON.parse(JSON.stringify(this._oligos)) : null); } - public getOrderMap(other_order: number[]): number[] { + public getOrderMap(otherOrder: number[]): number[] { if (this._oligos == null) { return null; } - let idx_map: number[] = []; + let idxMap: number[] = []; let ofs: number[] = []; let ii: number = this._sequence.length; let jj: number; @@ -1575,17 +1546,17 @@ export default class Pose2D extends ContainerObject implements Updatable { ofs[this._oligosOrder[jj]] = ii; ii += 1 + this._oligos[this._oligosOrder[jj]].sequence.length; } - for (ii = 0; ii < this._sequence.length; ii++) idx_map[ii] = ii; + for (ii = 0; ii < this._sequence.length; ii++) idxMap[ii] = ii; for (jj = 0; jj < this._oligos.length; jj++) { - let zz: number = (other_order == null ? jj : other_order[jj]); + let zz: number = (otherOrder == null ? jj : otherOrder[jj]); let kk: number = ofs[zz]; let xx: number; for (xx = 0; xx <= this._oligos[zz].sequence.length; xx++) { - idx_map[ii + xx] = kk + xx; + idxMap[ii + xx] = kk + xx; } ii += xx; } - return idx_map; + return idxMap; } public saveMarkersContext(): void { @@ -1597,12 +1568,16 @@ export default class Pose2D extends ContainerObject implements Updatable { } public transformMarkers(): void { - if (this._prevOligosOrder == null || this._oligosOrder == null || this._prevOligosOrder.length !== this._oligosOrder.length) { + if ( + this._prevOligosOrder == null + || this._oligosOrder == null + || this._prevOligosOrder.length !== this._oligosOrder.length + ) { this._prevOligosOrder = null; return; } - let idx_map: number[] = this.getOrderMap(this._prevOligosOrder); + let idxMap: number[] = this.getOrderMap(this._prevOligosOrder); this._prevOligosOrder = null; // black marks @@ -1610,41 +1585,41 @@ export default class Pose2D extends ContainerObject implements Updatable { this.clearTracking(); let ii: number; for (ii = 0; ii < indices.length; ii++) { - indices[ii] = idx_map[indices[ii]]; + indices[ii] = idxMap[indices[ii]]; this.addBaseMark(indices[ii]); } // blue highlights ("magic glue") - let new_design: boolean[] = []; + let newDesign: boolean[] = []; for (ii = 0; ii < this.fullSequenceLength; ii++) { - new_design[idx_map[ii]] = this._designStruct[ii]; + newDesign[idxMap[ii]] = this._designStruct[ii]; } - this._designStruct = new_design; + this._designStruct = newDesign; this.updateDesignHighlight(); } - public setOligo(oligo: number[], mode: number | string = Pose2D.OLIGO_MODE_DIMER, o_name: string = null): void { + public setOligo(oligo: number[], mode: number | string = Pose2D.OLIGO_MODE_DIMER, oName: string = null): void { if (oligo == null) { this._oligo = null; return; } this._oligo = oligo.slice(); - this._oligoName = o_name; + this._oligoName = oName; // Puzzle JSON encodes oligoMode as a string, for some reason - this._oligoMode = typeof(mode) === "number" ? mode : Number(mode); + this._oligoMode = typeof (mode) === 'number' ? mode : Number(mode); let seq: number[] = this.fullSequence; if (seq.length > this._bases.length) { let diff: number = (seq.length - this._bases.length); - for (let i: number = 0; i < diff; i++) { + for (let i = 0; i < diff; i++) { this.createBase(); } } let n: number = seq.length; - for (let k: number = 0; k < n; k++) { + for (let k = 0; k < n; k++) { this._bases[k].setType(seq[k]); this._bases[k].baseIndex = k; } @@ -1679,7 +1654,7 @@ export default class Pose2D extends ContainerObject implements Updatable { return seq; } // _oligos != null, we have a multistrand target - for (let ii: number = 0; ii < this._oligos.length; ii++) { + for (let ii = 0; ii < this._oligos.length; ii++) { seq.push(EPars.RNABASE_CUT); seq = seq.concat(this._oligos[this._oligosOrder[ii]].sequence); } @@ -1696,7 +1671,7 @@ export default class Pose2D extends ContainerObject implements Updatable { if (this._oligoMode === Pose2D.OLIGO_MODE_DIMER) len++; return len; } - for (let ii: number = 0; ii < this._oligos.length; ii++) { + for (let ii = 0; ii < this._oligos.length; ii++) { len += 1 + this._oligos[ii].sequence.length; } return len; @@ -1705,13 +1680,13 @@ export default class Pose2D extends ContainerObject implements Updatable { public getStrandName(seqnum: number): string { if (this._oligos != null && seqnum >= this._sequence.length) { let seq: number[] = this._sequence.slice(); - for (let ii: number = 0; ii < this._oligos.length; ii++) { + for (let ii = 0; ii < this._oligos.length; ii++) { seq.push(EPars.RNABASE_CUT); seq = seq.concat(this._oligos[this._oligosOrder[ii]].sequence); if (seqnum < seq.length) { - let o_name: string = this._oligos[this._oligosOrder[ii]]['name']; - if (o_name == null) o_name = "Oligo " + (this._oligosOrder[ii] + 1).toString(); - return o_name; + let oName: string = this._oligos[this._oligosOrder[ii]]['name']; + if (oName == null) oName = `Oligo ${(this._oligosOrder[ii] + 1).toString()}`; + return oName; } } } @@ -1726,39 +1701,13 @@ export default class Pose2D extends ContainerObject implements Updatable { return this._sequence; } let seq: number[] = this._sequence.slice(); - for (let ii: number = 0; ii < this._oligosPaired; ii++) { + for (let ii = 0; ii < this._oligosPaired; ii++) { seq.push(EPars.RNABASE_CUT); seq = seq.concat(this._oligos[this._oligosOrder[ii]].sequence); } return seq; } - public set pairs(pairs: number[]) { - let seq: number[] = this.fullSequence; - if (pairs.length !== seq.length) { - log.debug(pairs.length, seq.length); - throw new Error("Pair length doesn't match sequence length"); - } - - if (EPars.arePairsSame(pairs, this._pairs)) { - return; - } - - this._pairs = pairs.slice(); - - for (let ii: number = 0; ii < this._pairs.length; ii++) { - if (this._pairs[ii] > ii) { - this._pairs[this._pairs[ii]] = ii; - } - } - - /// Recompute sequence layout - this.computeLayout(false); - this.checkPairs(); - this.updateMolecule(); - this.generateScoreNodes(); - } - public isPairSatisfied(a: number, b: number): boolean { if (b < a) { let temp: number = a; @@ -1778,6 +1727,43 @@ export default class Pose2D extends ContainerObject implements Updatable { return this._sequence.length; } + public set sequence(sequence: number[]) { + if (Arrays.shallowEqual(this._sequence, sequence)) { + return; + } + + if (this._locks == null) { + this._locks = Pose2D.createDefaultLocks(this._sequence.length); + } + + this._sequence = sequence.slice(); + if (this._sequence.length > this._bases.length) { + let diff: number = (this._sequence.length - this._bases.length); + for (let ii = 0; ii < diff; ii++) { + this.createBase(); + this._locks.push(false); + } + } else if (this._sequence.length < this._bases.length) { + for (let ii: number = this._sequence.length; ii < this._bases.length; ii++) { + if (this.isTrackedIndex(ii)) { + this.removeBlackMark(ii); + } + } + } + + let n: number = this.fullSequenceLength; + for (let ii = 0; ii < n; ii++) { + if (ii < this._sequence.length) { + this._bases[ii].setType(this._sequence[ii]); + } + this._bases[ii].baseIndex = ii; + } + + this.checkPairs(); + this.updateMolecule(); + this.generateScoreNodes(); + } + public get sequence(): number[] { return this._sequence.slice(); } @@ -1790,19 +1776,45 @@ export default class Pose2D extends ContainerObject implements Updatable { return this._bases[seq]; } + public set pairs(pairs: number[]) { + let seq: number[] = this.fullSequence; + if (pairs.length !== seq.length) { + log.debug(pairs.length, seq.length); + throw new Error("Pair length doesn't match sequence length"); + } + + if (EPars.arePairsSame(pairs, this._pairs)) { + return; + } + + this._pairs = pairs.slice(); + + for (let ii = 0; ii < this._pairs.length; ii++) { + if (this._pairs[ii] > ii) { + this._pairs[this._pairs[ii]] = ii; + } + } + + // / Recompute sequence layout + this.computeLayout(false); + this.checkPairs(); + this.updateMolecule(); + this.generateScoreNodes(); + } + public get pairs(): number[] { return this._pairs.slice(); } public checkOverlap(): boolean { let radius: number = Pose2D.ZOOM_SPACINGS[0]; - let rna_drawer: RNALayout = new RNALayout(radius, radius); - rna_drawer.setupTree(this._pairs); - rna_drawer.drawTree(); + let rnaDrawer: RNALayout = new RNALayout(radius, radius); + rnaDrawer.setupTree(this._pairs); + rnaDrawer.drawTree(); let xarray: number[] = new Array(this._bases.length); let yarray: number[] = new Array(this._bases.length); - rna_drawer.getCoords(xarray, yarray); - for (let ii: number = 0; ii < this._bases.length; ii++) { + rnaDrawer.getCoords(xarray, yarray); + for (let ii = 0; ii < this._bases.length; ii++) { let ax: number = xarray[ii]; let ay: number = yarray[ii]; for (let jj: number = ii + 2; jj < this._bases.length; jj++) { @@ -1818,11 +1830,11 @@ export default class Pose2D extends ContainerObject implements Updatable { return false; } - //highlight the base before the cursor + // highlight the base before the cursor public trackCursor(index: number): void { this._cursorIndex = index; if (this._cursorIndex > 0) { - let center: Point = this.getBaseXY(this._cursorIndex - 1); + let center: Point = this.getBaseLoc(this._cursorIndex - 1); if (this._cursorBox == null) { this._cursorBox = new Graphics(); this.container.addChild(this._cursorBox); @@ -1843,17 +1855,17 @@ export default class Pose2D extends ContainerObject implements Updatable { return this._cursorIndex; } - /*override*/ + /* override */ public update(dt: number): void { if (!this.display.worldVisible) { // update is expensive, so don't bother doing it if we're not visible return; } - let current_time: number = this.mode.time; + let currentTime: number = this.mode.time; for (let anchor of this._anchoredObjects) { if (anchor.isLive) { - let p: Point = this.getBaseXY(anchor.base); + let p: Point = this.getBaseLoc(anchor.base); anchor.object.display.position = new Point(p.x + anchor.offset.x, p.y + anchor.offset.y); } } @@ -1866,17 +1878,17 @@ export default class Pose2D extends ContainerObject implements Updatable { this._bases[ii].display.visible = ii < fullSeq.length && this._bases[ii].type !== EPars.RNABASE_CUT; } - var basesMoved = false; + let basesMoved = false; if (this._baseToX) { basesMoved = true; // Update base locations if (this._foldStartTime < 0) { - this._foldStartTime = current_time; + this._foldStartTime = currentTime; } - let prog = (current_time - this._foldStartTime) / (this._foldDuration); - let done: boolean = false; + let prog = (currentTime - this._foldStartTime) / (this._foldDuration); + let done = false; if (prog >= 1) { prog = 1; @@ -1894,10 +1906,10 @@ export default class Pose2D extends ContainerObject implements Updatable { let vx: number = this._baseToX[ii] - this._baseFromX[ii]; let vy: number = this._baseToY[ii] - this._baseFromY[ii]; - let current_x: number = this._baseFromX[ii] + (vx + (vx * prog)) / 2 * prog; - let current_y: number = this._baseFromY[ii] + (vy + (vy * prog)) / 2 * prog; + let currentX: number = this._baseFromX[ii] + (vx + (vx * prog)) / 2 * prog; + let currentY: number = this._baseFromY[ii] + (vy + (vy * prog)) / 2 * prog; - this._bases[ii].setXY(current_x, current_y); + this._bases[ii].setXY(currentX, currentY); } if (done) { @@ -1911,7 +1923,7 @@ export default class Pose2D extends ContainerObject implements Updatable { if (this.checkOverlap()) { // If overlaps have been introduced, make sure the explosion factor input is shown this._explosionFactorPanel.display.visible = true; - } else if (this._explosionFactorPanel.display.visible == true) { + } else if (this._explosionFactorPanel.display.visible === true) { // If all overlaps have been removed, remove the explosion this._explosionFactor = 1; this._explosionFactorPanel.display.visible = false; @@ -1919,38 +1931,35 @@ export default class Pose2D extends ContainerObject implements Updatable { this._redraw = true; } } + } else if (currentTime - this.lastSampledTime > 2 && !this._isExploding) { + this.lastSampledTime = currentTime; - } else { - if (current_time - this.lastSampledTime > 2 && !this._isExploding) { - this.lastSampledTime = current_time; - - for (let ii = 0; ii < fullSeq.length; ii++) { - if (this._pairs[ii] < 0 && !this._simpleGraphicsMods && Math.random() > 0.7) { - this._bases[ii].animate(); - } + for (let ii = 0; ii < fullSeq.length; ii++) { + if (this._pairs[ii] < 0 && !this._simpleGraphicsMods && Math.random() > 0.7) { + this._bases[ii].animate(); } } } - /// Update score node + // / Update score node this.updateScoreNodeVisualization(this._offX !== this._prevOffsetX || this._offY !== this._prevOffsetY); - /// Bitblt rendering - let need_redraw: boolean = false; + // / Bitblt rendering + let needRedraw = false; - for (let ii = 0; ii < fullSeq.length && !need_redraw; ii++) { - need_redraw = need_redraw || this._bases[ii].needRedraw(this._simpleGraphicsMods); + for (let ii = 0; ii < fullSeq.length && !needRedraw; ii++) { + needRedraw = needRedraw || this._bases[ii].needRedraw(this._simpleGraphicsMods); } - if (need_redraw || this._redraw) { + if (needRedraw || this._redraw) { // Create highlight state to pass to bases. - let hl_state: RNAHighlightState = null; + let hlState: RNAHighlightState = null; if (this._allNewHighlights.length > 0) { - hl_state = new RNAHighlightState(); - hl_state.nuc = []; - hl_state.isOn = true; + hlState = new RNAHighlightState(); + hlState.nuc = []; + hlState.isOn = true; for (let existingHighlight of this._allNewHighlights) { - hl_state.nuc = hl_state.nuc.concat(existingHighlight.nuc); + hlState.nuc = hlState.nuc.concat(existingHighlight.nuc); } } @@ -1960,18 +1969,20 @@ export default class Pose2D extends ContainerObject implements Updatable { continue; } - let use_barcode: boolean = false; + let useBarcode = false; if (this._barcodes != null && this._barcodes.indexOf(ii) >= 0) { - use_barcode = true; + useBarcode = true; } - this._bases[ii].forceUnpaired = (this._forcedStruct != null && this._forcedStruct[ii] === EPars.FORCE_UNPAIRED); + this._bases[ii].forceUnpaired = ( + this._forcedStruct != null && this._forcedStruct[ii] === EPars.FORCE_UNPAIRED + ); let drawFlags: number = BaseDrawFlags.builder() .locked(this.isLocked(ii)) .letterMode(this._lettermode) .lowPerform(this._simpleGraphicsMods) - .useBarcode(use_barcode) + .useBarcode(useBarcode) .result(); let numberBitmap: Texture = null; @@ -1979,7 +1990,9 @@ export default class Pose2D extends ContainerObject implements Updatable { numberBitmap = BitmapManager.getNumberBitmap(ii + 1); } - this._bases[ii].setDrawParams(this._zoomLevel, this._offX, this._offY, current_time, drawFlags, numberBitmap, hl_state); + this._bases[ii].setDrawParams( + this._zoomLevel, this._offX, this._offY, currentTime, drawFlags, numberBitmap, hlState + ); } if (this._displayAuxInfo) { @@ -1995,7 +2008,7 @@ export default class Pose2D extends ContainerObject implements Updatable { if (this._trackedIndices.length === this._baseBoxes.length && this._trackedIndices.length !== 0) { let n: number = this._trackedIndices.length; for (let ii = 0; ii < n; ii++) { - center = this.getBaseXY(this._trackedIndices[ii]); + center = this.getBaseLoc(this._trackedIndices[ii]); this._baseBoxes[ii].x = center.x; this._baseBoxes[ii].y = center.y; const color = this._baseBoxes[ii].lineColor; @@ -2004,9 +2017,9 @@ export default class Pose2D extends ContainerObject implements Updatable { this._baseBoxes[ii].drawCircle(0, 0, Pose2D.BASE_TRACK_RADIUS[this.zoomLevel]); } } - + if (this._cursorIndex > 0) { - center = this.getBaseXY(this._cursorIndex - 1); + center = this.getBaseLoc(this._cursorIndex - 1); this._cursorBox.x = center.x; this._cursorBox.y = center.y; this._cursorBox.visible = true; @@ -2020,31 +2033,31 @@ export default class Pose2D extends ContainerObject implements Updatable { this._moleculeLayer.visible = false; if (this._molecularBindingBases != null && this._molecule != null) { - let mol_x: number = 0; - let mol_y: number = 0; - let nbases: number = 0; + let molX = 0; + let molY = 0; + let nbases = 0; for (let ii = 0; ii < fullSeq.length; ii++) { let baseglow: BaseGlow = this._molecularBindingBases[ii]; if (baseglow != null) { let pos: Point = this._bases[ii].getLastDrawnPos(); - baseglow.updateView(this._zoomLevel, pos.x, pos.y, current_time); - mol_x += pos.x; - mol_y += pos.y; + baseglow.updateView(this._zoomLevel, pos.x, pos.y, currentTime); + molX += pos.x; + molY += pos.y; nbases += 1; } } if (nbases > 0) { - mol_x /= nbases; - mol_y /= nbases; + molX /= nbases; + molY /= nbases; } if (!this._moleculeIsBound) { - mol_x = 30; - mol_y = 200; + molX = 30; + molY = 200; } - this._molecule.updateView(this._zoomLevel, mol_x, mol_y, current_time); + this._molecule.updateView(this._zoomLevel, molX, molY, currentTime); this._moleculeLayer.visible = true; } @@ -2053,68 +2066,67 @@ export default class Pose2D extends ContainerObject implements Updatable { this._oligoBases = new Array(fullSeq.length); } - let bound_len: number = this.getBoundSequence().length; + let boundLen: number = this.getBoundSequence().length; for (let ii = fullSeq.indexOf(EPars.RNABASE_CUT) + 1; ii < fullSeq.length; ii++) { let baseglow = this._oligoBases[ii]; if (baseglow == null) { baseglow = new BaseGlow(); this._oligoBases[ii] = baseglow; } - if ((this._oligoPaired || (this._oligosPaired > 0 && ii < bound_len)) && this._pairs[ii] >= 0) { + if ((this._oligoPaired || (this._oligosPaired > 0 && ii < boundLen)) && this._pairs[ii] >= 0) { baseglow.isWrong = this._restrictedHighlightBox.isInQueue(ii); let pos = this._bases[ii].getLastDrawnPos(); - baseglow.updateView(this._zoomLevel, pos.x, pos.y, current_time); + baseglow.updateView(this._zoomLevel, pos.x, pos.y, currentTime); this._moleculeLayer.visible = true; } } } - let go_x: number = 0; - let go_y: number = 0; + let goX = 0; + let goY = 0; for (let ii = 0; ii < fullSeq.length - 1; ii++) { - let out_x: number = go_x; - let out_y: number = go_y; + let outX: number = goX; + let outY: number = goY; if (this._sequence.length < fullSeq.length && ii === this._sequence.length - 1) { - this._bases[ii].setGoDir(go_x, go_y); - this._bases[ii].setOutDir(-go_y, go_x); + this._bases[ii].setGoDir(goX, goY); + this._bases[ii].setOutDir(-goY, goX); this._bases[ii].setLast(true); continue; } - go_x = this._bases[ii + 1].x - this._bases[ii].x; - go_y = this._bases[ii + 1].y - this._bases[ii].y; + goX = this._bases[ii + 1].x - this._bases[ii].x; + goY = this._bases[ii + 1].y - this._bases[ii].y; - out_x += go_x; - out_y += go_y; + outX += goX; + outY += goY; if (ii > 0) { - out_x /= 2.0; - out_y /= 2.0; + outX /= 2.0; + outY /= 2.0; } - this._bases[ii].setGoDir(go_x, go_y); - this._bases[ii].setOutDir(-out_y, out_x); + this._bases[ii].setGoDir(goX, goY); + this._bases[ii].setOutDir(-outY, outX); this._bases[ii].setLast(false); } if (fullSeq.length >= 1) { - - this._bases[fullSeq.length - 1].setGoDir(go_x, go_y); - this._bases[fullSeq.length - 1].setOutDir(-go_y, go_x); + this._bases[fullSeq.length - 1].setGoDir(goX, goY); + this._bases[fullSeq.length - 1].setOutDir(-goY, goX); this._bases[fullSeq.length - 1].setLast(true); - } - /// Praise stacks when RNA is not moving + // / Praise stacks when RNA is not moving if (!this._offsetTranslating && this._baseToX == null) { if (this._praiseQueue.length > 0) { for (let ii = 0; ii < this._praiseQueue.length; ii += 2) { this.onPraiseStack( this._praiseQueue[ii], this._praiseQueue[ii + 1], - (ii + 1) === (this._praiseQueue.length - 1)); + (ii + 1) === (this._praiseQueue.length - 1) + ); } this._praiseQueue = []; } else if (this._praiseSeq.length > 0) { @@ -2127,7 +2139,7 @@ export default class Pose2D extends ContainerObject implements Updatable { if (this._isExploding && !this._offsetTranslating && this._baseToX == null) { if (this._explosionStartTime < 0) { - this._explosionStartTime = current_time; + this._explosionStartTime = currentTime; this._origOffsetX = this._offX; this._origOffsetY = this._offY; } @@ -2136,7 +2148,7 @@ export default class Pose2D extends ContainerObject implements Updatable { this._offY = this._origOffsetY + (Math.random() * 2 - 1) * 5; this._redraw = true; - let prog = (current_time - this._explosionStartTime) * 5; + let prog = (currentTime - this._explosionStartTime) * 5; if (this._explosionRays.length >= fullSeq.length) { for (let ii = 0; ii < Math.min(prog, fullSeq.length); ii++) { @@ -2148,32 +2160,31 @@ export default class Pose2D extends ContainerObject implements Updatable { ray.fadeIn(); } - ray.display.position = this.getBaseXY(ii); + ray.display.position = this.getBaseLoc(ii); } } else { let diff: number = (fullSeq.length - this._explosionRays.length) / this._explosionRays.length; - let diff_walker: number = 0; - let ray_walker: number = 0; + let diffWalker = 0; + let rayWalker = 0; for (let ii = 0; ii < fullSeq.length; ii++) { - if (diff_walker < 1) { - if (ray_walker >= this._explosionRays.length || ray_walker >= prog) { + if (diffWalker < 1) { + if (rayWalker >= this._explosionRays.length || rayWalker >= prog) { continue; } - const ray = this._explosionRays[ray_walker]; + const ray = this._explosionRays[rayWalker]; if (!ray.display.visible) { ray.display.alpha = 0; ray.display.visible = true; ray.fadeIn(); } - ray.display.position = this.getBaseXY(ii); - ray_walker++; - diff_walker += diff; - + ray.display.position = this.getBaseLoc(ii); + rayWalker++; + diffWalker += diff; } else { - diff_walker -= 1; + diffWalker -= 1; } } } @@ -2188,8 +2199,8 @@ export default class Pose2D extends ContainerObject implements Updatable { } public numPairs(satisfied: boolean): number { - let n: number = 0; - for (let ii: number = 0; ii < this._pairs.length; ii++) { + let n = 0; + for (let ii = 0; ii < this._pairs.length; ii++) { if (this._pairs[ii] > ii && (!satisfied || this.isPairSatisfied(ii, this._pairs[ii]))) { n++; } @@ -2214,8 +2225,9 @@ export default class Pose2D extends ContainerObject implements Updatable { this._showTotalEnergy = show; this._primaryScoreEnergyDisplay.visible = (show && this._scoreFolder != null); this._deltaScoreEnergyDisplay.visible = (show && this._scoreFolder != null); - this._secondaryScoreEnergyDisplay.visible = - (show && this._scoreFolder != null && this._secondaryScoreEnergyDisplay.hasText); + this._secondaryScoreEnergyDisplay.visible = ( + show && this._scoreFolder != null && this._secondaryScoreEnergyDisplay.hasText + ); } public get showExplosionFactor(): boolean { @@ -2227,7 +2239,7 @@ export default class Pose2D extends ContainerObject implements Updatable { } public set scoreFolder(folder: Folder) { - if (this._scoreFolder != folder) { + if (this._scoreFolder !== folder) { this._scoreFolder = folder; this.showTotalEnergy = this._showTotalEnergy; this.generateScoreNodes(); @@ -2246,71 +2258,69 @@ export default class Pose2D extends ContainerObject implements Updatable { public baseShift(parenthesis: string, op: PuzzleEditOp, index: number): void { let sequence: number[] = this.sequence; let locks: boolean[] = this.puzzleLocks; - let binding_site: boolean[] = this.molecularBindingSite; - let sequence_backup: number[] = this.sequence; - let locks_backup: boolean[] = this.puzzleLocks; - let binding_site_backup: boolean[] = this.molecularBindingSite; + let bindingSite: boolean[] = this.molecularBindingSite; + let sequenceBackup: number[] = this.sequence; + let locksBackup: boolean[] = this.puzzleLocks; + let bindingSiteBackup: boolean[] = this.molecularBindingSite; let pindex: number; if (sequence.length > parenthesis.length) { sequence = sequence.slice(0, parenthesis.length); locks = locks.slice(0, parenthesis.length); - binding_site = binding_site.slice(0, parenthesis.length); + bindingSite = bindingSite.slice(0, parenthesis.length); } for (let ii: number = sequence.length; ii < parenthesis.length; ii++) { sequence.push(EPars.RNABASE_ADENINE); locks.push(false); - binding_site.push(false); + bindingSite.push(false); } // BASE SHIFTING MODIFIED HERE. Delete comments to apply the changes if (op === PuzzleEditOp.ADD_BASE) { // Add a base - let after_index: number[] = sequence.slice(index); - let after_lock_index: boolean[] = locks.slice(index); - let after_binding_site_index: boolean[] = binding_site.slice(index); + let afterIndex: number[] = sequence.slice(index); + let afterLockIndex: boolean[] = locks.slice(index); + let afterBindingSiteIndex: boolean[] = bindingSite.slice(index); sequence[index] = EPars.RNABASE_ADENINE; locks[index] = false; - binding_site[index] = false; + bindingSite[index] = false; - for (let ii = 0; ii < after_index.length - 1; ii++) { - sequence[ii + index + 1] = after_index[ii]; - locks[ii + index + 1] = after_lock_index[ii]; - binding_site[ii + index + 1] = after_binding_site_index[ii]; + for (let ii = 0; ii < afterIndex.length - 1; ii++) { + sequence[ii + index + 1] = afterIndex[ii]; + locks[ii + index + 1] = afterLockIndex[ii]; + bindingSite[ii + index + 1] = afterBindingSiteIndex[ii]; } } else if (op === PuzzleEditOp.ADD_PAIR) { // Add a pair pindex = this.pairs[index]; - let after_index = sequence.slice(index); - let after_lock_index = locks.slice(index); - let after_binding_site_index = binding_site.slice(index); + let afterIndex = sequence.slice(index); + let afterLockIndex = locks.slice(index); + let afterBindingSiteIndex = bindingSite.slice(index); sequence[index] = EPars.RNABASE_ADENINE; sequence[pindex + 2] = EPars.RNABASE_ADENINE; locks[index] = false; locks[pindex + 2] = false; - binding_site[index] = false; - binding_site[pindex + 2] = false; + bindingSite[index] = false; + bindingSite[pindex + 2] = false; - for (let ii = 0; ii < after_index.length - 2; ii++) { + for (let ii = 0; ii < afterIndex.length - 2; ii++) { if (ii + index > pindex) { - sequence[ii + index + 2] = after_index[ii]; - locks[ii + index + 2] = after_lock_index[ii]; - binding_site[ii + index + 2] = after_binding_site_index[ii]; + sequence[ii + index + 2] = afterIndex[ii]; + locks[ii + index + 2] = afterLockIndex[ii]; + bindingSite[ii + index + 2] = afterBindingSiteIndex[ii]; } else { - sequence[ii + index + 1] = after_index[ii]; - locks[ii + index + 1] = after_lock_index[ii]; - binding_site[ii + index + 1] = after_binding_site_index[ii]; + sequence[ii + index + 1] = afterIndex[ii]; + locks[ii + index + 1] = afterLockIndex[ii]; + bindingSite[ii + index + 1] = afterBindingSiteIndex[ii]; } - } - } else if (op === PuzzleEditOp.ADD_CYCLE) { // Add a cycle of length 3 - let after_index = sequence.slice(index); - let after_lock_index = locks.slice(index); - let after_binding_site_index = binding_site.slice(index); + let afterIndex = sequence.slice(index); + let afterLockIndex = locks.slice(index); + let afterBindingSiteIndex = bindingSite.slice(index); sequence[index] = EPars.RNABASE_ADENINE; sequence[index + 1] = EPars.RNABASE_ADENINE; @@ -2324,59 +2334,57 @@ export default class Pose2D extends ContainerObject implements Updatable { locks[index + 3] = false; locks[index + 4] = false; - binding_site[index] = false; - binding_site[index + 1] = false; - binding_site[index + 2] = false; - binding_site[index + 3] = false; - binding_site[index + 4] = false; + bindingSite[index] = false; + bindingSite[index + 1] = false; + bindingSite[index + 2] = false; + bindingSite[index + 3] = false; + bindingSite[index + 4] = false; - for (let ii = 0; ii < after_index.length - 5; ii++) { - sequence[ii + index + 5] = after_index[ii]; - locks[ii + index + 5] = after_lock_index[ii]; - binding_site[ii + index + 5] = after_binding_site_index[ii]; + for (let ii = 0; ii < afterIndex.length - 5; ii++) { + sequence[ii + index + 5] = afterIndex[ii]; + locks[ii + index + 5] = afterLockIndex[ii]; + bindingSite[ii + index + 5] = afterBindingSiteIndex[ii]; } - } else if (op === PuzzleEditOp.DELETE_PAIR) { // Delete a pair pindex = this.pairs[index]; - let after_index = sequence_backup.slice(index + 1); - let after_lock_index = locks_backup.slice(index + 1); - let after_binding_site_index = binding_site_backup.slice(index + 1); + let afterIndex = sequenceBackup.slice(index + 1); + let afterLockIndex = locksBackup.slice(index + 1); + let afterBindingSiteIndex = bindingSiteBackup.slice(index + 1); - for (let ii = 0; ii < after_index.length - 1; ii++) { + for (let ii = 0; ii < afterIndex.length - 1; ii++) { if (ii + index >= pindex - 1) { - sequence[ii + index] = after_index[ii + 1]; - locks[ii + index] = after_lock_index[ii + 1]; - binding_site[ii + index] = after_binding_site_index[ii + 1]; + sequence[ii + index] = afterIndex[ii + 1]; + locks[ii + index] = afterLockIndex[ii + 1]; + bindingSite[ii + index] = afterBindingSiteIndex[ii + 1]; } else { - sequence[ii + index] = after_index[ii]; - locks[ii + index] = after_lock_index[ii]; - binding_site[ii + index] = after_binding_site_index[ii]; + sequence[ii + index] = afterIndex[ii]; + locks[ii + index] = afterLockIndex[ii]; + bindingSite[ii + index] = afterBindingSiteIndex[ii]; } } - } else if (op === PuzzleEditOp.DELETE_BASE) { // Delete a base - let after_index = sequence_backup.slice(index + 1); - let after_lock_index = locks_backup.slice(index + 1); - let after_binding_site_index = binding_site_backup.slice(index + 1); + let afterIndex = sequenceBackup.slice(index + 1); + let afterLockIndex = locksBackup.slice(index + 1); + let afterBindingSiteIndex = bindingSiteBackup.slice(index + 1); - for (let ii = 0; ii < after_index.length; ii++) { - sequence[ii + index] = after_index[ii]; - locks[ii + index] = after_lock_index[ii]; - binding_site[ii + index] = after_binding_site_index[ii]; + for (let ii = 0; ii < afterIndex.length; ii++) { + sequence[ii + index] = afterIndex[ii]; + locks[ii + index] = afterLockIndex[ii]; + bindingSite[ii + index] = afterBindingSiteIndex[ii]; } } this.sequence = sequence; this.puzzleLocks = locks; this.molecularStructure = EPars.parenthesisToPairs(parenthesis); - this.molecularBindingSite = binding_site; + this.molecularBindingSite = bindingSite; this.parenthesis = parenthesis; } - public registerPaintTool(paint_color: number, tool: Booster): void { - this._dynPaintColors.push(paint_color); + public registerPaintTool(paintColor: number, tool: Booster): void { + this._dynPaintColors.push(paintColor); this._dynPaintTools.push(tool); } @@ -2402,9 +2410,9 @@ export default class Pose2D extends ContainerObject implements Updatable { this.doneColoring(); } - public forceEditable(b: boolean, edit_list: number[] = null): void { + public forceEditable(b: boolean, editList: number[] = null): void { this._editable = b; - this._editable_indices = edit_list; + this._editableIndices = editList; } private computeLayout(fast: boolean = false): void { @@ -2416,34 +2424,34 @@ export default class Pose2D extends ContainerObject implements Updatable { } let n: number = fullSeq.length; - let x_mid: number = 0; - let y_mid: number = 0; + let xMid = 0; + let yMid = 0; let xarray: number[] = new Array(n); let yarray: number[] = new Array(n); - let rna_drawer: RNALayout; + let rnaDrawer: RNALayout; - let exception_indices: number[] = null; + let exceptionIndices: number[] = null; if (fullSeq.indexOf(EPars.RNABASE_CUT) >= 0) { - exception_indices = []; - exception_indices.push(0); - let oligo_index: number = -1; + exceptionIndices = []; + exceptionIndices.push(0); + let oligoIndex = -1; // array of positions of connectors "&" - while (fullSeq.indexOf(EPars.RNABASE_CUT, oligo_index + 1) >= 0) { - oligo_index = fullSeq.indexOf(EPars.RNABASE_CUT, oligo_index + 1); - exception_indices.push(oligo_index); + while (fullSeq.indexOf(EPars.RNABASE_CUT, oligoIndex + 1) >= 0) { + oligoIndex = fullSeq.indexOf(EPars.RNABASE_CUT, oligoIndex + 1); + exceptionIndices.push(oligoIndex); } } - rna_drawer = new RNALayout( + rnaDrawer = new RNALayout( Pose2D.ZOOM_SPACINGS[this._zoomLevel], Pose2D.ZOOM_SPACINGS[this._zoomLevel] * this._explosionFactor, - exception_indices + exceptionIndices ); - rna_drawer.setupTree(this._pairs); - rna_drawer.drawTree(); - rna_drawer.getCoords(xarray, yarray); + rnaDrawer.setupTree(this._pairs); + rnaDrawer.drawTree(); + rnaDrawer.getCoords(xarray, yarray); if (this._desiredAngle === 90) { let tmp = xarray; @@ -2456,7 +2464,7 @@ export default class Pose2D extends ContainerObject implements Updatable { let ymin: number = yarray[0]; let ymax: number = yarray[0]; - for (let ii: number = 0; ii < n; ii++) { + for (let ii = 0; ii < n; ii++) { if (xarray[ii] < xmin) { xmin = xarray[ii]; } @@ -2474,20 +2482,20 @@ export default class Pose2D extends ContainerObject implements Updatable { } } - x_mid = (xmax + xmin) / 2.0; - y_mid = (ymax + ymin) / 2.0; + xMid = (xmax + xmin) / 2.0; + yMid = (ymax + ymin) / 2.0; this._baseFromX = new Array(n); this._baseFromY = new Array(n); this._baseToX = new Array(n); this._baseToY = new Array(n); - for (let ii: number = 0; ii < n; ii++) { + for (let ii = 0; ii < n; ii++) { this._baseFromX[ii] = this._bases[ii].x; this._baseFromY[ii] = this._bases[ii].y; - this._baseToX[ii] = xarray[ii] - x_mid; - this._baseToY[ii] = yarray[ii] - y_mid; + this._baseToX[ii] = xarray[ii] - xMid; + this._baseToY[ii] = yarray[ii] - yMid; } this._foldStartTime = -1; @@ -2518,7 +2526,9 @@ export default class Pose2D extends ContainerObject implements Updatable { // this._feedback_objs[ii].set_pos(new UDim(0, 0, obj_p.x, obj_p.y)); // this._feedback_objs[ii].graphics.clear(); // this._feedback_objs[ii].graphics.beginFill(0x000000, 0.35); - // this._feedback_objs[ii].graphics.drawRoundRect(0, 0, this._feedback_objs[ii].text_width(), this._feedback_objs[ii].text_height(), 12); + // this._feedback_objs[ii].graphics.drawRoundRect( + // 0, 0, this._feedback_objs[ii].text_width(), this._feedback_objs[ii].text_height(), 12 + // ); // } } @@ -2556,7 +2566,6 @@ export default class Pose2D extends ContainerObject implements Updatable { this._locks[seqnum] = !this._locks[seqnum]; this._bases[seqnum].setDirty(); this._lockUpdated = true; - } else if (this._currentColor === EPars.RNABASE_BINDING_SITE) { if (this._bindingSite != null && this._bindingSite[seqnum]) { this._bindingSite = []; @@ -2566,165 +2575,52 @@ export default class Pose2D extends ContainerObject implements Updatable { this.molecularBindingSite = this._bindingSite; this._bindingSiteUpdated = true; } else { - let binding_bases: number[] = EPars.isInternal(seqnum, this._pairs); - if (binding_bases != null && binding_bases.length > 4) { + let bindingBases: number[] = EPars.isInternal(seqnum, this._pairs); + if (bindingBases != null && bindingBases.length > 4) { this._bindingSite = []; for (let ii = 0; ii < this._sequence.length; ii++) { this._bindingSite.push(false); } - for (let ii = 0; ii < binding_bases.length; ii++) { - this._bindingSite[binding_bases[ii]] = true; + for (let ii = 0; ii < bindingBases.length; ii++) { + this._bindingSite[bindingBases[ii]] = true; } this.molecularBindingSite = this._bindingSite; this._bindingSiteUpdated = true; } else { (this.mode as GameMode).showNotification( - "Binding site can be only formed at loops between 2 stacks\n(Internal loops and Bulges)"); + 'Binding site can be only formed at loops between 2 stacks\n(Internal loops and Bulges)' + ); } } - } else if (this._mouseDownAltKey) { if (this.toggleDesignStruct(seqnum)) { this._designStructUpdated = true; } - } else { - - if (!this.isLocked(seqnum)) { - - if (this._currentColor >= 1 && this._currentColor <= 4) { - this._mutatedSequence[seqnum] = this._currentColor; - ROPWait.notifyPaint(seqnum, this._bases[seqnum].type, this._currentColor); - this._bases[seqnum].setType(this._currentColor, true); - } else if (this._currentColor === EPars.RNABASE_RANDOM) { - let randbase: number = Math.floor(Math.random() * 4) % 4 + 1; - this._mutatedSequence[seqnum] = randbase; - this._bases[seqnum].setType(randbase, true) - } else if (this._currentColor === EPars.RNABASE_PAIR) { - if (this._pairs[seqnum] >= 0) { - let pi = this._pairs[seqnum]; - - if (this.isLocked(pi)) { - return; - } - - let click_base: number = this._mutatedSequence[seqnum]; - - this._mutatedSequence[seqnum] = this._mutatedSequence[pi]; - this._mutatedSequence[pi] = click_base; - - this._bases[seqnum].setType(this._mutatedSequence[seqnum], true); - this._bases[pi].setType(this._mutatedSequence[pi], true); - } - } else if (this._currentColor === EPars.RNABASE_MAGIC) { - this._mutatedSequence[seqnum] = this._currentColor; - this._bases[seqnum].setType(this._currentColor); - } else if (this._currentColor === EPars.RNABASE_AU_PAIR) { - if (this._pairs[seqnum] >= 0) { - let pi = this._pairs[seqnum]; - - if (this.isLocked(pi)) { - return; - } - - this._mutatedSequence[seqnum] = EPars.RNABASE_ADENINE; - this._mutatedSequence[pi] = EPars.RNABASE_URACIL; - - this._bases[seqnum].setType(this._mutatedSequence[seqnum], true); - this._bases[pi].setType(this._mutatedSequence[pi], true); - } - } else if (this._currentColor === EPars.RNABASE_GC_PAIR) { - if (this._pairs[seqnum] >= 0) { - let pi = this._pairs[seqnum]; - - if (this.isLocked(pi)) { - return; - } - - this._mutatedSequence[seqnum] = EPars.RNABASE_GUANINE; - this._mutatedSequence[pi] = EPars.RNABASE_CYTOSINE; - - this._bases[seqnum].setType(this._mutatedSequence[seqnum], true); - this._bases[pi].setType(this._mutatedSequence[pi], true); - } - } else if (this._currentColor === EPars.RNABASE_GU_PAIR) { - if (this._pairs[seqnum] >= 0) { - let pi = this._pairs[seqnum]; - - if (this.isLocked(pi)) { - return; - } - - this._mutatedSequence[seqnum] = EPars.RNABASE_URACIL; - this._mutatedSequence[pi] = EPars.RNABASE_GUANINE; - - this._bases[seqnum].setType(this._mutatedSequence[seqnum], true); - this._bases[pi].setType(this._mutatedSequence[pi], true); - } - } else if (this._dynPaintColors.indexOf(this._currentColor) >= 0) { - let index: number = this._dynPaintColors.indexOf(this._currentColor); - this._dynPaintTools[index].onPaint(this, seqnum); - } - } - } - } - } - - private onBaseMouseMove(seqnum: number): void { - if (!this._coloring && this._shiftStart >= 0 && seqnum < this.sequenceLength) { - this._shiftEnd = seqnum; - this.updateShiftHighlight(); - } - - if (!this._coloring || (seqnum === this._lastColoredIndex)) { - return; - } - - if (this._currentColor === EPars.RNABASE_LOCK) { - if (!this._locks) { - this._locks = []; - for (let ii: number = 0; ii < this._sequence.length; ii++) { - this._locks.push(false); - } - } - this._locks[seqnum] = !this._locks[seqnum]; - this._bases[seqnum].setDirty(); - this._lockUpdated = true; - - } else if (this._mouseDownAltKey) { - if (this.toggleDesignStruct(seqnum)) { - this._designStructUpdated = true; - } - - } else { - if (!this.isLocked(seqnum)) { + } else if (!this.isLocked(seqnum)) { if (this._currentColor >= 1 && this._currentColor <= 4) { this._mutatedSequence[seqnum] = this._currentColor; ROPWait.notifyPaint(seqnum, this._bases[seqnum].type, this._currentColor); this._bases[seqnum].setType(this._currentColor, true); - } else if (this._currentColor === EPars.RNABASE_RANDOM) { - let randbase: number = Math.floor(Math.random() * 4) % 4 + 1; + let randbase: number = (Math.floor(Math.random() * 4) % 4) + 1; this._mutatedSequence[seqnum] = randbase; - this._bases[seqnum].setType(randbase, true) + this._bases[seqnum].setType(randbase, true); } else if (this._currentColor === EPars.RNABASE_PAIR) { if (this._pairs[seqnum] >= 0) { let pi = this._pairs[seqnum]; - if (this._pairs[seqnum] >= 0) { - pi = this._pairs[seqnum]; - if (this.isLocked(pi)) { - return; - } + if (this.isLocked(pi)) { + return; + } - let click_base: number = this._mutatedSequence[seqnum]; + let clickBase: number = this._mutatedSequence[seqnum]; - this._mutatedSequence[seqnum] = this._mutatedSequence[pi]; - this._mutatedSequence[pi] = click_base; + this._mutatedSequence[seqnum] = this._mutatedSequence[pi]; + this._mutatedSequence[pi] = clickBase; - this._bases[seqnum].setType(this._mutatedSequence[seqnum], true); - this._bases[pi].setType(this._mutatedSequence[pi], true); - } + this._bases[seqnum].setType(this._mutatedSequence[seqnum], true); + this._bases[pi].setType(this._mutatedSequence[pi], true); } } else if (this._currentColor === EPars.RNABASE_MAGIC) { this._mutatedSequence[seqnum] = this._currentColor; @@ -2773,8 +2669,112 @@ export default class Pose2D extends ContainerObject implements Updatable { } } else if (this._dynPaintColors.indexOf(this._currentColor) >= 0) { let index: number = this._dynPaintColors.indexOf(this._currentColor); - this._dynPaintTools[index].onPainting(this, seqnum); + this._dynPaintTools[index].onPaint(this, seqnum); + } + } + } + } + + private onBaseMouseMove(seqnum: number): void { + if (!this._coloring && this._shiftStart >= 0 && seqnum < this.sequenceLength) { + this._shiftEnd = seqnum; + this.updateShiftHighlight(); + } + + if (!this._coloring || (seqnum === this._lastColoredIndex)) { + return; + } + + if (this._currentColor === EPars.RNABASE_LOCK) { + if (!this._locks) { + this._locks = []; + for (let ii = 0; ii < this._sequence.length; ii++) { + this._locks.push(false); + } + } + this._locks[seqnum] = !this._locks[seqnum]; + this._bases[seqnum].setDirty(); + this._lockUpdated = true; + } else if (this._mouseDownAltKey) { + if (this.toggleDesignStruct(seqnum)) { + this._designStructUpdated = true; + } + } else if (!this.isLocked(seqnum)) { + if (this._currentColor >= 1 && this._currentColor <= 4) { + this._mutatedSequence[seqnum] = this._currentColor; + ROPWait.notifyPaint(seqnum, this._bases[seqnum].type, this._currentColor); + this._bases[seqnum].setType(this._currentColor, true); + } else if (this._currentColor === EPars.RNABASE_RANDOM) { + let randbase: number = (Math.floor(Math.random() * 4) % 4) + 1; + this._mutatedSequence[seqnum] = randbase; + this._bases[seqnum].setType(randbase, true); + } else if (this._currentColor === EPars.RNABASE_PAIR) { + if (this._pairs[seqnum] >= 0) { + let pi = this._pairs[seqnum]; + if (this._pairs[seqnum] >= 0) { + pi = this._pairs[seqnum]; + + if (this.isLocked(pi)) { + return; + } + + let clickBase: number = this._mutatedSequence[seqnum]; + + this._mutatedSequence[seqnum] = this._mutatedSequence[pi]; + this._mutatedSequence[pi] = clickBase; + + this._bases[seqnum].setType(this._mutatedSequence[seqnum], true); + this._bases[pi].setType(this._mutatedSequence[pi], true); + } + } + } else if (this._currentColor === EPars.RNABASE_MAGIC) { + this._mutatedSequence[seqnum] = this._currentColor; + this._bases[seqnum].setType(this._currentColor); + } else if (this._currentColor === EPars.RNABASE_AU_PAIR) { + if (this._pairs[seqnum] >= 0) { + let pi = this._pairs[seqnum]; + + if (this.isLocked(pi)) { + return; + } + + this._mutatedSequence[seqnum] = EPars.RNABASE_ADENINE; + this._mutatedSequence[pi] = EPars.RNABASE_URACIL; + + this._bases[seqnum].setType(this._mutatedSequence[seqnum], true); + this._bases[pi].setType(this._mutatedSequence[pi], true); } + } else if (this._currentColor === EPars.RNABASE_GC_PAIR) { + if (this._pairs[seqnum] >= 0) { + let pi = this._pairs[seqnum]; + + if (this.isLocked(pi)) { + return; + } + + this._mutatedSequence[seqnum] = EPars.RNABASE_GUANINE; + this._mutatedSequence[pi] = EPars.RNABASE_CYTOSINE; + + this._bases[seqnum].setType(this._mutatedSequence[seqnum], true); + this._bases[pi].setType(this._mutatedSequence[pi], true); + } + } else if (this._currentColor === EPars.RNABASE_GU_PAIR) { + if (this._pairs[seqnum] >= 0) { + let pi = this._pairs[seqnum]; + + if (this.isLocked(pi)) { + return; + } + + this._mutatedSequence[seqnum] = EPars.RNABASE_URACIL; + this._mutatedSequence[pi] = EPars.RNABASE_GUANINE; + + this._bases[seqnum].setType(this._mutatedSequence[seqnum], true); + this._bases[pi].setType(this._mutatedSequence[pi], true); + } + } else if (this._dynPaintColors.indexOf(this._currentColor) >= 0) { + let index: number = this._dynPaintColors.indexOf(this._currentColor); + this._dynPaintTools[index].onPainting(this, seqnum); } } this._lastColoredIndex = seqnum; @@ -2795,7 +2795,11 @@ export default class Pose2D extends ContainerObject implements Updatable { if (this._shiftStart < 0) { this._shiftHighlightBox.clear(); } else { - this._shiftHighlightBox.setHighlight(HighlightType.SHIFT, this._shiftEnd < this._shiftStart ? [this._shiftEnd, this._shiftStart] : [this._shiftStart, this._shiftEnd]); + this._shiftHighlightBox.setHighlight( + HighlightType.SHIFT, + this._shiftEnd < this._shiftStart + ? [this._shiftEnd, this._shiftStart] : [this._shiftStart, this._shiftEnd] + ); this._shiftHighlightBox.isOn = false; } } @@ -2803,12 +2807,13 @@ export default class Pose2D extends ContainerObject implements Updatable { private static drawEnergyHighlight(hilite: Graphics, energy: Sprite): Graphics { // Draw highlight around the energy reading. // Give it a bit of padding so the highlight isn't so tight. - const PADDING: number = 2; + const PADDING = 2; return hilite.clear() .lineStyle(1, 0xFFFFFF, 0.7) .drawRoundedRect( energy.x - PADDING, energy.y - PADDING, - energy.width + PADDING, energy.height + PADDING, 10); + energy.width + PADDING, energy.height + PADDING, 10 + ); } private updateEnergyHighlight(energy: Sprite, idx: number, vis: boolean): void { @@ -2819,16 +2824,13 @@ export default class Pose2D extends ContainerObject implements Updatable { let obj = new SceneObject(Pose2D.drawEnergyHighlight(new Graphics(), energy)); obj.display.alpha = 0; - obj.addObject(new RepeatingTask((): SerialTask => { - return new SerialTask( - new AlphaTask(1, 0.5), - new AlphaTask(0, 0.5) - ) - })); + obj.addObject(new RepeatingTask((): SerialTask => new SerialTask( + new AlphaTask(1, 0.5), + new AlphaTask(0, 0.5) + ))); this.addObject(obj, this.container); this._energyHighlights.push(obj); - } else { let obj = this._energyHighlights[idx]; obj.display.visible = vis; @@ -2851,46 +2853,45 @@ export default class Pose2D extends ContainerObject implements Updatable { return; } - let cleaving_site: number = this._auxInfo[Pose2D.CLEAVING_SITE]; - if (cleaving_site < this._bases.length - 1) { - let b_x: number = this._bases[cleaving_site].x + this._offX; - let b_y: number = this._bases[cleaving_site].y + this._offY; + let cleavingSite: number = this._auxInfo[Pose2D.CLEAVING_SITE]; + if (cleavingSite < this._bases.length - 1) { + let bX: number = this._bases[cleavingSite].x + this._offX; + let bY: number = this._bases[cleavingSite].y + this._offY; - let b_next_x: number = this._bases[cleaving_site + 1].x + this._offX; - let b_next_y: number = this._bases[cleaving_site + 1].y + this._offY; + let bNextX: number = this._bases[cleavingSite + 1].x + this._offX; + let bNextY: number = this._bases[cleavingSite + 1].y + this._offY; - let c_x: number = (b_x + b_next_x) / 2.0; - let c_y: number = (b_y + b_next_y) / 2.0; + let cX: number = (bX + bNextX) / 2.0; + let cY: number = (bY + bNextY) / 2.0; - let go_x: number = b_next_y - b_y; - let go_y: number = -(b_next_x - b_x); + let goX: number = bNextY - bY; + let goY: number = -(bNextX - bX); this._auxInfoCanvas.lineStyle(3, 0xFF0000, 0.9); - this._auxInfoCanvas.moveTo(c_x + go_x / 2.0, c_y + go_y / 2.0); - this._auxInfoCanvas.lineTo(c_x - go_x / 2.0, c_y - go_y / 2.0); + this._auxInfoCanvas.moveTo(cX + goX / 2.0, cY + goY / 2.0); + this._auxInfoCanvas.lineTo(cX - goX / 2.0, cY - goY / 2.0); - this._auxTextballoon.display.position = new Point(c_x + go_x / 2.0, c_y + go_y / 2.0); + this._auxTextballoon.display.position = new Point(cX + goX / 2.0, cY + goY / 2.0); } } private checkPairs(): void { let fullSeq: number[] = this.fullSequence; - for (let ii: number = 0; ii < this._pairs.length; ii++) { + for (let ii = 0; ii < this._pairs.length; ii++) { if (this._pairs[ii] >= 0 && this.isPairSatisfied(ii, this._pairs[ii])) { - - let pair_str: number = Pose2D.getPairStrength(fullSeq[ii], fullSeq[this._pairs[ii]]); + let pairStr: number = Pose2D.getPairStrength(fullSeq[ii], fullSeq[this._pairs[ii]]); if (this._baseToX) { this._bases[ii].setPairing(true, this._baseToX[this._pairs[ii]] - this._baseToX[ii], this._baseToY[this._pairs[ii]] - this._baseToY[ii], - 0.5, pair_str); + 0.5, pairStr); } else { this._bases[ii].setPairing(true, this._bases[this._pairs[ii]].x - this._bases[ii].x, this._bases[this._pairs[ii]].y - this._bases[ii].y, - 0.5, pair_str); + 0.5, pairStr); } } else { this._bases[ii].setPairing(false, -1, -1, 0.5, -1); @@ -2916,8 +2917,8 @@ export default class Pose2D extends ContainerObject implements Updatable { this._scoreNodeHighlight.beginFill(0xFFFFFF, 0.22); let indices: number[] = this._scoreNodes[this._scoreNodeIndex].baseIndices; - for (let ii: number = 0; ii < indices.length; ii++) { - let p: Point = this.getBaseXY(indices[ii]); + for (let ii = 0; ii < indices.length; ii++) { + let p: Point = this.getBaseLoc(indices[ii]); if (ii === 0) { this._scoreNodeHighlight.moveTo(p.x, p.y); @@ -2933,24 +2934,24 @@ export default class Pose2D extends ContainerObject implements Updatable { if (this._scoreTexts != null) { for (let ii = 0; ii < this._scoreNodes.length; ii++) { let indices: number[] = this._scoreNodes[ii].baseIndices; - let x_avg: number = 0; - let y_avg: number = 0; + let xAvg = 0; + let yAvg = 0; - for (let jj: number = 0; jj < indices.length; jj++) { - let p: Point = this.getBaseXY(indices[jj]); - x_avg += p.x; - y_avg += p.y; + for (let jj = 0; jj < indices.length; jj++) { + let p: Point = this.getBaseLoc(indices[jj]); + xAvg += p.x; + yAvg += p.y; } if (indices.length > 0) { - x_avg /= indices.length; - y_avg /= indices.length; + xAvg /= indices.length; + yAvg /= indices.length; } - x_avg -= this._scoreTexts[ii].width / 2; - y_avg -= this._scoreTexts[ii].height / 2; + xAvg -= this._scoreTexts[ii].width / 2; + yAvg -= this._scoreTexts[ii].height / 2; - this._scoreTexts[ii].position = new Point(x_avg, y_avg); + this._scoreTexts[ii].position = new Point(xAvg, yAvg); this._scoreTexts[ii].visible = (this._zoomLevel < 4); this.updateEnergyHighlight(this._scoreTexts[ii], ii, this._scoreTexts[ii].visible); } @@ -2966,28 +2967,28 @@ export default class Pose2D extends ContainerObject implements Updatable { this._scoreNodeIndex = -1; if (this._scoreNodes != null) { - let totalScore: number = 0; - let nodeFound: boolean = false; - let nodeTxt: string = ""; - let nodeLabel: string = ""; - let nodeScore: string = ""; + let totalScore = 0; + let nodeFound = false; + let nodeTxt = ''; + let nodeLabel = ''; + let nodeScore = ''; if (this._poseField.containsPoint(Flashbang.globalMouse.x, Flashbang.globalMouse.y)) { - let mouse_p: Point = this.display.toLocal(Flashbang.globalMouse, undefined, Pose2D.MOUSE_LOC); - let base_xys: Point[] = []; + let mouseP: Point = this.display.toLocal(Flashbang.globalMouse, undefined, Pose2D.MOUSE_LOC); + let baseXys: Point[] = []; - for (let ii: number = 0; ii < this.fullSequenceLength; ii++) { - base_xys.push(this.getBaseXY(ii)); + for (let ii = 0; ii < this.fullSequenceLength; ii++) { + baseXys.push(this.getBaseLoc(ii)); } for (let ii = 0; ii < this._scoreNodes.length; ii++) { - let base_indices: number[] = this._scoreNodes[ii].baseIndices; - let node_points: Point[] = []; + let baseIndices: number[] = this._scoreNodes[ii].baseIndices; + let nodePoints: Point[] = []; - for (let jj: number = 0; jj < base_indices.length; jj++) { - node_points.push(base_xys[base_indices[jj]]); + for (let jj = 0; jj < baseIndices.length; jj++) { + nodePoints.push(baseXys[baseIndices[jj]]); } - if (!nodeFound && Utility.isPointWithin(mouse_p, node_points)) { + if (!nodeFound && Utility.isPointWithin(mouseP, nodePoints)) { nodeTxt = this._scoreNodes[ii].text; nodeLabel = this._scoreNodes[ii].textLabel; nodeScore = this._scoreNodes[ii].textScore; @@ -3001,67 +3002,65 @@ export default class Pose2D extends ContainerObject implements Updatable { totalScore += scoreNode.score; } - let scoreLabel = "Total"; - let scoreScore = ""; - let factor: number = 0; - if ((this._molecularBindingBases != null) || - (this._oligo != null && this._oligoMode === Pose2D.OLIGO_MODE_DIMER) || - (this._oligos != null)) { - - let label_elems: string[] = []; - let score_elems: string[] = []; + let scoreLabel = 'Total'; + let scoreScore = ''; + let factor = 0; + if ((this._molecularBindingBases != null) + || (this._oligo != null && this._oligoMode === Pose2D.OLIGO_MODE_DIMER) + || (this._oligos != null)) { + let labelElems: string[] = []; + let scoreElems: string[] = []; if (this._molecularBindingBases != null) { factor++; if (this._moleculeIsBoundReal) { - label_elems.push(EnergyScoreDisplay.green("Molecule Bound")); + labelElems.push(EnergyScoreDisplay.green('Molecule Bound')); // Round to 2 decimal places let bonus = Math.round(this._molecularBindingBonus * 1e2) / 1e2; - score_elems.push(EnergyScoreDisplay.green(` ${bonus} kcal`)); + scoreElems.push(EnergyScoreDisplay.green(` ${bonus} kcal`)); } else { - label_elems.push(EnergyScoreDisplay.grey("Molecule Not Bound")); - score_elems.push(EnergyScoreDisplay.grey(" (0 kcal)")); + labelElems.push(EnergyScoreDisplay.grey('Molecule Not Bound')); + scoreElems.push(EnergyScoreDisplay.grey(' (0 kcal)')); } } if (this._oligo != null && this._oligoMode === Pose2D.OLIGO_MODE_DIMER) { factor++; let malus: number = this._duplexCost + Math.round(this._oligoMalus); if (this._oligoPaired) { - label_elems.push(EnergyScoreDisplay.green("Oligo Bound")); - score_elems.push(EnergyScoreDisplay.red(` ${malus.toFixed(2)} kcal`)); + labelElems.push(EnergyScoreDisplay.green('Oligo Bound')); + scoreElems.push(EnergyScoreDisplay.red(` ${malus.toFixed(2)} kcal`)); } else { - label_elems.push(EnergyScoreDisplay.grey("Oligo Not Bound")); - score_elems.push(EnergyScoreDisplay.grey(` ${malus.toFixed(2)} kcal`)); + labelElems.push(EnergyScoreDisplay.grey('Oligo Not Bound')); + scoreElems.push(EnergyScoreDisplay.grey(` ${malus.toFixed(2)} kcal`)); } } if (this._oligos != null) { factor++; if (this._oligosPaired === 0) { if (this._oligos.length > 1) { - label_elems.push(EnergyScoreDisplay.grey("No Oligo Bound")); + labelElems.push(EnergyScoreDisplay.grey('No Oligo Bound')); } else { - label_elems.push(EnergyScoreDisplay.grey("Oligo Not Bound")); + labelElems.push(EnergyScoreDisplay.grey('Oligo Not Bound')); } - score_elems.push(EnergyScoreDisplay.grey(" (0 kcal)")); + scoreElems.push(EnergyScoreDisplay.grey(' (0 kcal)')); } else { let malus = this._duplexCost; for (let ii = 0; ii < this._oligosPaired; ii++) { malus += Math.round(this._oligos[this._oligosOrder[ii]].malus); } if (this._oligosPaired > 1) { - label_elems.push(EnergyScoreDisplay.green("Oligos Bound")); + labelElems.push(EnergyScoreDisplay.green('Oligos Bound')); } else { - label_elems.push(EnergyScoreDisplay.green("Oligo Bound")); + labelElems.push(EnergyScoreDisplay.green('Oligo Bound')); } - score_elems.push(EnergyScoreDisplay.red(` ${malus.toFixed(2)} kcal`)); + scoreElems.push(EnergyScoreDisplay.red(` ${malus.toFixed(2)} kcal`)); } } - scoreLabel += EnergyScoreDisplay.grey(" (") + label_elems.join(", ") + EnergyScoreDisplay.grey(")"); - scoreScore = (totalScore / 100).toString() + score_elems.join(""); - + scoreLabel += EnergyScoreDisplay.grey(' (') + labelElems.join(', ') + EnergyScoreDisplay.grey(')'); + scoreScore = (totalScore / 100).toString() + scoreElems.join(''); } else { - scoreScore = (totalScore / 100).toString() + " kcal"; + scoreScore = `${(totalScore / 100).toString()} kcal`; } this.updateEnergyDisplaySizeLocation(factor); @@ -3074,13 +3073,13 @@ export default class Pose2D extends ContainerObject implements Updatable { let attemptSetDelta = () => { try { this._deltaScoreEnergyDisplay.setEnergyText( - "Natural/Target Delta", - Math.round(this._getEnergyDelta()) / 100 + " kcal" + 'Natural/Target Delta', + `${Math.round(this._getEnergyDelta()) / 100} kcal` ); } catch (e) { setTimeout(attemptSetDelta, 1000); } - } + }; setTimeout(attemptSetDelta, 50); } } @@ -3089,17 +3088,17 @@ export default class Pose2D extends ContainerObject implements Updatable { this._primaryScoreEnergyDisplay.position = new Point(17, 118); this._primaryScoreEnergyDisplay.setSize(111 + factor * 59, 40); - this._deltaScoreEnergyDisplay.position = new Point(17 + 119 + factor * 59, 118) + this._deltaScoreEnergyDisplay.position = new Point(17 + 119 + factor * 59, 118); this._deltaScoreEnergyDisplay.setSize(111, 40); - this._secondaryScoreEnergyDisplay.position = new Point(17 + 119*2 + factor * 59, 118); + this._secondaryScoreEnergyDisplay.position = new Point(17 + 119 * 2 + factor * 59, 118); this._secondaryScoreEnergyDisplay.setSize(111, 40); } private clearScoreTexts(): void { if (this._scoreTexts != null) { - for (let score_text of this._scoreTexts) { - score_text.destroy({children: true}); + for (let scoreText of this._scoreTexts) { + scoreText.destroy({children: true}); } this._scoreTexts = null; } @@ -3110,28 +3109,27 @@ export default class Pose2D extends ContainerObject implements Updatable { this._scoreNodeHighlight.clear(); this.clearEnergyHighlights(); - if (this._scoreFolder == null || - this._sequence == null || - this._sequence.length === 0 || - this._pairs == null || - this._pairs.length !== this.fullSequenceLength) { - + if (this._scoreFolder == null + || this._sequence == null + || this._sequence.length === 0 + || this._pairs == null + || this._pairs.length !== this.fullSequenceLength) { this.clearScoreTexts(); return; } - /// JEE : It's a bit of waste to generate RNALayout twice (once here, once when drawing rna) - /// But this is cheap, so it shouldn't matter too much - let score_tree: RNALayout = new RNALayout; - score_tree.setupTree(this.satisfiedPairs); + // / JEE : It's a bit of waste to generate RNALayout twice (once here, once when drawing rna) + // / But this is cheap, so it shouldn't matter too much + let scoreTree: RNALayout = new RNALayout(); + scoreTree.setupTree(this.satisfiedPairs); - let treeroot: RNATreeNode = score_tree.root; - score_tree.scoreTree(this.fullSequence, this._scoreFolder); + let treeroot: RNATreeNode = scoreTree.root; + scoreTree.scoreTree(this.fullSequence, this._scoreFolder); - let score_nodes: ScoreDisplayNode[] = []; - let root_coords: number[] = []; - this.generateScoreNodesRecursive(treeroot, root_coords, score_nodes); - this._scoreNodes = score_nodes; + let scoreNodes: ScoreDisplayNode[] = []; + let rootCoords: number[] = []; + this.generateScoreNodesRecursive(treeroot, rootCoords, scoreNodes); + this._scoreNodes = scoreNodes; this.clearScoreTexts(); if (this._displayScoreTexts) { @@ -3162,7 +3160,7 @@ export default class Pose2D extends ContainerObject implements Updatable { } } - let child_coords: number[]; + let childCoords: number[]; if (root.isPair) { if (root.children.length > 1) { @@ -3171,29 +3169,28 @@ export default class Pose2D extends ContainerObject implements Updatable { if (root.children.length !== 0) { if (root.children[0].isPair) { - child_coords = []; + childCoords = []; - child_coords.push(root.indexA); - child_coords.push(root.indexB); + childCoords.push(root.indexA); + childCoords.push(root.indexB); - child_coords.push(root.children[0].indexB); - child_coords.push(root.children[0].indexA); + childCoords.push(root.children[0].indexB); + childCoords.push(root.children[0].indexA); let newnode = new ScoreDisplayNode(); nodes.push(newnode); - newnode.setType(ScoreDisplayNodeType.STACK, child_coords, root.score); + newnode.setType(ScoreDisplayNodeType.STACK, childCoords, root.score); this.generateScoreNodesRecursive(root.children[0], null, nodes); } else { - child_coords = []; + childCoords = []; - child_coords.push(root.indexB); - child_coords.push(root.indexA); + childCoords.push(root.indexB); + childCoords.push(root.indexA); - this.generateScoreNodesRecursive(root.children[0], child_coords, nodes); + this.generateScoreNodesRecursive(root.children[0], childCoords, nodes); } } - } else { for (let child of root.children) { this.generateScoreNodesRecursive(child, coords, nodes); @@ -3209,9 +3206,9 @@ export default class Pose2D extends ContainerObject implements Updatable { } private isEditable(seqnum: number): boolean { - if (this._editable_indices != null) { - let in_list: boolean = (this._editable_indices.indexOf(seqnum) !== -1); - return this._editable ? in_list : !in_list; + if (this._editableIndices != null) { + let inList: boolean = (this._editableIndices.indexOf(seqnum) !== -1); + return this._editable ? inList : !inList; } else { return this._editable; } @@ -3254,7 +3251,7 @@ export default class Pose2D extends ContainerObject implements Updatable { private _width: number = 0; private _height: number = 0; - /// Array of sequence/pairs + // / Array of sequence/pairs private _sequence: number[] = []; private _mutatedSequence: number[]; private _pairs: number[] = []; @@ -3273,7 +3270,7 @@ export default class Pose2D extends ContainerObject implements Updatable { private _parenthesis: string; private _shiftLimit: number; - /// Oligos + // / Oligos private _oligo: number[] = null; private _oligoMode: number = Pose2D.OLIGO_MODE_DIMER; private _oligoName: string = null; @@ -3282,7 +3279,7 @@ export default class Pose2D extends ContainerObject implements Updatable { private _oligoBases: BaseGlow[] = null; // for glows private _oligoPaired: boolean = false; - /// Multistrands + // / Multistrands private _oligos: Oligo[] = null; private _oligosOrder: number[] = null; private _prevOligosOrder: number[]; @@ -3299,22 +3296,22 @@ export default class Pose2D extends ContainerObject implements Updatable { private _bindingSiteUpdated: boolean; private _designStructUpdated: boolean; - /// Scripted painters + // / Scripted painters private _dynPaintColors: number[] = []; private _dynPaintTools: Booster[] = []; - /// Is this pose editable? + // / Is this pose editable? private _editable: boolean; - private _editable_indices: number[] = null; + private _editableIndices: number[] = null; - /// Pointer to callback function to be called after change in pose + // / Pointer to callback function to be called after change in pose private _poseEditCallback: () => void = null; private _trackMovesCallback: (count: number, moves: any[]) => void = null; private _addBaseCallback: (parenthesis: string, op: PuzzleEditOp, index: number) => void; private _startMousedownCallback: PoseMouseDownCallback; private _mouseDownAltKey: boolean = false; - /// Pointer to function that needs to be called in a GameMode to have access to appropriate state + // / Pointer to function that needs to be called in a GameMode to have access to appropriate state private _getEnergyDelta: () => number; private _lettermode: boolean = false; @@ -3322,10 +3319,10 @@ export default class Pose2D extends ContainerObject implements Updatable { private _redraw: boolean = true; - /// Time which we sampled bases to animate last time; + // / Time which we sampled bases to animate last time; private lastSampledTime: number = -1; - /// Pose position offset + // / Pose position offset private _offX: number = 0; private _offY: number = 0; private _prevOffsetX: number = 0; @@ -3336,7 +3333,7 @@ export default class Pose2D extends ContainerObject implements Updatable { private _endOffsetX: number; private _endOffsetY: number; - /// For base moving animation + // / For base moving animation private _baseFromX: number[]; private _baseFromY: number[]; private _baseToX: number[]; @@ -3348,7 +3345,7 @@ export default class Pose2D extends ContainerObject implements Updatable { private _zoomLevel: number = 0; private _desiredAngle: number = 0; - /// Is explosion animation on going? + // / Is explosion animation on going? private _isExploding: boolean = false; private _explosionStartTime: number = -1; private _explosionRays: LightRay[]; @@ -3357,7 +3354,7 @@ export default class Pose2D extends ContainerObject implements Updatable { private _onExplosionComplete: () => void; - /// Selection box + // / Selection box private _selectionHighlightBox: HighlightBox; private _restrictedHighlightBox: HighlightBox; private _highlightRestricted: boolean = false; @@ -3368,11 +3365,11 @@ export default class Pose2D extends ContainerObject implements Updatable { private _shiftStart: number = -1; private _shiftEnd: number = -1; - /// For praising stacks + // / For praising stacks private _praiseQueue: number[] = []; private _praiseSeq: number[] = []; - /// Score display nodes + // / Score display nodes private _scoreNodes: ScoreDisplayNode[]; private _scoreTexts: Sprite[]; private _scoreFolder: Folder; @@ -3390,7 +3387,7 @@ export default class Pose2D extends ContainerObject implements Updatable { private _explosionFactor: number = 1; private _explosionFactorPanel: ExplosionFactorPanel; - /// For tracking a base + // / For tracking a base private _trackedIndices: number[] = []; private _baseBoxes: Graphics[] = []; private _cursorIndex: number = 0; @@ -3398,11 +3395,11 @@ export default class Pose2D extends ContainerObject implements Updatable { private _lastShiftedIndex: number = -1; private _lastShiftedCommand: number = -1; - /// Rendering mode + // / Rendering mode private _numberingMode: boolean = false; private _simpleGraphicsMods: boolean = false; - /// Last exp paint data + // / Last exp paint data private _expPainter: ExpPainter = null; private _expMid: number = 0; private _expHi: number = 0; @@ -3421,14 +3418,14 @@ export default class Pose2D extends ContainerObject implements Updatable { private _highlightEnergyText: boolean = false; private _energyHighlights: SceneObject[] = []; /* - * NEW HIGHLIGHT. - * - Input: List of nucleotides that we wish to highlight. - * - Unhighlighted Nucleotides: Draw at 65% opacity. - * - Highlight Nucleotides: Brighten glow around the nucleotide. - */ + * NEW HIGHLIGHT. + * - Input: List of nucleotides that we wish to highlight. + * - Unhighlighted Nucleotides: Draw at 65% opacity. + * - Highlight Nucleotides: Brighten glow around the nucleotide. + */ private _allNewHighlights: RNAHighlightState[] = []; - private static readonly CLEAVING_SITE = "cleaving_site"; + private static readonly CLEAVING_SITE = 'cleavingSite'; private static readonly P: Point = new Point(); } @@ -3440,6 +3437,6 @@ export interface Oligo { } export class RNAHighlightState { - public nuc: number[] = null; // nucleotides + public nuc: number[] = null; // nucleotides public isOn: boolean = false; } diff --git a/src/eterna/pose2D/PoseField.ts b/src/eterna/pose2D/PoseField.ts index 0a7e3701b..4056b299f 100644 --- a/src/eterna/pose2D/PoseField.ts +++ b/src/eterna/pose2D/PoseField.ts @@ -1,9 +1,11 @@ -import {Graphics, Point} from "pixi.js"; -import {Flashbang, GameObjectRef} from "flashbang/core"; -import {InputUtil, KeyboardEventType, KeyboardListener, KeyCode, MouseWheelListener} from "flashbang/input"; -import {ContainerObject, Dragger} from "flashbang/objects"; -import {ROPWait} from "eterna/rscript"; -import Pose2D from "./Pose2D"; +import {Graphics, Point} from 'pixi.js'; +import {Flashbang, GameObjectRef} from 'flashbang/core'; +import { + InputUtil, KeyboardEventType, KeyboardListener, KeyCode, MouseWheelListener +} from 'flashbang/input'; +import {ContainerObject, Dragger} from 'flashbang/objects'; +import {ROPWait} from 'eterna/rscript'; +import Pose2D from './Pose2D'; type InteractionEvent = PIXI.interaction.InteractionEvent; @@ -23,7 +25,7 @@ export default class PoseField extends ContainerObject implements KeyboardListen this.addObject(this._pose, this.container); - this.pointerDown.filter(InputUtil.IsLeftMouse).connect((e) => this.onMouseDown(e)); + this.pointerDown.filter(InputUtil.IsLeftMouse).connect(e => this.onMouseDown(e)); this.pointerUp.filter(InputUtil.IsLeftMouse).connect(() => this.onMouseUp()); this.regs.add(this.mode.keyboardInput.pushListener(this)); @@ -82,21 +84,19 @@ export default class PoseField extends ContainerObject implements KeyboardListen } public zoomIn(): void { - let prev_zoom: number = this._pose.zoomLevel; + let prevZoom: number = this._pose.zoomLevel; - if (prev_zoom === 0) - return; + if (prevZoom === 0) return; - this._pose.setZoomLevel(prev_zoom - 1); + this._pose.setZoomLevel(prevZoom - 1); } public zoomOut(): void { - let prev_zoom: number = this._pose.zoomLevel; + let prevZoom: number = this._pose.zoomLevel; - if (prev_zoom === Pose2D.ZOOM_SPACINGS.length - 1) - return; + if (prevZoom === Pose2D.ZOOM_SPACINGS.length - 1) return; - this._pose.setZoomLevel(prev_zoom + 1); + this._pose.setZoomLevel(prevZoom + 1); } public get pose(): Pose2D { @@ -150,7 +150,7 @@ export default class PoseField extends ContainerObject implements KeyboardListen } public onKeyboardEvent(e: KeyboardEvent): boolean { - if (!this.display.visible || e.type != KeyboardEventType.KEY_DOWN) { + if (!this.display.visible || e.type !== KeyboardEventType.KEY_DOWN) { return false; } diff --git a/src/eterna/pose2D/PoseOp.ts b/src/eterna/pose2D/PoseOp.ts index 68a6f5afc..bc5af8ae9 100644 --- a/src/eterna/pose2D/PoseOp.ts +++ b/src/eterna/pose2D/PoseOp.ts @@ -2,7 +2,7 @@ export default class PoseOp { public sn?: number; public fn: () => void; - public constructor(sn: number | null, fn: () => void) { + constructor(sn: number | null, fn: () => void) { this.sn = sn; this.fn = fn; } diff --git a/src/eterna/pose2D/PoseUtil.ts b/src/eterna/pose2D/PoseUtil.ts index 46fa31526..6d7fc1285 100644 --- a/src/eterna/pose2D/PoseUtil.ts +++ b/src/eterna/pose2D/PoseUtil.ts @@ -1,5 +1,5 @@ -import EPars from "eterna/EPars"; -import PuzzleEditOp from "./PuzzleEditOp"; +import EPars from 'eterna/EPars'; +import PuzzleEditOp from './PuzzleEditOp'; /** Utility functions for pose data */ export default class PoseUtil { @@ -16,27 +16,27 @@ export default class PoseUtil { } public static addBaseWithIndex(index: number, pairs: number[]): any[] { - let mutated_pairs: number[]; - mutated_pairs = pairs.slice(0, index); - mutated_pairs.push(-1); - mutated_pairs = mutated_pairs.concat(pairs.slice(index, pairs.length)); - - for (let ii: number = 0; ii < mutated_pairs.length; ii++) { - if (mutated_pairs[ii] >= index) { - mutated_pairs[ii]++; + let mutatedPairs: number[]; + mutatedPairs = pairs.slice(0, index); + mutatedPairs.push(-1); + mutatedPairs = mutatedPairs.concat(pairs.slice(index, pairs.length)); + + for (let ii = 0; ii < mutatedPairs.length; ii++) { + if (mutatedPairs[ii] >= index) { + mutatedPairs[ii]++; } } - let parenthesis: string = EPars.pairsToParenthesis(mutated_pairs); - return [parenthesis, PuzzleEditOp.ADD_BASE, mutated_pairs]; + let parenthesis: string = EPars.pairsToParenthesis(mutatedPairs); + return [parenthesis, PuzzleEditOp.ADD_BASE, mutatedPairs]; } public static addPairWithIndex(index: number, pairs: number[]): any[] { - let mutated_pairs: number[]; + let mutatedPairs: number[]; let parenthesis: string; let ii: number; - //if index is paired - //add another pair before index + // if index is paired + // add another pair before index let pindex: number = pairs[index]; if (pindex >= 0) { if (index > pindex) { @@ -44,59 +44,57 @@ export default class PoseUtil { index = pindex; pindex = tmp; } - mutated_pairs = pairs.slice(0, index); - mutated_pairs.push(-1); - mutated_pairs = mutated_pairs.concat(pairs.slice(index, pindex + 1)); - mutated_pairs.push(-1); - mutated_pairs = mutated_pairs.concat(pairs.slice(pindex + 1, pairs.length)); - - for (ii = 0; ii < mutated_pairs.length; ii++) { - if (mutated_pairs[ii] > pindex) { - mutated_pairs[ii] += 2; - } else if (mutated_pairs[ii] >= index) { - mutated_pairs[ii] += 1; + mutatedPairs = pairs.slice(0, index); + mutatedPairs.push(-1); + mutatedPairs = mutatedPairs.concat(pairs.slice(index, pindex + 1)); + mutatedPairs.push(-1); + mutatedPairs = mutatedPairs.concat(pairs.slice(pindex + 1, pairs.length)); + + for (ii = 0; ii < mutatedPairs.length; ii++) { + if (mutatedPairs[ii] > pindex) { + mutatedPairs[ii] += 2; + } else if (mutatedPairs[ii] >= index) { + mutatedPairs[ii] += 1; } } - mutated_pairs[index] = pindex + 2; - mutated_pairs[pindex + 2] = index; + mutatedPairs[index] = pindex + 2; + mutatedPairs[pindex + 2] = index; - parenthesis = EPars.pairsToParenthesis(mutated_pairs); + parenthesis = EPars.pairsToParenthesis(mutatedPairs); return [parenthesis, PuzzleEditOp.ADD_PAIR]; - - } - //add a cycle of length 3 - else { - mutated_pairs = pairs.slice(0, index); + } else { + // add a cycle of length 3 + mutatedPairs = pairs.slice(0, index); for (ii = 0; ii < 5; ii++) { - mutated_pairs.push(-1); + mutatedPairs.push(-1); } - mutated_pairs = mutated_pairs.concat(pairs.slice(index, pairs.length)); - for (ii = 0; ii < mutated_pairs.length; ii++) { - if (mutated_pairs[ii] >= index) { - mutated_pairs[ii] += 5; + mutatedPairs = mutatedPairs.concat(pairs.slice(index, pairs.length)); + for (ii = 0; ii < mutatedPairs.length; ii++) { + if (mutatedPairs[ii] >= index) { + mutatedPairs[ii] += 5; } } - mutated_pairs[index] = index + 4; - mutated_pairs[index + 4] = index; + mutatedPairs[index] = index + 4; + mutatedPairs[index + 4] = index; - parenthesis = EPars.pairsToParenthesis(mutated_pairs); + parenthesis = EPars.pairsToParenthesis(mutatedPairs); return [parenthesis, PuzzleEditOp.ADD_CYCLE]; } } public static deleteNopairWithIndex(index: number, pairs: number[]): any[] { - let mutated_pairs: number[]; + let mutatedPairs: number[]; let parenthesis: string; - mutated_pairs = pairs.slice(0, index); - mutated_pairs = mutated_pairs.concat(pairs.slice(index + 1, pairs.length)); - for (let ii: number = 0; ii < mutated_pairs.length; ii++) { - if (mutated_pairs[ii] >= index) { - mutated_pairs[ii] -= 1; + mutatedPairs = pairs.slice(0, index); + mutatedPairs = mutatedPairs.concat(pairs.slice(index + 1, pairs.length)); + for (let ii = 0; ii < mutatedPairs.length; ii++) { + if (mutatedPairs[ii] >= index) { + mutatedPairs[ii] -= 1; } } - parenthesis = EPars.pairsToParenthesis(mutated_pairs); - return [parenthesis, PuzzleEditOp.DELETE_BASE, mutated_pairs]; + parenthesis = EPars.pairsToParenthesis(mutatedPairs); + return [parenthesis, PuzzleEditOp.DELETE_BASE, mutatedPairs]; } public static deletePairWithIndex(index: number, pairs: number[]): any[] { @@ -105,7 +103,7 @@ export default class PoseUtil { throw new Error("base doesn't have pair"); } - let mutated_pairs: number[]; + let mutatedPairs: number[]; let parenthesis: string; if (index > pindex) { @@ -113,18 +111,18 @@ export default class PoseUtil { index = pindex; pindex = tmp; } - mutated_pairs = pairs.slice(0, index); - mutated_pairs = mutated_pairs.concat(pairs.slice(index + 1, pindex)); - mutated_pairs = mutated_pairs.concat(pairs.slice(pindex + 1, pairs.length)); - for (let ii: number = 0; ii < mutated_pairs.length; ii++) { - if (mutated_pairs[ii] > pindex) { - mutated_pairs[ii] -= 2; - } else if (mutated_pairs[ii] >= index) { - mutated_pairs[ii] -= 1; + mutatedPairs = pairs.slice(0, index); + mutatedPairs = mutatedPairs.concat(pairs.slice(index + 1, pindex)); + mutatedPairs = mutatedPairs.concat(pairs.slice(pindex + 1, pairs.length)); + for (let ii = 0; ii < mutatedPairs.length; ii++) { + if (mutatedPairs[ii] > pindex) { + mutatedPairs[ii] -= 2; + } else if (mutatedPairs[ii] >= index) { + mutatedPairs[ii] -= 1; } } - parenthesis = EPars.pairsToParenthesis(mutated_pairs); + parenthesis = EPars.pairsToParenthesis(mutatedPairs); return [parenthesis, PuzzleEditOp.DELETE_PAIR]; } diff --git a/src/eterna/pose2D/PuzzleEditOp.ts b/src/eterna/pose2D/PuzzleEditOp.ts index a2ee5ad0d..44d0294b8 100644 --- a/src/eterna/pose2D/PuzzleEditOp.ts +++ b/src/eterna/pose2D/PuzzleEditOp.ts @@ -1,9 +1,9 @@ enum PuzzleEditOp { - ADD_BASE = "AddBase", - ADD_PAIR = "AddPair", - ADD_CYCLE = "AddCycle", - DELETE_PAIR = "DeletePair", - DELETE_BASE = "DeleteBase", + ADD_BASE = 'AddBase', + ADD_PAIR = 'AddPair', + ADD_CYCLE = 'AddCycle', + DELETE_PAIR = 'DeletePair', + DELETE_BASE = 'DeleteBase', } export default PuzzleEditOp; diff --git a/src/eterna/pose2D/RNAAnchorObject.ts b/src/eterna/pose2D/RNAAnchorObject.ts index 8e0353b64..ef00e82e3 100644 --- a/src/eterna/pose2D/RNAAnchorObject.ts +++ b/src/eterna/pose2D/RNAAnchorObject.ts @@ -1,6 +1,6 @@ -import {Point} from "pixi.js" -import {GameObjectRef} from "flashbang/core"; -import {SceneObject} from "flashbang/objects"; +import {Point} from 'pixi.js'; +import {GameObjectRef} from 'flashbang/core'; +import {SceneObject} from 'flashbang/objects'; export default class RNAAnchorObject { public ref: GameObjectRef; @@ -15,7 +15,7 @@ export default class RNAAnchorObject { return this.ref.isLive; } - public constructor(object: SceneObject, base: number, offset: Point) { + constructor(object: SceneObject, base: number, offset: Point) { this.ref = object.ref; this.base = base; this.offset = offset; diff --git a/src/eterna/pose2D/RNALayout.ts b/src/eterna/pose2D/RNALayout.ts index 6daaf5258..d7856ae16 100644 --- a/src/eterna/pose2D/RNALayout.ts +++ b/src/eterna/pose2D/RNALayout.ts @@ -1,5 +1,5 @@ -import EPars from "eterna/EPars"; -import {Folder} from "eterna/folding"; +import EPars from 'eterna/EPars'; +import {Folder} from 'eterna/folding'; export class RNATreeNode { public isPair: boolean = false; @@ -18,7 +18,7 @@ export class RNATreeNode { } export default class RNALayout { - public constructor(primSpace: number = 45, pairSpace: number = 45, exceptionIndices: number[] = null) { + constructor(primSpace: number = 45, pairSpace: number = 45, exceptionIndices: number[] = null) { this._primarySpace = primSpace; this._pairSpace = pairSpace; if (exceptionIndices != null) { @@ -31,62 +31,62 @@ export default class RNALayout { } public setupTree(pairs: number[]): void { - let dangling_start: number = 0; - let dangling_end: number = 0; + let danglingStart = 0; + let danglingEnd = 0; let ii: number; - let bi_pairs: number[] = new Array(pairs.length); + let biPairs: number[] = new Array(pairs.length); - /// Delete old tree + // / Delete old tree this._root = null; - /// save for later + // / save for later this._origPairs = pairs.slice(); for (ii = 0; ii < pairs.length; ii++) { - bi_pairs[ii] = -1; + biPairs[ii] = -1; } for (ii = 0; ii < pairs.length; ii++) { if (ii < pairs[ii]) { - bi_pairs[ii] = pairs[ii]; - bi_pairs[pairs[ii]] = ii; + biPairs[ii] = pairs[ii]; + biPairs[pairs[ii]] = ii; } } - for (ii = 0; ii < bi_pairs.length; ii++) { - if (bi_pairs[ii] < 0) { - dangling_start++; + for (ii = 0; ii < biPairs.length; ii++) { + if (biPairs[ii] < 0) { + danglingStart++; } else { break; } } - for (ii = bi_pairs.length - 1; ii >= 0; ii--) { - if (bi_pairs[ii] < 0) { - dangling_end++; + for (ii = biPairs.length - 1; ii >= 0; ii--) { + if (biPairs[ii] < 0) { + danglingEnd++; } else { break; } } - /// Array that will be used for scoring - this._biPairs = new Array(bi_pairs.length + 1); - for (ii = 0; ii < bi_pairs.length; ii++) { - this._biPairs[ii + 1] = bi_pairs[ii] + 1; + // / Array that will be used for scoring + this._biPairs = new Array(biPairs.length + 1); + for (ii = 0; ii < biPairs.length; ii++) { + this._biPairs[ii + 1] = biPairs[ii] + 1; } - this._biPairs[0] = bi_pairs.length; + this._biPairs[0] = biPairs.length; - if (dangling_start === bi_pairs.length) { + if (danglingStart === biPairs.length) { return; } - this._root = new RNATreeNode; + this._root = new RNATreeNode(); - for (let jj: number = 0; jj < bi_pairs.length; jj++) { - if (bi_pairs[jj] >= 0) { - this.addNodesRecursive(bi_pairs, this._root, jj, bi_pairs[jj]); - jj = bi_pairs[jj]; + for (let jj = 0; jj < biPairs.length; jj++) { + if (biPairs[jj] >= 0) { + this.addNodesRecursive(biPairs, this._root, jj, biPairs[jj]); + jj = biPairs[jj]; } else { - let newsubnode: RNATreeNode = new RNATreeNode; + let newsubnode: RNATreeNode = new RNATreeNode(); newsubnode.isPair = false; newsubnode.indexA = jj; this._root.children.push(newsubnode); @@ -97,45 +97,47 @@ export default class RNALayout { public getCoords(xarray: number[], yarray: number[]): void { if (this._root != null) { this.getCoordsRecursive(this._root, xarray, yarray); - } else { + } else if (xarray.length < 3) { // there is no structure (no pairs) - if (xarray.length < 3) { - // really short, just place them in a vertical line - for (let ii = 0; ii < xarray.length; ii++) { - xarray[ii] = 0; - yarray[ii] = ii * this._primarySpace; - } - } else { - // if longer, make the sequence form a circle instead - // FIXME: there's a bit of code duplication here, somewhat inelegant... - let circle_length: number = (xarray.length + 1) * this._primarySpace + this._pairSpace; - let circle_radius: number = circle_length / (2 * Math.PI); - let length_walker: number = this._pairSpace / 2.0; - let go_x: number = 0; - let go_y: number = 1; - let _root_x: number = go_x * circle_radius; - let _root_y: number = go_y * circle_radius; - let cross_x: number = -go_y; - let cross_y: number = go_x; - let oligo_displacement: number = 0; - - for (let ii = 0; ii < xarray.length; ii++) { - if (this._exceptionIndices != null && this._exceptionIndices.indexOf(ii) >= 0) { - oligo_displacement += 2 * this._primarySpace; - } + // really short, just place them in a vertical line + for (let ii = 0; ii < xarray.length; ii++) { + xarray[ii] = 0; + yarray[ii] = ii * this._primarySpace; + } + } else { + // if longer, make the sequence form a circle instead + // FIXME: there's a bit of code duplication here, somewhat inelegant... + let circleLength: number = (xarray.length + 1) * this._primarySpace + this._pairSpace; + let circleRadius: number = circleLength / (2 * Math.PI); + let lengthWalker: number = this._pairSpace / 2.0; + let goX = 0; + let goY = 1; + let _rootX: number = goX * circleRadius; + let _rootY: number = goY * circleRadius; + let crossX: number = -goY; + let crossY: number = goX; + let oligoDisplacement = 0; + + for (let ii = 0; ii < xarray.length; ii++) { + if (this._exceptionIndices != null && this._exceptionIndices.indexOf(ii) >= 0) { + oligoDisplacement += 2 * this._primarySpace; } - circle_length += oligo_displacement; - - for (let ii = 0; ii < xarray.length; ii++) { - length_walker += this._primarySpace; - if (this._exceptionIndices != null && this._exceptionIndices.indexOf(ii) >= 0) { - length_walker += 2 * this._primarySpace; - } + } + circleLength += oligoDisplacement; - let rad_angle: number = length_walker / circle_length * 2 * Math.PI - Math.PI / 2.0; - xarray[ii] = _root_x + Math.cos(rad_angle) * cross_x * circle_radius + Math.sin(rad_angle) * go_x * circle_radius; - yarray[ii] = _root_y + Math.cos(rad_angle) * cross_y * circle_radius + Math.sin(rad_angle) * go_y * circle_radius; + for (let ii = 0; ii < xarray.length; ii++) { + lengthWalker += this._primarySpace; + if (this._exceptionIndices != null && this._exceptionIndices.indexOf(ii) >= 0) { + lengthWalker += 2 * this._primarySpace; } + + let radAngle: number = lengthWalker / circleLength * 2 * Math.PI - Math.PI / 2.0; + xarray[ii] = ( + _rootX + Math.cos(radAngle) * crossX * circleRadius + Math.sin(radAngle) * goX * circleRadius + ); + yarray[ii] = ( + _rootY + Math.cos(radAngle) * crossY * circleRadius + Math.sin(radAngle) * goY * circleRadius + ); } } } @@ -154,10 +156,10 @@ export default class RNALayout { return this.getTotalScoreRecursive(this._root); } - /// DO NOT remove these _old methods until the new ones (below) are fully validated + // / DO NOT remove these _old methods until the new ones (below) are fully validated public scoreTreeOld(seq: number[], folder: Folder): void { if (this._biPairs == null || seq.length !== (this._biPairs.length - 1)) { - throw new Error("Layout tree is not properly setup for scoring " + this._biPairs.length + " " + seq.length); + throw new Error(`Layout tree is not properly setup for scoring ${this._biPairs.length} ${seq.length}`); } if (this._root == null) { @@ -171,12 +173,12 @@ export default class RNALayout { S[ii + 1] = seq[ii]; } - this.scoreTreeRecursiveOld(S, folder, this._root, null) + this.scoreTreeRecursiveOld(S, folder, this._root, null); } public scoreTree(seq: number[], folder: Folder): void { if (this._biPairs == null) { - throw new Error("Layout tree is not properly setup for scoring"); + throw new Error('Layout tree is not properly setup for scoring'); } if (this._root == null) { @@ -189,29 +191,28 @@ export default class RNALayout { this.scoreTreeRecursive(nnfe, this._root, null); } - private addNodesRecursive(bi_pairs: number[], rootnode: RNATreeNode, start_index: number, end_index: number): void { - if (start_index > end_index) { - throw new Error("Error occured while drawing RNA"); + private addNodesRecursive(biPairs: number[], rootnode: RNATreeNode, startIndex: number, endIndex: number): void { + if (startIndex > endIndex) { + throw new Error('Error occured while drawing RNA'); } let newnode: RNATreeNode; - if (bi_pairs[start_index] === end_index) { - newnode = new RNATreeNode; + if (biPairs[startIndex] === endIndex) { + newnode = new RNATreeNode(); newnode.isPair = true; - newnode.indexA = start_index; - newnode.indexB = end_index; - - this.addNodesRecursive(bi_pairs, newnode, start_index + 1, end_index - 1); + newnode.indexA = startIndex; + newnode.indexB = endIndex; + this.addNodesRecursive(biPairs, newnode, startIndex + 1, endIndex - 1); } else { - newnode = new RNATreeNode; + newnode = new RNATreeNode(); - for (let jj = start_index; jj <= end_index; jj++) { - if (bi_pairs[jj] >= 0) { - this.addNodesRecursive(bi_pairs, newnode, jj, bi_pairs[jj]); - jj = bi_pairs[jj]; + for (let jj = startIndex; jj <= endIndex; jj++) { + if (biPairs[jj] >= 0) { + this.addNodesRecursive(biPairs, newnode, jj, biPairs[jj]); + jj = biPairs[jj]; } else { - let newsubnode: RNATreeNode = new RNATreeNode; + let newsubnode: RNATreeNode = new RNATreeNode(); newsubnode.isPair = false; newsubnode.indexA = jj; newnode.children.push(newsubnode); @@ -220,126 +221,145 @@ export default class RNALayout { } rootnode.children.push(newnode); - } private getCoordsRecursive(rootnode: RNATreeNode, xarray: number[], yarray: number[]): void { if (rootnode.isPair) { - let cross_x: number = -rootnode.goY; - let cross_y: number = rootnode.goX; + let crossX: number = -rootnode.goY; + let crossY: number = rootnode.goX; - xarray[rootnode.indexA] = rootnode.x + cross_x * this._pairSpace / 2.0; - xarray[rootnode.indexB] = rootnode.x - cross_x * this._pairSpace / 2.0; + xarray[rootnode.indexA] = rootnode.x + crossX * this._pairSpace / 2.0; + xarray[rootnode.indexB] = rootnode.x - crossX * this._pairSpace / 2.0; - yarray[rootnode.indexA] = rootnode.y + cross_y * this._pairSpace / 2.0; - yarray[rootnode.indexB] = rootnode.y - cross_y * this._pairSpace / 2.0; + yarray[rootnode.indexA] = rootnode.y + crossY * this._pairSpace / 2.0; + yarray[rootnode.indexB] = rootnode.y - crossY * this._pairSpace / 2.0; } else if (rootnode.indexA >= 0) { xarray[rootnode.indexA] = rootnode.x; yarray[rootnode.indexA] = rootnode.y; } - for (let ii: number = 0; ii < rootnode.children.length; ii++) { + for (let ii = 0; ii < rootnode.children.length; ii++) { this.getCoordsRecursive(rootnode.children[ii], xarray, yarray); } - } - private drawTreeRecursive(rootnode: RNATreeNode, parentnode: RNATreeNode, start_x: number, start_y: number, go_x: number, go_y: number): void { - let cross_x: number = -go_y; - let cross_y: number = go_x; + private drawTreeRecursive( + rootnode: RNATreeNode, parentnode: RNATreeNode, startX: number, startY: number, goX: number, goY: number + ): void { + let crossX: number = -goY; + let crossY: number = goX; - let children_width: number = rootnode.children.length * RNALayout.NODE_R * 2; - let oligo_displacement: number = 0; + let childrenWidth: number = rootnode.children.length * RNALayout.NODE_R * 2; + let oligoDisplacement = 0; - rootnode.goX = go_x; - rootnode.goY = go_y; + rootnode.goX = goX; + rootnode.goY = goY; if (rootnode.children.length === 1) { - rootnode.x = start_x; - rootnode.y = start_y; + rootnode.x = startX; + rootnode.y = startY; if (rootnode.children[0].isPair) { - this.drawTreeRecursive(rootnode.children[0], rootnode, start_x + go_x * this._primarySpace, start_y + go_y * this._primarySpace, go_x, go_y); + this.drawTreeRecursive( + rootnode.children[0], rootnode, + startX + goX * this._primarySpace, startY + goY * this._primarySpace, goX, goY + ); } else if (!rootnode.children[0].isPair && rootnode.children[0].indexA < 0) { - this.drawTreeRecursive(rootnode.children[0], rootnode, start_x, start_y, go_x, go_y); + this.drawTreeRecursive(rootnode.children[0], rootnode, startX, startY, goX, goY); } else { - this.drawTreeRecursive(rootnode.children[0], rootnode, start_x + go_x * this._primarySpace, start_y + go_y * this._primarySpace, go_x, go_y); + this.drawTreeRecursive( + rootnode.children[0], rootnode, + startX + goX * this._primarySpace, startY + goY * this._primarySpace, goX, goY + ); } } else if (rootnode.children.length > 1) { - let ii: number; - let npairs: number = 0; + let npairs = 0; for (ii = 0; ii < rootnode.children.length; ii++) { if (rootnode.children[ii].isPair) { npairs++; } - if (this._exceptionIndices != null && (this._exceptionIndices.indexOf(rootnode.children[ii].indexA) >= 0 || this._exceptionIndices.indexOf(rootnode.children[ii].indexB) >= 0)) { - oligo_displacement += 2 * this._primarySpace; + if ( + this._exceptionIndices != null + && ( + this._exceptionIndices.indexOf(rootnode.children[ii].indexA) >= 0 + || this._exceptionIndices.indexOf(rootnode.children[ii].indexB) >= 0 + ) + ) { + oligoDisplacement += 2 * this._primarySpace; } } - let circle_length: number = (rootnode.children.length + 1) * this._primarySpace + (npairs + 1) * this._pairSpace; - circle_length += oligo_displacement; + let circleLength = (rootnode.children.length + 1) * this._primarySpace + (npairs + 1) * this._pairSpace; + circleLength += oligoDisplacement; - let circle_radius: number = circle_length / (2 * Math.PI); - let length_walker: number = this._pairSpace / 2.0; + let circleRadius = circleLength / (2 * Math.PI); + let lengthWalker = this._pairSpace / 2.0; if (parentnode == null) { - rootnode.x = go_x * circle_radius; - rootnode.y = go_y * circle_radius; + rootnode.x = goX * circleRadius; + rootnode.y = goY * circleRadius; } else { - rootnode.x = parentnode.x + go_x * circle_radius; - rootnode.y = parentnode.y + go_y * circle_radius; + rootnode.x = parentnode.x + goX * circleRadius; + rootnode.y = parentnode.y + goY * circleRadius; } for (ii = 0; ii < rootnode.children.length; ii++) { - - length_walker += this._primarySpace; - if (this._exceptionIndices != null && (this._exceptionIndices.indexOf(rootnode.children[ii].indexA) >= 0 || this._exceptionIndices.indexOf(rootnode.children[ii].indexB) >= 0)) { - length_walker += 2 * this._primarySpace; + lengthWalker += this._primarySpace; + if ( + this._exceptionIndices != null + && ( + this._exceptionIndices.indexOf(rootnode.children[ii].indexA) >= 0 + || this._exceptionIndices.indexOf(rootnode.children[ii].indexB) >= 0 + ) + ) { + lengthWalker += 2 * this._primarySpace; } if (rootnode.children[ii].isPair) { - length_walker += this._pairSpace / 2.0; + lengthWalker += this._pairSpace / 2.0; } - let rad_angle: number = length_walker / circle_length * 2 * Math.PI - Math.PI / 2.0; - let child_x: number = rootnode.x + Math.cos(rad_angle) * cross_x * circle_radius + Math.sin(rad_angle) * go_x * circle_radius; - let child_y: number = rootnode.y + Math.cos(rad_angle) * cross_y * circle_radius + Math.sin(rad_angle) * go_y * circle_radius; + let radAngle = lengthWalker / circleLength * 2 * Math.PI - Math.PI / 2.0; + let childX = ( + rootnode.x + Math.cos(radAngle) * crossX * circleRadius + Math.sin(radAngle) * goX * circleRadius + ); + let childY = ( + rootnode.y + Math.cos(radAngle) * crossY * circleRadius + Math.sin(radAngle) * goY * circleRadius + ); - let child_go_x: number = child_x - rootnode.x; - let child_go_y: number = child_y - rootnode.y; - let child_go_len: number = Math.sqrt(child_go_x * child_go_x + child_go_y * child_go_y); + let childGoX = childX - rootnode.x; + let childGoY = childY - rootnode.y; + let childGoLen = Math.sqrt(childGoX * childGoX + childGoY * childGoY); - this.drawTreeRecursive(rootnode.children[ii], rootnode, child_x, child_y, - child_go_x / child_go_len, child_go_y / child_go_len); + this.drawTreeRecursive(rootnode.children[ii], rootnode, childX, childY, + childGoX / childGoLen, childGoY / childGoLen); if (rootnode.children[ii].isPair) { - length_walker += this._pairSpace / 2.0; + lengthWalker += this._pairSpace / 2.0; } } } else { - rootnode.x = start_x; - rootnode.y = start_y; + rootnode.x = startX; + rootnode.y = startY; } - } private getTotalScoreRecursive(rootnode: RNATreeNode): number { let score: number = rootnode.score; - for (let ii: number = 0; ii < rootnode.children.length; ii++) { + for (let ii = 0; ii < rootnode.children.length; ii++) { score += this.getTotalScoreRecursive(rootnode.children[ii]); } return score; } private scoreTreeRecursiveOld(S: number[], folder: Folder, rootnode: RNATreeNode, parentnode: RNATreeNode): void { - - let type1: number, type2: number; + let type1: number; let + type2: number; if (rootnode.isPair) { - /// Pair node + // / Pair node if (rootnode.children.length > 1) { - throw new Error("Pair node should never have more than one child"); + throw new Error('Pair node should never have more than one child'); } if (rootnode.children.length === 0) { @@ -347,84 +367,81 @@ export default class RNALayout { } if (rootnode.children[0].isPair) { - type1 = EPars.pairType(S[rootnode.indexA + 1], S[rootnode.indexB + 1]); type2 = EPars.pairType(S[rootnode.children[0].indexB + 1], S[rootnode.children[0].indexA + 1]); - rootnode.score = folder.loopEnergy(0, 0, type1, type2, S[rootnode.indexA + 1 + 1], S[rootnode.indexB - 1 + 1], - S[rootnode.children[0].indexA + 1 + 1], S[rootnode.children[0].indexB - 1 + 1], true, true); + rootnode.score = folder.loopEnergy( + 0, 0, type1, type2, S[rootnode.indexA + 1 + 1], S[rootnode.indexB - 1 + 1], + S[rootnode.children[0].indexA + 1 + 1], S[rootnode.children[0].indexB - 1 + 1], true, true + ); } this.scoreTreeRecursiveOld(S, folder, rootnode.children[0], rootnode); - } else if (!rootnode.isPair && rootnode.indexA >= 0) { - /// Single residue node - return; + // / Single residue node + } else { - /// Virtual node + // / Virtual node - /// Top root case + // / Top root case if (parentnode == null) { - /// initial ml scoring + // / initial ml scoring rootnode.score = folder.mlEnergy(this._biPairs, S, 0, true); - } else { - if (!parentnode.isPair) { - throw new Error("Parent node must be a pair"); - } + } else if (!parentnode.isPair) { + throw new Error('Parent node must be a pair'); } let ii: number; - let num_stacks: number = 0; - let first_stack_index: number = -1; + let numStacks = 0; + let firstStackIndex = -1; for (ii = 0; ii < rootnode.children.length; ii++) { if (rootnode.children[ii].isPair) { - num_stacks++; - if (first_stack_index < 0) { - first_stack_index = ii; + numStacks++; + if (firstStackIndex < 0) { + firstStackIndex = ii; } } else if (rootnode.children[ii].indexA < 0) { - throw new Error("Virtual node should not have a virtual node child"); + throw new Error('Virtual node should not have a virtual node child'); } } - let i: number, j: number, p: number, q: number; - - if (num_stacks === 1 && parentnode != null) { + let i: number; let j: number; let p: number; let + q: number; + if (numStacks === 1 && parentnode != null) { i = parentnode.indexA + 1; j = parentnode.indexB + 1; - p = rootnode.children[first_stack_index].indexA + 1; - q = rootnode.children[first_stack_index].indexB + 1; + p = rootnode.children[firstStackIndex].indexA + 1; + q = rootnode.children[firstStackIndex].indexB + 1; type1 = EPars.pairType(S[i], S[j]); type2 = EPars.pairType(S[q], S[p]); - rootnode.score = folder.loopEnergy(p - i - 1, j - q - 1, type1, type2, S[i + 1], S[j - 1], S[p - 1], S[q + 1], true, true); - - } else if (num_stacks === 0) { + rootnode.score = folder.loopEnergy( + p - i - 1, j - q - 1, type1, type2, S[i + 1], S[j - 1], S[p - 1], S[q + 1], true, true + ); + } else if (numStacks === 0) { i = parentnode.indexA + 1; j = parentnode.indexB + 1; let type: number = EPars.pairType(S[i], S[j]); rootnode.score = folder.hairpinEnergy(j - i - 1, type, S[i + 1], S[j - 1], S, i, j); - } else if (num_stacks > 1 && parentnode != null) { - + } else if (numStacks > 1 && parentnode != null) { i = parentnode.indexA + 1; let cuti: number = folder.cutInLoop(i); - rootnode.score = (cuti === 0) ? folder.mlEnergy(this._biPairs, S, i, false) : folder.mlEnergy(this._biPairs, S, cuti, true); + rootnode.score = (cuti === 0) + ? folder.mlEnergy(this._biPairs, S, i, false) : folder.mlEnergy(this._biPairs, S, cuti, true); } for (ii = 0; ii < rootnode.children.length; ii++) { this.scoreTreeRecursiveOld(S, folder, rootnode.children[ii], rootnode); } - } - } private scoreTreeRecursive(nnfe: number[], rootnode: RNATreeNode, parentnode: RNATreeNode): void { if (rootnode.isPair) { - /// Pair node + // / Pair node if (rootnode.children.length > 1) { - throw new Error("Pair node should never have more than one child"); + throw new Error('Pair node should never have more than one child'); } if (rootnode.children.length === 0) { @@ -436,45 +453,43 @@ export default class RNALayout { } this.scoreTreeRecursive(nnfe, rootnode.children[0], rootnode); - } else if (!rootnode.isPair && rootnode.indexA >= 0) { - /// Single residue node - return; + // / Single residue node + } else { - /// Virtual node + // / Virtual node - /// Top root case + // / Top root case if (parentnode == null) { - /// initial ml scoring + // / initial ml scoring rootnode.score = RNALayout.lookupFe(nnfe, -1); - } else { - if (!parentnode.isPair) { - throw new Error("Parent node must be a pair"); - } + } else if (!parentnode.isPair) { + throw new Error('Parent node must be a pair'); } let ii: number; - let num_stacks: number = 0; - let first_stack_index: number = -1; + let numStacks = 0; + let firstStackIndex = -1; for (ii = 0; ii < rootnode.children.length; ii++) { if (rootnode.children[ii].isPair) { - num_stacks++; - if (first_stack_index < 0) { - first_stack_index = ii; + numStacks++; + if (firstStackIndex < 0) { + firstStackIndex = ii; } } else if (rootnode.children[ii].indexA < 0) { - throw new Error("Virtual node should not have a virtual node child"); + throw new Error('Virtual node should not have a virtual node child'); } } - let i: number, j: number, p: number, q: number; + let i: number; let j: number; let p: number; let + q: number; - if (num_stacks === 1 && parentnode != null) { + if (numStacks === 1 && parentnode != null) { rootnode.score = RNALayout.lookupFe(nnfe, parentnode.indexA); - } else if (num_stacks === 0) { + } else if (numStacks === 0) { rootnode.score = RNALayout.lookupFe(nnfe, parentnode.indexA); - } else if (num_stacks > 1 && parentnode != null) { + } else if (numStacks > 1 && parentnode != null) { rootnode.score = RNALayout.lookupFe(nnfe, parentnode.indexA); } @@ -484,9 +499,9 @@ export default class RNALayout { } } - /// FIXME: there's surely a smarter way to do this... + // / FIXME: there's surely a smarter way to do this... private static lookupFe(nnfe: number[], index: number): number { - for (let ii: number = 0; ii < nnfe.length - 1; ii += 2) { + for (let ii = 0; ii < nnfe.length - 1; ii += 2) { if (nnfe[ii] === index) return nnfe[ii + 1]; } return 0; @@ -500,7 +515,7 @@ export default class RNALayout { private _root: RNATreeNode; private _origPairs: number[]; - /// "New" method to gather NN free energies, just use the folding engine + // / "New" method to gather NN free energies, just use the folding engine private _biPairs: number[]; private static readonly NODE_R = 10; diff --git a/src/eterna/pose2D/ScoreDisplayNode.ts b/src/eterna/pose2D/ScoreDisplayNode.ts index 3c81e6146..519e0f7cd 100644 --- a/src/eterna/pose2D/ScoreDisplayNode.ts +++ b/src/eterna/pose2D/ScoreDisplayNode.ts @@ -1,4 +1,4 @@ -import {MathUtil, ColorUtil} from "flashbang/util"; +import {MathUtil, ColorUtil} from 'flashbang/util'; export enum ScoreDisplayNodeType { STACK = 0, LOOP @@ -9,9 +9,9 @@ export default class ScoreDisplayNode { return this._baseIndices; } - public setType(type: number, base_indices: number[], score: number): void { + public setType(type: number, baseIndices: number[], score: number): void { this._type = type; - this._baseIndices = base_indices.slice(); + this._baseIndices = baseIndices.slice(); this._score = score; } @@ -24,31 +24,30 @@ export default class ScoreDisplayNode { } public get textLabel(): string { - return (this._type === ScoreDisplayNodeType.STACK ? "Stack" : "Loop"); + return (this._type === ScoreDisplayNodeType.STACK ? 'Stack' : 'Loop'); } public get textScore(): string { - return (this._score / 100).toString() + " kcal"; + return `${(this._score / 100).toString()} kcal`; } public get text(): string { - return this.textLabel + "\n" + (this._score / 100).toString() + " kcal"; + return `${this.textLabel}\n${(this._score / 100).toString()} kcal`; } public get scoreColor(): number { - let r: number = 0; - let g: number = 0; - let b: number = 0; + let r = 0; + let g = 0; + let b = 0; let score: number = this._score / 100.0; - let prog: number = 0; + let prog = 0; if (score > 0) { prog = MathUtil.clamp(score / 5.0, 0, 1); r = 1; g = (1 - prog) + (30 / 255) * prog; b = (1 - prog) + (30 / 255) * prog; - } else { prog = MathUtil.clamp(score / -5.0, 0, 1); g = 1; @@ -61,7 +60,6 @@ export default class ScoreDisplayNode { public get scoreString(): string { return (this._score / 100.0).toString(); - } private _type: number; diff --git a/src/eterna/pose2D/index.ts b/src/eterna/pose2D/index.ts index 79994e957..c0f6482c4 100644 --- a/src/eterna/pose2D/index.ts +++ b/src/eterna/pose2D/index.ts @@ -1,17 +1,19 @@ -export {default as Base} from "./Base"; -export {default as BaseAssets} from "./BaseAssets"; -export {default as BaseDrawFlags} from "./BaseDrawFlags"; -export {default as BaseTextures} from "./BaseTextures"; -export {default as EnergyScoreDisplay} from "./EnergyScoreDisplay"; -export {default as ExplosionFactorPanel} from "./ExplosionFactorPanel"; -export {default as HighlightBox, HighlightType} from "./HighlightBox"; -export {default as Molecule} from "./Molecule"; -export {default as PaintCursor} from "./PaintCursor"; -export {default as Pose2D, PoseMouseDownCallback, Oligo, RNAHighlightState} from "./Pose2D"; -export {default as PoseField} from "./PoseField"; -export {default as PoseOp} from "./PoseOp"; -export {default as PoseUtil} from "./PoseUtil"; -export {default as PuzzleEditOp} from "./PuzzleEditOp"; -export {default as RNAAnchorObject} from "./RNAAnchorObject"; -export {default as RNALayout, RNATreeNode} from "./RNALayout"; -export {default as ScoreDisplayNode, ScoreDisplayNodeType} from "./ScoreDisplayNode"; \ No newline at end of file +export {default as Base} from './Base'; +export {default as BaseAssets} from './BaseAssets'; +export {default as BaseDrawFlags} from './BaseDrawFlags'; +export {default as BaseTextures} from './BaseTextures'; +export {default as EnergyScoreDisplay} from './EnergyScoreDisplay'; +export {default as ExplosionFactorPanel} from './ExplosionFactorPanel'; +export {default as HighlightBox, HighlightType} from './HighlightBox'; +export {default as Molecule} from './Molecule'; +export {default as PaintCursor} from './PaintCursor'; +export { + default as Pose2D, PoseMouseDownCallback, Oligo, RNAHighlightState +} from './Pose2D'; +export {default as PoseField} from './PoseField'; +export {default as PoseOp} from './PoseOp'; +export {default as PoseUtil} from './PoseUtil'; +export {default as PuzzleEditOp} from './PuzzleEditOp'; +export {default as RNAAnchorObject} from './RNAAnchorObject'; +export {default as RNALayout, RNATreeNode} from './RNALayout'; +export {default as ScoreDisplayNode, ScoreDisplayNodeType} from './ScoreDisplayNode'; diff --git a/src/eterna/puzzle/Constraints.ts b/src/eterna/puzzle/Constraints.ts index 16188a486..cb9dee5ec 100644 --- a/src/eterna/puzzle/Constraints.ts +++ b/src/eterna/puzzle/Constraints.ts @@ -1,42 +1,42 @@ export enum ConstraintType { - SHAPE = "SHAPE", - ANTISHAPE = "ANTISHAPE", - SOFT = "SOFT", - - A = "A", - U = "U", - G = "G", - C = "C", - - AMAX = "AMAX", - UMAX = "UMAX", - GMAX = "GMAX", - CMAX = "CMAX", - - CONSECUTIVE_G = "CONSECUTIVE_G", - CONSECUTIVE_C = "CONSECUTIVE_C", - CONSECUTIVE_A = "CONSECUTIVE_A", - - GU = "GU", - AU = "AU", - GC = "GC", - - GCMIN = "GCMIN", - NOGC = "NOGC", - NOGU = "NOGU", - AUMAX = "AUMAX", - - BOOST = "BOOST", - PAIRS = "PAIRS", - STACK = "STACK", - MUTATION = "MUTATION", - BINDINGS = "BINDINGS", - BARCODE = "BARCODE", - OLIGO_BOUND = "OLIGO_BOUND", - OLIGO_UNBOUND = "OLIGO_UNBOUND", - - LAB_REQUIREMENTS = "LAB_REQUIREMENTS", - SCRIPT = "SCRIPT", + SHAPE = 'SHAPE', + ANTISHAPE = 'ANTISHAPE', + SOFT = 'SOFT', + + A = 'A', + U = 'U', + G = 'G', + C = 'C', + + AMAX = 'AMAX', + UMAX = 'UMAX', + GMAX = 'GMAX', + CMAX = 'CMAX', + + CONSECUTIVE_G = 'CONSECUTIVE_G', + CONSECUTIVE_C = 'CONSECUTIVE_C', + CONSECUTIVE_A = 'CONSECUTIVE_A', + + GU = 'GU', + AU = 'AU', + GC = 'GC', + + GCMIN = 'GCMIN', + NOGC = 'NOGC', + NOGU = 'NOGU', + AUMAX = 'AUMAX', + + BOOST = 'BOOST', + PAIRS = 'PAIRS', + STACK = 'STACK', + MUTATION = 'MUTATION', + BINDINGS = 'BINDINGS', + BARCODE = 'BARCODE', + OLIGO_BOUND = 'OLIGO_BOUND', + OLIGO_UNBOUND = 'OLIGO_UNBOUND', + + LAB_REQUIREMENTS = 'LAB_REQUIREMENTS', + SCRIPT = 'SCRIPT', } export default class Constraints { diff --git a/src/eterna/puzzle/Puzzle.ts b/src/eterna/puzzle/Puzzle.ts index a58bd7312..a8523a296 100644 --- a/src/eterna/puzzle/Puzzle.ts +++ b/src/eterna/puzzle/Puzzle.ts @@ -1,9 +1,9 @@ -import Constants from "eterna/Constants"; -import EPars from "eterna/EPars"; -import {Folder, FolderManager, Vienna} from "eterna/folding"; -import {EternaURL} from "eterna/net"; -import {Pose2D} from "eterna/pose2D"; -import {ConstraintType} from "./Constraints"; +import Constants from 'eterna/Constants'; +import EPars from 'eterna/EPars'; +import {Folder, FolderManager, Vienna} from 'eterna/folding'; +import {EternaURL} from 'eterna/net'; +import {Pose2D} from 'eterna/pose2D'; +import {ConstraintType} from './Constraints'; export interface BoostersData { mission?: any; @@ -13,31 +13,31 @@ export interface BoostersData { } export enum PuzzleType { - BASIC = "Basic", - SWITCH_BASIC = "SwitchBasic", - CHALLENGE = "Challenge", - EXPERIMENTAL = "Experimental" + BASIC = 'Basic', + SWITCH_BASIC = 'SwitchBasic', + CHALLENGE = 'Challenge', + EXPERIMENTAL = 'Experimental' } export enum PoseState { - NATIVE = "NATIVE", - FROZEN = "FROZEN", - TARGET = "TARGET", + NATIVE = 'NATIVE', + FROZEN = 'FROZEN', + TARGET = 'TARGET', // TODO: move these to another enum; // they are only used to communicate events to rscript - PIP = "PIP", - NONPIP = "NONPIP", - SECOND = "SECOND", + PIP = 'PIP', + NONPIP = 'NONPIP', + SECOND = 'SECOND', } export default class Puzzle { - public static isAptamerType(tc_type: string): boolean { - return (Puzzle.T_APTAMER.indexOf(tc_type) >= 0); + public static isAptamerType(tcType: string): boolean { + return (Puzzle.T_APTAMER.indexOf(tcType) >= 0); } - public static isOligoType(tc_type: string): boolean { - return (Puzzle.T_OLIGO.indexOf(tc_type) >= 0); + public static isOligoType(tcType: string): boolean { + return (Puzzle.T_OLIGO.indexOf(tcType) >= 0); } public static probeTail(seq: number[]): number[] { @@ -56,7 +56,7 @@ export default class Puzzle { return seq; } - public constructor(nid: number, name: string, puzzleType: PuzzleType) { + constructor(nid: number, name: string, puzzleType: PuzzleType) { this._nid = nid; this._name = name; this._puzzleType = puzzleType; @@ -70,11 +70,11 @@ export default class Puzzle { public canUseFolder(folder: Folder): boolean { return !( - (this.hasTargetType("multistrand") && !folder.canMultifold) - || (this.hasTargetType("aptamer") && !folder.canFoldWithBindingSite) - || (this.hasTargetType("oligo") && !folder.canCofold) - || (this.hasTargetType("aptamer+oligo") && !folder.canFoldWithBindingSite) - || (this.hasTargetType("aptamer+oligo") && !folder.canCofold) + (this.hasTargetType('multistrand') && !folder.canMultifold) + || (this.hasTargetType('aptamer') && !folder.canFoldWithBindingSite) + || (this.hasTargetType('oligo') && !folder.canCofold) + || (this.hasTargetType('aptamer+oligo') && !folder.canFoldWithBindingSite) + || (this.hasTargetType('aptamer+oligo') && !folder.canCofold) ); } @@ -136,11 +136,11 @@ export default class Puzzle { public get targetConditions(): any[] { if (this._targetConditions == null) { - let target_conditions: any[] = []; + let targetConditions: any[] = []; for (let ii = 0; ii < this._secstructs.length; ii++) { - target_conditions.push(null); + targetConditions.push(null); } - return target_conditions; + return targetConditions; } else { return this._targetConditions; } @@ -199,7 +199,7 @@ export default class Puzzle { } } - /** Returns temporary_constraints, if they're set, else constraints */ + /** Returns temporaryConstraints, if they're set, else constraints */ public get curConstraints(): string[] { return this.temporaryConstraints || this.constraints; } @@ -266,55 +266,62 @@ export default class Puzzle { let concentration: number; for (let ii = 0; ii < this._targetConditions.length; ii++) { - if (this._targetConditions[ii]["secstruct"] == null) { + if (this._targetConditions[ii]['secstruct'] == null) { throw new Error("Can't find secstruct from a target condition"); } - this._secstructs.push(this._targetConditions[ii]["secstruct"]); + this._secstructs.push(this._targetConditions[ii]['secstruct']); - let tc_type: string = this._targetConditions[ii]["type"]; + let tcType: string = this._targetConditions[ii]['type']; // Aptamers - if (Puzzle.isAptamerType(tc_type) && this._targetConditions[ii]["site"] != null) { - let binding_pairs: any[] = []; - let binding_site: any[] = this._targetConditions[ii]["site"]; - let target_pairs: number[] = EPars.parenthesisToPairs(this.getSecstruct(ii)); + if (Puzzle.isAptamerType(tcType) && this._targetConditions[ii]['site'] != null) { + let bindingPairs: any[] = []; + let bindingSite: any[] = this._targetConditions[ii]['site']; + let targetPairs: number[] = EPars.parenthesisToPairs(this.getSecstruct(ii)); - for (let jj = 0; jj < binding_site.length; jj++) { - binding_pairs.push(target_pairs[binding_site[jj]]); + for (let jj = 0; jj < bindingSite.length; jj++) { + bindingPairs.push(targetPairs[bindingSite[jj]]); } - this._targetConditions[ii]["binding_pairs"] = binding_pairs; - this._targetConditions[ii]["bonus"] = -0.6 * Math.log(this._targetConditions[ii]["concentration"] / 3) * 100; + this._targetConditions[ii]['binding_pairs'] = bindingPairs; + this._targetConditions[ii]['bonus'] = ( + -0.6 * Math.log(this._targetConditions[ii]['concentration'] / 3) * 100 + ); } // Simple oligos - if (Puzzle.isOligoType(tc_type) && this._targetConditions[ii].hasOwnProperty("fold_mode") === false) { - this._targetConditions[ii]["fold_mode"] = Pose2D.OLIGO_MODE_DIMER.toString(); + if ( + Puzzle.isOligoType(tcType) + && Object.hasOwnProperty.call(this._targetConditions[ii], 'fold_mode') === false + ) { + this._targetConditions[ii]['fold_mode'] = Pose2D.OLIGO_MODE_DIMER.toString(); } - if (Puzzle.isOligoType(tc_type) && this._targetConditions[ii]["oligo_sequence"] != null) { + if (Puzzle.isOligoType(tcType) && this._targetConditions[ii]['oligo_sequence'] != null) { concentration = 0; - if (this._targetConditions[ii]["oligo_concentration"] != null) { - concentration = this._targetConditions[ii]["oligo_concentration"]; + if (this._targetConditions[ii]['oligo_concentration'] != null) { + concentration = this._targetConditions[ii]['oligo_concentration']; } else { concentration = 1.0; } - this._targetConditions[ii]["malus"] = -Constants.BOLTZMANN * (Constants.KELVIN_0C + 37) * Math.log(concentration); + this._targetConditions[ii]['malus'] = ( + -Constants.BOLTZMANN * (Constants.KELVIN_0C + 37) * Math.log(concentration) + ); } // Multi-strands - if (this._targetConditions[ii]["type"] === "multistrand") { - let oligos: any[] = this._targetConditions[ii]["oligos"]; + if (this._targetConditions[ii]['type'] === 'multistrand') { + let oligos: any[] = this._targetConditions[ii]['oligos']; for (let jj = 0; jj < oligos.length; jj++) { concentration = 0; - if (oligos[jj]["concentration"] != null) { - concentration = oligos[jj]["concentration"]; + if (oligos[jj]['concentration'] != null) { + concentration = oligos[jj]['concentration']; } else { concentration = 1.0; } - oligos[jj]["malus"] = -Constants.BOLTZMANN * (Constants.KELVIN_0C + 37) * Math.log(concentration); + oligos[jj]['malus'] = -Constants.BOLTZMANN * (Constants.KELVIN_0C + 37) * Math.log(concentration); } } } @@ -328,19 +335,19 @@ export default class Puzzle { this._savedSequence = EPars.stringToSequence(seq); } - public set uiSpecs(ui_spec: string[]) { + public set uiSpecs(uiSpec: string[]) { this._defaultPoseState = null; this._useModes = 0; - for (let ii = 0; ii < ui_spec.length; ii++) { - if (ui_spec[ii] === "NOMODES") { + for (let ii = 0; ii < uiSpec.length; ii++) { + if (uiSpec[ii] === 'NOMODES') { this._useModes = Puzzle.BOOL_FALSE; - } else if (ui_spec[ii] === "STARTSTATE") { - this._defaultPoseState = (ui_spec[ii + 1].toUpperCase()); + } else if (uiSpec[ii] === 'STARTSTATE') { + this._defaultPoseState = (uiSpec[ii + 1].toUpperCase()); ii++; - } else if (ui_spec[ii] === "NOTOOLS") { + } else if (uiSpec[ii] === 'NOTOOLS') { this._useTools = Puzzle.BOOL_FALSE; - } else if (ui_spec[ii] === "NOPALLETE") { + } else if (uiSpec[ii] === 'NOPALLETE') { this._usePallete = Puzzle.BOOL_FALSE; } } @@ -403,8 +410,8 @@ export default class Puzzle { return this._useBarcode; } - public set useBarcode(use_barcode: boolean) { - this._useBarcode = use_barcode; + public set useBarcode(useBarcode: boolean) { + this._useBarcode = useBarcode; } public get isUndoZoomAllowed(): boolean { @@ -416,15 +423,15 @@ export default class Puzzle { } public get isPairBrushAllowed(): boolean { - let is_basic: boolean = (this._puzzleType !== PuzzleType.BASIC); - let has_target = false; + let isBasic: boolean = (this._puzzleType !== PuzzleType.BASIC); + let hasTarget = false; for (let ii = 0; ii < this._constraints.length; ii++) { if (this._constraints[ii] === ConstraintType.SHAPE) { - has_target = true; + hasTarget = true; } } - return is_basic || has_target; + return isBasic || hasTarget; } public get areModesAvailable(): boolean { @@ -451,8 +458,8 @@ export default class Puzzle { } } - public set defaultMode(default_mode: PoseState) { - this._defaultPoseState = default_mode; + public set defaultMode(defaultMode: PoseState) { + this._defaultPoseState = defaultMode; } public get isUsingTails(): boolean { @@ -481,17 +488,17 @@ export default class Puzzle { public getName(linked: boolean = false): string { if (linked && this._puzzleType !== PuzzleType.EXPERIMENTAL) { - let url: string = EternaURL.createURL({page: "puzzle", nid: this._nid}); + let url: string = EternaURL.createURL({page: 'puzzle', nid: this._nid}); return `${this._name}`; } return this._name; } - public hasTargetType(tc_type: string): boolean { + public hasTargetType(tcType: string): boolean { if (this._targetConditions == null) return false; for (let ii = 0; ii < this._targetConditions.length; ii++) { - if (this._targetConditions[ii]["type"] === tc_type) { + if (this._targetConditions[ii]['type'] === tcType) { return true; } } @@ -514,7 +521,7 @@ export default class Puzzle { } // FIXME: This needs revision, see https://github.com/EteRNAgame/eterna/blob/1e537defaad17674b189df697ee6f1c7cca070c0/flash-rna/flash-rna/PoseEdit.as#L2163 - let len: number = this._beginningSequence != null ? this._beginningSequence.length : this._secstructs[index].length; + let len = this._beginningSequence != null ? this._beginningSequence.length : this._secstructs[index].length; for (let ii = 0; ii < len; ii++) { if (this._beginningSequence != null) { seq.push(this._beginningSequence[ii]); @@ -544,52 +551,52 @@ export default class Puzzle { return seq.slice(0, seq.length - minus); } - public setUseTails(use_tails: boolean, use_short_tails: boolean): void { - this._useTails = use_tails; - this._useShortTails = use_short_tails; + public setUseTails(useTails: boolean, useShortTails: boolean): void { + this._useTails = useTails; + this._useShortTails = useShortTails; } - public transformSequence(seq: number[], target_index: number): number[] { + public transformSequence(seq: number[], targetIndex: number): number[] { if (this._targetConditions != null) { - if (this._targetConditions[target_index]["sequence"] != null) { - let target_seq_temp: number[] = EPars.stringToSequence(this._targetConditions[target_index]["sequence"]); - let target_seq: number[] = []; + if (this._targetConditions[targetIndex]['sequence'] != null) { + let targetSeqTemp: number[] = EPars.stringToSequence(this._targetConditions[targetIndex]['sequence']); + let targetSeq: number[] = []; if (this._useTails) { if (this._useShortTails) { - target_seq.push(EPars.RNABASE_GUANINE); - target_seq.push(EPars.RNABASE_GUANINE); + targetSeq.push(EPars.RNABASE_GUANINE); + targetSeq.push(EPars.RNABASE_GUANINE); } else { - target_seq.push(EPars.RNABASE_GUANINE); - target_seq.push(EPars.RNABASE_GUANINE); - target_seq.push(EPars.RNABASE_ADENINE); - target_seq.push(EPars.RNABASE_ADENINE); - target_seq.push(EPars.RNABASE_ADENINE); + targetSeq.push(EPars.RNABASE_GUANINE); + targetSeq.push(EPars.RNABASE_GUANINE); + targetSeq.push(EPars.RNABASE_ADENINE); + targetSeq.push(EPars.RNABASE_ADENINE); + targetSeq.push(EPars.RNABASE_ADENINE); } } - for (let ii = 0; ii < target_seq_temp.length; ii++) { - target_seq.push(target_seq_temp[ii]); + for (let ii = 0; ii < targetSeqTemp.length; ii++) { + targetSeq.push(targetSeqTemp[ii]); } if (this._useTails) { for (let ii = 0; ii < 20; ii++) { - target_seq.push(EPars.RNABASE_LAST20[ii]); + targetSeq.push(EPars.RNABASE_LAST20[ii]); } } let locks: boolean[] = this.puzzleLocks; - if (locks.length !== target_seq.length || target_seq.length !== seq.length) { + if (locks.length !== targetSeq.length || targetSeq.length !== seq.length) { throw new Error("lock length doesn't match object sequence"); } - for (let ii = 0; ii < target_seq.length; ii++) { + for (let ii = 0; ii < targetSeq.length; ii++) { if (!locks[ii]) { - target_seq[ii] = seq[ii]; + targetSeq[ii] = seq[ii]; } } - return target_seq; + return targetSeq; } } return seq; @@ -643,7 +650,7 @@ export default class Puzzle { private _numSubmissions: number = 3; private _folder: string; private _reward: number = 0; - private _rscriptOps: string = ""; + private _rscriptOps: string = ''; private _defaultPoseState: PoseState; private _useTools: number = 0; private _usePallete: number = 0; @@ -653,11 +660,11 @@ export default class Puzzle { private _isSoftConstraint: boolean = false; private _boosterDefs: BoostersData = null; - private static readonly T_APTAMER: string[] = ["aptamer", "aptamer+oligo"]; - private static readonly T_OLIGO: string[] = ["oligo", "aptamer+oligo"]; + private static readonly T_APTAMER: string[] = ['aptamer', 'aptamer+oligo']; + private static readonly T_OLIGO: string[] = ['oligo', 'aptamer+oligo']; private static readonly BOOL_TRUE: number = 1; private static readonly BOOL_FALSE: number = 2; - private static readonly DEFAULT_MISSION_TEXT: string = "Match the desired RNA shape!"; + private static readonly DEFAULT_MISSION_TEXT: string = 'Match the desired RNA shape!'; } diff --git a/src/eterna/puzzle/PuzzleManager.ts b/src/eterna/puzzle/PuzzleManager.ts index 3c6a23a8a..3d118c5e3 100644 --- a/src/eterna/puzzle/PuzzleManager.ts +++ b/src/eterna/puzzle/PuzzleManager.ts @@ -1,9 +1,8 @@ -import * as log from "loglevel"; -import Eterna from "eterna/Eterna"; -import {CSVParser} from "eterna/util"; -import {Folder, FolderManager} from "../folding"; -import Puzzle from "./Puzzle"; -import SolutionManager from "./SolutionManager"; +import * as log from 'loglevel'; +import Eterna from 'eterna/Eterna'; +import {Folder, FolderManager} from '../folding'; +import Puzzle from './Puzzle'; +import SolutionManager from './SolutionManager'; export default class PuzzleManager { public static get instance(): PuzzleManager { @@ -14,105 +13,105 @@ export default class PuzzleManager { } public parsePuzzle(json: any): Puzzle { - let newpuz: Puzzle = new Puzzle(Number(json["id"]), json["title"], json["type"]); + let newpuz: Puzzle = new Puzzle(Number(json['id']), json['title'], json['type']); - if (json["body"]) { + if (json['body']) { // Convention: mission texts are encapsulated by // ... // This allows to reuse existing descriptions, just insert the span element where appropriate // Or one can add a new mission statement, and HTML-hide it if necessary using - let res: RegExpExecArray = PuzzleManager.RE_MISSION_TEXT.exec(json["body"]); + let res: RegExpExecArray = PuzzleManager.RE_MISSION_TEXT.exec(json['body']); if (res != null && res.length >= 2) { - newpuz.missionText = res[1]; + [, newpuz.missionText] = res; } } - if (json["locks"] && json["locks"].length > 0) { - let lock_str: string = json["locks"]; + if (json['locks'] && json['locks'].length > 0) { + let lockStr: string = json['locks']; let locks: boolean[] = []; - for (let kk = 0; kk < lock_str.length; kk++) { - locks.push(lock_str.charAt(kk) === "x"); + for (let kk = 0; kk < lockStr.length; kk++) { + locks.push(lockStr.charAt(kk) === 'x'); } newpuz.puzzleLocks = locks; } - if (json["objective"]) { - let objective: any = JSON.parse(json["objective"])[0]; - if (objective["shift_limit"]) { - newpuz.shiftLimit = objective["shift_limit"]; + if (json['objective']) { + let objective: any = JSON.parse(json['objective'])[0]; + if (objective['shift_limit']) { + newpuz.shiftLimit = objective['shift_limit']; } else { newpuz.shiftLimit = 0; } } - if (json["beginseq"] && json["beginseq"].length > 0) { - if (json["beginseq"].length !== json["secstruct"].length) { - throw new Error(`Beginning sequence length doesn't match pair length for puzzle ${json["Title"]}`); + if (json['beginseq'] && json['beginseq'].length > 0) { + if (json['beginseq'].length !== json['secstruct'].length) { + throw new Error(`Beginning sequence length doesn't match pair length for puzzle ${json['Title']}`); } - newpuz.beginningSequence = json["beginseq"]; + newpuz.beginningSequence = json['beginseq']; } - if (json["saved_sequence"] && json["saved_sequence"].length > 0) { - if (json["saved_sequence"].length === json["secstruct"].length && json["type"] === "Challenge") { - newpuz.savedSequenceString = json["saved_sequence"]; + if (json['saved_sequence'] && json['saved_sequence'].length > 0) { + if (json['saved_sequence'].length === json['secstruct'].length && json['type'] === 'Challenge') { + newpuz.savedSequenceString = json['saved_sequence']; } } - let usetails = Number(json["usetails"]); + let usetails = Number(json['usetails']); newpuz.setUseTails(usetails > 0, usetails === 2); - if (json["folder"] && json["folder"].length > 0) { - newpuz.folderName = json["folder"]; + if (json['folder'] && json['folder'].length > 0) { + newpuz.folderName = json['folder']; } - if (json["reward"] && json["reward"].length > 0) { - newpuz.reward = Number(json["reward"]); + if (json['reward'] && json['reward'].length > 0) { + newpuz.reward = Number(json['reward']); } - if (json["ui-specs"]) { + if (json['ui-specs']) { // New style UI elements (scripted) are identified as JSON objects - if (json["ui-specs"].substr(0, 1) === "{") { - newpuz.boosters = JSON.parse(json["ui-specs"]); + if (json['ui-specs'].substr(0, 1) === '{') { + newpuz.boosters = JSON.parse(json['ui-specs']); } else { // Fallback for the old tutorials - newpuz.uiSpecs = json["ui-specs"].split(","); + newpuz.uiSpecs = json['ui-specs'].split(','); } } - if (json["next-puzzle"]) { - newpuz.nextPuzzleID = Number(json["next-puzzle"]); + if (json['next-puzzle']) { + newpuz.nextPuzzleID = Number(json['next-puzzle']); } - if (json["last-round"] != null) { - newpuz.round = Number(json["last-round"]) + 1; + if (json['last-round'] != null) { + newpuz.round = Number(json['last-round']) + 1; } - if (json["objective"] && json["objective"].length > 0) { - newpuz.objective = JSON.parse(json["objective"]); + if (json['objective'] && json['objective'].length > 0) { + newpuz.objective = JSON.parse(json['objective']); } else { - newpuz.secstructs = [json["secstruct"]]; + newpuz.secstructs = [json['secstruct']]; } - if (json["check_hairpin"] && Number(json["check_hairpin"])) { + if (json['check_hairpin'] && Number(json['check_hairpin'])) { newpuz.useBarcode = true; } - if (json["num-submissions"] != null) { - newpuz.numSubmissions = Number(json["num-submissions"]); + if (json['num-submissions'] != null) { + newpuz.numSubmissions = Number(json['num-submissions']); } - if (json["rscript"]) { - newpuz.rscript = json["rscript"]; + if (json['rscript']) { + newpuz.rscript = json['rscript']; } - if (json["events"]) { - newpuz.rscript = json["events"]; + if (json['events']) { + newpuz.rscript = json['events']; } - if (json["hint"]) { - newpuz.hint = json["hint"]; + if (json['hint']) { + newpuz.hint = json['hint']; } if (newpuz.nodeID === 877668) { @@ -123,34 +122,42 @@ export default class PuzzleManager { newpuz.objective = JSON.parse(PuzzleManager.OBJECTIVE_1420804); } - let target_conditions: any[] = newpuz.targetConditions; - if (target_conditions != null) { - for (let ii = 0; ii < target_conditions.length; ii++) { - if (target_conditions[ii] != null) { - let constrained_bases: any[] = target_conditions[ii]["structure_constrained_bases"]; - if (constrained_bases != null) { - if (constrained_bases.length % 2 === 0) { - target_conditions[ii]["structure_constraints"] = []; - for (let jj = 0; jj < target_conditions[ii]["secstruct"].length; jj++) target_conditions[ii]["structure_constraints"][jj] = false; + let {targetConditions} = newpuz; + if (targetConditions != null) { + for (let ii = 0; ii < targetConditions.length; ii++) { + if (targetConditions[ii] != null) { + let constrainedBases: any[] = targetConditions[ii]['structure_constrained_bases']; + if (constrainedBases != null) { + if (constrainedBases.length % 2 === 0) { + targetConditions[ii]['structure_constraints'] = []; + for (let jj = 0; jj < targetConditions[ii]['secstruct'].length; jj++) { + targetConditions[ii]['structure_constraints'][jj] = false; + } - for (let jj = 0; jj < constrained_bases.length; jj += 2) { - for (let kk = constrained_bases[jj]; kk <= constrained_bases[jj + 1]; kk++) { - target_conditions[ii]["structure_constraints"][kk] = true; + for (let jj = 0; jj < constrainedBases.length; jj += 2) { + for (let kk = constrainedBases[jj]; kk <= constrainedBases[jj + 1]; kk++) { + targetConditions[ii]['structure_constraints'][kk] = true; } } } } - let anti_constrained_bases: any[] = target_conditions[ii]["anti_structure_constrained_bases"]; - if (anti_constrained_bases != null) { - if (target_conditions[ii]["anti_secstruct"] != null && target_conditions[ii]["anti_secstruct"].length === target_conditions[ii]["secstruct"].length) { - if (anti_constrained_bases.length % 2 === 0) { - target_conditions[ii]["anti_structure_constraints"] = []; - for (let jj = 0; jj < target_conditions[ii]["secstruct"].length; jj++) target_conditions[ii]["anti_structure_constraints"][jj] = false; + let antiConstrainedBases: any[] = targetConditions[ii]['anti_structure_constrained_bases']; + if (antiConstrainedBases != null) { + if ( + targetConditions[ii]['anti_secstruct'] != null + && targetConditions[ii]['anti_secstruct'].length + === targetConditions[ii]['secstruct'].length + ) { + if (antiConstrainedBases.length % 2 === 0) { + targetConditions[ii]['anti_structure_constraints'] = []; + for (let jj = 0; jj < targetConditions[ii]['secstruct'].length; jj++) { + targetConditions[ii]['anti_structure_constraints'][jj] = false; + } - for (let jj = 0; jj < anti_constrained_bases.length; jj += 2) { - for (let kk = anti_constrained_bases[jj]; kk <= anti_constrained_bases[jj + 1]; kk++) { - target_conditions[ii]["anti_structure_constraints"][kk] = true; + for (let jj = 0; jj < antiConstrainedBases.length; jj += 2) { + for (let kk = antiConstrainedBases[jj]; kk <= antiConstrainedBases[jj + 1]; kk++) { + targetConditions[ii]['anti_structure_constraints'][kk] = true; } } } @@ -160,19 +167,21 @@ export default class PuzzleManager { } } - if (json["constraints"] && json["constraints"].length > 0) { - let constraints: string[] = CSVParser.splitOnComma(json["constraints"]); - if (json["check_hairpin"] && Number(json["check_hairpin"])) { - constraints.push("BARCODE"); - constraints.push("0"); + if (json['constraints'] && json['constraints'].length > 0) { + let constraints: string[] = json['constraints'].split(','); + if (json['check_hairpin'] && Number(json['check_hairpin'])) { + constraints.push('BARCODE'); + constraints.push('0'); } newpuz.constraints = constraints; - } else if (json["check_hairpin"] && Number(json["check_hairpin"])) { - newpuz.constraints = ["BARCODE", "0"]; + } else if (json['check_hairpin'] && Number(json['check_hairpin'])) { + newpuz.constraints = ['BARCODE', '0']; } if (!newpuz.canUseFolder(FolderManager.instance.getFolder(newpuz.folderName))) { - newpuz.folderName = FolderManager.instance.getNextFolder(newpuz.folderName, (folder: Folder) => !newpuz.canUseFolder(folder)).name; + newpuz.folderName = FolderManager.instance.getNextFolder( + newpuz.folderName, (folder: Folder) => !newpuz.canUseFolder(folder) + ).name; } let replace = false; @@ -194,7 +203,7 @@ export default class PuzzleManager { public getPuzzleByID(puznid: number, scriptid: number = -1): Promise { for (let puzzle of this._puzzles) { - if (puzzle.nodeID == puznid) { + if (puzzle.nodeID === puznid) { return Promise.resolve(puzzle); } } @@ -202,12 +211,12 @@ export default class PuzzleManager { log.info(`Loading puzzle [nid=${puznid}, scriptid=${scriptid}...]`); return Eterna.client.getPuzzle(puznid, scriptid) .then((json: any) => { - let data: any = json["data"]; - if (data["hairpins"]) { - SolutionManager.instance.addHairpins(data["hairpins"]); + let data = json['data']; + if (data['hairpins']) { + SolutionManager.instance.addHairpins(data['hairpins']); } - let puzzle = this.parsePuzzle(data["puzzle"]); + let puzzle = this.parsePuzzle(data['puzzle']); log.info(`Loaded puzzle [name=${puzzle.getName()}]`); return puzzle; }); @@ -217,9 +226,11 @@ export default class PuzzleManager { private static _instance: PuzzleManager; - private static readonly OBJECTIVE_877668 = "[{\"type\":\"single\",\"secstruct\":\".....................(((((............)))))\"},{\"type\":\"aptamer\",\"site\":[2,3,4,5,6,7,8,9,18,19,20,21,22,23,24],\"concentration\":100,\"secstruct\":\"(((......(((....))).....)))................\"}]"; - private static readonly OBJECTIVE_885046 = "[{\"type\":\"single\",\"secstruct\":\".....................(((((((............)))))))\"},{\"type\":\"aptamer\",\"site\":[8,9,10,11,12,13,14,15,26,27,28,29,30,31,32],\"concentration\":10000,\"secstruct\":\"((((......((((....)))).....))))................\"}]"; - private static readonly OBJECTIVE_1420804 = "[{\"type\":\"single\",\"secstruct\":\".....................(((((((............)))))))........\"},{\"type\":\"aptamer\",\"site\":[12,13,14,15,16,17,18,19,33,34,35,36,37,38,39],\"concentration\":10000,\"secstruct\":\"..(((.((......(((((....)).))).....)))))................\"}]"; + /* eslint-disable max-len */ + private static readonly OBJECTIVE_877668 = '[{"type":"single","secstruct":".....................(((((............)))))"},{"type":"aptamer","site":[2,3,4,5,6,7,8,9,18,19,20,21,22,23,24],"concentration":100,"secstruct":"(((......(((....))).....)))................"}]'; + private static readonly OBJECTIVE_885046 = '[{"type":"single","secstruct":".....................(((((((............)))))))"},{"type":"aptamer","site":[8,9,10,11,12,13,14,15,26,27,28,29,30,31,32],"concentration":10000,"secstruct":"((((......((((....)))).....))))................"}]'; + private static readonly OBJECTIVE_1420804 = '[{"type":"single","secstruct":".....................(((((((............)))))))........"},{"type":"aptamer","site":[12,13,14,15,16,17,18,19,33,34,35,36,37,38,39],"concentration":10000,"secstruct":"..(((.((......(((((....)).))).....)))))................"}]'; + /* eslint-enable max-len */ private static readonly RE_MISSION_TEXT = /(.*?)<\/span>/s; } diff --git a/src/eterna/puzzle/Solution.ts b/src/eterna/puzzle/Solution.ts index 8e409014b..39665fbc9 100644 --- a/src/eterna/puzzle/Solution.ts +++ b/src/eterna/puzzle/Solution.ts @@ -1,10 +1,10 @@ -import Eterna from "eterna/Eterna"; -import Feedback from "eterna/Feedback"; +import Eterna from 'eterna/Eterna'; +import Feedback from 'eterna/Feedback'; export default class Solution { - public constructor(nid: number, puzzle_nid: number) { + constructor(nid: number, puzzleNID: number) { this._nid = nid; - this._puzzleNid = puzzle_nid; + this._puzzleNid = puzzleNID; } public set freeEnergy(fe: number) { @@ -20,12 +20,12 @@ export default class Solution { if (this._desc) { let newlinereg = /\n/g; - this._shortDesc = this._desc.replace(newlinereg, " "); + this._shortDesc = this._desc.replace(newlinereg, ' '); newlinereg = /\r/g; - this._shortDesc = this._shortDesc.replace(newlinereg, " "); + this._shortDesc = this._shortDesc.replace(newlinereg, ' '); } else { - this._shortDesc = "No description available"; - this._desc = "No description available"; + this._shortDesc = 'No description available'; + this._desc = 'No description available'; } } @@ -44,9 +44,9 @@ export default class Solution { this._title = title; let newlinereg = /\n/g; - this._title = this._title.replace(newlinereg, " "); + this._title = this._title.replace(newlinereg, ' '); newlinereg = /\r/g; - this._title = this._title.replace(newlinereg, " "); + this._title = this._title.replace(newlinereg, ' '); } public get nodeID(): number { @@ -103,9 +103,9 @@ export default class Solution { this._meltingPoint = mp; } - public setNumVotes(num_votes: number, num_my_votes: number): void { - this._numVotes = num_votes; - this._numMyVotes = num_my_votes; + public setNumVotes(numVotes: number, numMyVotes: number): void { + this._numVotes = numVotes; + this._numMyVotes = numMyVotes; } public setPlayer(name: string, id: number): void { @@ -128,9 +128,9 @@ export default class Solution { return Promise.resolve(this._foldData); } else { return Eterna.client.getSolutionInfo(this._nid).then((json) => { - let data: any = json["data"]; - if (data["solution"] != null) { - this.foldData = JSON.parse(data["solution"]["fold-data"]); + let data = json['data']; + if (data['solution'] != null) { + this.foldData = JSON.parse(data['solution']['fold-data']); } return this._foldData; @@ -142,51 +142,51 @@ export default class Solution { } public getProperty(keyword: string): any { - if (keyword === "Title") { + if (keyword === 'Title') { return this._title; - } else if (keyword === "GU Pairs") { + } else if (keyword === 'GU Pairs') { return this._numGUs; - } else if (keyword === "GC Pairs") { + } else if (keyword === 'GC Pairs') { return this._numGCs; - } else if (keyword === "UA Pairs") { + } else if (keyword === 'UA Pairs') { return this._numUAs; - } else if (keyword === "Melting Point") { + } else if (keyword === 'Melting Point') { return this._meltingPoint; - } else if (keyword === "Designer") { + } else if (keyword === 'Designer') { return this._playerName; - } else if (keyword === "Sequence") { + } else if (keyword === 'Sequence') { return this._sequence; - } else if (keyword === "Free Energy") { + } else if (keyword === 'Free Energy') { return this._freeEnergy; - } else if (keyword === "Description") { + } else if (keyword === 'Description') { return this._shortDesc; - } else if (keyword === "Round") { + } else if (keyword === 'Round') { return this._round; - } else if (keyword === "Votes") { + } else if (keyword === 'Votes') { if (this._synthesizedRound) { return -1; } return this._numVotes; - } else if (keyword === "My Votes") { + } else if (keyword === 'My Votes') { if (this._synthesizedRound) { return -1; } return this._numMyVotes; - } else if (keyword === "Synthesized") { + } else if (keyword === 'Synthesized') { if (this._synthesizedRound > 0) { - return "y"; + return 'y'; } else { - return "n"; + return 'n'; } - } else if (keyword === "Synthesis score") { + } else if (keyword === 'Synthesis score') { if (this._expFeedback != null && this._expFeedback.getShapeData() != null) { return this._synthesisScore; } else if (this._expFeedback != null && this._expFeedback.isFailed() !== 0) { return this._expFeedback.isFailed(); } else { - return Feedback.EXPCODES[Feedback.EXPSTRINGS.indexOf("NOT SYNTHESIZED")]; + return Feedback.EXPCODES[Feedback.EXPSTRINGS.indexOf('NOT SYNTHESIZED')]; } - } else if (keyword === "Id") { + } else if (keyword === 'Id') { return this._nid; } @@ -199,7 +199,7 @@ export default class Solution { private _sequence: string; private _title: string; private _playerID: number = -1; - private _playerName: string = ""; + private _playerName: string = ''; private _numGUs: number; private _numGCs: number; private _numUAs: number; diff --git a/src/eterna/puzzle/SolutionManager.ts b/src/eterna/puzzle/SolutionManager.ts index f4ed244eb..25bc416fb 100644 --- a/src/eterna/puzzle/SolutionManager.ts +++ b/src/eterna/puzzle/SolutionManager.ts @@ -1,9 +1,8 @@ -import * as log from "loglevel"; -import EPars from "eterna/EPars"; -import Eterna from "eterna/Eterna"; -import Feedback from "eterna/Feedback"; -import {CSVParser} from "eterna/util"; -import Solution from "./Solution"; +import * as log from 'loglevel'; +import EPars from 'eterna/EPars'; +import Eterna from 'eterna/Eterna'; +import Feedback from 'eterna/Feedback'; +import Solution from './Solution'; export default class SolutionManager { public static get instance(): SolutionManager { @@ -16,12 +15,11 @@ export default class SolutionManager { public getSolutionsForPuzzle(puzzleID: number): Promise { log.info(`Loading solutions for puzzle ${puzzleID}...`); return Eterna.client.getSolutions(puzzleID).then((json) => { - let data: any = json["data"]; - let solutionsData: any[] = data["solutions"]; + let solutionsData = json['data']['solutions']; this._solutions = []; - for (let data of solutionsData) { - this._solutions.push(SolutionManager.processData(data)); + for (let solution of solutionsData) { + this._solutions.push(SolutionManager.processData(solution)); } return this._solutions; @@ -69,7 +67,7 @@ export default class SolutionManager { public getMyCurrentSolutionTitles(round: number): string[] { let titles: string[] = []; for (let solution of this._solutions) { - if (solution.getProperty("Round") === round && solution.playerID === Eterna.playerID) { + if (solution.getProperty('Round') === round && solution.playerID === Eterna.playerID) { titles.push(solution.title); } } @@ -78,44 +76,44 @@ export default class SolutionManager { } private static processData(obj: any): Solution { - let newsol: Solution = new Solution(Number(obj["id"]), Number(obj["puznid"])); - newsol.sequence = obj["sequence"]; - newsol.title = obj["title"]; + let newsol: Solution = new Solution(Number(obj['id']), Number(obj['puznid'])); + newsol.sequence = obj['sequence']; + newsol.title = obj['title']; let newfb: Feedback = null; - let player_name = ""; - let player_id = -1; + let playerName = ''; + let playerID = -1; - if (obj["name"] != null) { - player_name = obj["name"]; + if (obj['name'] != null) { + playerName = obj['name']; } - if (obj["uid"] != null) { - player_id = Number(obj["uid"]); + if (obj['uid'] != null) { + playerID = Number(obj['uid']); } - newsol.setPlayer(player_name, player_id); - newsol.setNumPairs(Number(obj["gc"]), Number(obj["gu"]), Number(obj["au"])); - newsol.meltingPoint(Number(obj["meltpoint"])); - newsol.freeEnergy = Number(obj["energy"]); - newsol.desc = obj["body"]; - newsol.round = Number(obj["submitted-round"]); - newsol.setSynthesis(Number(obj["synthesis-round"]), Number(obj["synthesis-score"])); - - if (obj["synthesis-data"] && obj["synthesis-data"].length > 0) { - let synthesis_data_raw: any = JSON.parse(obj["synthesis-data"]); - if (Array.isArray(synthesis_data_raw)) { - let synthesis_data: any[] = synthesis_data_raw; - - for (let ii = 0; ii < synthesis_data.length; ii++) { - let synthesis: any = synthesis_data[ii]; - if (synthesis["reactive"] === "SHAPE") { + newsol.setPlayer(playerName, playerID); + newsol.setNumPairs(Number(obj['gc']), Number(obj['gu']), Number(obj['au'])); + newsol.meltingPoint(Number(obj['meltpoint'])); + newsol.freeEnergy = Number(obj['energy']); + newsol.desc = obj['body']; + newsol.round = Number(obj['submitted-round']); + newsol.setSynthesis(Number(obj['synthesis-round']), Number(obj['synthesis-score'])); + + if (obj['synthesis-data'] && obj['synthesis-data'].length > 0) { + let synthesisDataRaw: any = JSON.parse(obj['synthesis-data']); + if (Array.isArray(synthesisDataRaw)) { + let synthesisData: any[] = synthesisDataRaw; + + for (let ii = 0; ii < synthesisData.length; ii++) { + let synthesis: any = synthesisData[ii]; + if (synthesis['reactive'] === 'SHAPE') { let peaks: number[] = []; - peaks.push(Number(synthesis["start_index"])); + peaks.push(Number(synthesis['start_index'])); - for (let ss = 0; ss < synthesis["peaks"].length; ss++) { - peaks.push(Number(synthesis["peaks"][ss])); + for (let ss = 0; ss < synthesis['peaks'].length; ss++) { + peaks.push(Number(synthesis['peaks'][ss])); } if (newfb == null) { @@ -124,63 +122,63 @@ export default class SolutionManager { newfb.setShapeData( peaks, - Number(synthesis["target_index"]), - Number(synthesis["threshold"]), - Number(synthesis["max"]), - Number(synthesis["min"]), + Number(synthesis['target_index']), + Number(synthesis['threshold']), + Number(synthesis['max']), + Number(synthesis['min']), null ); } } // / Ad-hoc handling for different exp types : Brent's theophylline puzzle - } else if (synthesis_data_raw["type"] === "brent_theo") { + } else if (synthesisDataRaw['type'] === 'brent_theo') { if (newfb == null) { newfb = new Feedback(); } - newfb.brentTheoData(synthesis_data_raw); + newfb.brentTheoData(synthesisDataRaw); } - } else if (obj["SHAPE"] != null && obj["SHAPE"].length > 0) { + } else if (obj['SHAPE'] != null && obj['SHAPE'].length > 0) { if (newfb == null) { newfb = new Feedback(); } - if (Feedback.EXPSTRINGS.indexOf(obj["SHAPE"]) >= 0) { - newfb.setShapeData(null, 0, null, null, null, obj["SHAPE"]); + if (Feedback.EXPSTRINGS.indexOf(obj['SHAPE']) >= 0) { + newfb.setShapeData(null, 0, null, null, null, obj['SHAPE']); } else { - let shape_array: any[] = CSVParser.splitOnComma(obj["SHAPE"]); - for (let kk = 0; kk < shape_array.length; kk++) { - shape_array[kk] = Number(shape_array[kk]); + let shapeArray = obj['SHAPE'].split(','); + for (let kk = 0; kk < shapeArray.length; kk++) { + shapeArray[kk] = Number(shapeArray[kk]); } let max: any = null; let min: any = null; let threshold: any = null; - if (obj["SHAPE-threshold"] != null && obj["SHAPE-threshold"] !== "") { - threshold = Number(obj["SHAPE-threshold"]); + if (obj['SHAPE-threshold'] != null && obj['SHAPE-threshold'] !== '') { + threshold = Number(obj['SHAPE-threshold']); } - if (obj["SHAPE-max"] != null && obj["SHAPE-max"] !== "") { - max = Number(obj["SHAPE-max"]); + if (obj['SHAPE-max'] != null && obj['SHAPE-max'] !== '') { + max = Number(obj['SHAPE-max']); } - if (obj["SHAPE-min"] != null && obj["SHAPE-min"] !== "") { - min = Number(obj["SHAPE-min"]); + if (obj['SHAPE-min'] != null && obj['SHAPE-min'] !== '') { + min = Number(obj['SHAPE-min']); } - newfb.setShapeData(shape_array, 0, threshold, max, min, null); + newfb.setShapeData(shapeArray, 0, threshold, max, min, null); } } - newsol.setPlayer(player_name, player_id); + newsol.setPlayer(playerName, playerID); newsol.expFeedback = newfb; - if (obj["has-fold-data"] != null) { - newsol.hasFoldData = obj["has-fold-data"] !== 0; + if (obj['has-fold-data'] != null) { + newsol.hasFoldData = obj['has-fold-data'] !== 0; } - if (obj["fold-data"] != null) { - newsol.foldData = JSON.parse(obj["fold-data"]); + if (obj['fold-data'] != null) { + newsol.foldData = JSON.parse(obj['fold-data']); } return newsol; diff --git a/src/eterna/puzzle/index.ts b/src/eterna/puzzle/index.ts index c1ece4b96..e93e91ad8 100644 --- a/src/eterna/puzzle/index.ts +++ b/src/eterna/puzzle/index.ts @@ -1,7 +1,7 @@ -export {default as Constraints, ConstraintType} from "./Constraints"; +export {default as Constraints, ConstraintType} from './Constraints'; export { default as Puzzle, BoostersData, PuzzleType, PoseState -} from "./Puzzle"; -export {default as PuzzleManager} from "./PuzzleManager"; -export {default as Solution} from "./Solution"; -export {default as SolutionManager} from "./SolutionManager"; +} from './Puzzle'; +export {default as PuzzleManager} from './PuzzleManager'; +export {default as Solution} from './Solution'; +export {default as SolutionManager} from './SolutionManager'; diff --git a/src/eterna/rank/PlayerRank.ts b/src/eterna/rank/PlayerRank.ts index 8f20098de..e16292e9f 100644 --- a/src/eterna/rank/PlayerRank.ts +++ b/src/eterna/rank/PlayerRank.ts @@ -3,7 +3,7 @@ export default class PlayerRank { public score: number; public rank: number; - public constructor(name: string, score: number | string) { + constructor(name: string, score: number | string) { this.name = name; this.score = Number(score); this.rank = 0; diff --git a/src/eterna/rank/RankBoard.ts b/src/eterna/rank/RankBoard.ts index 54f92dee7..1246a5808 100644 --- a/src/eterna/rank/RankBoard.ts +++ b/src/eterna/rank/RankBoard.ts @@ -1,15 +1,15 @@ -import {Point} from "pixi.js"; -import {Updatable} from "flashbang/core"; -import {ContainerObject} from "flashbang/objects"; -import PlayerRank from "./PlayerRank"; -import RankRowLayout from "./RankRowLayout"; +import {Point} from 'pixi.js'; +import {Updatable} from 'flashbang/core'; +import {ContainerObject} from 'flashbang/objects'; +import PlayerRank from './PlayerRank'; +import RankRowLayout from './RankRowLayout'; export default class RankBoard extends ContainerObject implements Updatable { public static readonly ROW_WIDTH = 400; public static readonly ROW_HEIGHT = 20; public static readonly PLAYER_ROW_HEIGHT = 32; - public constructor(startingRank: number, rankData: PlayerRank[], offsetBtwRankCoin: number) { + constructor(startingRank: number, rankData: PlayerRank[], offsetBtwRankCoin: number) { super(); this._rankData = rankData; this._startingPosition = 0; @@ -35,16 +35,22 @@ export default class RankBoard extends ContainerObject implements Updatable { } public update(dt: number): void { - let parentOffset: number = this.container.y - this._startingPosition; + let parentOffset = this.container.y - this._startingPosition; for (let ii = 0; ii < this._rows.length; ii++) { - // pos_offset / RankBoard.ROW_HEIGHT = How many entries we have moved by - let loopNum: number = Math.floor((parentOffset / RankBoard.ROW_HEIGHT - ii + 2) / 3); // How many times a row has looped - let rankIdx: number = loopNum * this._rows.length + ii; // this row's player index in the data array - if (rankIdx < this._rankData.length) { // Catch if entry doesn't exist (ie. rank 1) + // posOffset / RankBoard.ROW_HEIGHT = How many entries we have moved by + // How many times a row has looped + let loopNum = Math.floor((parentOffset / RankBoard.ROW_HEIGHT - ii + 2) / 3); + // This row's player index in the data array + let rankIdx = loopNum * this._rows.length + ii; + if (rankIdx < this._rankData.length) { + // Catch if entry doesn't exist (ie. rank 1) const row = this._rows[ii]; - row.display.position.y = RankBoard.ROW_HEIGHT * (this._rankData.length - ii - 1) // Starting position - - this._rows.length * RankBoard.ROW_HEIGHT // Height of all entries combined, allows looping - * loopNum; // Multiplied by how many loops this row has gone through + // Starting position + row.display.position.y = RankBoard.ROW_HEIGHT * (this._rankData.length - ii - 1) + // Height of all entries combined, allows looping + - this._rows.length * RankBoard.ROW_HEIGHT + // Multiplied by how many loops this row has gone through + * loopNum; const rank: PlayerRank = this._rankData[rankIdx]; row.setRank(rank.rank); @@ -59,5 +65,6 @@ export default class RankBoard extends ContainerObject implements Updatable { private _startingPosition: number; - private static readonly NUM_VISIBLE: number = 2; // the number of entries you want visible at once (intermediary entry is automatically added) + // The number of entries you want visible at once (intermediary entry is automatically added) + private static readonly NUM_VISIBLE: number = 2; } diff --git a/src/eterna/rank/RankRowLayout.ts b/src/eterna/rank/RankRowLayout.ts index 8d530f23f..48db850f5 100644 --- a/src/eterna/rank/RankRowLayout.ts +++ b/src/eterna/rank/RankRowLayout.ts @@ -1,22 +1,22 @@ -import {Point, Text} from "pixi.js"; -import {ContainerObject} from "flashbang/objects"; -import {TextUtil} from "flashbang/util"; -import {Fonts} from "eterna/util"; -import PlayerRank from "./PlayerRank"; +import {Point, Text} from 'pixi.js'; +import {ContainerObject} from 'flashbang/objects'; +import {TextUtil} from 'flashbang/util'; +import {Fonts} from 'eterna/util'; +import PlayerRank from './PlayerRank'; export default class RankRowLayout extends ContainerObject { - public constructor(rank: number, data: PlayerRank, rankScoreOffset: number, + constructor(rank: number, data: PlayerRank, rankScoreOffset: number, fontSize: number = 18, maxNameWidth: number = -1, textColor: number = 0xFFFFFF) { super(); - this._tfName = Fonts.stdRegular("", fontSize).color(textColor).build(); + this._tfName = Fonts.stdRegular('', fontSize).color(textColor).build(); this.container.addChild(this._tfName); - this._tfRank = Fonts.stdRegular("", fontSize).color(textColor).build(); + this._tfRank = Fonts.stdRegular('', fontSize).color(textColor).build(); this._tfRank.position = new Point(130, 0); this.container.addChild(this._tfRank); - this._tfScore = Fonts.stdRegular("", fontSize).color(textColor).build(); + this._tfScore = Fonts.stdRegular('', fontSize).color(textColor).build(); this._tfScore.position = new Point(130 + rankScoreOffset, 0); this.container.addChild(this._tfScore); @@ -26,7 +26,7 @@ export default class RankRowLayout extends ContainerObject { } public setRank(rank: number): void { - this._tfRank.text = rank < 0 ? "" : `${rank}`; + this._tfRank.text = rank < 0 ? '' : `${rank}`; this._rank = rank; } @@ -37,7 +37,7 @@ export default class RankRowLayout extends ContainerObject { public setPlayerName(name: string, maxTextWidth: number = -1): void { this._tfName.text = name; if (maxTextWidth >= 0) { - TextUtil.trimTextToWidth(this._tfName, maxTextWidth, "..."); + TextUtil.trimTextToWidth(this._tfName, maxTextWidth, '...'); } this._playerName = this._tfName.text; } @@ -47,7 +47,7 @@ export default class RankRowLayout extends ContainerObject { } public setScore(score: number): void { - this._tfScore.text = (score < 0) ? "" : score.toString(); + this._tfScore.text = (score < 0) ? '' : score.toString(); this._score = score; } diff --git a/src/eterna/rank/RankScroll.ts b/src/eterna/rank/RankScroll.ts index e31b1afff..5b18e9616 100644 --- a/src/eterna/rank/RankScroll.ts +++ b/src/eterna/rank/RankScroll.ts @@ -1,113 +1,113 @@ -import {Graphics, Point, Text} from "pixi.js"; -import {ContainerObject} from "flashbang/objects"; +import {Graphics, Point, Text} from 'pixi.js'; +import {ContainerObject} from 'flashbang/objects'; import { AlphaTask, DelayTask, InterpolatingTask, LocationTask, ParallelTask, SerialTask, VisibleTask -} from "flashbang/tasks"; -import {Easing, EasingFunc} from "flashbang/util"; -import Eterna from "eterna/Eterna"; -import {GamePanel} from "eterna/ui"; -import {Fonts} from "eterna/util"; -import {VibrateTask} from "eterna/vfx"; -import PlayerRank from "./PlayerRank"; -import RankBoard from "./RankBoard"; -import RankRowLayout from "./RankRowLayout"; +} from 'flashbang/tasks'; +import {Easing, EasingFunc} from 'flashbang/util'; +import Eterna from 'eterna/Eterna'; +import {GamePanel} from 'eterna/ui'; +import {Fonts} from 'eterna/util'; +import {VibrateTask} from 'eterna/vfx'; +import PlayerRank from './PlayerRank'; +import RankBoard from './RankBoard'; +import RankRowLayout from './RankRowLayout'; export default class RankScroll extends ContainerObject { public static hasRankScrollData(submissionRsp: any): boolean { - return (submissionRsp["pointsrank-before"] != null && submissionRsp["pointsrank-after"] != null); + return (submissionRsp['pointsrank-before'] != null && submissionRsp['pointsrank-after'] != null); } /** Creates a RankScroll object with data returned from the submit-solution server response */ public static fromSubmissionResponse(submissionRsp: any): RankScroll { if (!RankScroll.hasRankScrollData(submissionRsp)) { - throw new Error("No RankScroll data in submission response"); + throw new Error('No RankScroll data in submission response'); } - let pointsrank_before: any = submissionRsp["pointsrank-before"]; - let pointsrank_after: any = submissionRsp["pointsrank-after"]; + let pointsrankBefore: any = submissionRsp['pointsrank-before']; + let pointsrankAfter: any = submissionRsp['pointsrank-after']; let player: PlayerRank; let ranks: PlayerRank[] = []; - let prevRank: number = pointsrank_before["rank"]; - let newRank: number = pointsrank_after["rank"]; - let prevPoints: number = pointsrank_before["points"]; - let newPoints: number = pointsrank_after["points"]; - let prevRicher: any[] = pointsrank_before["richer"]; - let prevPoorer: any[] = pointsrank_before["poorer"]; - let newRicher: any[] = pointsrank_after["richer"]; - let newPoorer: any[] = pointsrank_after["poorer"]; + let prevRank: number = pointsrankBefore['rank']; + let newRank: number = pointsrankAfter['rank']; + let prevPoints: number = pointsrankBefore['points']; + let newPoints: number = pointsrankAfter['points']; + let prevRicher: any[] = pointsrankBefore['richer']; + let prevPoorer: any[] = pointsrankBefore['poorer']; + let newRicher: any[] = pointsrankAfter['richer']; + let newPoorer: any[] = pointsrankAfter['poorer']; // / Don't even need to move if (prevPoints >= newPoints || prevRank <= newRank) { for (let ii = 0; ii < newRicher.length; ii++) { - let rank = new PlayerRank(newRicher[ii]["name"], newRicher[ii]["points"]); - rank.rank = newRicher[ii]["rank"]; + let rank = new PlayerRank(newRicher[ii]['name'], newRicher[ii]['points']); + rank.rank = newRicher[ii]['rank']; ranks.push(rank); } for (let ii = 0; ii < newPoorer.length; ii++) { - let rank = new PlayerRank(newPoorer[ii]["name"], newPoorer[ii]["points"]); - rank.rank = newPoorer[ii]["rank"]; + let rank = new PlayerRank(newPoorer[ii]['name'], newPoorer[ii]['points']); + rank.rank = newPoorer[ii]['rank']; ranks.push(rank); } - let playername = Eterna.playerName || "You"; + let playername = Eterna.playerName || 'You'; player = new PlayerRank(playername, prevPoints); player.rank = newRank; } else { - let last_after_entry_uid = -1; + let lastAfterEntryUID = -1; for (let ii = 0; ii < newRicher.length; ii++) { - let rank = new PlayerRank(newRicher[ii]["name"], newRicher[ii]["points"]); - rank.rank = newRicher[ii]["rank"]; + let rank = new PlayerRank(newRicher[ii]['name'], newRicher[ii]['points']); + rank.rank = newRicher[ii]['rank']; ranks.push(rank); - last_after_entry_uid = newRicher[ii]["uid"]; + lastAfterEntryUID = newRicher[ii]['uid']; } for (let ii = 0; ii < newPoorer.length; ii++) { - let rank = new PlayerRank(newPoorer[ii]["name"], newPoorer[ii]["points"]); - rank.rank = newPoorer[ii]["rank"]; + let rank = new PlayerRank(newPoorer[ii]['name'], newPoorer[ii]['points']); + rank.rank = newPoorer[ii]['rank']; ranks.push(rank); - last_after_entry_uid = newPoorer[ii]["uid"]; + lastAfterEntryUID = newPoorer[ii]['uid']; } - let common_entry = false; - let common_index = 0; + let commonEntry = false; + let commonIndex = 0; for (let ii = 0; ii < prevRicher.length; ii++) { - if (prevRicher[ii]["uid"] === last_after_entry_uid) { - common_entry = true; - common_index = ii; + if (prevRicher[ii]['uid'] === lastAfterEntryUID) { + commonEntry = true; + commonIndex = ii; break; } } - if (!common_entry) { + if (!commonEntry) { for (let ii = 0; ii < prevPoorer.length; ii++) { - if (prevPoorer[ii]["uid"] === last_after_entry_uid) { - common_entry = true; - common_index = -ii; + if (prevPoorer[ii]['uid'] === lastAfterEntryUID) { + commonEntry = true; + commonIndex = -ii; break; } } } - if (!common_entry || common_index >= 0) { - for (let ii = common_index; ii < prevRicher.length; ii++) { - let rank = new PlayerRank(prevRicher[ii]["name"], prevRicher[ii]["points"]); - rank.rank = prevRicher[ii]["rank"]; + if (!commonEntry || commonIndex >= 0) { + for (let ii = commonIndex; ii < prevRicher.length; ii++) { + let rank = new PlayerRank(prevRicher[ii]['name'], prevRicher[ii]['points']); + rank.rank = prevRicher[ii]['rank']; ranks.push(rank); } } - if (!common_entry || common_index >= 0) { - common_index = 0; + if (!commonEntry || commonIndex >= 0) { + commonIndex = 0; } - for (let ii = -common_index; ii < prevPoorer.length; ii++) { - let rank = new PlayerRank(prevPoorer[ii]["name"], prevPoorer[ii]["points"]); - rank.rank = prevPoorer[ii]["rank"]; + for (let ii = -commonIndex; ii < prevPoorer.length; ii++) { + let rank = new PlayerRank(prevPoorer[ii]['name'], prevPoorer[ii]['points']); + rank.rank = prevPoorer[ii]['rank']; ranks.push(rank); } - let playername = Eterna.playerName || "You"; + let playername = Eterna.playerName || 'You'; player = new PlayerRank(playername, prevPoints); player.rank = prevRank; } @@ -115,7 +115,7 @@ export default class RankScroll extends ContainerObject { return new RankScroll(ranks, player, newPoints, newRank); } - public constructor(allRanks: PlayerRank[], playerRank: PlayerRank, newScore: number, newRank: number) { + constructor(allRanks: PlayerRank[], playerRank: PlayerRank, newScore: number, newRank: number) { super(); this._allRanks = allRanks; this._playerRank = playerRank; @@ -127,7 +127,7 @@ export default class RankScroll extends ContainerObject { super.added(); // How many rows other than player's will show for each top/bottom side - const size_indicator = 1; + const sizeIndicator = 1; let startScore: number = this._playerRank.score; let startRank: number = this._playerRank.rank; @@ -139,7 +139,7 @@ export default class RankScroll extends ContainerObject { for (let ii = 0; ii < this._allRanks.length; ii++) { if (this._allRanks[ii].score <= this._newScore) { - topStartingIdx = ii - size_indicator; + topStartingIdx = ii - sizeIndicator; bottomStartingIdx = ii; endIdx = ii; startingSet = true; @@ -148,28 +148,28 @@ export default class RankScroll extends ContainerObject { } if (!startingSet) { - topStartingIdx = (this._allRanks.length - size_indicator); + topStartingIdx = (this._allRanks.length - sizeIndicator); bottomStartingIdx = this._allRanks.length; endIdx = this._allRanks.length; } - let top_ending_index = 0; - let bottom_ending_index = 0; - let ending_set = false; + let topEndingIndex = 0; + let bottomEndingIndex = 0; + let endingSet = false; let startIdx = 0; for (let ii = 0; ii < this._allRanks.length; ii++) { if (this._allRanks[ii].score <= startScore) { - top_ending_index = ii - 1; - bottom_ending_index = ii - 1 + size_indicator; - ending_set = true; + topEndingIndex = ii - 1; + bottomEndingIndex = ii - 1 + sizeIndicator; + endingSet = true; startIdx = ii; break; } } - if (!ending_set) { - top_ending_index = this._allRanks.length - 1; - bottom_ending_index = this._allRanks.length - 1 + size_indicator; + if (!endingSet) { + topEndingIndex = this._allRanks.length - 1; + bottomEndingIndex = this._allRanks.length - 1 + sizeIndicator; startIdx = this._allRanks.length; } @@ -187,31 +187,31 @@ export default class RankScroll extends ContainerObject { this._scoreOffset = this._newScore - startScore; this._moveOffset = startIdx - endIdx; - let max_width = 85; + let maxWidth = 85; // Make rank data coming down from top (of player) - let rank_data_top: PlayerRank[] = []; + let rankDataTop: PlayerRank[] = []; - for (let ii = topStartingIdx; ii <= top_ending_index; ii++) { + for (let ii = topStartingIdx; ii <= topEndingIndex; ii++) { if (ii < 0) { - const dummyrank = new PlayerRank("", -1); + const dummyrank = new PlayerRank('', -1); dummyrank.rank = -1; - rank_data_top.push(dummyrank); + rankDataTop.push(dummyrank); } else { - rank_data_top.push(this._allRanks[ii]); + rankDataTop.push(this._allRanks[ii]); } } // Make rank data coming out of bottom (of player) - let rank_data_bottom: any[] = []; - for (let ii = bottomStartingIdx; ii <= bottom_ending_index; ii++) { + let rankDataBottom: any[] = []; + for (let ii = bottomStartingIdx; ii <= bottomEndingIndex; ii++) { if (ii < this._allRanks.length) { let clone: PlayerRank = this._allRanks[ii].clone(); - rank_data_bottom.push(clone); + rankDataBottom.push(clone); } else { - const dummyrank = new PlayerRank("", -1); + const dummyrank = new PlayerRank('', -1); dummyrank.rank = -1; - rank_data_bottom.push(dummyrank); + rankDataBottom.push(dummyrank); } } @@ -221,37 +221,44 @@ export default class RankScroll extends ContainerObject { this.addObject(bg, this.container); // Set up rankboard according to above infos - this._rankBoardTop = new RankBoard(topStartingIdx + 1, rank_data_top.reverse(), max_width); - let mask_top: Graphics = new Graphics(); - mask_top.beginFill(0x00FF00, 0); - mask_top.drawRect(0, 0, RankBoard.ROW_WIDTH, size_indicator * RankBoard.ROW_HEIGHT); - this.container.addChild(mask_top); - this._rankBoardTop.display.mask = mask_top; - this._rankBoardTop.display.position = new Point(0, -((rank_data_top.length - size_indicator) * RankBoard.ROW_HEIGHT)); + this._rankBoardTop = new RankBoard(topStartingIdx + 1, rankDataTop.reverse(), maxWidth); + let maskTop: Graphics = new Graphics(); + maskTop.beginFill(0x00FF00, 0); + maskTop.drawRect(0, 0, RankBoard.ROW_WIDTH, sizeIndicator * RankBoard.ROW_HEIGHT); + this.container.addChild(maskTop); + this._rankBoardTop.display.mask = maskTop; + this._rankBoardTop.display.position = new Point( + 0, -((rankDataTop.length - sizeIndicator) * RankBoard.ROW_HEIGHT) + ); this._rankBoardTop.registerStartingPos(); this.addObject(this._rankBoardTop, this.container); - this._rankBoardBottom = new RankBoard(this._newRank + 1, rank_data_bottom.reverse(), max_width); + this._rankBoardBottom = new RankBoard(this._newRank + 1, rankDataBottom.reverse(), maxWidth); - let mask_bottom: Graphics = new Graphics(); - mask_bottom.beginFill(0x00FF00, 0); - mask_bottom.drawRect(0, size_indicator * RankBoard.ROW_HEIGHT + RankBoard.PLAYER_ROW_HEIGHT, RankBoard.ROW_WIDTH, size_indicator * RankBoard.ROW_HEIGHT); - this.container.addChild(mask_bottom); - this._rankBoardBottom.display.mask = mask_bottom; + let maskBottom: Graphics = new Graphics(); + maskBottom.beginFill(0x00FF00, 0); + maskBottom.drawRect( + 0, sizeIndicator * RankBoard.ROW_HEIGHT + RankBoard.PLAYER_ROW_HEIGHT, + RankBoard.ROW_WIDTH, sizeIndicator * RankBoard.ROW_HEIGHT + ); + this.container.addChild(maskBottom); + this._rankBoardBottom.display.mask = maskBottom; this._rankBoardBottom.display.position = new Point(0, - (size_indicator * RankBoard.ROW_HEIGHT) + RankBoard.PLAYER_ROW_HEIGHT + (sizeIndicator * RankBoard.ROW_HEIGHT) + RankBoard.PLAYER_ROW_HEIGHT - (this._moveOffset * RankBoard.ROW_HEIGHT)); this._rankBoardBottom.registerStartingPos(); this.addObject(this._rankBoardBottom, this.container); // Set current player's row as center position - this._playerRow = new RankRowLayout(startRank, this._playerRank, max_width, 20, 100, 0xEBA800); - this._playerRow.display.position = new Point(0, size_indicator * RankBoard.ROW_HEIGHT + 4); + this._playerRow = new RankRowLayout(startRank, this._playerRank, maxWidth, 20, 100, 0xEBA800); + this._playerRow.display.position = new Point(0, sizeIndicator * RankBoard.ROW_HEIGHT + 4); this.addObject(this._playerRow, this.container); this._tfRankOffset = Fonts.stdRegular(`+${this._rankOffset}`, 20).color(0xffffff).bold().build(); - this._tfRankOffset.position = new Point(-this._tfRankOffset.width - 10, size_indicator * RankBoard.ROW_HEIGHT + 4); + this._tfRankOffset.position = new Point( + -this._tfRankOffset.width - 10, sizeIndicator * RankBoard.ROW_HEIGHT + 4 + ); this._tfRankOffset.visible = true; this.container.addChild(this._tfRankOffset); } @@ -330,7 +337,7 @@ export default class RankScroll extends ContainerObject { } class RankScoreTask extends InterpolatingTask { - public constructor(newRank: number, newScore: number, duration: number, easing: EasingFunc) { + constructor(newRank: number, newScore: number, duration: number, easing: EasingFunc) { super(duration, easing); this._newRank = newRank; this._newScore = newScore; diff --git a/src/eterna/rank/index.ts b/src/eterna/rank/index.ts index eb0c56890..17ac8e556 100644 --- a/src/eterna/rank/index.ts +++ b/src/eterna/rank/index.ts @@ -1,4 +1,4 @@ -export {default as PlayerRank} from "./PlayerRank"; -export {default as RankBoard} from "./RankBoard"; -export {default as RankRowLayout} from "./RankRowLayout"; -export {default as RankScroll} from "./RankScroll"; +export {default as PlayerRank} from './PlayerRank'; +export {default as RankBoard} from './RankBoard'; +export {default as RankRowLayout} from './RankRowLayout'; +export {default as RankScroll} from './RankScroll'; diff --git a/src/eterna/resources/BitmapManager.ts b/src/eterna/resources/BitmapManager.ts index 55409673e..066af561e 100644 --- a/src/eterna/resources/BitmapManager.ts +++ b/src/eterna/resources/BitmapManager.ts @@ -1,7 +1,7 @@ -import {Texture} from "pixi.js"; -import {Assert, TextBuilder, TextureUtil} from "flashbang/util"; -import {Fonts} from "eterna/util"; -import Bitmaps from "./Bitmaps"; +import {Texture} from 'pixi.js'; +import {Assert, TextBuilder, TextureUtil} from 'flashbang/util'; +import {Fonts} from 'eterna/util'; +import Bitmaps from './Bitmaps'; export default class BitmapManager { public static getBitmap(url: string): Texture { @@ -22,7 +22,9 @@ export default class BitmapManager { return BitmapManager.getTextBitmapImpl(txt, Fonts.ARIAL, 12, true, color); } - private static getTextBitmapImpl(text: string, fontName: string, fontSize: number, bold: boolean, color: number): Texture { + private static getTextBitmapImpl( + text: string, fontName: string, fontSize: number, bold: boolean, color: number + ): Texture { let bitmap: Texture = BitmapManager._textBitmaps.get(text); if (bitmap == null) { let builder = new TextBuilder(text).font(fontName).fontSize(fontSize).color(color); diff --git a/src/eterna/resources/Bitmaps.ts b/src/eterna/resources/Bitmaps.ts index d7e9d2d0f..46a135976 100644 --- a/src/eterna/resources/Bitmaps.ts +++ b/src/eterna/resources/Bitmaps.ts @@ -1,295 +1,295 @@ /* eslint-disable max-len, global-require */ export default class Bitmaps { - public static readonly NovaAMissionReq: string = require("assets/NOVA/Mission/a-box.png"); - public static readonly NovaAReq: string = require("assets/NOVA/Constraints/a-requirement-box.png"); - public static readonly NovaARowMissionReq: string = require("assets/NOVA/Mission/a-row-box.png"); - public static readonly NovaARowReq: string = require("assets/NOVA/Constraints/a-row-req-box.png"); - public static readonly ActionbarCenterImg: string = require("assets/Actionbar/actionbar_center.png"); - public static readonly ActionbarLeftImg: string = require("assets/Actionbar/actionbar_left.png"); - public static readonly ActionbarRightImg: string = require("assets/Actionbar/actionbar_right.png"); - public static readonly ImgAddBaseOver: string = require("assets/NOVA/Edit/add_base_active.png"); - public static readonly ImgAddBase: string = require("assets/NOVA/Edit/add_base_normal.png"); - public static readonly ImgAddBaseSelect: string = require("assets/NOVA/Edit/add_base_selected.png"); - public static readonly ImgAddPairOver: string = require("assets/NOVA/Edit/add_pair_active.png"); - public static readonly ImgAddPair: string = require("assets/NOVA/Edit/add_pair_normal.png"); - public static readonly ImgAddPairSelect: string = require("assets/NOVA/Edit/add_pair_selected.png"); - public static readonly NovaAUReq: string = require("assets/NOVA/Constraints/au-requirement-carrier.png"); - public static readonly NovaAUMissionReq: string = require("assets/NOVA/Mission/au-requirement.png"); - public static readonly Backbone: string = require("assets/RNABase/backbone_new.png"); - public static readonly NovaBarcodeMissionReq: string = require("assets/NOVA/Mission/barcode-req-mission.png"); - public static readonly NovaBarcodeReq: string = require("assets/NOVA/Constraints/barcode-requirement-carrier.png"); - public static readonly ImgSelectBase: string = require("assets/NOVA/Palette/base-selected.png"); - public static readonly ImgBindingBaseGlow: string = require("assets/Aptamer/base_outer-1.png"); - public static readonly BaseAf: string = require("assets/RNABase/BaseAf.png"); - public static readonly BaseAfLock: string = require("assets/RNABase/BaseAfLock.png"); - public static readonly BaseAfMid: string = require("assets/RNABase/BaseAfMid.png"); - public static readonly BaseAfMidLock: string = require("assets/RNABase/BaseAfMidLock.png"); - public static readonly BaseCf: string = require("assets/RNABase/BaseCf.png"); - public static readonly BaseCfLock: string = require("assets/RNABase/BaseCfLock.png"); - public static readonly BaseCfMid: string = require("assets/RNABase/BaseCfMid.png"); - public static readonly BaseCfMidLock: string = require("assets/RNABase/BaseCfMidLock.png"); - public static readonly BaseGf: string = require("assets/RNABase/BaseGf.png"); - public static readonly BaseGfLock: string = require("assets/RNABase/BaseGfLock.png"); - public static readonly BaseGfMid: string = require("assets/RNABase/BaseGfMid.png"); - public static readonly BaseGfMidLock: string = require("assets/RNABase/BaseGfMidLock.png"); - public static readonly BaseUf: string = require("assets/RNABase/BaseUf.png"); - public static readonly BaseUfLock: string = require("assets/RNABase/BaseUfLock.png"); - public static readonly BaseUfMid: string = require("assets/RNABase/BaseUfMid.png"); - public static readonly BaseUfMidLock: string = require("assets/RNABase/BaseUfMidLock.png"); - public static readonly ImgMoney: string = require("assets/bet_big.png"); - public static readonly BaseUMid: string = require("assets/RNABase/blue_mid.png"); - public static readonly BaseUMidLock: string = require("assets/RNABase/blue_mid_lock.png"); - public static readonly BaseUOutline1: string = require("assets/RNABase/blue_outline_1.png"); - public static readonly BaseUOutline2: string = require("assets/RNABase/blue_outline_2_new.png"); - public static readonly BaseUPattern: string = require("assets/RNABase/blue_pattern.png"); - public static readonly BaseUMin: string = require("assets/RNABase/blue_small.png"); - public static readonly NovaBoostMissionReq: string = require("assets/NOVA/Mission/boost-req-mission.png"); - public static readonly NovaBoostReq: string = require("assets/NOVA/Constraints/boost-requirement-carrier.png"); - public static readonly NovaBoosters: string = require("assets/NOVA/booster_normal.png"); - public static readonly BubbleImg: string = require("assets/PuzzleEdit/btnDel.png"); - public static readonly Bubble00: string = require("assets/Bubble/bubble0.png"); - public static readonly Bubble10: string = require("assets/Bubble/bubble1.png"); - public static readonly Bubble03: string = require("assets/Bubble/bubble1_big_blurred.png"); - public static readonly Bubble01: string = require("assets/Bubble/bubble1_middle.png"); - public static readonly Bubble02: string = require("assets/Bubble/bubble1_small.png"); - public static readonly Bubble13: string = require("assets/Bubble/bubble2_big_blurred.png"); - public static readonly Bubble11: string = require("assets/Bubble/bubble2_middle.png"); - public static readonly Bubble12: string = require("assets/Bubble/bubble2_small.png"); - public static readonly NovaCMissionReq: string = require("assets/NOVA/Mission/c-box.png"); - public static readonly NovaCReq: string = require("assets/NOVA/Constraints/c-requirement-box.png"); - public static readonly NovaCRowMissionReq: string = require("assets/NOVA/Mission/c-row-box.png"); - public static readonly NovaCRowReq: string = require("assets/NOVA/Constraints/c-row-req-box.png"); - public static readonly ImgChatBoxArrowDown: string = require("assets/RinaChat/chatbox_arrow_down.png"); - public static readonly ImgChatBoxArrowUp: string = require("assets/RinaChat/chatbox_arrow_up.png"); - public static readonly ImgEndingMoney: string = require("assets/coin.png"); - public static readonly ImgColumnsOver: string = require("assets/NOVA/Columns/columns_active.png"); - public static readonly ImgColumnsHit: string = require("assets/NOVA/Columns/columns_hit.png"); - public static readonly ImgColumns: string = require("assets/NOVA/Columns/columns_normal.png"); - public static readonly ImgCopy: string = require("assets/NOVA/Copy/copy-1.png"); - public static readonly ImgCopyHit: string = require("assets/NOVA/Copy/copy-hit.png"); - public static readonly ImgCopyOver: string = require("assets/NOVA/Copy/copy-over.png"); - public static readonly ImgCross: string = require("assets/cross.png"); - public static readonly ActionbarDividerImg: string = require("assets/divider.png"); - public static readonly ImgDownArrow: string = require("assets/down_arrow.png"); - public static readonly CancelImg: string = require("assets/TangoIcons/emblem-unreadable.png"); - public static readonly ImgEndBoard: string = require("assets/endboard.png"); - public static readonly EnergyScoreBackground: string = require("assets/NOVA/Energy/energy-background.png"); - public static readonly EnterKeyImg: string = require("assets/enterkey.png"); - public static readonly ImgEraseOver: string = require("assets/NOVA/Edit/erase_active.png"); - public static readonly ImgErase: string = require("assets/NOVA/Edit/erase_normal.png"); - public static readonly ImgEraseSelect: string = require("assets/NOVA/Edit/erase_selected.png"); - public static readonly ImgEstimateOver: string = require("assets/NOVA/Estimate/estimate_active.png"); - public static readonly ImgEstimate: string = require("assets/NOVA/Estimate/estimate_normal.png"); - public static readonly ImgEstimateSelected: string = require("assets/NOVA/Estimate/estimate_selected.png"); - public static readonly ImgFb: string = require("assets/TangoIcons/evolver-32x32.png"); - public static readonly ImgFileOver: string = require("assets/NOVA/File/file_active.png"); - public static readonly ImgFileHit: string = require("assets/NOVA/File/file_hit.png"); - public static readonly ImgFile: string = require("assets/NOVA/File/file_normal.png"); - public static readonly NovaFingerClick: string = require("assets/NOVA/Hint/finger-click.png"); - public static readonly NovaFinger: string = require("assets/NOVA/Hint/finger.png"); - public static readonly ImgBadge1: string = require("assets/Achievements/Finished-Tutorial.png"); - public static readonly ImgFlaskOver: string = require("assets/NOVA/Flask/flask_active.png"); - public static readonly ImgFlask: string = require("assets/NOVA/Flask/flask_normal.png"); - public static readonly ImgFlaskSelected: string = require("assets/NOVA/Flask/flask_selected.png"); - public static readonly ImgFordPanel: string = require("assets/DesignBrowser/FordPanel.png"); - public static readonly SolutionBigFrame: string = require("assets/frame_big.png"); - public static readonly ImgFreezeOver: string = require("assets/NOVA/Freeze/freeze_active.png"); - public static readonly ImgFreeze: string = require("assets/NOVA/Freeze/freeze_normal.png"); - public static readonly ImgFreezeSelected: string = require("assets/NOVA/Freeze/freeze_selected.png"); - public static readonly NovaGMissionReq: string = require("assets/NOVA/Mission/g-box.png"); - public static readonly NovaGReq: string = require("assets/NOVA/Constraints/g-requirement-box.png"); - public static readonly NovaGRowMissionReq: string = require("assets/NOVA/Mission/g-row-box.png"); - public static readonly NovaGRowReq: string = require("assets/NOVA/Constraints/g-row-req-box.png"); - public static readonly NovaGCReq: string = require("assets/NOVA/Constraints/gc-requirement-carrier.png"); - public static readonly NovaGCMissionReq: string = require("assets/NOVA/Mission/gc-requirement.png"); - public static readonly GoDownImg: string = require("assets/TangoIcons/go-down.png"); - public static readonly GoUpImg: string = require("assets/TangoIcons/go-up.png"); - public static readonly BaseWMidPattern: string = require("assets/RNABase/gray_mid.png"); - public static readonly GreatImg: string = require("assets/Stamps/great.png"); - public static readonly NovaGreenCheck: string = require("assets/NOVA/Constraints/green-check.png"); - public static readonly NovaPassOutline: string = require("assets/NOVA/Constraints/green-outline.png"); - public static readonly BaseCMid: string = require("assets/RNABase/green_mid.png"); - public static readonly BaseCMidLock: string = require("assets/RNABase/green_mid_lock.png"); - public static readonly BaseCPattern: string = require("assets/RNABase/green_pattern.png"); - public static readonly BaseCMin: string = require("assets/RNABase/green_small.png"); - public static readonly ImgHintOver: string = require("assets/NOVA/Hint/hint_active.png"); - public static readonly ImgHintHit: string = require("assets/NOVA/Hint/hint_hit.png"); - public static readonly ImgHint: string = require("assets/NOVA/Hint/hint_normal.png"); - public static readonly ImgKnob: string = require("assets/NOVA/Knob/knob_bg.png"); - public static readonly ImgNotch: string = require("assets/NOVA/Knob/knob_notch.png"); - public static readonly ImgBadge2: string = require("assets/Achievements/Lab-access.png"); - public static readonly ImgLabReq: string = require("assets/lab1.png"); - public static readonly LBaseAf: string = require("assets/RNABase/LBaseAf.png"); - public static readonly LBaseCf: string = require("assets/RNABase/LBaseCf.png"); - public static readonly LBaseGf: string = require("assets/RNABase/LBaseGf.png"); - public static readonly LBaseUf: string = require("assets/RNABase/LBaseUf.png"); - public static readonly BaseALock: string = require("assets/RNABase/lock_a.png"); - public static readonly ImgLockOver: string = require("assets/NOVA/Lock/lock_active.png"); - public static readonly BaseCLock: string = require("assets/RNABase/lock_c.png"); - public static readonly BaseULock: string = require("assets/RNABase/lock_g.png"); - public static readonly ImgLock: string = require("assets/NOVA/Lock/lock_normal.png"); - public static readonly ImgLockSelect: string = require("assets/NOVA/Lock/lock_selected.png"); - public static readonly ImgEteRNALogo: string = require("assets/logo.png"); - public static readonly ImgMaximize: string = require("assets/MaximizeButton.png"); - public static readonly ImgMenuBorder: string = require("assets/menu-border.png"); - public static readonly NovaMenu: string = require("assets/NOVA/menu_button.png"); - public static readonly ImgMenuDot: string = require("assets/menudot.png"); - public static readonly BaseWMidOutline: string = require("assets/RNABase/mid_outline.png"); - public static readonly ImgZoomOutHit: string = require("assets/NOVA/Zoom/minus-hit.png"); - public static readonly ImgZoomOutDisable: string = require("assets/NOVA/Zoom/minus-inactive.png"); - public static readonly ImgZoomOutOver: string = require("assets/NOVA/Zoom/minus-over.png"); - public static readonly ImgZoomOut: string = require("assets/NOVA/Zoom/minus.png"); - public static readonly MinusImg: string = require("assets/Generic/minus.png"); - public static readonly ShiftLockMinus: string = require("assets/RNABase/minus_blue.png"); - public static readonly MissionBackgroundImage: string = require("assets/NOVA/Mission/mission-background-image.png"); - public static readonly ImgMoleculeOver: string = require("assets/NOVA/Molecule/molecule_active.png"); - public static readonly ImgMoleculeInner: string = require("assets/Aptamer/molecule_inner.png"); - public static readonly ImgMolecule: string = require("assets/NOVA/Molecule/molecule_normal.png"); - public static readonly ImgMoleculeOuter: string = require("assets/Aptamer/molecule_outer.png"); - public static readonly ImgMoleculeSelect: string = require("assets/NOVA/Molecule/molecule_selected.png"); - public static readonly AudioNormal: string = require("assets/mute-icon1.png"); - public static readonly AudioMute: string = require("assets/mute-icon2.png"); - public static readonly ImgNativeOver: string = require("assets/NOVA/Target/nature-over.png"); - public static readonly ImgNativeSelected: string = require("assets/NOVA/Target/nature-selected.png"); - public static readonly ImgNative: string = require("assets/NOVA/Target/nature.png"); - public static readonly LBaseU: string = require("assets/RNABase/new_big_blue.png"); - public static readonly BaseWPattern: string = require("assets/RNABase/new_big_gray.png"); - public static readonly LBaseC: string = require("assets/RNABase/new_big_green.png"); - public static readonly BaseWOutline: string = require("assets/RNABase/new_big_outline.png"); - public static readonly LBaseG: string = require("assets/RNABase/new_big_red.png"); - public static readonly LBaseA: string = require("assets/RNABase/new_big_yellow.png"); - public static readonly BaseU: string = require("assets/RNABase/new_g.png"); - public static readonly NovaNextHit: string = require("assets/NOVA/Buttons/next-hit.png"); - public static readonly NovaNextOver: string = require("assets/NOVA/Buttons/next-over.png"); - public static readonly NovaNext: string = require("assets/NOVA/Buttons/next.png"); - public static readonly ImgNextInside: string = require("assets/next_inside.png"); - public static readonly NovaNoGCReq: string = require("assets/NOVA/Constraints/nogc-requirement-box.png"); - public static readonly NovaNoGCMissionReq: string = require("assets/NOVA/Mission/nogc-requirement.png"); - public static readonly NovaNoGUReq: string = require("assets/NOVA/Constraints/noug-requirement-box.png"); - public static readonly NovaNoGUMissionReq: string = require("assets/NOVA/Mission/noug-requirement.png"); - public static readonly NovaBoundOligoMissionReq: string = require("assets/NOVA/Mission/oligo-bound-req-mission.png"); - public static readonly NovaBoundOligoReq: string = require("assets/NOVA/Constraints/oligo-bound-requirement-carrier.png"); - public static readonly NovaUnboundOligoMissionReq: string = require("assets/NOVA/Mission/oligo-unbound-req-mission.png"); - public static readonly NovaUnboundOligoReq: string = require("assets/NOVA/Constraints/oligo-unbound-requirement-carrier.png"); - public static readonly ImgSelectPair: string = require("assets/NOVA/Palette/pair-selected.png"); - public static readonly NovaPairsReq: string = require("assets/NOVA/Constraints/pairs-requirement-carrier.png"); - public static readonly NovaPairsMissionReq: string = require("assets/NOVA/Mission/pairs-requirement.png"); - public static readonly ImgPaletteNoBondsPairs: string = require("assets/NOVA/Palette/palette-nobonds.png"); - public static readonly ImgPaletteNoPairs: string = require("assets/NOVA/Palette/palette-nopairs.png"); - public static readonly ImgPalette: string = require("assets/NOVA/Palette/palette.png"); - public static readonly ImgColoringOver: string = require("assets/NOVA/Coloring/palette_active.png"); - public static readonly ImgColoring: string = require("assets/NOVA/Coloring/palette_normal.png"); - public static readonly ImgColoringSelected: string = require("assets/NOVA/Coloring/palette_selected.png"); - public static readonly MingPanel: string = require("assets/MingUI/panel.png"); - public static readonly ImgPasteOver: string = require("assets/NOVA/Copy/paste_active.png"); - public static readonly ImgPasteHit: string = require("assets/NOVA/Copy/paste_hit.png"); - public static readonly ImgPaste: string = require("assets/NOVA/Copy/paste_normal.png"); - public static readonly BonusSymbol: string = require("assets/penalty1.png"); - public static readonly ImgPipOver: string = require("assets/NOVA/Tile/pip_active.png"); - public static readonly ImgPipHit: string = require("assets/NOVA/Tile/pip_hit.png"); - public static readonly ImgPip: string = require("assets/NOVA/Tile/pip_normal.png"); - public static readonly PlayImageHit: string = require("assets/NOVA/Mission/play-button-hit.png"); - public static readonly PlayImageOver: string = require("assets/NOVA/Mission/play-button-over.png"); - public static readonly PlayImage: string = require("assets/NOVA/Mission/play-button.png"); - public static readonly ImgZoomInHit: string = require("assets/NOVA/Zoom/plus-hit.png"); - public static readonly ImgZoomInDisable: string = require("assets/NOVA/Zoom/plus-inactive.png"); - public static readonly ImgZoomInOver: string = require("assets/NOVA/Zoom/plus-over.png"); - public static readonly ImgZoomIn: string = require("assets/NOVA/Zoom/plus.png"); - public static readonly PlusImg: string = require("assets/Generic/plus.png"); - public static readonly ShiftLockPlus: string = require("assets/RNABase/plus_blue.png"); - public static readonly ShiftLock: string = require("assets/RNABase/plusminus.png"); - public static readonly NovaPrevHit: string = require("assets/NOVA/Buttons/prev-hit.png"); - public static readonly NovaPrevOver: string = require("assets/NOVA/Buttons/prev-over.png"); - public static readonly NovaPrev: string = require("assets/NOVA/Buttons/prev.png"); - public static readonly ImgSubmitOver: string = require("assets/NOVA/Publish/publish_active.png"); - public static readonly ImgSubmitHit: string = require("assets/NOVA/Publish/publish_hit.png"); - public static readonly ImgSubmit: string = require("assets/NOVA/Publish/publish_normal.png"); - public static readonly MissionPuzzleIdImage: string = require("assets/NOVA/Mission/puzzle-id-carrier.png"); - public static readonly MissionPuzzleThumbnailImage: string = require("assets/NOVA/Mission/puzzle-thumbnail-background.png"); - public static readonly PuzzleImg: string = require("assets/puzzle.png"); - public static readonly NovaPuzzleImg: string = require("assets/puzzle_icon.png"); - public static readonly NovaFailOutline: string = require("assets/NOVA/Constraints/red-outline.png"); - public static readonly BaseGLock: string = require("assets/RNABase/red_lock.png"); - public static readonly BaseGMid: string = require("assets/RNABase/red_mid.png"); - public static readonly BaseGMidLock: string = require("assets/RNABase/red_mid_lock.png"); - public static readonly BaseGPattern: string = require("assets/RNABase/red_pattern.png"); - public static readonly BaseGMin: string = require("assets/RNABase/red_small.png"); - public static readonly ImgRedoHit: string = require("assets/NOVA/Redo/redo-hit.png"); - public static readonly ImgRedoOver: string = require("assets/NOVA/Redo/redo-over.png"); - public static readonly ImgRedo: string = require("assets/NOVA/Redo/redo.png"); - public static readonly ImgResetHit: string = require("assets/NOVA/Reset/reset-hit.png"); - public static readonly ImgResetOver: string = require("assets/NOVA/Reset/reset-over.png"); - public static readonly ImgReset: string = require("assets/NOVA/Reset/reset.png"); - public static readonly RetryImg: string = require("assets/retry.png"); - public static readonly ImgReturnOver: string = require("assets/NOVA/Return/return_active.png"); - public static readonly ImgReturnHit: string = require("assets/NOVA/Return/return_hit.png"); - public static readonly ImgReturn: string = require("assets/NOVA/Return/return_normal.png"); - public static readonly ScoreCircle: string = require("assets/scorecircle small.png"); - public static readonly ImgScreenshotHit: string = require("assets/NOVA/Camera/screenshot-hit.png"); - public static readonly ImgScreenshotOver: string = require("assets/NOVA/Camera/screenshot-over.png"); - public static readonly ImgScreenshot: string = require("assets/NOVA/Camera/screenshot.png"); - public static readonly ImgSettingsHit: string = require("assets/NOVA/Options/settings-over-hit.png"); - public static readonly ImgSettingsOver: string = require("assets/NOVA/Options/settings-over.png"); - public static readonly ImgSettings: string = require("assets/NOVA/Options/settings.png"); - public static readonly ShapeImg: string = require("assets/shape.png"); - public static readonly BaseAShiftNoLock: string = require("assets/RNABase/shift_no_lock_a.png"); - public static readonly BackboneMid: string = require("assets/RNABase/small_backbone.png"); - public static readonly BaseWMin: string = require("assets/RNABase/small_gray.png"); - public static readonly ViewSolutionsImg: string = require("assets/small_jee_view_solutions.png"); - public static readonly RestoreImg: string = require("assets/small_restore.png"); - public static readonly SolutionSmallFrame: string = require("assets/sol_frame.png"); - public static readonly NovaSolver: string = require("assets/NOVA/solver_normal.png"); - public static readonly ImgEditSortOptionsOver: string = require("assets/NOVA/Sort/sort_active.png"); - public static readonly ImgEditSortOptionsHit: string = require("assets/NOVA/Sort/sort_hit.png"); - public static readonly ImgEditSortOptions: string = require("assets/NOVA/Sort/sort_normal.png"); - public static readonly ImgSpecOver: string = require("assets/NOVA/View/spec_active.png"); - public static readonly ImgSpecHit: string = require("assets/NOVA/View/spec_hit.png"); - public static readonly ImgSpec: string = require("assets/NOVA/View/spec_normal.png"); - public static readonly ImgSwapOver: string = require("assets/NOVA/Palette/Swap/swap-over.png"); - public static readonly ImgSwapSelect: string = require("assets/NOVA/Palette/Swap/swap-selected.png"); - public static readonly ImgSwap: string = require("assets/NOVA/Palette/Swap/swap.png"); - public static readonly ImgTargetOver: string = require("assets/NOVA/Target/target-over.png"); - public static readonly ImgTargetSelected: string = require("assets/NOVA/Target/target-selected.png"); - public static readonly ImgTarget: string = require("assets/NOVA/Target/target.png"); - public static readonly TemperatureImg: string = require("assets/temperature.png"); - public static readonly BaseC: string = require("assets/RNABase/thinner_green.png"); - public static readonly BaseCOutline: string = require("assets/RNABase/thinner_green_outline.png"); - public static readonly BaseG: string = require("assets/RNABase/thinner_red.png"); - public static readonly BaseGOutline: string = require("assets/RNABase/thinner_red_outline.png"); - public static readonly BaseA: string = require("assets/RNABase/thinner_yellow.png"); - public static readonly BaseAOutline: string = require("assets/RNABase/thinner_yellow_outline.png"); - public static readonly NovaPuzThumbLargeMet: string = require("assets/NOVA/Puzzle Thumbnail/thumbnail-large-met.png"); - public static readonly NovaPuzThumbLargeFail: string = require("assets/NOVA/Puzzle Thumbnail/thumbnail-large.png"); - public static readonly NovaPuzThumbSmallMet: string = require("assets/NOVA/Puzzle Thumbnail/thumbnail-small-met.png"); - public static readonly NovaPuzThumbSmallFail: string = require("assets/NOVA/Puzzle Thumbnail/thumbnail-small.png"); - public static readonly Satellite: string = require("assets/RNABase/triangle.png"); - public static readonly TrophyImg: string = require("assets/trophy_big.png"); - public static readonly NovaUMissionReq: string = require("assets/NOVA/Mission/u-box.png"); - public static readonly NovaUReq: string = require("assets/NOVA/Constraints/u-requirement-box.png"); - public static readonly NovaURowMissionReq: string = require("assets/NOVA/Mission/u-row-box.png"); - public static readonly NovaURowReq: string = require("assets/NOVA/Constraints/u-row-req-box.png"); - public static readonly NovaGUReq: string = require("assets/NOVA/Constraints/ug-requirement-carrier.png"); - public static readonly NovaGUMissionReq: string = require("assets/NOVA/Mission/ug-requirement.png"); - public static readonly MingFold: string = require("assets/MingModes/ui_fold.png"); - public static readonly MingFreeze: string = require("assets/MingModes/ui_freeze.png"); - public static readonly ImgUndoHit: string = require("assets/NOVA/Undo/undo-hit.png"); - public static readonly ImgUndoOver: string = require("assets/NOVA/Undo/undo-over.png"); - public static readonly ImgUndo: string = require("assets/NOVA/Undo/undo.png"); - public static readonly ImgUpArrow: string = require("assets/up_arrow.png"); - public static readonly Audio_Vol_Off: string = require("assets/volume_off.png"); - public static readonly Audio_Vol_On: string = require("assets/volume_on.png"); - public static readonly ImgVotes: string = require("assets/vote.png"); - public static readonly BaseAMidLock: string = require("assets/RNABase/yellow_mid_lock.png"); - public static readonly BaseAMid: string = require("assets/RNABase/yellow_middle.png"); - public static readonly BaseAPattern: string = require("assets/RNABase/yellow_pattern.png"); - public static readonly BaseAMin: string = require("assets/RNABase/yellow_small.png"); + public static readonly NovaAMissionReq: string = require('assets/NOVA/Mission/a-box.png'); + public static readonly NovaAReq: string = require('assets/NOVA/Constraints/a-requirement-box.png'); + public static readonly NovaARowMissionReq: string = require('assets/NOVA/Mission/a-row-box.png'); + public static readonly NovaARowReq: string = require('assets/NOVA/Constraints/a-row-req-box.png'); + public static readonly ActionbarCenterImg: string = require('assets/Actionbar/actionbar_center.png'); + public static readonly ActionbarLeftImg: string = require('assets/Actionbar/actionbar_left.png'); + public static readonly ActionbarRightImg: string = require('assets/Actionbar/actionbar_right.png'); + public static readonly ImgAddBaseOver: string = require('assets/NOVA/Edit/add_base_active.png'); + public static readonly ImgAddBase: string = require('assets/NOVA/Edit/add_base_normal.png'); + public static readonly ImgAddBaseSelect: string = require('assets/NOVA/Edit/add_base_selected.png'); + public static readonly ImgAddPairOver: string = require('assets/NOVA/Edit/add_pair_active.png'); + public static readonly ImgAddPair: string = require('assets/NOVA/Edit/add_pair_normal.png'); + public static readonly ImgAddPairSelect: string = require('assets/NOVA/Edit/add_pair_selected.png'); + public static readonly NovaAUReq: string = require('assets/NOVA/Constraints/au-requirement-carrier.png'); + public static readonly NovaAUMissionReq: string = require('assets/NOVA/Mission/au-requirement.png'); + public static readonly Backbone: string = require('assets/RNABase/backbone_new.png'); + public static readonly NovaBarcodeMissionReq: string = require('assets/NOVA/Mission/barcode-req-mission.png'); + public static readonly NovaBarcodeReq: string = require('assets/NOVA/Constraints/barcode-requirement-carrier.png'); + public static readonly ImgSelectBase: string = require('assets/NOVA/Palette/base-selected.png'); + public static readonly ImgBindingBaseGlow: string = require('assets/Aptamer/base_outer-1.png'); + public static readonly BaseAf: string = require('assets/RNABase/BaseAf.png'); + public static readonly BaseAfLock: string = require('assets/RNABase/BaseAfLock.png'); + public static readonly BaseAfMid: string = require('assets/RNABase/BaseAfMid.png'); + public static readonly BaseAfMidLock: string = require('assets/RNABase/BaseAfMidLock.png'); + public static readonly BaseCf: string = require('assets/RNABase/BaseCf.png'); + public static readonly BaseCfLock: string = require('assets/RNABase/BaseCfLock.png'); + public static readonly BaseCfMid: string = require('assets/RNABase/BaseCfMid.png'); + public static readonly BaseCfMidLock: string = require('assets/RNABase/BaseCfMidLock.png'); + public static readonly BaseGf: string = require('assets/RNABase/BaseGf.png'); + public static readonly BaseGfLock: string = require('assets/RNABase/BaseGfLock.png'); + public static readonly BaseGfMid: string = require('assets/RNABase/BaseGfMid.png'); + public static readonly BaseGfMidLock: string = require('assets/RNABase/BaseGfMidLock.png'); + public static readonly BaseUf: string = require('assets/RNABase/BaseUf.png'); + public static readonly BaseUfLock: string = require('assets/RNABase/BaseUfLock.png'); + public static readonly BaseUfMid: string = require('assets/RNABase/BaseUfMid.png'); + public static readonly BaseUfMidLock: string = require('assets/RNABase/BaseUfMidLock.png'); + public static readonly ImgMoney: string = require('assets/bet_big.png'); + public static readonly BaseUMid: string = require('assets/RNABase/blue_mid.png'); + public static readonly BaseUMidLock: string = require('assets/RNABase/blue_mid_lock.png'); + public static readonly BaseUOutline1: string = require('assets/RNABase/blue_outline_1.png'); + public static readonly BaseUOutline2: string = require('assets/RNABase/blue_outline_2_new.png'); + public static readonly BaseUPattern: string = require('assets/RNABase/blue_pattern.png'); + public static readonly BaseUMin: string = require('assets/RNABase/blue_small.png'); + public static readonly NovaBoostMissionReq: string = require('assets/NOVA/Mission/boost-req-mission.png'); + public static readonly NovaBoostReq: string = require('assets/NOVA/Constraints/boost-requirement-carrier.png'); + public static readonly NovaBoosters: string = require('assets/NOVA/booster_normal.png'); + public static readonly BubbleImg: string = require('assets/PuzzleEdit/btnDel.png'); + public static readonly Bubble00: string = require('assets/Bubble/bubble0.png'); + public static readonly Bubble10: string = require('assets/Bubble/bubble1.png'); + public static readonly Bubble03: string = require('assets/Bubble/bubble1_big_blurred.png'); + public static readonly Bubble01: string = require('assets/Bubble/bubble1_middle.png'); + public static readonly Bubble02: string = require('assets/Bubble/bubble1_small.png'); + public static readonly Bubble13: string = require('assets/Bubble/bubble2_big_blurred.png'); + public static readonly Bubble11: string = require('assets/Bubble/bubble2_middle.png'); + public static readonly Bubble12: string = require('assets/Bubble/bubble2_small.png'); + public static readonly NovaCMissionReq: string = require('assets/NOVA/Mission/c-box.png'); + public static readonly NovaCReq: string = require('assets/NOVA/Constraints/c-requirement-box.png'); + public static readonly NovaCRowMissionReq: string = require('assets/NOVA/Mission/c-row-box.png'); + public static readonly NovaCRowReq: string = require('assets/NOVA/Constraints/c-row-req-box.png'); + public static readonly ImgChatBoxArrowDown: string = require('assets/RinaChat/chatbox_arrow_down.png'); + public static readonly ImgChatBoxArrowUp: string = require('assets/RinaChat/chatbox_arrow_up.png'); + public static readonly ImgEndingMoney: string = require('assets/coin.png'); + public static readonly ImgColumnsOver: string = require('assets/NOVA/Columns/columns_active.png'); + public static readonly ImgColumnsHit: string = require('assets/NOVA/Columns/columns_hit.png'); + public static readonly ImgColumns: string = require('assets/NOVA/Columns/columns_normal.png'); + public static readonly ImgCopy: string = require('assets/NOVA/Copy/copy-1.png'); + public static readonly ImgCopyHit: string = require('assets/NOVA/Copy/copy-hit.png'); + public static readonly ImgCopyOver: string = require('assets/NOVA/Copy/copy-over.png'); + public static readonly ImgCross: string = require('assets/cross.png'); + public static readonly ActionbarDividerImg: string = require('assets/divider.png'); + public static readonly ImgDownArrow: string = require('assets/down_arrow.png'); + public static readonly CancelImg: string = require('assets/TangoIcons/emblem-unreadable.png'); + public static readonly ImgEndBoard: string = require('assets/endboard.png'); + public static readonly EnergyScoreBackground: string = require('assets/NOVA/Energy/energy-background.png'); + public static readonly EnterKeyImg: string = require('assets/enterkey.png'); + public static readonly ImgEraseOver: string = require('assets/NOVA/Edit/erase_active.png'); + public static readonly ImgErase: string = require('assets/NOVA/Edit/erase_normal.png'); + public static readonly ImgEraseSelect: string = require('assets/NOVA/Edit/erase_selected.png'); + public static readonly ImgEstimateOver: string = require('assets/NOVA/Estimate/estimate_active.png'); + public static readonly ImgEstimate: string = require('assets/NOVA/Estimate/estimate_normal.png'); + public static readonly ImgEstimateSelected: string = require('assets/NOVA/Estimate/estimate_selected.png'); + public static readonly ImgFb: string = require('assets/TangoIcons/evolver-32x32.png'); + public static readonly ImgFileOver: string = require('assets/NOVA/File/file_active.png'); + public static readonly ImgFileHit: string = require('assets/NOVA/File/file_hit.png'); + public static readonly ImgFile: string = require('assets/NOVA/File/file_normal.png'); + public static readonly NovaFingerClick: string = require('assets/NOVA/Hint/finger-click.png'); + public static readonly NovaFinger: string = require('assets/NOVA/Hint/finger.png'); + public static readonly ImgBadge1: string = require('assets/Achievements/Finished-Tutorial.png'); + public static readonly ImgFlaskOver: string = require('assets/NOVA/Flask/flask_active.png'); + public static readonly ImgFlask: string = require('assets/NOVA/Flask/flask_normal.png'); + public static readonly ImgFlaskSelected: string = require('assets/NOVA/Flask/flask_selected.png'); + public static readonly ImgFordPanel: string = require('assets/DesignBrowser/FordPanel.png'); + public static readonly SolutionBigFrame: string = require('assets/frame_big.png'); + public static readonly ImgFreezeOver: string = require('assets/NOVA/Freeze/freeze_active.png'); + public static readonly ImgFreeze: string = require('assets/NOVA/Freeze/freeze_normal.png'); + public static readonly ImgFreezeSelected: string = require('assets/NOVA/Freeze/freeze_selected.png'); + public static readonly NovaGMissionReq: string = require('assets/NOVA/Mission/g-box.png'); + public static readonly NovaGReq: string = require('assets/NOVA/Constraints/g-requirement-box.png'); + public static readonly NovaGRowMissionReq: string = require('assets/NOVA/Mission/g-row-box.png'); + public static readonly NovaGRowReq: string = require('assets/NOVA/Constraints/g-row-req-box.png'); + public static readonly NovaGCReq: string = require('assets/NOVA/Constraints/gc-requirement-carrier.png'); + public static readonly NovaGCMissionReq: string = require('assets/NOVA/Mission/gc-requirement.png'); + public static readonly GoDownImg: string = require('assets/TangoIcons/go-down.png'); + public static readonly GoUpImg: string = require('assets/TangoIcons/go-up.png'); + public static readonly BaseWMidPattern: string = require('assets/RNABase/gray_mid.png'); + public static readonly GreatImg: string = require('assets/Stamps/great.png'); + public static readonly NovaGreenCheck: string = require('assets/NOVA/Constraints/green-check.png'); + public static readonly NovaPassOutline: string = require('assets/NOVA/Constraints/green-outline.png'); + public static readonly BaseCMid: string = require('assets/RNABase/green_mid.png'); + public static readonly BaseCMidLock: string = require('assets/RNABase/green_mid_lock.png'); + public static readonly BaseCPattern: string = require('assets/RNABase/green_pattern.png'); + public static readonly BaseCMin: string = require('assets/RNABase/green_small.png'); + public static readonly ImgHintOver: string = require('assets/NOVA/Hint/hint_active.png'); + public static readonly ImgHintHit: string = require('assets/NOVA/Hint/hint_hit.png'); + public static readonly ImgHint: string = require('assets/NOVA/Hint/hint_normal.png'); + public static readonly ImgKnob: string = require('assets/NOVA/Knob/knob_bg.png'); + public static readonly ImgNotch: string = require('assets/NOVA/Knob/knob_notch.png'); + public static readonly ImgBadge2: string = require('assets/Achievements/Lab-access.png'); + public static readonly ImgLabReq: string = require('assets/lab1.png'); + public static readonly LBaseAf: string = require('assets/RNABase/LBaseAf.png'); + public static readonly LBaseCf: string = require('assets/RNABase/LBaseCf.png'); + public static readonly LBaseGf: string = require('assets/RNABase/LBaseGf.png'); + public static readonly LBaseUf: string = require('assets/RNABase/LBaseUf.png'); + public static readonly BaseALock: string = require('assets/RNABase/lock_a.png'); + public static readonly ImgLockOver: string = require('assets/NOVA/Lock/lock_active.png'); + public static readonly BaseCLock: string = require('assets/RNABase/lock_c.png'); + public static readonly BaseULock: string = require('assets/RNABase/lock_g.png'); + public static readonly ImgLock: string = require('assets/NOVA/Lock/lock_normal.png'); + public static readonly ImgLockSelect: string = require('assets/NOVA/Lock/lock_selected.png'); + public static readonly ImgEteRNALogo: string = require('assets/logo.png'); + public static readonly ImgMaximize: string = require('assets/MaximizeButton.png'); + public static readonly ImgMenuBorder: string = require('assets/menu-border.png'); + public static readonly NovaMenu: string = require('assets/NOVA/menu_button.png'); + public static readonly ImgMenuDot: string = require('assets/menudot.png'); + public static readonly BaseWMidOutline: string = require('assets/RNABase/mid_outline.png'); + public static readonly ImgZoomOutHit: string = require('assets/NOVA/Zoom/minus-hit.png'); + public static readonly ImgZoomOutDisable: string = require('assets/NOVA/Zoom/minus-inactive.png'); + public static readonly ImgZoomOutOver: string = require('assets/NOVA/Zoom/minus-over.png'); + public static readonly ImgZoomOut: string = require('assets/NOVA/Zoom/minus.png'); + public static readonly MinusImg: string = require('assets/Generic/minus.png'); + public static readonly ShiftLockMinus: string = require('assets/RNABase/minus_blue.png'); + public static readonly MissionBackgroundImage: string = require('assets/NOVA/Mission/mission-background-image.png'); + public static readonly ImgMoleculeOver: string = require('assets/NOVA/Molecule/molecule_active.png'); + public static readonly ImgMoleculeInner: string = require('assets/Aptamer/molecule_inner.png'); + public static readonly ImgMolecule: string = require('assets/NOVA/Molecule/molecule_normal.png'); + public static readonly ImgMoleculeOuter: string = require('assets/Aptamer/molecule_outer.png'); + public static readonly ImgMoleculeSelect: string = require('assets/NOVA/Molecule/molecule_selected.png'); + public static readonly AudioNormal: string = require('assets/mute-icon1.png'); + public static readonly AudioMute: string = require('assets/mute-icon2.png'); + public static readonly ImgNativeOver: string = require('assets/NOVA/Target/nature-over.png'); + public static readonly ImgNativeSelected: string = require('assets/NOVA/Target/nature-selected.png'); + public static readonly ImgNative: string = require('assets/NOVA/Target/nature.png'); + public static readonly LBaseU: string = require('assets/RNABase/new_big_blue.png'); + public static readonly BaseWPattern: string = require('assets/RNABase/new_big_gray.png'); + public static readonly LBaseC: string = require('assets/RNABase/new_big_green.png'); + public static readonly BaseWOutline: string = require('assets/RNABase/new_big_outline.png'); + public static readonly LBaseG: string = require('assets/RNABase/new_big_red.png'); + public static readonly LBaseA: string = require('assets/RNABase/new_big_yellow.png'); + public static readonly BaseU: string = require('assets/RNABase/new_g.png'); + public static readonly NovaNextHit: string = require('assets/NOVA/Buttons/next-hit.png'); + public static readonly NovaNextOver: string = require('assets/NOVA/Buttons/next-over.png'); + public static readonly NovaNext: string = require('assets/NOVA/Buttons/next.png'); + public static readonly ImgNextInside: string = require('assets/next_inside.png'); + public static readonly NovaNoGCReq: string = require('assets/NOVA/Constraints/nogc-requirement-box.png'); + public static readonly NovaNoGCMissionReq: string = require('assets/NOVA/Mission/nogc-requirement.png'); + public static readonly NovaNoGUReq: string = require('assets/NOVA/Constraints/noug-requirement-box.png'); + public static readonly NovaNoGUMissionReq: string = require('assets/NOVA/Mission/noug-requirement.png'); + public static readonly NovaBoundOligoMissionReq: string = require('assets/NOVA/Mission/oligo-bound-req-mission.png'); + public static readonly NovaBoundOligoReq: string = require('assets/NOVA/Constraints/oligo-bound-requirement-carrier.png'); + public static readonly NovaUnboundOligoMissionReq: string = require('assets/NOVA/Mission/oligo-unbound-req-mission.png'); + public static readonly NovaUnboundOligoReq: string = require('assets/NOVA/Constraints/oligo-unbound-requirement-carrier.png'); + public static readonly ImgSelectPair: string = require('assets/NOVA/Palette/pair-selected.png'); + public static readonly NovaPairsReq: string = require('assets/NOVA/Constraints/pairs-requirement-carrier.png'); + public static readonly NovaPairsMissionReq: string = require('assets/NOVA/Mission/pairs-requirement.png'); + public static readonly ImgPaletteNoBondsPairs: string = require('assets/NOVA/Palette/palette-nobonds.png'); + public static readonly ImgPaletteNoPairs: string = require('assets/NOVA/Palette/palette-nopairs.png'); + public static readonly ImgPalette: string = require('assets/NOVA/Palette/palette.png'); + public static readonly ImgColoringOver: string = require('assets/NOVA/Coloring/palette_active.png'); + public static readonly ImgColoring: string = require('assets/NOVA/Coloring/palette_normal.png'); + public static readonly ImgColoringSelected: string = require('assets/NOVA/Coloring/palette_selected.png'); + public static readonly MingPanel: string = require('assets/MingUI/panel.png'); + public static readonly ImgPasteOver: string = require('assets/NOVA/Copy/paste_active.png'); + public static readonly ImgPasteHit: string = require('assets/NOVA/Copy/paste_hit.png'); + public static readonly ImgPaste: string = require('assets/NOVA/Copy/paste_normal.png'); + public static readonly BonusSymbol: string = require('assets/penalty1.png'); + public static readonly ImgPipOver: string = require('assets/NOVA/Tile/pip_active.png'); + public static readonly ImgPipHit: string = require('assets/NOVA/Tile/pip_hit.png'); + public static readonly ImgPip: string = require('assets/NOVA/Tile/pip_normal.png'); + public static readonly PlayImageHit: string = require('assets/NOVA/Mission/play-button-hit.png'); + public static readonly PlayImageOver: string = require('assets/NOVA/Mission/play-button-over.png'); + public static readonly PlayImage: string = require('assets/NOVA/Mission/play-button.png'); + public static readonly ImgZoomInHit: string = require('assets/NOVA/Zoom/plus-hit.png'); + public static readonly ImgZoomInDisable: string = require('assets/NOVA/Zoom/plus-inactive.png'); + public static readonly ImgZoomInOver: string = require('assets/NOVA/Zoom/plus-over.png'); + public static readonly ImgZoomIn: string = require('assets/NOVA/Zoom/plus.png'); + public static readonly PlusImg: string = require('assets/Generic/plus.png'); + public static readonly ShiftLockPlus: string = require('assets/RNABase/plus_blue.png'); + public static readonly ShiftLock: string = require('assets/RNABase/plusminus.png'); + public static readonly NovaPrevHit: string = require('assets/NOVA/Buttons/prev-hit.png'); + public static readonly NovaPrevOver: string = require('assets/NOVA/Buttons/prev-over.png'); + public static readonly NovaPrev: string = require('assets/NOVA/Buttons/prev.png'); + public static readonly ImgSubmitOver: string = require('assets/NOVA/Publish/publish_active.png'); + public static readonly ImgSubmitHit: string = require('assets/NOVA/Publish/publish_hit.png'); + public static readonly ImgSubmit: string = require('assets/NOVA/Publish/publish_normal.png'); + public static readonly MissionPuzzleIdImage: string = require('assets/NOVA/Mission/puzzle-id-carrier.png'); + public static readonly MissionPuzzleThumbnailImage: string = require('assets/NOVA/Mission/puzzle-thumbnail-background.png'); + public static readonly PuzzleImg: string = require('assets/puzzle.png'); + public static readonly NovaPuzzleImg: string = require('assets/puzzle_icon.png'); + public static readonly NovaFailOutline: string = require('assets/NOVA/Constraints/red-outline.png'); + public static readonly BaseGLock: string = require('assets/RNABase/red_lock.png'); + public static readonly BaseGMid: string = require('assets/RNABase/red_mid.png'); + public static readonly BaseGMidLock: string = require('assets/RNABase/red_mid_lock.png'); + public static readonly BaseGPattern: string = require('assets/RNABase/red_pattern.png'); + public static readonly BaseGMin: string = require('assets/RNABase/red_small.png'); + public static readonly ImgRedoHit: string = require('assets/NOVA/Redo/redo-hit.png'); + public static readonly ImgRedoOver: string = require('assets/NOVA/Redo/redo-over.png'); + public static readonly ImgRedo: string = require('assets/NOVA/Redo/redo.png'); + public static readonly ImgResetHit: string = require('assets/NOVA/Reset/reset-hit.png'); + public static readonly ImgResetOver: string = require('assets/NOVA/Reset/reset-over.png'); + public static readonly ImgReset: string = require('assets/NOVA/Reset/reset.png'); + public static readonly RetryImg: string = require('assets/retry.png'); + public static readonly ImgReturnOver: string = require('assets/NOVA/Return/return_active.png'); + public static readonly ImgReturnHit: string = require('assets/NOVA/Return/return_hit.png'); + public static readonly ImgReturn: string = require('assets/NOVA/Return/return_normal.png'); + public static readonly ScoreCircle: string = require('assets/scorecircle small.png'); + public static readonly ImgScreenshotHit: string = require('assets/NOVA/Camera/screenshot-hit.png'); + public static readonly ImgScreenshotOver: string = require('assets/NOVA/Camera/screenshot-over.png'); + public static readonly ImgScreenshot: string = require('assets/NOVA/Camera/screenshot.png'); + public static readonly ImgSettingsHit: string = require('assets/NOVA/Options/settings-over-hit.png'); + public static readonly ImgSettingsOver: string = require('assets/NOVA/Options/settings-over.png'); + public static readonly ImgSettings: string = require('assets/NOVA/Options/settings.png'); + public static readonly ShapeImg: string = require('assets/shape.png'); + public static readonly BaseAShiftNoLock: string = require('assets/RNABase/shift_no_lock_a.png'); + public static readonly BackboneMid: string = require('assets/RNABase/small_backbone.png'); + public static readonly BaseWMin: string = require('assets/RNABase/small_gray.png'); + public static readonly ViewSolutionsImg: string = require('assets/small_jee_view_solutions.png'); + public static readonly RestoreImg: string = require('assets/small_restore.png'); + public static readonly SolutionSmallFrame: string = require('assets/sol_frame.png'); + public static readonly NovaSolver: string = require('assets/NOVA/solver_normal.png'); + public static readonly ImgEditSortOptionsOver: string = require('assets/NOVA/Sort/sort_active.png'); + public static readonly ImgEditSortOptionsHit: string = require('assets/NOVA/Sort/sort_hit.png'); + public static readonly ImgEditSortOptions: string = require('assets/NOVA/Sort/sort_normal.png'); + public static readonly ImgSpecOver: string = require('assets/NOVA/View/spec_active.png'); + public static readonly ImgSpecHit: string = require('assets/NOVA/View/spec_hit.png'); + public static readonly ImgSpec: string = require('assets/NOVA/View/spec_normal.png'); + public static readonly ImgSwapOver: string = require('assets/NOVA/Palette/Swap/swap-over.png'); + public static readonly ImgSwapSelect: string = require('assets/NOVA/Palette/Swap/swap-selected.png'); + public static readonly ImgSwap: string = require('assets/NOVA/Palette/Swap/swap.png'); + public static readonly ImgTargetOver: string = require('assets/NOVA/Target/target-over.png'); + public static readonly ImgTargetSelected: string = require('assets/NOVA/Target/target-selected.png'); + public static readonly ImgTarget: string = require('assets/NOVA/Target/target.png'); + public static readonly TemperatureImg: string = require('assets/temperature.png'); + public static readonly BaseC: string = require('assets/RNABase/thinner_green.png'); + public static readonly BaseCOutline: string = require('assets/RNABase/thinner_green_outline.png'); + public static readonly BaseG: string = require('assets/RNABase/thinner_red.png'); + public static readonly BaseGOutline: string = require('assets/RNABase/thinner_red_outline.png'); + public static readonly BaseA: string = require('assets/RNABase/thinner_yellow.png'); + public static readonly BaseAOutline: string = require('assets/RNABase/thinner_yellow_outline.png'); + public static readonly NovaPuzThumbLargeMet: string = require('assets/NOVA/Puzzle Thumbnail/thumbnail-large-met.png'); + public static readonly NovaPuzThumbLargeFail: string = require('assets/NOVA/Puzzle Thumbnail/thumbnail-large.png'); + public static readonly NovaPuzThumbSmallMet: string = require('assets/NOVA/Puzzle Thumbnail/thumbnail-small-met.png'); + public static readonly NovaPuzThumbSmallFail: string = require('assets/NOVA/Puzzle Thumbnail/thumbnail-small.png'); + public static readonly Satellite: string = require('assets/RNABase/triangle.png'); + public static readonly TrophyImg: string = require('assets/trophy_big.png'); + public static readonly NovaUMissionReq: string = require('assets/NOVA/Mission/u-box.png'); + public static readonly NovaUReq: string = require('assets/NOVA/Constraints/u-requirement-box.png'); + public static readonly NovaURowMissionReq: string = require('assets/NOVA/Mission/u-row-box.png'); + public static readonly NovaURowReq: string = require('assets/NOVA/Constraints/u-row-req-box.png'); + public static readonly NovaGUReq: string = require('assets/NOVA/Constraints/ug-requirement-carrier.png'); + public static readonly NovaGUMissionReq: string = require('assets/NOVA/Mission/ug-requirement.png'); + public static readonly MingFold: string = require('assets/MingModes/ui_fold.png'); + public static readonly MingFreeze: string = require('assets/MingModes/ui_freeze.png'); + public static readonly ImgUndoHit: string = require('assets/NOVA/Undo/undo-hit.png'); + public static readonly ImgUndoOver: string = require('assets/NOVA/Undo/undo-over.png'); + public static readonly ImgUndo: string = require('assets/NOVA/Undo/undo.png'); + public static readonly ImgUpArrow: string = require('assets/up_arrow.png'); + public static readonly Audio_Vol_Off: string = require('assets/volume_off.png'); + public static readonly Audio_Vol_On: string = require('assets/volume_on.png'); + public static readonly ImgVotes: string = require('assets/vote.png'); + public static readonly BaseAMidLock: string = require('assets/RNABase/yellow_mid_lock.png'); + public static readonly BaseAMid: string = require('assets/RNABase/yellow_middle.png'); + public static readonly BaseAPattern: string = require('assets/RNABase/yellow_pattern.png'); + public static readonly BaseAMin: string = require('assets/RNABase/yellow_small.png'); public static get all(): string[] { if (Bitmaps.ALL_URLS == null) { Bitmaps.ALL_URLS = []; for (let value of Object.values(Bitmaps)) { - if (typeof (value) === "string") { + if (typeof (value) === 'string') { Bitmaps.ALL_URLS.push(value); } } diff --git a/src/eterna/resources/PlaySoundTask.ts b/src/eterna/resources/PlaySoundTask.ts index af8455aa6..673a874f2 100644 --- a/src/eterna/resources/PlaySoundTask.ts +++ b/src/eterna/resources/PlaySoundTask.ts @@ -1,8 +1,8 @@ -import {ObjectTask} from "flashbang/core"; -import Eterna from "eterna/Eterna"; +import {ObjectTask} from 'flashbang/core'; +import Eterna from 'eterna/Eterna'; export default class PlaySoundTask extends ObjectTask { - public constructor(name: string) { + constructor(name: string) { super(); this._soundName = name; } diff --git a/src/eterna/resources/SoundManager.ts b/src/eterna/resources/SoundManager.ts index b3822e81e..4337c61b5 100644 --- a/src/eterna/resources/SoundManager.ts +++ b/src/eterna/resources/SoundManager.ts @@ -1,11 +1,11 @@ -import * as log from "loglevel"; -import "pixi-sound"; -import {RegistrationGroup} from "signals"; -import Eterna from "eterna/Eterna"; -import {EternaSettings} from "eterna/settings"; +import * as log from 'loglevel'; +import 'pixi-sound'; +import {RegistrationGroup} from 'signals'; +import Eterna from 'eterna/Eterna'; +import {EternaSettings} from 'eterna/settings'; export default class SoundManager { - public constructor(settings: EternaSettings) { + constructor(settings: EternaSettings) { this._settings = settings; this._regs.add(settings.soundMute.connectNotify((mute) => { @@ -50,7 +50,7 @@ export default class SoundManager { * when it has completed loading. */ class EternaSound { - public constructor(url: string) { + constructor(url: string) { this._sound = PIXI.sound.Sound.from({url, preload: true, loaded: () => this.onLoaded()}); } diff --git a/src/eterna/resources/Sounds.ts b/src/eterna/resources/Sounds.ts index 7dd5aa9d0..a83b36862 100644 --- a/src/eterna/resources/Sounds.ts +++ b/src/eterna/resources/Sounds.ts @@ -1,27 +1,27 @@ /* eslint-disable max-len, global-require */ export default class Sounds { - public static readonly SoundSwitch: string = require("assets/Sounds/1-TextBubble-Click-A.mp3"); - public static readonly SoundButtonClick: string = require("assets/Sounds/1-TextBubble-Click-C.mp3"); - public static readonly SoundAllConditions: string = require("assets/Sounds/11-Flag.mp3"); - public static readonly SoundPaint: string = require("assets/Sounds/2-BubblePop-06.mp3"); - public static readonly SoundPuzzleClear: string = require("assets/Sounds/3-PuzzleClear-A.mp3"); - public static readonly SoundSmashStamp: string = require("assets/Sounds/5-SmashStamp.mp3"); - public static readonly SoundB: string = require("assets/Sounds/7-B.mp3"); - public static readonly SoundGExtra: string = require("assets/Sounds/7-G(Extra).mp3"); - public static readonly SoundG: string = require("assets/Sounds/7-G.mp3"); - public static readonly SoundGB: string = require("assets/Sounds/7-GB.mp3"); - public static readonly SoundRExtra: string = require("assets/Sounds/7-R(Extra).mp3"); - public static readonly SoundR: string = require("assets/Sounds/7-R.mp3"); - public static readonly SoundRB: string = require("assets/Sounds/7-RB.mp3"); - public static readonly SoundRG: string = require("assets/Sounds/7-RG.mp3"); - public static readonly SoundRY: string = require("assets/Sounds/7-RY.mp3"); - public static readonly SoundYExtra: string = require("assets/Sounds/7-Y(Extra).mp3"); - public static readonly SoundY: string = require("assets/Sounds/7-Y.mp3"); - public static readonly SoundYB: string = require("assets/Sounds/7-YB.mp3"); - public static readonly SoundCondition: string = require("assets/Sounds/8-Condition.mp3"); - public static readonly SoundDecondition: string = require("assets/Sounds/8-DeCondition.mp3"); - public static readonly SoundScriptFail: string = require("assets/Sounds/8-DeReward.mp3"); - public static readonly SoundScriptExec: string = require("assets/Sounds/8-RewardSound-B.mp3"); - public static readonly SoundScriptDone: string = require("assets/Sounds/8-RewardSound.mp3"); + public static readonly SoundSwitch: string = require('assets/Sounds/1-TextBubble-Click-A.mp3'); + public static readonly SoundButtonClick: string = require('assets/Sounds/1-TextBubble-Click-C.mp3'); + public static readonly SoundAllConditions: string = require('assets/Sounds/11-Flag.mp3'); + public static readonly SoundPaint: string = require('assets/Sounds/2-BubblePop-06.mp3'); + public static readonly SoundPuzzleClear: string = require('assets/Sounds/3-PuzzleClear-A.mp3'); + public static readonly SoundSmashStamp: string = require('assets/Sounds/5-SmashStamp.mp3'); + public static readonly SoundB: string = require('assets/Sounds/7-B.mp3'); + public static readonly SoundGExtra: string = require('assets/Sounds/7-G(Extra).mp3'); + public static readonly SoundG: string = require('assets/Sounds/7-G.mp3'); + public static readonly SoundGB: string = require('assets/Sounds/7-GB.mp3'); + public static readonly SoundRExtra: string = require('assets/Sounds/7-R(Extra).mp3'); + public static readonly SoundR: string = require('assets/Sounds/7-R.mp3'); + public static readonly SoundRB: string = require('assets/Sounds/7-RB.mp3'); + public static readonly SoundRG: string = require('assets/Sounds/7-RG.mp3'); + public static readonly SoundRY: string = require('assets/Sounds/7-RY.mp3'); + public static readonly SoundYExtra: string = require('assets/Sounds/7-Y(Extra).mp3'); + public static readonly SoundY: string = require('assets/Sounds/7-Y.mp3'); + public static readonly SoundYB: string = require('assets/Sounds/7-YB.mp3'); + public static readonly SoundCondition: string = require('assets/Sounds/8-Condition.mp3'); + public static readonly SoundDecondition: string = require('assets/Sounds/8-DeCondition.mp3'); + public static readonly SoundScriptFail: string = require('assets/Sounds/8-DeReward.mp3'); + public static readonly SoundScriptExec: string = require('assets/Sounds/8-RewardSound-B.mp3'); + public static readonly SoundScriptDone: string = require('assets/Sounds/8-RewardSound.mp3'); } diff --git a/src/eterna/resources/index.ts b/src/eterna/resources/index.ts index 6080dfb2a..70f0fab1e 100644 --- a/src/eterna/resources/index.ts +++ b/src/eterna/resources/index.ts @@ -1,5 +1,5 @@ -export {default as BitmapManager} from "./BitmapManager"; -export {default as Bitmaps} from "./Bitmaps"; -export {default as PlaySoundTask} from "./PlaySoundTask"; -export {default as SoundManager} from "./SoundManager"; -export {default as Sounds} from "./Sounds"; +export {default as BitmapManager} from './BitmapManager'; +export {default as Bitmaps} from './Bitmaps'; +export {default as PlaySoundTask} from './PlaySoundTask'; +export {default as SoundManager} from './SoundManager'; +export {default as Sounds} from './Sounds'; diff --git a/src/eterna/rscript/NovaPaintHint.ts b/src/eterna/rscript/NovaPaintHint.ts index 61a4d0dd2..793c9e52b 100644 --- a/src/eterna/rscript/NovaPaintHint.ts +++ b/src/eterna/rscript/NovaPaintHint.ts @@ -1,9 +1,9 @@ -import {Point, Sprite, Texture} from "pixi.js"; -import {Updatable} from "flashbang/core"; -import {Vector2} from "flashbang/geom"; -import {ContainerObject} from "flashbang/objects"; -import {Pose2D} from "eterna/pose2D"; -import {BitmapManager, Bitmaps} from "eterna/resources"; +import {Point, Sprite, Texture} from 'pixi.js'; +import {Updatable} from 'flashbang/core'; +import {Vector2} from 'flashbang/geom'; +import {ContainerObject} from 'flashbang/objects'; +import {Pose2D} from 'eterna/pose2D'; +import {BitmapManager, Bitmaps} from 'eterna/resources'; export default class NovaPaintHint extends ContainerObject implements Updatable { @@ -38,23 +38,23 @@ export default class NovaPaintHint extends ContainerObject implements Updatable return; } - let current_time = this.mode.time; + let currentTime = this.mode.time; let startPos: Point = this._startPoint; if (this._anchorSet) { - startPos = this._rna.getBaseXY(this._base); + startPos = this._rna.getBaseLoc(this._base); } if (this._lastTimeTick === 0) { - this._lastTimeTick = current_time; + this._lastTimeTick = currentTime; return; } if (this._startAnimTime === -1) { - this._startAnimTime = current_time; + this._startAnimTime = currentTime; } - let stageTime: number = (current_time - this._startAnimTime); + let stageTime: number = (currentTime - this._startAnimTime); let dir: Vector2 = new Vector2(this._endPoint.x - this._startPoint.x, this._endPoint.y - this._startPoint.y); if (stageTime < 1.5 && this._curStage === 0) { if (stageTime >= 1.4) { @@ -63,12 +63,15 @@ export default class NovaPaintHint extends ContainerObject implements Updatable this._img.texture = this._clickImg; } } else if (this._curStage === 1) { - let deltaTime: number = current_time - this._lastTimeTick; + let deltaTime: number = currentTime - this._lastTimeTick; // Move from our current position to the end let stepDistance = deltaTime * NovaPaintHint.PAINT_HINT_SPEED; this._totalDistance += stepDistance; - if (this._totalDistance >= Vector2.distance(this._startPoint.x, this._startPoint.y, this._endPoint.x, this._endPoint.y) - 1.5) { - this._endAnimTime = current_time; + if ( + this._totalDistance + >= Vector2.distance(this._startPoint.x, this._startPoint.y, this._endPoint.x, this._endPoint.y) - 1.5 + ) { + this._endAnimTime = currentTime; ++this._curStage; } } else if (this._curStage === 2) { @@ -77,7 +80,7 @@ export default class NovaPaintHint extends ContainerObject implements Updatable return; } - let endTime: number = (current_time - this._endAnimTime) / 1000.0; + let endTime: number = (currentTime - this._endAnimTime) / 1000.0; if (endTime > 1.0) { this._startAnimTime = -1; this._curStage = 0; @@ -86,7 +89,7 @@ export default class NovaPaintHint extends ContainerObject implements Updatable this._img.texture = this._noClick; } } - this._lastTimeTick = current_time; + this._lastTimeTick = currentTime; dir.length = this._totalDistance; this.display.position = new Point(startPos.x + dir.x, startPos.y + dir.y); diff --git a/src/eterna/rscript/RNAScript.ts b/src/eterna/rscript/RNAScript.ts index ce2a3a1d8..b15726676 100644 --- a/src/eterna/rscript/RNAScript.ts +++ b/src/eterna/rscript/RNAScript.ts @@ -1,18 +1,18 @@ -import {PoseEditMode} from "eterna/mode"; -import {Puzzle} from "eterna/puzzle"; -import ROPHighlight, {ROPHighlightMode} from "./ROPHighlight"; -import ROPHint from "./ROPHint"; -import ROPPre from "./ROPPre"; -import ROPRNA, {ROPRNAType} from "./ROPRNA"; -import ROPTextbox, {ROPTextboxMode} from "./ROPTextbox"; -import ROPUI from "./ROPUI"; -import ROPWait, {ROPWaitType} from "./ROPWait"; -import RScriptEnv from "./RScriptEnv"; -import RScriptOp from "./RScriptOp"; -import RScriptOpTree from "./RScriptOpTree"; +import {PoseEditMode} from 'eterna/mode'; +import {Puzzle} from 'eterna/puzzle'; +import ROPHighlight, {ROPHighlightMode} from './ROPHighlight'; +import ROPHint from './ROPHint'; +import ROPPre from './ROPPre'; +import ROPRNA, {ROPRNAType} from './ROPRNA'; +import ROPTextbox, {ROPTextboxMode} from './ROPTextbox'; +import ROPUI from './ROPUI'; +import ROPWait, {ROPWaitType} from './ROPWait'; +import RScriptEnv from './RScriptEnv'; +import RScriptOp from './RScriptOp'; +import RScriptOpTree from './RScriptOpTree'; export default class RNAScript { - public constructor(puz: Puzzle, ui: PoseEditMode) { + constructor(puz: Puzzle, ui: PoseEditMode) { let strData: string = puz.rscript; this._env = new RScriptEnv(ui, puz); @@ -24,7 +24,7 @@ export default class RNAScript { // Convert string into instructions by splitting at semicolons. // If we ever make "Blocks" (i.e for IF conditionals), we'll need to make this a little // more complex - let instructions: string[] = strData.split(";"); + let instructions: string[] = strData.split(';'); // For each instruction, make it into an RScriptOp (OP). // Give it to the OpTree to handle placing it where it should go. @@ -64,16 +64,16 @@ export default class RNAScript { } private createOpFromInstruction(instruction: string): RScriptOp { - instruction = instruction.replace(/^\s*/, ""); - instruction = instruction.replace(/\s*$/, ""); - if (instruction === "") { + instruction = instruction.replace(/^\s*/, ''); + instruction = instruction.replace(/\s*$/, ''); + if (instruction === '') { return null; } - const instRegex = /(\#PRE\-)?(\w+)\s*(.*)/ig; + const instRegex = /(#PRE-)?(\w+)\s*(.*)/ig; let regResult: RegExpExecArray; if ((regResult = instRegex.exec(instruction)) != null) { - let op: string = (regResult[1] ? regResult[1] : "") + regResult[2]; + let op: string = (regResult[1] ? regResult[1] : '') + regResult[2]; let args: string = regResult[3]; // Based on the OP, create the proper RScriptOp. let ret: RScriptOp = this.opToRScriptOp(op, args); @@ -88,8 +88,8 @@ export default class RNAScript { private opToRScriptOp(op: string, args: string): RScriptOp { // Strip op of any pre/post white space - op = op.replace(/^\s*/, ""); - op = op.replace(/\s*$/, ""); + op = op.replace(/^\s*/, ''); + op = op.replace(/\s*$/, ''); // Regex to detect the various commands let textboxRegex = /(Show|Hide)(Textbox|Arrow)(Location|Nucleotide)?/ig; @@ -109,34 +109,36 @@ export default class RNAScript { return null; } else if ((regResult = textboxRegex.exec(op))) { let textboxMode: ROPTextboxMode; - if (regResult[2].toUpperCase() === "ARROW") { + if (regResult[2].toUpperCase() === 'ARROW') { if (regResult[3]) { - textboxMode = regResult[3].toUpperCase() === "LOCATION" + textboxMode = regResult[3].toUpperCase() === 'LOCATION' ? ROPTextboxMode.ARROW_LOCATION : ROPTextboxMode.ARROW_NUCLEOTIDE; } else { textboxMode = ROPTextboxMode.ARROW_DEFAULT; } } else if (regResult[3]) { - textboxMode = regResult[3].toUpperCase() === "LOCATION" + textboxMode = regResult[3].toUpperCase() === 'LOCATION' ? ROPTextboxMode.TEXTBOX_LOCATION : ROPTextboxMode.TEXTBOX_NUCLEOTIDE; } else { textboxMode = ROPTextboxMode.TEXTBOX_DEFAULT; } - let show: boolean = regResult[1].toUpperCase() === "SHOW"; + let show: boolean = regResult[1].toUpperCase() === 'SHOW'; return new ROPTextbox(this._env, show, textboxMode); } else if ((regResult = highlightRegex.exec(op))) { return new ROPHighlight( - regResult[1].toUpperCase() === "SHOW", + regResult[1].toUpperCase() === 'SHOW', regResult[2] ? ROPHighlightMode.UI : ROPHighlightMode.RNA, this._env ); } else if ((regResult = uiRegex.exec(op))) { - return new ROPUI(this._env, regResult[1].toUpperCase() !== "HIDE", regResult[1].toUpperCase() === "DISABLE"); + return new ROPUI( + this._env, regResult[1].toUpperCase() !== 'HIDE', regResult[1].toUpperCase() === 'DISABLE' + ); } else if ((regResult = hintRegex.exec(op))) { - return new ROPHint(regResult[1].toUpperCase() === "SHOW", this._env); + return new ROPHint(regResult[1].toUpperCase() === 'SHOW', this._env); } else if ((regResult = waitRegex.exec(op))) { let waitType: ROPWaitType = regResult[1].toUpperCase(); return new ROPWait(waitType, this._env); diff --git a/src/eterna/rscript/ROPHighlight.ts b/src/eterna/rscript/ROPHighlight.ts index e834f9b9b..1798e8b27 100644 --- a/src/eterna/rscript/ROPHighlight.ts +++ b/src/eterna/rscript/ROPHighlight.ts @@ -1,24 +1,24 @@ -import * as log from "loglevel"; -import {Graphics, Point} from "pixi.js"; -import {GameObject} from "flashbang/core"; -import {SceneObject} from "flashbang/objects"; -import {AlphaTask, RepeatingTask, SerialTask} from "flashbang/tasks"; -import {ColorUtil, Easing} from "flashbang/util"; -import {RNAHighlightState} from "eterna/pose2D"; -import {ConstraintBox, EternaMenu} from "eterna/ui"; -import RScriptEnv from "./RScriptEnv"; -import RScriptOp from "./RScriptOp"; -import {RScriptUIElement, GetRScriptUIElementBounds, RScriptUIElementID} from "./RScriptUIElement"; +import * as log from 'loglevel'; +import {Graphics, Point} from 'pixi.js'; +import {GameObject} from 'flashbang/core'; +import {SceneObject} from 'flashbang/objects'; +import {AlphaTask, RepeatingTask, SerialTask} from 'flashbang/tasks'; +import {ColorUtil, Easing, Assert} from 'flashbang/util'; +import {RNAHighlightState} from 'eterna/pose2D'; +import {ConstraintBox, EternaMenu} from 'eterna/ui'; +import RScriptEnv from './RScriptEnv'; +import RScriptOp from './RScriptOp'; +import {RScriptUIElement, GetRScriptUIElementBounds, RScriptUIElementID} from './RScriptUIElement'; export enum ROPHighlightMode { - RNA = "RNA", - UI = "UI" + RNA = 'RNA', + UI = 'UI' } export default class ROPHighlight extends RScriptOp { - public static readonly ID_POSTFIX = "_highlight_"; + public static readonly ID_POSTFIX = '_highlight_'; - public constructor(isVisible: boolean, inMode: ROPHighlightMode, env: RScriptEnv) { + constructor(isVisible: boolean, inMode: ROPHighlightMode, env: RScriptEnv) { super(env); this._opVisible = isVisible; this._mode = inMode; @@ -66,14 +66,14 @@ export default class ROPHighlight extends RScriptOp { const elementSize: Point = this.getUiElementSize(uiElement, padding, elementID); const uiElementBounds = GetRScriptUIElementBounds(uiElement); - const new_x: number = (highlightParent === uiElement ? 0 : uiElementBounds.x) - padding.x + offset.x; - const new_y: number = (highlightParent === uiElement ? 0 : uiElementBounds.y) - padding.y + offset.y; + const newX: number = (highlightParent === uiElement ? 0 : uiElementBounds.x) - padding.x + offset.x; + const newY: number = (highlightParent === uiElement ? 0 : uiElementBounds.y) - padding.y + offset.y; const highlight = new Graphics(); highlight.alpha = 0; highlight.clear(); highlight.lineStyle(5, this._color, 0.7); - highlight.drawRoundedRect(new_x, new_y, elementSize.x, elementSize.y, 4); + highlight.drawRoundedRect(newX, newY, elementSize.x, elementSize.y, 4); const highlightObj = new SceneObject(highlight); highlightObj.addObject(new RepeatingTask(() => new SerialTask( @@ -89,134 +89,140 @@ export default class ROPHighlight extends RScriptOp { /* override */ protected parseArgument(arg: string, i: number): void { switch (i) { - case 0: - if (!this._opVisible) { - this._id = this._env.getStringRef(arg); - } else if (this._mode === ROPHighlightMode.RNA) { - this._startIdx = Number(arg) - 1; - } else if (this._mode === ROPHighlightMode.UI) { - this._uiElementString = (this._env.getStringRef(arg).toUpperCase() as RScriptUIElementID); - } - break; - case 1: - if (this._mode === ROPHighlightMode.RNA) { - this._endIdx = Number(arg) - 1; - } else if (this._mode === ROPHighlightMode.UI) { - this._id = this._env.getStringRef(arg); - } - break; - case 2: - if (this._mode === ROPHighlightMode.RNA) { - this._id = this._env.getStringRef(arg); - } else if (this._mode === ROPHighlightMode.UI) { + case 0: + if (!this._opVisible) { + this._id = this._env.getStringRef(arg); + } else if (this._mode === ROPHighlightMode.RNA) { + this._startIdx = Number(arg) - 1; + } else if (this._mode === ROPHighlightMode.UI) { + this._uiElementString = (this._env.getStringRef(arg).toUpperCase() as RScriptUIElementID); + } + break; + case 1: + if (this._mode === ROPHighlightMode.RNA) { + this._endIdx = Number(arg) - 1; + } else if (this._mode === ROPHighlightMode.UI) { + this._id = this._env.getStringRef(arg); + } + break; + case 2: + if (this._mode === ROPHighlightMode.RNA) { + this._id = this._env.getStringRef(arg); + } else if (this._mode === ROPHighlightMode.UI) { + this._color = ColorUtil.fromString(`#${this._env.getStringRef(arg)}`); + } + break; + case 3: this._color = ColorUtil.fromString(`#${this._env.getStringRef(arg)}`); - } - break; - case 3: - this._color = ColorUtil.fromString(`#${this._env.getStringRef(arg)}`); - break; + break; + default: + log.warn(`ROPHighlight has no argument at position ${i}`); } } private getUiElementSize(uiObj: RScriptUIElement, padding: Point, key: RScriptUIElementID): Point { const bounds = GetRScriptUIElementBounds(uiObj); - let size: Point = new Point(bounds.width + (2 * padding.x), bounds.height + (2 * padding.y)); + let size = new Point(bounds.width + (2 * padding.x), bounds.height + (2 * padding.y)); switch (key) { - case RScriptUIElementID.OBJECTIVES: - let n: number = this._env.ui.constraintCount; - let firstObj: ConstraintBox = this._env.ui.getConstraint(0); - let lastObj: ConstraintBox = this._env.ui.getConstraint(n - 1); - size.x = lastObj.display.x - firstObj.display.x + lastObj.width + 2 * padding.x; - size.y = 84; - break; - case RScriptUIElementID.SHAPEOBJECTIVE: - size.x = 84; - size.y = 84; - break; - case RScriptUIElementID.OBJECTIVE: - size.x = 10 + (uiObj as ConstraintBox).width; - size.y = 84; - break; - case RScriptUIElementID.SWAP: - size.x -= 6; - break; - case RScriptUIElementID.ACTION_MENU: - size = new Point( - (uiObj as EternaMenu).getWidth(false) + 2 * padding.x, - (uiObj as EternaMenu).height + 2 * padding.y - ); - // no break statement, intentional! - case RScriptUIElementID.ZOOMIN: - case RScriptUIElementID.ZOOMOUT: - case RScriptUIElementID.UNDO: - case RScriptUIElementID.REDO: - case RScriptUIElementID.RESET: - case RScriptUIElementID.PIP: - size.x -= 5; - break; - case RScriptUIElementID.AU: - case RScriptUIElementID.UA: - case RScriptUIElementID.GU: - case RScriptUIElementID.UG: - case RScriptUIElementID.GC: - case RScriptUIElementID.CG: - size.x = 30; - size.y = 15; - break; - case RScriptUIElementID.AUCOMPLETE: - case RScriptUIElementID.UACOMPLETE: - case RScriptUIElementID.GUCOMPLETE: - case RScriptUIElementID.UGCOMPLETE: - case RScriptUIElementID.GCCOMPLETE: - case RScriptUIElementID.CGCOMPLETE: - size.x += 24; - break; - case RScriptUIElementID.HELP: - size.x -= 6; - break; - case RScriptUIElementID.TOGGLENATURAL: - case RScriptUIElementID.TOGGLETARGET: - - break; + case RScriptUIElementID.OBJECTIVES: { + let n: number = this._env.ui.constraintCount; + let firstObj: ConstraintBox = this._env.ui.getConstraint(0); + let lastObj: ConstraintBox = this._env.ui.getConstraint(n - 1); + size.x = lastObj.display.x - firstObj.display.x + lastObj.width + 2 * padding.x; + size.y = 84; + break; + } + case RScriptUIElementID.SHAPEOBJECTIVE: + size.x = 84; + size.y = 84; + break; + case RScriptUIElementID.OBJECTIVE: + size.x = 10 + (uiObj as ConstraintBox).width; + size.y = 84; + break; + case RScriptUIElementID.SWAP: + size.x -= 6; + break; + case RScriptUIElementID.ACTION_MENU: + size = new Point( + (uiObj as EternaMenu).getWidth(false) + 2 * padding.x, + (uiObj as EternaMenu).height + 2 * padding.y + ); + // break omitted + case RScriptUIElementID.ZOOMIN: + case RScriptUIElementID.ZOOMOUT: + case RScriptUIElementID.UNDO: + case RScriptUIElementID.REDO: + case RScriptUIElementID.RESET: + case RScriptUIElementID.PIP: + size.x -= 5; + break; + case RScriptUIElementID.AU: + case RScriptUIElementID.UA: + case RScriptUIElementID.GU: + case RScriptUIElementID.UG: + case RScriptUIElementID.GC: + case RScriptUIElementID.CG: + size.x = 30; + size.y = 15; + break; + case RScriptUIElementID.AUCOMPLETE: + case RScriptUIElementID.UACOMPLETE: + case RScriptUIElementID.GUCOMPLETE: + case RScriptUIElementID.UGCOMPLETE: + case RScriptUIElementID.GCCOMPLETE: + case RScriptUIElementID.CGCOMPLETE: + size.x += 24; + break; + case RScriptUIElementID.HELP: + size.x -= 6; + break; + case RScriptUIElementID.TOGGLENATURAL: + case RScriptUIElementID.TOGGLETARGET: + break; + default: + log.warn(`UI element does not have size: ${key}`); } return size; } private getUiElementReference(key: RScriptUIElementID, altParam: number = -1): any { switch (key) { - case RScriptUIElementID.A: - case RScriptUIElementID.U: - case RScriptUIElementID.G: - case RScriptUIElementID.C: - case RScriptUIElementID.AU: - case RScriptUIElementID.UA: - case RScriptUIElementID.GU: - case RScriptUIElementID.UG: - case RScriptUIElementID.GC: - case RScriptUIElementID.CG: - case RScriptUIElementID.AUCOMPLETE: - case RScriptUIElementID.UACOMPLETE: - case RScriptUIElementID.GUCOMPLETE: - case RScriptUIElementID.UGCOMPLETE: - case RScriptUIElementID.GCCOMPLETE: - case RScriptUIElementID.CGCOMPLETE: - return this._env.getUIElement(RScriptUIElementID.PALETTE); - case RScriptUIElementID.OBJECTIVES: - return this._env.getUIElement(RScriptUIElementID.OBJECTIVE, 0); - case RScriptUIElementID.OBJECTIVE: - return this._env.getUIElement(RScriptUIElementID.OBJECTIVE, altParam); - case RScriptUIElementID.ACTION_MENU: - case RScriptUIElementID.SWAP: - case RScriptUIElementID.TOGGLENATURAL: - case RScriptUIElementID.TOGGLETARGET: - case RScriptUIElementID.ZOOMIN: - case RScriptUIElementID.ZOOMOUT: - case RScriptUIElementID.UNDO: - case RScriptUIElementID.REDO: - case RScriptUIElementID.PIP: - case RScriptUIElementID.SWITCH: - return this._env.getUIElement(key); + case RScriptUIElementID.A: + case RScriptUIElementID.U: + case RScriptUIElementID.G: + case RScriptUIElementID.C: + case RScriptUIElementID.AU: + case RScriptUIElementID.UA: + case RScriptUIElementID.GU: + case RScriptUIElementID.UG: + case RScriptUIElementID.GC: + case RScriptUIElementID.CG: + case RScriptUIElementID.AUCOMPLETE: + case RScriptUIElementID.UACOMPLETE: + case RScriptUIElementID.GUCOMPLETE: + case RScriptUIElementID.UGCOMPLETE: + case RScriptUIElementID.GCCOMPLETE: + case RScriptUIElementID.CGCOMPLETE: + return this._env.getUIElement(RScriptUIElementID.PALETTE); + case RScriptUIElementID.OBJECTIVES: + return this._env.getUIElement(RScriptUIElementID.OBJECTIVE, 0); + case RScriptUIElementID.OBJECTIVE: + return this._env.getUIElement(RScriptUIElementID.OBJECTIVE, altParam); + case RScriptUIElementID.ACTION_MENU: + case RScriptUIElementID.SWAP: + case RScriptUIElementID.TOGGLENATURAL: + case RScriptUIElementID.TOGGLETARGET: + case RScriptUIElementID.ZOOMIN: + case RScriptUIElementID.ZOOMOUT: + case RScriptUIElementID.UNDO: + case RScriptUIElementID.REDO: + case RScriptUIElementID.PIP: + case RScriptUIElementID.SWITCH: + return this._env.getUIElement(key); + default: + log.warn(`No reference exist for UI element ${key}`); } return this._env.ui; } @@ -233,42 +239,44 @@ export default class ROPHighlight extends RScriptOp { private static getUiElementOffset(id: RScriptUIElementID): Point { let offset: Point = new Point(0, 0); switch (id) { - case RScriptUIElementID.SWAP: - offset = new Point(4, 0); - break; - case RScriptUIElementID.A: - case RScriptUIElementID.U: - case RScriptUIElementID.G: - case RScriptUIElementID.C: - break; - case RScriptUIElementID.AU: - case RScriptUIElementID.UA: - case RScriptUIElementID.GU: - case RScriptUIElementID.UG: - case RScriptUIElementID.GC: - case RScriptUIElementID.CG: - offset = new Point(8, 7); - break; - case RScriptUIElementID.AUCOMPLETE: - case RScriptUIElementID.UACOMPLETE: - case RScriptUIElementID.GUCOMPLETE: - case RScriptUIElementID.UGCOMPLETE: - case RScriptUIElementID.GCCOMPLETE: - case RScriptUIElementID.CGCOMPLETE: - offset = new Point(-19, 0); - break; - case RScriptUIElementID.TOGGLENATURAL: - case RScriptUIElementID.TOGGLETARGET: - case RScriptUIElementID.RESET: - case RScriptUIElementID.ZOOMIN: - case RScriptUIElementID.ZOOMOUT: - case RScriptUIElementID.UNDO: - case RScriptUIElementID.REDO: - case RScriptUIElementID.PIP: - break; - case RScriptUIElementID.OBJECTIVES: - offset = new Point(-5, 0); - break; + case RScriptUIElementID.SWAP: + offset = new Point(4, 0); + break; + case RScriptUIElementID.A: + case RScriptUIElementID.U: + case RScriptUIElementID.G: + case RScriptUIElementID.C: + break; + case RScriptUIElementID.AU: + case RScriptUIElementID.UA: + case RScriptUIElementID.GU: + case RScriptUIElementID.UG: + case RScriptUIElementID.GC: + case RScriptUIElementID.CG: + offset = new Point(8, 7); + break; + case RScriptUIElementID.AUCOMPLETE: + case RScriptUIElementID.UACOMPLETE: + case RScriptUIElementID.GUCOMPLETE: + case RScriptUIElementID.UGCOMPLETE: + case RScriptUIElementID.GCCOMPLETE: + case RScriptUIElementID.CGCOMPLETE: + offset = new Point(-19, 0); + break; + case RScriptUIElementID.TOGGLENATURAL: + case RScriptUIElementID.TOGGLETARGET: + case RScriptUIElementID.RESET: + case RScriptUIElementID.ZOOMIN: + case RScriptUIElementID.ZOOMOUT: + case RScriptUIElementID.UNDO: + case RScriptUIElementID.REDO: + case RScriptUIElementID.PIP: + break; + case RScriptUIElementID.OBJECTIVES: + offset = new Point(-5, 0); + break; + default: + log.warn(`UIElement ${id} has no defined offset`); } return offset; } @@ -278,7 +286,7 @@ export default class ROPHighlight extends RScriptOp { private _startIdx: number = -1; private _endIdx: number = -1; - private _id: string = ""; + private _id: string = ''; private _color: number = 0xffffff; private _uiElementString: string; } diff --git a/src/eterna/rscript/ROPHint.ts b/src/eterna/rscript/ROPHint.ts index 4d92a1bca..bd6d1fcea 100644 --- a/src/eterna/rscript/ROPHint.ts +++ b/src/eterna/rscript/ROPHint.ts @@ -1,10 +1,10 @@ -import {Point} from "pixi.js"; -import NovaPaintHint from "./NovaPaintHint"; -import RScriptEnv from "./RScriptEnv"; -import RScriptOp from "./RScriptOp"; +import {Point} from 'pixi.js'; +import NovaPaintHint from './NovaPaintHint'; +import RScriptEnv from './RScriptEnv'; +import RScriptOp from './RScriptOp'; export default class ROPHint extends RScriptOp { - public constructor(isVisible: boolean, env: RScriptEnv) { + constructor(isVisible: boolean, env: RScriptEnv) { super(env); this._opVisible = isVisible; } @@ -26,8 +26,8 @@ export default class ROPHint extends RScriptOp { return; } - let startPoint: Point = this._env.pose.getBaseXY(this._startIdx); - let endPoint: Point = this._env.pose.getBaseXY(this._endIdx); + let startPoint: Point = this._env.pose.getBaseLoc(this._startIdx); + let endPoint: Point = this._env.pose.getBaseLoc(this._endIdx); let hint: NovaPaintHint = new NovaPaintHint(startPoint, endPoint, this._loop); hint.setAnchorNucleotide(this._env.pose, this._startIdx); @@ -39,24 +39,24 @@ export default class ROPHint extends RScriptOp { /* override */ protected parseArgument(arg: string, i: number): void { switch (i) { - case 0: - if (!this._opVisible) { + case 0: + if (!this._opVisible) { + this._id = this._env.getStringRef(arg); + } else { + this._startIdx = Number(arg) - 1; + } + break; + case 1: + this._endIdx = Number(arg); + break; + case 2: this._id = this._env.getStringRef(arg); - } else { - this._startIdx = Number(arg) - 1; - } - break; - case 1: - this._endIdx = Number(arg); - break; - case 2: - this._id = this._env.getStringRef(arg); - break; - case 3: - this._loop = (arg.toUpperCase() === "TRUE"); - break; - default: - throw (`Invalid argument to ROPHint: ${arg}`); + break; + case 3: + this._loop = (arg.toUpperCase() === 'TRUE'); + break; + default: + throw new Error(`Invalid argument to ROPHint: ${arg}`); } } @@ -65,10 +65,10 @@ export default class ROPHint extends RScriptOp { } private readonly _opVisible: boolean; - private _id: string = ""; + private _id: string = ''; private _startIdx: number = 0; private _endIdx: number = 0; private _loop: boolean; - private static readonly id_postfix: string = "_hint_"; + private static readonly id_postfix: string = '_hint_'; } diff --git a/src/eterna/rscript/ROPPre.ts b/src/eterna/rscript/ROPPre.ts index f76f71167..0740a0cac 100644 --- a/src/eterna/rscript/ROPPre.ts +++ b/src/eterna/rscript/ROPPre.ts @@ -1,6 +1,16 @@ -import {PoseState} from "eterna/puzzle"; -import RScriptEnv from "./RScriptEnv"; -import RScriptOp from "./RScriptOp"; +import {PoseState} from 'eterna/puzzle'; +import RScriptEnv from './RScriptEnv'; +import RScriptOp from './RScriptOp'; + +enum ROPPreType { + DISABLE_MISSION_SCREEN = 'DISABLE_MISSION_SCREEN', + USE_ALTERNATE_PALETTE = 'USE_ALTERNATE_PALETTE', + DISABLE_HINTS = 'DISABLE_HINTS', + DISABLE_OBJECTIVES = 'DISABLE_OBJECTIVES', + DISABLE_UI_ELEMENT = 'DISABLE_UI_ELEMENT', + DISABLE_RNA_CHANGE = 'DISABLE_RNA_CHANGE', + SET_DEFAULT_FOLD_MODE = 'SET_DEFAULT_FOLD_MODE', +} export default class ROPPre extends RScriptOp { constructor(command: string, env: RScriptEnv) { @@ -26,70 +36,70 @@ export default class ROPPre extends RScriptOp { this._type = ROPPreType.DISABLE_OBJECTIVES; } else if ((regResult = hideUIRegex.exec(command)) != null) { this._type = ROPPreType.DISABLE_UI_ELEMENT; - this._doVisible = (regResult[1].toUpperCase() !== "HIDE"); - this._doDisable = (regResult[1].toUpperCase() === "DISABLE"); + this._doVisible = (regResult[1].toUpperCase() !== 'HIDE'); + this._doDisable = (regResult[1].toUpperCase() === 'DISABLE'); } else if ((regResult = disableRNAMod.exec(command))) { this._type = ROPPreType.DISABLE_RNA_CHANGE; } else if ((regResult = modeRegex.exec(command)) != null) { this._type = ROPPreType.SET_DEFAULT_FOLD_MODE; - this._foldMode = (regResult[1].toUpperCase() === "NATIVE" ? PoseState.NATIVE : PoseState.TARGET); + this._foldMode = (regResult[1].toUpperCase() === 'NATIVE' ? PoseState.NATIVE : PoseState.TARGET); } } public initArgs(args: string): void { - this._allArgs = args.split(","); + this._allArgs = args.split(','); for (let i = 0; i < this._allArgs.length; ++i) { - this._allArgs[i] = this._allArgs[i].replace(/^\s*/, ""); - this._allArgs[i] = this._allArgs[i].replace(/\s*$/, ""); + this._allArgs[i] = this._allArgs[i].replace(/^\s*/, ''); + this._allArgs[i] = this._allArgs[i].replace(/\s*$/, ''); } } /* override */ public exec(): void { switch (this._type) { - case ROPPreType.DISABLE_MISSION_SCREEN: - this._env.ui.showMissionScreen(false); - break; - case ROPPreType.USE_ALTERNATE_PALETTE: - this._env.ui.toolbar.palette.setOverrideNoPair(); - this._env.ui.toolbar.palette.changeNoPairMode(); - break; - case ROPPreType.DISABLE_HINTS: - // _env.GetUI().remove_hint_system(true); - break; - case ROPPreType.DISABLE_OBJECTIVES: - this._env.ui.showConstraints(false); - break; - case ROPPreType.DISABLE_UI_ELEMENT: - for (let i = 0; i < this._allArgs.length; ++i) { - if (this._allArgs[i].toUpperCase() === "ENERGY") { - this._env.ui.ropSetDisplayScoreTexts(this._doVisible); - continue; - } - if (this._allArgs[i].toUpperCase() === "BASENUMBERING") { - this._env.ui.ropSetShowNumbering(this._doVisible); - continue; - } - if (this._allArgs[i].toUpperCase() === "TOTALENERGY") { - this._env.ui.ropSetShowTotalEnergy(this._doVisible); - continue; - } - this._env.showHideUI(this._allArgs[i], this._doVisible, this._doDisable); - if (!this._doVisible) { - if (this._allArgs[i].toUpperCase() === "OBJECTIVES") { - this._env.ui.showConstraints(false); + case ROPPreType.DISABLE_MISSION_SCREEN: + this._env.ui.showMissionScreen(false); + break; + case ROPPreType.USE_ALTERNATE_PALETTE: + this._env.ui.toolbar.palette.setOverrideNoPair(); + this._env.ui.toolbar.palette.changeNoPairMode(); + break; + case ROPPreType.DISABLE_HINTS: + // _env.GetUI().remove_hint_system(true); + break; + case ROPPreType.DISABLE_OBJECTIVES: + this._env.ui.showConstraints(false); + break; + case ROPPreType.DISABLE_UI_ELEMENT: + for (let i = 0; i < this._allArgs.length; ++i) { + if (this._allArgs[i].toUpperCase() === 'ENERGY') { + this._env.ui.ropSetDisplayScoreTexts(this._doVisible); + continue; + } + if (this._allArgs[i].toUpperCase() === 'BASENUMBERING') { + this._env.ui.ropSetShowNumbering(this._doVisible); + continue; + } + if (this._allArgs[i].toUpperCase() === 'TOTALENERGY') { + this._env.ui.ropSetShowTotalEnergy(this._doVisible); + continue; + } + this._env.showHideUI(this._allArgs[i], this._doVisible, this._doDisable); + if (!this._doVisible) { + if (this._allArgs[i].toUpperCase() === 'OBJECTIVES') { + this._env.ui.showConstraints(false); + } } } - } - break; - case ROPPreType.DISABLE_RNA_CHANGE: - // no-op. What was this for? - break; - case ROPPreType.SET_DEFAULT_FOLD_MODE: - this._env.puzzle.defaultMode = this._foldMode; - break; - default: - throw new Error(`Invalid Preprocessing Command: ${this._type}`); + break; + case ROPPreType.DISABLE_RNA_CHANGE: + // no-op. What was this for? + break; + case ROPPreType.SET_DEFAULT_FOLD_MODE: + this._env.puzzle.defaultMode = this._foldMode; + break; + default: + throw new Error(`Invalid Preprocessing Command: ${this._type}`); } } @@ -99,13 +109,3 @@ export default class ROPPre extends RScriptOp { private readonly _foldMode: PoseState; private _allArgs: string[]; } - -enum ROPPreType { - DISABLE_MISSION_SCREEN = "DISABLE_MISSION_SCREEN", - USE_ALTERNATE_PALETTE = "USE_ALTERNATE_PALETTE", - DISABLE_HINTS = "DISABLE_HINTS", - DISABLE_OBJECTIVES = "DISABLE_OBJECTIVES", - DISABLE_UI_ELEMENT = "DISABLE_UI_ELEMENT", - DISABLE_RNA_CHANGE = "DISABLE_RNA_CHANGE", - SET_DEFAULT_FOLD_MODE = "SET_DEFAULT_FOLD_MODE", -} diff --git a/src/eterna/rscript/ROPRNA.ts b/src/eterna/rscript/ROPRNA.ts index 45ca5f793..ccb446a08 100644 --- a/src/eterna/rscript/ROPRNA.ts +++ b/src/eterna/rscript/ROPRNA.ts @@ -1,16 +1,16 @@ -import {MathUtil} from "flashbang/util"; -import {StringToPaletteTargetType} from "eterna/ui"; -import RScriptEnv from "./RScriptEnv"; -import RScriptOp from "./RScriptOp"; +import {MathUtil} from 'flashbang/util'; +import {StringToPaletteTargetType} from 'eterna/ui'; +import RScriptEnv from './RScriptEnv'; +import RScriptOp from './RScriptOp'; export enum ROPRNAType { - SETBASE = "SETBASE", - CHANGEMODE = "CHANGEMODE", - ENABLEMODIFICATION = "ENABLEMODIFICATION", - SETPAINTER = "SETPAINTER", - CHANGESTATE = "CHANGESTATE", - SETZOOM = "SETZOOM", - SETPIP = "SETPIP", + SETBASE = 'SETBASE', + CHANGEMODE = 'CHANGEMODE', + ENABLEMODIFICATION = 'ENABLEMODIFICATION', + SETPAINTER = 'SETPAINTER', + CHANGESTATE = 'CHANGESTATE', + SETZOOM = 'SETZOOM', + SETPIP = 'SETPIP', } export default class ROPRNA extends RScriptOp { @@ -34,7 +34,7 @@ export default class ROPRNA extends RScriptOp { this._env.pose.forceEditable(this._enabled, this._scope); } else if (this._type === ROPRNAType.SETPAINTER) { let {ui} = this._env; - if (this._color === "SWAP") { + if (this._color === 'SWAP') { ui.toolbar.pairSwapButton.click(); } else { let paletteTargetType = StringToPaletteTargetType(this._color); @@ -54,40 +54,40 @@ export default class ROPRNA extends RScriptOp { /* override */ protected parseArgument(arg: string, i: number): void { switch (i) { - case 0: // Nucleotide index when changing nucleotide color. Fold mode in Mode 1. - if (this._type === ROPRNAType.SETBASE) { - this._nucIdx = Number(arg) - 1; - } else if (this._type === ROPRNAType.CHANGEMODE) { - this._foldMode = Number(arg); - } else if (this._type === ROPRNAType.ENABLEMODIFICATION || this._type === ROPRNAType.SETPIP) { - this._enabled = (arg.toUpperCase() === "TRUE"); - } else if (this._type === ROPRNAType.SETPAINTER) { - this._color = this._env.getStringRef(arg); - } else if (this._type === ROPRNAType.CHANGESTATE) { - this._state = Number(arg) - 1; - } else if (this._type === ROPRNAType.SETZOOM) { - this._zoomLevel = MathUtil.clamp(Number(arg), 0, 4); - } - break; - case 1: - if (this._type === ROPRNAType.SETBASE) { - this._color = this._env.getStringRef(arg); - } else if (this._type === ROPRNAType.ENABLEMODIFICATION) { - this._scope = []; - this._scope.push(Number(arg) - 1); - } else if (this._type === ROPRNAType.SETZOOM) { - this._animate = (arg.toUpperCase() === "TRUE"); - } - break; - default: - if (this._type === ROPRNAType.ENABLEMODIFICATION) { - this._scope.push(Number(arg) - 1); - } else if (this._type === ROPRNAType.SETZOOM) { - this._center = (arg.toUpperCase() === "TRUE"); - } else { - throw new Error(`Invalid argument for ROP: RNA -- ${this._env.getStringRef(arg)}`); - } - break; + case 0: // Nucleotide index when changing nucleotide color. Fold mode in Mode 1. + if (this._type === ROPRNAType.SETBASE) { + this._nucIdx = Number(arg) - 1; + } else if (this._type === ROPRNAType.CHANGEMODE) { + this._foldMode = Number(arg); + } else if (this._type === ROPRNAType.ENABLEMODIFICATION || this._type === ROPRNAType.SETPIP) { + this._enabled = (arg.toUpperCase() === 'TRUE'); + } else if (this._type === ROPRNAType.SETPAINTER) { + this._color = this._env.getStringRef(arg); + } else if (this._type === ROPRNAType.CHANGESTATE) { + this._state = Number(arg) - 1; + } else if (this._type === ROPRNAType.SETZOOM) { + this._zoomLevel = MathUtil.clamp(Number(arg), 0, 4); + } + break; + case 1: + if (this._type === ROPRNAType.SETBASE) { + this._color = this._env.getStringRef(arg); + } else if (this._type === ROPRNAType.ENABLEMODIFICATION) { + this._scope = []; + this._scope.push(Number(arg) - 1); + } else if (this._type === ROPRNAType.SETZOOM) { + this._animate = (arg.toUpperCase() === 'TRUE'); + } + break; + default: + if (this._type === ROPRNAType.ENABLEMODIFICATION) { + this._scope.push(Number(arg) - 1); + } else if (this._type === ROPRNAType.SETZOOM) { + this._center = (arg.toUpperCase() === 'TRUE'); + } else { + throw new Error(`Invalid argument for ROP: RNA -- ${this._env.getStringRef(arg)}`); + } + break; } } diff --git a/src/eterna/rscript/ROPTextbox.ts b/src/eterna/rscript/ROPTextbox.ts index 165262166..052cbeff1 100644 --- a/src/eterna/rscript/ROPTextbox.ts +++ b/src/eterna/rscript/ROPTextbox.ts @@ -1,30 +1,30 @@ -import * as log from "loglevel"; -import {ExtendedTextStyle} from "pixi-multistyle-text"; -import {Point} from "pixi.js"; -import {Flashbang, GameObject} from "flashbang/core"; -import {Vector2} from "flashbang/geom"; -import {ColorUtil, StyledTextBuilder} from "flashbang/util"; -import {RNAAnchorObject} from "eterna/pose2D"; -import {FancyTextBalloon} from "eterna/ui"; -import {Fonts} from "eterna/util"; -import ROPWait from "./ROPWait"; -import RScriptArrow from "./RScriptArrow"; -import RScriptEnv from "./RScriptEnv"; -import RScriptOp from "./RScriptOp"; +import * as log from 'loglevel'; +import {ExtendedTextStyle} from 'pixi-multistyle-text'; +import {Point} from 'pixi.js'; +import {Flashbang, GameObject} from 'flashbang/core'; +import {Vector2} from 'flashbang/geom'; +import {ColorUtil, StyledTextBuilder} from 'flashbang/util'; +import {RNAAnchorObject} from 'eterna/pose2D'; +import {FancyTextBalloon} from 'eterna/ui'; +import {Fonts} from 'eterna/util'; +import ROPWait from './ROPWait'; +import RScriptArrow from './RScriptArrow'; +import RScriptEnv from './RScriptEnv'; +import RScriptOp from './RScriptOp'; export enum ROPTextboxMode { - TEXTBOX_LOCATION = "TEXTBOX_LOCATION", - TEXTBOX_NUCLEOTIDE = "TEXTBOX_NUCLEOTIDE", - TEXTBOX_DEFAULT = "TEXTBOX_DEFAULT", - ARROW_LOCATION = "ARROW_LOCATION", - ARROW_NUCLEOTIDE = "ARROW_NUCLEOTIDE", - ARROW_DEFAULT = "ARROW_DEFAULT", + TEXTBOX_LOCATION = 'TEXTBOX_LOCATION', + TEXTBOX_NUCLEOTIDE = 'TEXTBOX_NUCLEOTIDE', + TEXTBOX_DEFAULT = 'TEXTBOX_DEFAULT', + ARROW_LOCATION = 'ARROW_LOCATION', + ARROW_NUCLEOTIDE = 'ARROW_NUCLEOTIDE', + ARROW_DEFAULT = 'ARROW_DEFAULT', } export default class ROPTextbox extends RScriptOp { - public static readonly ID_POSTFIX = "_textbox_"; + public static readonly ID_POSTFIX = '_textbox_'; - public constructor(env: RScriptEnv, show: boolean, mode: ROPTextboxMode) { + constructor(env: RScriptEnv, show: boolean, mode: ROPTextboxMode) { super(env); this._show = show; this._mode = mode; @@ -41,12 +41,12 @@ export default class ROPTextbox extends RScriptOp { private showTextbox(): void { let textBox = new FancyTextBalloon(0x122944, 1.0, true, 0xC0DCE7); if (this._initialShow) { - if (this._forceTopmost && false) { - // parent = Application.instance.get_front_object_container(); - // Application.instance.get_front_object_container().add_object(textBox); - } else { - this._env.addObject(textBox, this._env.container); - } + // if (this._forceTopmost && false) { + // parent = Application.instance.get_front_object_container(); + // Application.instance.get_front_object_container().add_object(textBox); + // } else { + this._env.addObject(textBox, this._env.container); + // } } this._env.setVar(this._id, textBox); @@ -73,7 +73,7 @@ export default class ROPTextbox extends RScriptOp { textBox.title = this._title; } - if (this._buttonText !== "") { + if (this._buttonText !== '') { textBox.showButton(true).clicked.connect(() => this.onClickEvent()); } else { textBox.showButton(false); @@ -87,7 +87,7 @@ export default class ROPTextbox extends RScriptOp { ); } else if (this._mode === ROPTextboxMode.TEXTBOX_NUCLEOTIDE) { // Get position of the textbox based on position of the nucleotide. - let p: Point = this._env.pose.getBaseXY(this._nucIdx); + let p: Point = this._env.pose.getBaseLoc(this._nucIdx); let offset = new Point(ROPTextbox.DEFAULT_X_OFFSET, -(textBox.container.height * 0.5) - 10); if (this._hasXOffset) { offset.x = this._xOffset; @@ -133,7 +133,7 @@ export default class ROPTextbox extends RScriptOp { Flashbang.stageHeight * this._yPos + this._yRel ); } else if (this._mode === ROPTextboxMode.ARROW_NUCLEOTIDE) { - newArrow.display.position = this._env.pose.getBaseXY(this._nucIdx); + newArrow.display.position = this._env.pose.getBaseLoc(this._nucIdx); } // Determine where we want to draw the tip of the arrow @@ -189,9 +189,9 @@ export default class ROPTextbox extends RScriptOp { } else { offset.length = this._xOffset; } - let p = this._env.pose.getBaseXY(this._nucIdx); + let p = this._env.pose.getBaseLoc(this._nucIdx); newArrow.display.position = new Point(p.x + offset.x, p.y + offset.y); - log.debug("TODO: set_anchor_nucleotide?"); + log.debug('TODO: set_anchor_nucleotide?'); // TSC - I'm not sure if this is ever called or what it should do // newArrow.set_anchor_nucleotide(this._env.GetRNA(), this._nuc_idx, offset.x, offset.y); } @@ -232,140 +232,146 @@ export default class ROPTextbox extends RScriptOp { let rx = /^([^+-]*)((?:\+|-).+)$/g; let regResult: RegExpExecArray = null; switch (i) { - case 0: // Always text in "Show". Is the ID in Hide and regular Show or for arrows. - if (this._show && (this._mode === ROPTextboxMode.TEXTBOX_NUCLEOTIDE || this._mode === ROPTextboxMode.TEXTBOX_LOCATION)) { - this._text = this._env.getStringRef(arg); - } else if (this._show && this._mode === ROPTextboxMode.ARROW_LOCATION) { - if ((regResult = rx.exec(arg)) != null) { - this._xPos = Number(regResult[1]); - this._xRel = Number(regResult[2]); + case 0: // Always text in "Show". Is the ID in Hide and regular Show or for arrows. + if ( + this._show + && ( + this._mode === ROPTextboxMode.TEXTBOX_NUCLEOTIDE + || this._mode === ROPTextboxMode.TEXTBOX_LOCATION + ) + ) { + this._text = this._env.getStringRef(arg); + } else if (this._show && this._mode === ROPTextboxMode.ARROW_LOCATION) { + if ((regResult = rx.exec(arg)) != null) { + this._xPos = Number(regResult[1]); + this._xRel = Number(regResult[2]); + } else { + this._xPos = Number(arg); + } + } else if (this._show && this._mode === ROPTextboxMode.ARROW_NUCLEOTIDE) { + this._nucIdx = Number(arg) - 1; } else { - this._xPos = Number(arg); + this._id = this._env.getStringRef(arg); } - } else if (this._show && this._mode === ROPTextboxMode.ARROW_NUCLEOTIDE) { - this._nucIdx = Number(arg) - 1; - } else { - this._id = this._env.getStringRef(arg); - } - break; - case 1: // X in mode 0. Nucleotide index in mode 1. - if (this._mode === ROPTextboxMode.TEXTBOX_LOCATION) { - if ((regResult = rx.exec(arg)) != null) { - this._xPos = Number(regResult[1]); - this._xRel = Number(regResult[2]); + break; + case 1: // X in mode 0. Nucleotide index in mode 1. + if (this._mode === ROPTextboxMode.TEXTBOX_LOCATION) { + if ((regResult = rx.exec(arg)) != null) { + this._xPos = Number(regResult[1]); + this._xRel = Number(regResult[2]); + } else { + this._xPos = Number(arg); + } + } else if (this._mode === ROPTextboxMode.ARROW_LOCATION) { + if ((regResult = rx.exec(arg)) != null) { + this._yPos = Number(regResult[1]); + this._yRel = Number(regResult[2]); + } else { + this._yPos = Number(arg); + } + } else if (this._mode === ROPTextboxMode.ARROW_NUCLEOTIDE) { + this._id = this._env.getStringRef(arg); } else { - this._xPos = Number(arg); + this._nucIdx = Number(arg) - 1; } - } else if (this._mode === ROPTextboxMode.ARROW_LOCATION) { - if ((regResult = rx.exec(arg)) != null) { - this._yPos = Number(regResult[1]); - this._yRel = Number(regResult[2]); + break; + case 2: // Y in mode 0. Title in mode 1. + if (this._mode === ROPTextboxMode.TEXTBOX_LOCATION) { + if ((regResult = rx.exec(arg)) != null) { + this._yPos = Number(regResult[1]); + this._yRel = Number(regResult[2]); + } else { + this._yPos = Number(arg); + } + } else if (this._mode === ROPTextboxMode.ARROW_LOCATION) { + this._id = this._env.getStringRef(arg); + } else if (this._mode === ROPTextboxMode.ARROW_NUCLEOTIDE) { + this._arrowRotation = Number(arg); } else { - this._yPos = Number(arg); + this._title = this._env.getStringRef(arg); } - } else if (this._mode === ROPTextboxMode.ARROW_NUCLEOTIDE) { - this._id = this._env.getStringRef(arg); - } else { - this._nucIdx = Number(arg) - 1; - } - break; - case 2: // Y in mode 0. Title in mode 1. - if (this._mode === ROPTextboxMode.TEXTBOX_LOCATION) { - if ((regResult = rx.exec(arg)) != null) { - this._yPos = Number(regResult[1]); - this._yRel = Number(regResult[2]); + break; + case 3: // Title in mode 0. Id in mode 1. + if (this._mode === ROPTextboxMode.TEXTBOX_LOCATION) { + this._title = this._env.getStringRef(arg); + } else if (this._mode === ROPTextboxMode.ARROW_LOCATION) { + this._arrowRotation = Number(arg); + } else if (this._mode === ROPTextboxMode.ARROW_NUCLEOTIDE) { + this._arrowLength = Number(arg); } else { - this._yPos = Number(arg); + this._id = this._env.getStringRef(arg); } - } else if (this._mode === ROPTextboxMode.ARROW_LOCATION) { - this._id = this._env.getStringRef(arg); - } else if (this._mode === ROPTextboxMode.ARROW_NUCLEOTIDE) { - this._arrowRotation = Number(arg); - } else { - this._title = this._env.getStringRef(arg); - } - break; - case 3: // Title in mode 0. Id in mode 1. - if (this._mode === ROPTextboxMode.TEXTBOX_LOCATION) { - this._title = this._env.getStringRef(arg); - } else if (this._mode === ROPTextboxMode.ARROW_LOCATION) { - this._arrowRotation = Number(arg); - } else if (this._mode === ROPTextboxMode.ARROW_NUCLEOTIDE) { - this._arrowLength = Number(arg); - } else { - this._id = this._env.getStringRef(arg); - } - break; - case 4: // Id in mode 0. Button text in mode 1. - if (this._mode === ROPTextboxMode.TEXTBOX_LOCATION) { - this._id = this._env.getStringRef(arg); - } else if (this._mode === ROPTextboxMode.ARROW_LOCATION) { - this._arrowLength = Number(arg); - } else if (this._mode === ROPTextboxMode.ARROW_NUCLEOTIDE) { - this._myWidth = Number(arg); - } else { - this._buttonText = this._env.getStringRef(arg); - } - break; - case 5: // Button text in mode 1. - if (this._mode === ROPTextboxMode.TEXTBOX_LOCATION) { - this._buttonText = this._env.getStringRef(arg); - } else if (this._mode === ROPTextboxMode.ARROW_LOCATION) { - this._myWidth = Number(arg); - } else if (this._mode === ROPTextboxMode.ARROW_NUCLEOTIDE) { - this._hasParent = ROPTextbox.parseBool(arg); - } else { - this._initialShow = ROPTextbox.parseBool(arg); - } - break; - case 6: - if (this._mode === ROPTextboxMode.ARROW_LOCATION) { - this._hasParent = ROPTextbox.parseBool(arg); - } else if (this._mode === ROPTextboxMode.ARROW_NUCLEOTIDE) { - this._parentID = this._env.getStringRef(arg); - } else if (this._mode === ROPTextboxMode.TEXTBOX_NUCLEOTIDE) { - this._fixedSize = ROPTextbox.parseBool(arg); - } else { - this._initialShow = ROPTextbox.parseBool(arg); - } - break; - case 7: - if (this._mode === ROPTextboxMode.ARROW_LOCATION) { - this._parentID = this._env.getStringRef(arg); - } else if (this._mode === ROPTextboxMode.ARROW_NUCLEOTIDE) { - this._fillColor = ColorUtil.fromString(`#${this._env.getStringRef(arg)}`); - } else if (this._mode === ROPTextboxMode.TEXTBOX_LOCATION) { - this._fixedSize = ROPTextbox.parseBool(arg); - } else if (this._mode === ROPTextboxMode.TEXTBOX_NUCLEOTIDE) { - this._forceTopmost = ROPTextbox.parseBool(arg); - } - break; - case 8: - if (this._mode === ROPTextboxMode.ARROW_LOCATION) { - this._fillColor = ColorUtil.fromString(`#${this._env.getStringRef(arg)}`); - } else if (this._mode === ROPTextboxMode.ARROW_NUCLEOTIDE) { - this._outlineColor = ColorUtil.fromString(`#${this._env.getStringRef(arg)}`); - } else if (this._mode === ROPTextboxMode.TEXTBOX_LOCATION) { - this._forceTopmost = ROPTextbox.parseBool(arg); - } else if (this._mode === ROPTextboxMode.TEXTBOX_NUCLEOTIDE) { - this._hasXOffset = true; - this._xOffset = Number(arg); - } - break; - case 9: - if (this._mode === ROPTextboxMode.TEXTBOX_NUCLEOTIDE) { - this._hasYOffset = true; - this._yOffset = Number(arg); - } else if (this._mode === ROPTextboxMode.ARROW_NUCLEOTIDE) { - this._hasXOffset = true; - this._xOffset = Number(arg); - } else { - this._outlineColor = ColorUtil.fromString(`#${this._env.getStringRef(arg)}`); - } - break; + break; + case 4: // Id in mode 0. Button text in mode 1. + if (this._mode === ROPTextboxMode.TEXTBOX_LOCATION) { + this._id = this._env.getStringRef(arg); + } else if (this._mode === ROPTextboxMode.ARROW_LOCATION) { + this._arrowLength = Number(arg); + } else if (this._mode === ROPTextboxMode.ARROW_NUCLEOTIDE) { + this._myWidth = Number(arg); + } else { + this._buttonText = this._env.getStringRef(arg); + } + break; + case 5: // Button text in mode 1. + if (this._mode === ROPTextboxMode.TEXTBOX_LOCATION) { + this._buttonText = this._env.getStringRef(arg); + } else if (this._mode === ROPTextboxMode.ARROW_LOCATION) { + this._myWidth = Number(arg); + } else if (this._mode === ROPTextboxMode.ARROW_NUCLEOTIDE) { + this._hasParent = ROPTextbox.parseBool(arg); + } else { + this._initialShow = ROPTextbox.parseBool(arg); + } + break; + case 6: + if (this._mode === ROPTextboxMode.ARROW_LOCATION) { + this._hasParent = ROPTextbox.parseBool(arg); + } else if (this._mode === ROPTextboxMode.ARROW_NUCLEOTIDE) { + this._parentID = this._env.getStringRef(arg); + } else if (this._mode === ROPTextboxMode.TEXTBOX_NUCLEOTIDE) { + this._fixedSize = ROPTextbox.parseBool(arg); + } else { + this._initialShow = ROPTextbox.parseBool(arg); + } + break; + case 7: + if (this._mode === ROPTextboxMode.ARROW_LOCATION) { + this._parentID = this._env.getStringRef(arg); + } else if (this._mode === ROPTextboxMode.ARROW_NUCLEOTIDE) { + this._fillColor = ColorUtil.fromString(`#${this._env.getStringRef(arg)}`); + } else if (this._mode === ROPTextboxMode.TEXTBOX_LOCATION) { + this._fixedSize = ROPTextbox.parseBool(arg); + } else if (this._mode === ROPTextboxMode.TEXTBOX_NUCLEOTIDE) { + this._forceTopmost = ROPTextbox.parseBool(arg); + } + break; + case 8: + if (this._mode === ROPTextboxMode.ARROW_LOCATION) { + this._fillColor = ColorUtil.fromString(`#${this._env.getStringRef(arg)}`); + } else if (this._mode === ROPTextboxMode.ARROW_NUCLEOTIDE) { + this._outlineColor = ColorUtil.fromString(`#${this._env.getStringRef(arg)}`); + } else if (this._mode === ROPTextboxMode.TEXTBOX_LOCATION) { + this._forceTopmost = ROPTextbox.parseBool(arg); + } else if (this._mode === ROPTextboxMode.TEXTBOX_NUCLEOTIDE) { + this._hasXOffset = true; + this._xOffset = Number(arg); + } + break; + case 9: + if (this._mode === ROPTextboxMode.TEXTBOX_NUCLEOTIDE) { + this._hasYOffset = true; + this._yOffset = Number(arg); + } else if (this._mode === ROPTextboxMode.ARROW_NUCLEOTIDE) { + this._hasXOffset = true; + this._xOffset = Number(arg); + } else { + this._outlineColor = ColorUtil.fromString(`#${this._env.getStringRef(arg)}`); + } + break; - default: - throw new Error(`Invalid argument for ROP: Textbox -- ${this._env.getStringRef(arg)}`); + default: + throw new Error(`Invalid argument for ROP: Textbox -- ${this._env.getStringRef(arg)}`); } } @@ -391,23 +397,25 @@ export default class ROPTextbox extends RScriptOp { } private static processText(inText: string): string { - if (!inText) return ""; - inText = inText.replace(/\ op.addNucleotideCompletion(i, newColor)); + ROPWait.genericNotifyClear( + ROPWaitType.NUCLEOTIDECHANGE, (op: ROPWait): boolean => op.addNucleotideCompletion(i, newColor) + ); - ROPWait.genericNotifyClear(ROPWaitType.MUTATION, (op: ROPWait): boolean => op.addNucleotideCompletion(i, newColor)); + ROPWait.genericNotifyClear( + ROPWaitType.MUTATION, (op: ROPWait): boolean => op.addNucleotideCompletion(i, newColor) + ); } public static notifyBlackMark(i: number, marked: boolean): void { @@ -81,14 +85,16 @@ export default class ROPWait extends RScriptOp { } public static notifyTextboxProgress(id: string): void { - ROPWait.genericNotifyClear(ROPWaitType.TEXTBOX, (op: ROPWait): boolean => (op.id + ROPTextbox.ID_POSTFIX === id)); + ROPWait.genericNotifyClear( + ROPWaitType.TEXTBOX, (op: ROPWait): boolean => (op.id + ROPTextbox.ID_POSTFIX === id) + ); } public static notifyFinishRNA(): void { ROPWait.genericNotifyClear(ROPWaitType.NUCLEOTIDEPAIR, (): boolean => true); } - public constructor(waitType: ROPWaitType, env: RScriptEnv) { + constructor(waitType: ROPWaitType, env: RScriptEnv) { super(env); this._waitType = waitType; ROPWait.registerROPWait(this); @@ -193,7 +199,7 @@ export default class ROPWait extends RScriptOp { this._allNucleotidesCompleted = []; } - if (this._expectedColor && color !== this._expectedColor && color !== "") { + if (this._expectedColor && color !== this._expectedColor && color !== '') { return false; } @@ -254,66 +260,66 @@ export default class ROPWait extends RScriptOp { /* override */ protected parseArgument(arg: string, i: number): void { switch (i) { - case 0: - if (this._waitType === ROPWaitType.CLICKUI) { - this._elements.push(this._env.getStringRef(arg).toUpperCase()); - } else if (this._waitType === ROPWaitType.TEXTBOX) { - this._id = this._env.getStringRef(arg); - } else if (this._waitType === ROPWaitType.MUTATION) { - if ("AUGC".indexOf(arg.toUpperCase()) !== -1) { - this._expectedColor = this._env.getStringRef(arg).toUpperCase().replace(" ", ""); + case 0: + if (this._waitType === ROPWaitType.CLICKUI) { + this._elements.push(this._env.getStringRef(arg).toUpperCase()); + } else if (this._waitType === ROPWaitType.TEXTBOX) { + this._id = this._env.getStringRef(arg); + } else if (this._waitType === ROPWaitType.MUTATION) { + if ('AUGC'.indexOf(arg.toUpperCase()) !== -1) { + this._expectedColor = this._env.getStringRef(arg).toUpperCase().replace(' ', ''); + } else { + this._elements.push(Number(arg) - 1); + } + } else if (this._waitType === ROPWaitType.TIME) { + this._delay = Number(arg); } else { + this._startIdx = Number(arg) - 1; + } + break; + case 1: + if (this._waitType === ROPWaitType.CLICKUI) { + this._elements.push(this._env.getStringRef(arg).toUpperCase()); + } else if (this._waitType === ROPWaitType.NUCLEOTIDEPAIR) { + this._color1 = this._env.getStringRef(arg).toUpperCase().replace(' ', ''); + } else if (this._waitType === ROPWaitType.MUTATION) { this._elements.push(Number(arg) - 1); + } else { + this._endIdx = Number(arg) - 1; } - } else if (this._waitType === ROPWaitType.TIME) { - this._delay = Number(arg); - } else { - this._startIdx = Number(arg) - 1; - } - break; - case 1: - if (this._waitType === ROPWaitType.CLICKUI) { - this._elements.push(this._env.getStringRef(arg).toUpperCase()); - } else if (this._waitType === ROPWaitType.NUCLEOTIDEPAIR) { - this._color1 = this._env.getStringRef(arg).toUpperCase().replace(" ", ""); - } else if (this._waitType === ROPWaitType.MUTATION) { - this._elements.push(Number(arg) - 1); - } else { - this._endIdx = Number(arg) - 1; - } - break; - case 2: - if (this._waitType === ROPWaitType.CLICKUI) { - this._elements.push(this._env.getStringRef(arg).toUpperCase()); - } else if (this._waitType === ROPWaitType.NUCLEOTIDECHANGE) { - this._expectedColor = this._env.getStringRef(arg); - } else if (this._waitType === ROPWaitType.PAINT) { - this._id = this._env.getStringRef(arg); - } else if (this._waitType === ROPWaitType.NUCLEOTIDEPAIR) { - this._color2 = this._env.getStringRef(arg).toUpperCase().replace(" ", ""); - } else if (this._waitType === ROPWaitType.MUTATION) { - this._elements.push(Number(arg) - 1); - } - break; - case 3: - if (this._waitType === ROPWaitType.CLICKUI) { - this._elements.push(this._env.getStringRef(arg).toUpperCase()); - } else if (this._waitType === ROPWaitType.MUTATION) { - this._elements.push(Number(arg) - 1); - } else { - this._expectedColor = this._env.getStringRef(arg).toUpperCase().replace(" ", ""); - } - break; - default: - if (this._waitType === ROPWaitType.CLICKUI) { - this._elements.push(this._env.getStringRef(arg).toUpperCase()); - } else if (this._waitType === ROPWaitType.MUTATION) { - this._elements.push(Number(arg) - 1); - } else { - throw new Error("Too many arguments for a ROP Wait Instruction"); - } - break; + break; + case 2: + if (this._waitType === ROPWaitType.CLICKUI) { + this._elements.push(this._env.getStringRef(arg).toUpperCase()); + } else if (this._waitType === ROPWaitType.NUCLEOTIDECHANGE) { + this._expectedColor = this._env.getStringRef(arg); + } else if (this._waitType === ROPWaitType.PAINT) { + this._id = this._env.getStringRef(arg); + } else if (this._waitType === ROPWaitType.NUCLEOTIDEPAIR) { + this._color2 = this._env.getStringRef(arg).toUpperCase().replace(' ', ''); + } else if (this._waitType === ROPWaitType.MUTATION) { + this._elements.push(Number(arg) - 1); + } + break; + case 3: + if (this._waitType === ROPWaitType.CLICKUI) { + this._elements.push(this._env.getStringRef(arg).toUpperCase()); + } else if (this._waitType === ROPWaitType.MUTATION) { + this._elements.push(Number(arg) - 1); + } else { + this._expectedColor = this._env.getStringRef(arg).toUpperCase().replace(' ', ''); + } + break; + default: + if (this._waitType === ROPWaitType.CLICKUI) { + this._elements.push(this._env.getStringRef(arg).toUpperCase()); + } else if (this._waitType === ROPWaitType.MUTATION) { + this._elements.push(Number(arg) - 1); + } else { + throw new Error('Too many arguments for a ROP Wait Instruction'); + } + break; } } @@ -340,15 +346,15 @@ export default class ROPWait extends RScriptOp { } } - private static notifyMark(mark_type: ROPWaitType, i: number, marked: boolean): void { + private static notifyMark(markType: ROPWaitType, i: number, marked: boolean): void { if (i === -1) { return; } - ROPWait.genericNotifyClear(mark_type, (op: ROPWait): boolean => op.addMarkCompletion(i, marked)); + ROPWait.genericNotifyClear(markType, (op: ROPWait): boolean => op.addMarkCompletion(i, marked)); } - private static genericNotifyClear(inType: ROPWaitType, clear_check: (op: ROPWait) => boolean): void { + private static genericNotifyClear(inType: ROPWaitType, clearCheck: (op: ROPWait) => boolean): void { if (ROPWait._allROPWaitOps == null || ROPWait._allROPWaitOps.get(inType) == null) { return; } @@ -357,7 +363,7 @@ export default class ROPWait extends RScriptOp { let clearOps: ROPWait[] = []; for (let op of list) { - if (op.isWaitActive() && clear_check(op)) { + if (op.isWaitActive() && clearCheck(op)) { clearOps.push(op); op.clearCondition(); } @@ -378,7 +384,7 @@ export default class ROPWait extends RScriptOp { private _color1: string; private _color2: string; - private _id: string = ""; + private _id: string = ''; private _conditionClear: boolean = false; diff --git a/src/eterna/rscript/RScriptArrow.ts b/src/eterna/rscript/RScriptArrow.ts index bf5af434b..befba65c6 100644 --- a/src/eterna/rscript/RScriptArrow.ts +++ b/src/eterna/rscript/RScriptArrow.ts @@ -1,10 +1,12 @@ -import {Graphics} from "pixi.js"; -import {SceneObject} from "flashbang/objects"; -import {MathUtil} from "flashbang/util"; -import {GraphicsUtil} from "eterna/util"; +import {Graphics} from 'pixi.js'; +import {SceneObject} from 'flashbang/objects'; +import {MathUtil} from 'flashbang/util'; +import {GraphicsUtil} from 'eterna/util'; export default class RScriptArrow extends SceneObject { - public constructor(triSize: number = 75, baseLength: number = 60, outlineColor: number = 0xDAE8F6, fillColor: number = 0xDAE8F6) { + constructor( + triSize: number = 75, baseLength: number = 60, outlineColor: number = 0xDAE8F6, fillColor: number = 0xDAE8F6 + ) { let graphics = new Graphics(); super(graphics); @@ -17,11 +19,6 @@ export default class RScriptArrow extends SceneObject { this.redrawIfDirty(); } - public get triSize(): number { return this._triSize; } - public get baseLength(): number { return this._baseLength; } - public get outlineColor(): number { return this._outlineColor; } - public get fillColor(): number { return this._fillColor; } - public get rotation(): number { return MathUtil.rad2Deg * this.display.rotation; } @@ -32,7 +29,9 @@ export default class RScriptArrow extends SceneObject { public redrawIfDirty(): void { if (this._needsRedraw) { - GraphicsUtil.drawArrow(this._triSize, this._baseLength, this._outlineColor, this._fillColor, this._graphics); + GraphicsUtil.drawArrow( + this._triSize, this._baseLength, this._outlineColor, this._fillColor, this._graphics + ); this._needsRedraw = false; } } @@ -44,6 +43,8 @@ export default class RScriptArrow extends SceneObject { } } + public get triSize(): number { return this._triSize; } + public set baseLength(value: number) { if (this._baseLength !== value) { this._baseLength = value; @@ -51,6 +52,8 @@ export default class RScriptArrow extends SceneObject { } } + public get baseLength(): number { return this._baseLength; } + public set outlineColor(value: number) { if (this._outlineColor !== value) { this._outlineColor = value; @@ -58,6 +61,8 @@ export default class RScriptArrow extends SceneObject { } } + public get outlineColor(): number { return this._outlineColor; } + public set fillColor(value: number) { if (this._fillColor !== value) { this._fillColor = value; @@ -65,6 +70,8 @@ export default class RScriptArrow extends SceneObject { } } + public get fillColor(): number { return this._fillColor; } + private readonly _graphics: Graphics; private _triSize: number; diff --git a/src/eterna/rscript/RScriptEnv.ts b/src/eterna/rscript/RScriptEnv.ts index ddb1e561b..7ff094e65 100644 --- a/src/eterna/rscript/RScriptEnv.ts +++ b/src/eterna/rscript/RScriptEnv.ts @@ -1,13 +1,13 @@ -import * as log from "loglevel"; -import {Container, DisplayObject} from "pixi.js"; -import {GameObject} from "flashbang/core"; -import {ContainerObject, Enableable} from "flashbang/objects"; -import EPars from "eterna/EPars"; -import {PoseEditMode} from "eterna/mode"; -import {Pose2D, RNAHighlightState} from "eterna/pose2D"; -import {Puzzle} from "eterna/puzzle"; -import {PaletteTargetType, TextBalloon, ToggleBar} from "eterna/ui"; -import {RScriptUIElement, RScriptUIElementID} from "./RScriptUIElement"; +import * as log from 'loglevel'; +import {Container, DisplayObject} from 'pixi.js'; +import {GameObject} from 'flashbang/core'; +import {ContainerObject, Enableable} from 'flashbang/objects'; +import EPars from 'eterna/EPars'; +import {PoseEditMode} from 'eterna/mode'; +import {Pose2D, RNAHighlightState} from 'eterna/pose2D'; +import {Puzzle} from 'eterna/puzzle'; +import {PaletteTargetType, TextBalloon, ToggleBar} from 'eterna/ui'; +import {RScriptUIElement, RScriptUIElementID} from './RScriptUIElement'; /** * RScript Environment. @@ -22,7 +22,7 @@ export default class RScriptEnv extends ContainerObject { return EPars.nucleotideToString(i, true, false); } - public constructor(ui: PoseEditMode, puz: Puzzle) { + constructor(ui: PoseEditMode, puz: Puzzle) { super(); this._ui = ui; this._puz = puz; @@ -30,7 +30,7 @@ export default class RScriptEnv extends ContainerObject { } public setTextboxVisible(id: string, isVisible: boolean): void { - if (id === "" || !this._vars.hasOwnProperty("id")) { + if (id === '' || !Object.prototype.hasOwnProperty.call(this._vars.hasOwnProperty, 'id')) { return; } @@ -52,11 +52,11 @@ export default class RScriptEnv extends ContainerObject { public getStringRef(ref: string): string { // Check if it's an actual ref. // If it's not, return it back unchanged - if (ref.indexOf("$$STRING_REF:") !== 0) { + if (ref.indexOf('$$STRING_REF:') !== 0) { return ref; } else { let value = this.getVar(ref); - if (typeof (value) === "string") { + if (typeof (value) === 'string') { return value; } else { log.warn(`'${ref}' is not a string`); @@ -67,7 +67,7 @@ export default class RScriptEnv extends ContainerObject { /** Remove all stored highlights and hints and stuff. */ public cleanup(): void { - for (let key in this._vars) { + for (let key of Object.keys(this._vars)) { this.deleteVar(key); } } @@ -92,17 +92,17 @@ export default class RScriptEnv extends ContainerObject { let uiElement: RScriptUIElement; // Used UI Element ID. - let splitId: string[] = key.split("-"); + let splitId: string[] = key.split('-'); // Detect a number if it is included in the ui element key. // So for the objectives: objective-### (format). // The input number will always come after the dash. The dash should be // included in the key that is passed. - let idString: string = splitId[0] + (splitId.length > 1 ? "-" : ""); + let idString: string = splitId[0] + (splitId.length > 1 ? '-' : ''); let elementID: RScriptUIElementID = (idString.toUpperCase()) as RScriptUIElementID; if (splitId.length > 2) { - throw new Error("Invalid UI Element ID format"); + throw new Error('Invalid UI Element ID format'); } let altParam = -1; @@ -167,73 +167,73 @@ export default class RScriptEnv extends ContainerObject { public getUIElement(type: RScriptUIElementID, i: number = -1): RScriptUIElement { switch (type) { - case RScriptUIElementID.ACTION_MENU: - return this.ui.toolbar.actionMenu; - case RScriptUIElementID.OBJECTIVES: - return this.ui.constraintsLayer; - case RScriptUIElementID.SHAPEOBJECTIVE: - return this.ui.get_shape_box(0); - case RScriptUIElementID.OBJECTIVE: - return this.ui.getConstraint(i); - case RScriptUIElementID.SWITCH: - return this.ui.toolbar.stateToggle; - case RScriptUIElementID.TOTALENERGY: - case RScriptUIElementID.PRIMARY_ENERGY: - return this.pose.primaryScoreDisplay; - case RScriptUIElementID.SECONDARY_ENERGY: - return this.pose.secondaryScoreDisplay; - case RScriptUIElementID.PALETTE: - case RScriptUIElementID.PALETTEALT: - return this.ui.toolbar.palette; - case RScriptUIElementID.TOGGLENATURAL: - return this.ui.toolbar.naturalButton; - case RScriptUIElementID.TOGGLETARGET: - return this.ui.toolbar.targetButton; - case RScriptUIElementID.TOGGLEBAR: - // NOTE: There is no longer a toggle bar... - return this.ui.toolbar.naturalButton; - case RScriptUIElementID.ZOOMIN: - return this.ui.toolbar.zoomInButton; - case RScriptUIElementID.ZOOMOUT: - return this.ui.toolbar.zoomOutButton; - case RScriptUIElementID.ACTIONBAR: - // NOTE: There is no longer an action bar... - return this.ui.toolbar.zoomInButton; - case RScriptUIElementID.RESET: - return this.ui.toolbar.resetButton; - case RScriptUIElementID.UNDO: - return this.ui.toolbar.undoButton; - case RScriptUIElementID.REDO: - return this.ui.toolbar.redoButton; - case RScriptUIElementID.SWAP: - return this.ui.toolbar.pairSwapButton; - case RScriptUIElementID.PIP: - return this.ui.toolbar.pipButton; - case RScriptUIElementID.A: - return this.ui.toolbar.palette.getTarget(PaletteTargetType.A); - case RScriptUIElementID.U: - return this.ui.toolbar.palette.getTarget(PaletteTargetType.U); - case RScriptUIElementID.G: - return this.ui.toolbar.palette.getTarget(PaletteTargetType.G); - case RScriptUIElementID.C: - return this.ui.toolbar.palette.getTarget(PaletteTargetType.C); - case RScriptUIElementID.AU: - case RScriptUIElementID.UA: - case RScriptUIElementID.AUCOMPLETE: - case RScriptUIElementID.UACOMPLETE: - return this.ui.toolbar.palette.getTarget(PaletteTargetType.AU); - case RScriptUIElementID.GU: - case RScriptUIElementID.UG: - case RScriptUIElementID.GUCOMPLETE: - case RScriptUIElementID.UGCOMPLETE: - return this.ui.toolbar.palette.getTarget(PaletteTargetType.UG); - case RScriptUIElementID.GC: - case RScriptUIElementID.CG: - case RScriptUIElementID.GCCOMPLETE: - case RScriptUIElementID.CGCOMPLETE: - return this.ui.toolbar.palette.getTarget(PaletteTargetType.GC); - default: - throw new Error(`Invalid UI Element: ${type}`); + case RScriptUIElementID.ACTION_MENU: + return this.ui.toolbar.actionMenu; + case RScriptUIElementID.OBJECTIVES: + return this.ui.constraintsLayer; + case RScriptUIElementID.SHAPEOBJECTIVE: + return this.ui.getShapeBox(0); + case RScriptUIElementID.OBJECTIVE: + return this.ui.getConstraint(i); + case RScriptUIElementID.SWITCH: + return this.ui.toolbar.stateToggle; + case RScriptUIElementID.TOTALENERGY: + case RScriptUIElementID.PRIMARY_ENERGY: + return this.pose.primaryScoreDisplay; + case RScriptUIElementID.SECONDARY_ENERGY: + return this.pose.secondaryScoreDisplay; + case RScriptUIElementID.PALETTE: + case RScriptUIElementID.PALETTEALT: + return this.ui.toolbar.palette; + case RScriptUIElementID.TOGGLENATURAL: + return this.ui.toolbar.naturalButton; + case RScriptUIElementID.TOGGLETARGET: + return this.ui.toolbar.targetButton; + case RScriptUIElementID.TOGGLEBAR: + // NOTE: There is no longer a toggle bar... + return this.ui.toolbar.naturalButton; + case RScriptUIElementID.ZOOMIN: + return this.ui.toolbar.zoomInButton; + case RScriptUIElementID.ZOOMOUT: + return this.ui.toolbar.zoomOutButton; + case RScriptUIElementID.ACTIONBAR: + // NOTE: There is no longer an action bar... + return this.ui.toolbar.zoomInButton; + case RScriptUIElementID.RESET: + return this.ui.toolbar.resetButton; + case RScriptUIElementID.UNDO: + return this.ui.toolbar.undoButton; + case RScriptUIElementID.REDO: + return this.ui.toolbar.redoButton; + case RScriptUIElementID.SWAP: + return this.ui.toolbar.pairSwapButton; + case RScriptUIElementID.PIP: + return this.ui.toolbar.pipButton; + case RScriptUIElementID.A: + return this.ui.toolbar.palette.getTarget(PaletteTargetType.A); + case RScriptUIElementID.U: + return this.ui.toolbar.palette.getTarget(PaletteTargetType.U); + case RScriptUIElementID.G: + return this.ui.toolbar.palette.getTarget(PaletteTargetType.G); + case RScriptUIElementID.C: + return this.ui.toolbar.palette.getTarget(PaletteTargetType.C); + case RScriptUIElementID.AU: + case RScriptUIElementID.UA: + case RScriptUIElementID.AUCOMPLETE: + case RScriptUIElementID.UACOMPLETE: + return this.ui.toolbar.palette.getTarget(PaletteTargetType.AU); + case RScriptUIElementID.GU: + case RScriptUIElementID.UG: + case RScriptUIElementID.GUCOMPLETE: + case RScriptUIElementID.UGCOMPLETE: + return this.ui.toolbar.palette.getTarget(PaletteTargetType.UG); + case RScriptUIElementID.GC: + case RScriptUIElementID.CG: + case RScriptUIElementID.GCCOMPLETE: + case RScriptUIElementID.CGCOMPLETE: + return this.ui.toolbar.palette.getTarget(PaletteTargetType.GC); + default: + throw new Error(`Invalid UI Element: ${type}`); } } diff --git a/src/eterna/rscript/RScriptOp.ts b/src/eterna/rscript/RScriptOp.ts index 7e5178bc9..334938a28 100644 --- a/src/eterna/rscript/RScriptOp.ts +++ b/src/eterna/rscript/RScriptOp.ts @@ -1,4 +1,4 @@ -import RScriptEnv from "./RScriptEnv"; +import RScriptEnv from './RScriptEnv'; /** * RScript Operation. @@ -33,15 +33,15 @@ export default abstract class RScriptOp { this._originalArgs = args; // Replace with \n regardless of where it is. - args = args.replace(/\/g, "\n"); + args = args.replace(//g, '\n'); args = this.createStrings(args); - let param: string[] = args.split(","); + let param: string[] = args.split(','); for (let i = 0; i < param.length; ++i) { let arg: string = param[i]; - arg = arg.replace(/^\s*/, ""); - arg = arg.replace(/\s*$/, ""); - if (arg === "") { + arg = arg.replace(/^\s*/, ''); + arg = arg.replace(/\s*$/, ''); + if (arg === '') { continue; } this.parseArgument(arg, i); @@ -62,20 +62,20 @@ export default abstract class RScriptOp { // Identify strings marked by "" or '' and store them in the environment. while (true) { // Find the first matching pair of quotation marks. Single or double. - let s_idx: number = arg.indexOf("'"); - let s_matchIdx: number = arg.indexOf("'", s_idx + 1); + let sIdx: number = arg.indexOf("'"); + let sMatchIdx: number = arg.indexOf("'", sIdx + 1); - let d_idx: number = arg.indexOf("\""); - let d_matchIdx: number = arg.indexOf("\"", d_idx + 1); + let dIdx: number = arg.indexOf('"'); + let dMatchIdx: number = arg.indexOf('"', dIdx + 1); let idx = -1; let matchIdx = -1; - if ((s_idx < d_idx || d_idx === -1) && s_idx >= 0 && s_matchIdx >= 0) { - idx = s_idx; - matchIdx = s_matchIdx; - } else if ((d_idx < s_idx || s_idx === -1) && d_idx >= 0 && d_matchIdx >= 0) { - idx = d_idx; - matchIdx = d_matchIdx; + if ((sIdx < dIdx || dIdx === -1) && sIdx >= 0 && sMatchIdx >= 0) { + idx = sIdx; + matchIdx = sMatchIdx; + } else if ((dIdx < sIdx || sIdx === -1) && dIdx >= 0 && dMatchIdx >= 0) { + idx = dIdx; + matchIdx = dMatchIdx; } if (idx === -1 || matchIdx === -1) { diff --git a/src/eterna/rscript/RScriptOpTree.ts b/src/eterna/rscript/RScriptOpTree.ts index b5c3af0ec..00362daa1 100644 --- a/src/eterna/rscript/RScriptOpTree.ts +++ b/src/eterna/rscript/RScriptOpTree.ts @@ -1,5 +1,5 @@ -import ROPWait from "./ROPWait"; -import RScriptOp from "./RScriptOp"; +import ROPWait from './ROPWait'; +import RScriptOp from './RScriptOp'; /* * RScript Operation Tree. @@ -43,14 +43,12 @@ export default class RScriptOpTree { } else if (this._curptr.isPaused() && this._waitQueue.indexOf(this._curptr)) { this._waitQueue.push(this._curptr); return null; - } else { + } else if (this.checkWaitQueueContinue()) { // If it cannot then see if the wait queue is clear. - if (this.checkWaitQueueContinue()) { - // Clear queue and proceed. - this._waitQueue.splice(0); - } else { - return null; - } + // Clear queue and proceed. + this._waitQueue.splice(0); + } else { + return null; } } diff --git a/src/eterna/rscript/RScriptUIElement.ts b/src/eterna/rscript/RScriptUIElement.ts index 29c28f8b1..44152a208 100644 --- a/src/eterna/rscript/RScriptUIElement.ts +++ b/src/eterna/rscript/RScriptUIElement.ts @@ -1,6 +1,6 @@ -import {DisplayObject, Rectangle} from "pixi.js"; -import {GameObject} from "flashbang/core"; -import {DisplayUtil} from "flashbang/util"; +import {DisplayObject, Rectangle} from 'pixi.js'; +import {GameObject} from 'flashbang/core'; +import {DisplayUtil} from 'flashbang/util'; export type RScriptUIElement = GameObject | DisplayObject | Rectangle; @@ -22,52 +22,52 @@ export function GetRScriptUIElementBounds(element: RScriptUIElement): Rectangle } export enum RScriptUIElementID { - TOGGLETARGET = "TOGGLETARGET", - TOGGLENATURAL = "TOGGLENATURAL", - ZOOMIN = "ZOOMIN", - ZOOMOUT = "ZOOMOUT", - RESET = "RESET", - UNDO = "UNDO", - REDO = "REDO", - SWAP = "SWAP", - HINT = "HINT", - PIP = "PIP", - FREEZE = "FREEZE", - SWITCH = "SWITCH", + TOGGLETARGET = 'TOGGLETARGET', + TOGGLENATURAL = 'TOGGLENATURAL', + ZOOMIN = 'ZOOMIN', + ZOOMOUT = 'ZOOMOUT', + RESET = 'RESET', + UNDO = 'UNDO', + REDO = 'REDO', + SWAP = 'SWAP', + HINT = 'HINT', + PIP = 'PIP', + FREEZE = 'FREEZE', + SWITCH = 'SWITCH', - OBJECTIVES = "OBJECTIVES", - OBJECTIVE = "OBJECTIVE-", - SHAPEOBJECTIVE = "SHAPEOBJECTIVE", + OBJECTIVES = 'OBJECTIVES', + OBJECTIVE = 'OBJECTIVE-', + SHAPEOBJECTIVE = 'SHAPEOBJECTIVE', - A = "A", - U = "U", - G = "G", - C = "C", - AU = "AU", - UA = "UA", - GU = "GU", - UG = "UG", - GC = "GC", - CG = "CG", - AUCOMPLETE = "AUCOMPLETE", - UACOMPLETE = "UACOMPLETE", - GUCOMPLETE = "GUCOMPLETE", - UGCOMPLETE = "UGCOMPLETE", - GCCOMPLETE = "GCCOMPLETE", - CGCOMPLETE = "CGCOMPLETE", + A = 'A', + U = 'U', + G = 'G', + C = 'C', + AU = 'AU', + UA = 'UA', + GU = 'GU', + UG = 'UG', + GC = 'GC', + CG = 'CG', + AUCOMPLETE = 'AUCOMPLETE', + UACOMPLETE = 'UACOMPLETE', + GUCOMPLETE = 'GUCOMPLETE', + UGCOMPLETE = 'UGCOMPLETE', + GCCOMPLETE = 'GCCOMPLETE', + CGCOMPLETE = 'CGCOMPLETE', - HELP = "HELP", + HELP = 'HELP', - TOTALENERGY = "TOTALENERGY", - PRIMARY_ENERGY = "PRIMARY_ENERGY", - SECONDARY_ENERGY = "SECONDARY_ENERGY", + TOTALENERGY = 'TOTALENERGY', + PRIMARY_ENERGY = 'PRIMARY_ENERGY', + SECONDARY_ENERGY = 'SECONDARY_ENERGY', - PALETTE = "PALETTE", - PALETTEALT = "PALETTEALT", - TOGGLEBAR = "TOGGLEBAR", - ACTIONBAR = "ACTIONBAR", - ACTION_MENU = "ACTION_MENU", + PALETTE = 'PALETTE', + PALETTEALT = 'PALETTEALT', + TOGGLEBAR = 'TOGGLEBAR', + ACTIONBAR = 'ACTIONBAR', + ACTION_MENU = 'ACTION_MENU', - ENERGY = "ENERGY", - BASENUMBERING = "BASENUMBERING" + ENERGY = 'ENERGY', + BASENUMBERING = 'BASENUMBERING' } diff --git a/src/eterna/rscript/index.ts b/src/eterna/rscript/index.ts index e192cc1c3..98ae22da5 100644 --- a/src/eterna/rscript/index.ts +++ b/src/eterna/rscript/index.ts @@ -1,14 +1,14 @@ -export {default as RScriptOp} from "./RScriptOp"; -export {default as NovaPaintHint} from "./NovaPaintHint"; -export {default as RNAScript} from "./RNAScript"; -export {default as ROPHighlight, ROPHighlightMode} from "./ROPHighlight"; -export {default as ROPHint} from "./ROPHint"; -export {default as ROPPre} from "./ROPPre"; -export {default as ROPRNA, ROPRNAType} from "./ROPRNA"; -export {default as ROPTextbox, ROPTextboxMode} from "./ROPTextbox"; -export {default as ROPUI} from "./ROPUI"; -export {default as ROPWait, ROPWaitType} from "./ROPWait"; -export {default as RScriptArrow} from "./RScriptArrow"; -export {default as RScriptEnv, RScriptVarType} from "./RScriptEnv"; -export {default as RScriptOpTree} from "./RScriptOpTree"; -export {RScriptUIElement, GetRScriptUIElementBounds, RScriptUIElementID} from "./RScriptUIElement"; +export {default as RScriptOp} from './RScriptOp'; +export {default as NovaPaintHint} from './NovaPaintHint'; +export {default as RNAScript} from './RNAScript'; +export {default as ROPHighlight, ROPHighlightMode} from './ROPHighlight'; +export {default as ROPHint} from './ROPHint'; +export {default as ROPPre} from './ROPPre'; +export {default as ROPRNA, ROPRNAType} from './ROPRNA'; +export {default as ROPTextbox, ROPTextboxMode} from './ROPTextbox'; +export {default as ROPUI} from './ROPUI'; +export {default as ROPWait, ROPWaitType} from './ROPWait'; +export {default as RScriptArrow} from './RScriptArrow'; +export {default as RScriptEnv, RScriptVarType} from './RScriptEnv'; +export {default as RScriptOpTree} from './RScriptOpTree'; +export {RScriptUIElement, GetRScriptUIElementBounds, RScriptUIElementID} from './RScriptUIElement'; diff --git a/src/eterna/settings/EternaSettings.ts b/src/eterna/settings/EternaSettings.ts index f00f241b3..5c66a863b 100644 --- a/src/eterna/settings/EternaSettings.ts +++ b/src/eterna/settings/EternaSettings.ts @@ -1,6 +1,6 @@ -import {Setting, Settings} from "flashbang/settings"; -import {DesignCategory} from "eterna/mode/DesignBrowser"; -import Eterna from "eterna/Eterna"; +import {Setting, Settings} from 'flashbang/settings'; +import {DesignCategory} from 'eterna/mode/DesignBrowser'; +import Eterna from 'eterna/Eterna'; export default class EternaSettings extends Settings { public readonly showChat: Setting; @@ -26,36 +26,36 @@ export default class EternaSettings extends Settings { public readonly saveGamesTransfered: Setting; - public constructor() { - super("EternaSettings"); + constructor() { + super('EternaSettings'); - this.showChat = this.setting("showChat", true); - this.showNumbers = this.setting("showNumbers", true); - this.showLetters = this.setting("showLetters", false); - this.displayFreeEnergies = this.setting("displayFreeEnergies", false); - this.highlightRestricted = this.setting("highlightRestricted", true); - this.autohideToolbar = this.setting("autohideToolbar", false); - this.freezeButtonAlwaysVisible = this.setting("freezeButtonAlwaysVisible", false); - this.multipleFoldingEngines = this.setting("multipleFoldingEngines", false); - this.useContinuousColors = this.setting("useContinuousColors", false); - this.useExtendedColors = this.setting("useExtendedColors", false); - this.displayAuxInfo = this.setting("displayAuxInfo", false); - this.soundMute = this.setting("soundMute", false); - this.soundVolume = this.setting("soundVolume", 0.6); - this.lastUsedFolder = this.setting("lastUsedFolder", null); - this.pipEnabled = this.setting("pipEnabled", false); - this.simpleGraphics = this.setting("simpleGraphics", false); + this.showChat = this.setting('showChat', true); + this.showNumbers = this.setting('showNumbers', true); + this.showLetters = this.setting('showLetters', false); + this.displayFreeEnergies = this.setting('displayFreeEnergies', false); + this.highlightRestricted = this.setting('highlightRestricted', true); + this.autohideToolbar = this.setting('autohideToolbar', false); + this.freezeButtonAlwaysVisible = this.setting('freezeButtonAlwaysVisible', false); + this.multipleFoldingEngines = this.setting('multipleFoldingEngines', false); + this.useContinuousColors = this.setting('useContinuousColors', false); + this.useExtendedColors = this.setting('useExtendedColors', false); + this.displayAuxInfo = this.setting('displayAuxInfo', false); + this.soundMute = this.setting('soundMute', false); + this.soundVolume = this.setting('soundVolume', 0.6); + this.lastUsedFolder = this.setting('lastUsedFolder', null); + this.pipEnabled = this.setting('pipEnabled', false); + this.simpleGraphics = this.setting('simpleGraphics', false); - this.designBrowserColumnNames = this.setting("designBrowserColumnNames", null); - this.designBrowserSelectedSolutionIDs = this.setting("designBrowserSelectedSolutionIDs", null); + this.designBrowserColumnNames = this.setting('designBrowserColumnNames', null); + this.designBrowserSelectedSolutionIDs = this.setting('designBrowserSelectedSolutionIDs', null); // Denotes whether savegames have been transfered from localstorage/storeJS/EternaSettings to // indexedDB/localforage/SaveGameManager - eventually this might be able to be dropped, // but anyone who hasn't run Eterna between the EternaJS launch and the time it was // introduced will loose any autosaves - this.saveGamesTransfered = this.setting("saveGamesTransfered", false); + this.saveGamesTransfered = this.setting('saveGamesTransfered', false); - if (this.saveGamesTransfered.value == false) { + if (this.saveGamesTransfered.value === false) { this._namespace.each((val, key) => { if (key.match(/^(puz|puzedit)_.*$/)) { Eterna.saveManager.save(key, val); diff --git a/src/eterna/settings/index.ts b/src/eterna/settings/index.ts index 8acdc3c6d..0b05a7dc7 100644 --- a/src/eterna/settings/index.ts +++ b/src/eterna/settings/index.ts @@ -1 +1,2 @@ -export {default as EternaSettings} from "./EternaSettings"; +/* eslint-disable import/prefer-default-export */ +export {default as EternaSettings} from './EternaSettings'; diff --git a/src/eterna/ui/ActionBar.ts b/src/eterna/ui/ActionBar.ts index ada237f07..7e8e78780 100644 --- a/src/eterna/ui/ActionBar.ts +++ b/src/eterna/ui/ActionBar.ts @@ -1,9 +1,9 @@ -import {Graphics, Point} from "pixi.js"; -import {ContainerObject, SceneObject} from "flashbang/objects"; -import {DisplayUtil} from "flashbang/util"; +import {Graphics, Point} from 'pixi.js'; +import {ContainerObject, SceneObject} from 'flashbang/objects'; +import {DisplayUtil} from 'flashbang/util'; export default class ActionBar extends ContainerObject { - public constructor(height: number = 0) { + constructor(height: number = 0) { super(); this._bg = new Graphics(); @@ -13,10 +13,10 @@ export default class ActionBar extends ContainerObject { this.doLayout(); } - public addItem(obj: SceneObject, layout: boolean = true, height_mod: number = 0): void { + public addItem(obj: SceneObject, layout: boolean = true, heightMod: number = 0): void { this._items.push(obj); this.addObject(obj, this.container); - this._heightMods.push(height_mod); + this._heightMods.push(heightMod); if (layout) { this.doLayout(); @@ -41,41 +41,43 @@ export default class ActionBar extends ContainerObject { return; } - let item_space = 35; - let bar_space = 10; + let itemSpace = 35; + let barSpace = 10; - let center_width = 0; + let centerWidth = 0; for (let ii = 0; ii < this._items.length; ii++) { - center_width += Math.max(DisplayUtil.width(this._items[ii].display), 35); + centerWidth += Math.max(DisplayUtil.width(this._items[ii].display), 35); } - center_width += (bar_space) * this._items.length + bar_space; - let whole_width: number = center_width; - let whole_height: number = this._height; + centerWidth += (barSpace) * this._items.length + barSpace; + let wholeWidth: number = centerWidth; + let wholeHeight: number = this._height; - if (whole_height < 1) { - let max_height = 0; - let vertical_margin = 10; + if (wholeHeight < 1) { + let maxHeight = 0; + let verticalMargin = 10; for (let ii = 0; ii < this._items.length; ii++) { - max_height = Math.max(max_height, DisplayUtil.height(this._items[ii].display)); + maxHeight = Math.max(maxHeight, DisplayUtil.height(this._items[ii].display)); } - whole_height = max_height + vertical_margin; + wholeHeight = maxHeight + verticalMargin; } - let item_space_walker = 0; + let itemSpaceWalker = 0; for (let ii = 0; ii < this._items.length; ii++) { - let cur_space: number = Math.max(DisplayUtil.width(this._items[ii].display), item_space); - let item_y: number = whole_height / 2.0 - DisplayUtil.height(this._items[ii].display) / 2.0 + this._heightMods[ii]; + let curSpace = Math.max(DisplayUtil.width(this._items[ii].display), itemSpace); + let itemY = wholeHeight / 2.0 - DisplayUtil.height(this._items[ii].display) / 2.0 + this._heightMods[ii]; + this._items[ii].display.position = new Point( - bar_space + bar_space / 2.0 + item_space_walker + (bar_space) * ii, - item_y + barSpace + barSpace / 2.0 + itemSpaceWalker + (barSpace) * ii, + itemY ); - item_space_walker += cur_space; + + itemSpaceWalker += curSpace; } this._bg.beginFill(0xffffff, 0.05); - this._bg.drawRoundedRect(0, 0, whole_width, whole_height, 10); + this._bg.drawRoundedRect(0, 0, wholeWidth, wholeHeight, 10); } public get width(): number { @@ -83,16 +85,16 @@ export default class ActionBar extends ContainerObject { return 0; } - let bar_space = 10; + let barSpace = 10; - let center_width = 0; + let centerWidth = 0; for (let ii = 0; ii < this._items.length; ii++) { - center_width += Math.max(DisplayUtil.width(this._items[ii].display), 35); + centerWidth += Math.max(DisplayUtil.width(this._items[ii].display), 35); } - center_width += (bar_space) * this._items.length + bar_space; + centerWidth += (barSpace) * this._items.length + barSpace; - return center_width; + return centerWidth; } private readonly _bg: Graphics; diff --git a/src/eterna/ui/AsyncProcessDialog.ts b/src/eterna/ui/AsyncProcessDialog.ts index 331391bd1..6599e39a7 100644 --- a/src/eterna/ui/AsyncProcessDialog.ts +++ b/src/eterna/ui/AsyncProcessDialog.ts @@ -1,13 +1,13 @@ -import {Point} from "pixi.js"; -import {Flashbang} from "flashbang/core"; -import {AlphaTask, RepeatingTask, SerialTask} from "flashbang/tasks"; -import {Easing} from "flashbang/util"; -import {Fonts} from "eterna/util"; -import Dialog from "./Dialog"; +import {Point} from 'pixi.js'; +import {Flashbang} from 'flashbang/core'; +import {AlphaTask, RepeatingTask, SerialTask} from 'flashbang/tasks'; +import {Easing} from 'flashbang/util'; +import {Fonts} from 'eterna/util'; +import Dialog from './Dialog'; /** Dims the screen and shows a notification text that fades in and out */ export default class AsyncProcessDialog extends Dialog { - public constructor(text: string) { + constructor(text: string) { super(); this._text = text; } diff --git a/src/eterna/ui/Band.ts b/src/eterna/ui/Band.ts index b5c1fc1e0..0ce171676 100644 --- a/src/eterna/ui/Band.ts +++ b/src/eterna/ui/Band.ts @@ -1,11 +1,11 @@ import { Graphics, Matrix, Point, Sprite, Text, Texture -} from "pixi.js"; -import {Updatable} from "flashbang/core"; -import {ContainerObject} from "flashbang/objects"; -import {ColorUtil, MathUtil, TextureUtil} from "flashbang/util"; -import {BitmapManager, Bitmaps} from "eterna/resources"; -import {Fonts} from "eterna/util"; +} from 'pixi.js'; +import {Updatable} from 'flashbang/core'; +import {ContainerObject} from 'flashbang/objects'; +import {ColorUtil, MathUtil, TextureUtil} from 'flashbang/util'; +import {BitmapManager, Bitmaps} from 'eterna/resources'; +import {Fonts} from 'eterna/util'; type ColorMatrixFilter = PIXI.filters.ColorMatrixFilter; @@ -26,9 +26,9 @@ export default class Band extends ContainerObject implements Updatable { this._st1 = new Sprite(); this.container.addChild(this._st1); - let score_text: Text = Fonts.arial("", 10).bold().build(); - score_text.position = new Point(2, 19); - this.container.addChild(score_text); + let scoreText: Text = Fonts.arial('', 10).bold().build(); + scoreText.position = new Point(2, 19); + this.container.addChild(scoreText); this.strength = strength; } @@ -52,12 +52,12 @@ export default class Band extends ContainerObject implements Updatable { this._startTime = dt; } - let pair_r: number = Math.cos((dt - this._startTime) * 4) * this._movDist + this._midDist; + let pairR: number = Math.cos((dt - this._startTime) * 4) * this._movDist + this._midDist; - this._st0.x = -pair_r; + this._st0.x = -pairR; this._st0.y = 0; - this._st1.x = pair_r; + this._st1.x = pairR; this._st1.y = 0; } diff --git a/src/eterna/ui/BaseGamePanel.ts b/src/eterna/ui/BaseGamePanel.ts index 384e07651..acf87d825 100644 --- a/src/eterna/ui/BaseGamePanel.ts +++ b/src/eterna/ui/BaseGamePanel.ts @@ -1,7 +1,7 @@ -import {ContainerObject} from "flashbang/objects"; +import {ContainerObject} from 'flashbang/objects'; export default abstract class BaseGamePanel extends ContainerObject { public abstract setSize(width: number, height: number): void; public abstract set title(title: string); - public abstract get titleHeight(): number + public abstract get titleHeight(): number; } diff --git a/src/eterna/ui/ConfirmDialog.ts b/src/eterna/ui/ConfirmDialog.ts index f291d0d0b..5e8e688e2 100644 --- a/src/eterna/ui/ConfirmDialog.ts +++ b/src/eterna/ui/ConfirmDialog.ts @@ -1,15 +1,15 @@ -import {Point} from "pixi.js"; -import {Flashbang, HAlign} from "flashbang/core"; -import {HLayoutContainer, VLayoutContainer} from "flashbang/layout"; -import {AlphaTask} from "flashbang/tasks"; -import {Fonts} from "eterna/util"; -import Dialog, {DialogCanceledError} from "./Dialog"; -import GameButton from "./GameButton"; -import GamePanel, {GamePanelType} from "./GamePanel"; -import HTMLTextObject from "./HTMLTextObject"; +import {Point} from 'pixi.js'; +import {Flashbang, HAlign} from 'flashbang/core'; +import {HLayoutContainer, VLayoutContainer} from 'flashbang/layout'; +import {AlphaTask} from 'flashbang/tasks'; +import {Fonts} from 'eterna/util'; +import Dialog, {DialogCanceledError} from './Dialog'; +import GameButton from './GameButton'; +import GamePanel, {GamePanelType} from './GamePanel'; +import HTMLTextObject from './HTMLTextObject'; export default class ConfirmDialog extends Dialog { - public constructor(prompt: string, promptIsHTML: boolean = false) { + constructor(prompt: string, promptIsHTML: boolean = false) { super(); this._prompt = prompt; this._useHTML = promptIsHTML; @@ -35,7 +35,7 @@ export default class ConfirmDialog extends Dialog { super.added(); let panel = new GamePanel(GamePanelType.NORMAL, 1.0, 0x152843, 0.27, 0xC0DCE7); - panel.title = "Are you sure?"; + panel.title = 'Are you sure?'; this.addObject(panel, this.container); let panelLayout = new VLayoutContainer(0, HAlign.CENTER); @@ -58,11 +58,11 @@ export default class ConfirmDialog extends Dialog { panelLayout.addVSpacer(10); panelLayout.addChild(buttonLayout); - let yesButton: GameButton = new GameButton().label("Yes", 16); + let yesButton: GameButton = new GameButton().label('Yes', 16); panel.addObject(yesButton, buttonLayout); yesButton.clicked.connect(() => this.close(true)); - let noButton: GameButton = new GameButton().label("No", 16); + let noButton: GameButton = new GameButton().label('No', 16); panel.addObject(noButton, buttonLayout); noButton.clicked.connect(() => this.close(false)); diff --git a/src/eterna/ui/ConstraintBox.ts b/src/eterna/ui/ConstraintBox.ts index cb53f15e4..862b21f12 100644 --- a/src/eterna/ui/ConstraintBox.ts +++ b/src/eterna/ui/ConstraintBox.ts @@ -1,31 +1,31 @@ -import MultiStyleText from "pixi-multistyle-text"; +import MultiStyleText from 'pixi-multistyle-text'; import { Container, Graphics, Point, Sprite, Text, Texture -} from "pixi.js"; -import {HAlign, VAlign} from "flashbang/core"; -import {ContainerObject, Enableable, SceneObject} from "flashbang/objects"; +} from 'pixi.js'; +import {HAlign, VAlign} from 'flashbang/core'; +import {ContainerObject, Enableable, SceneObject} from 'flashbang/objects'; import { AlphaTask, DelayTask, LocationTask, ParallelTask, ScaleTask, SerialTask, VisibleTask -} from "flashbang/tasks"; +} from 'flashbang/tasks'; import { DisplayUtil, Easing, StyledTextBuilder, TextureUtil -} from "flashbang/util"; -import {RegistrationGroup} from "signals"; -import EPars from "eterna/EPars"; -import {ConstraintType} from "eterna/puzzle"; -import {BitmapManager, Bitmaps} from "eterna/resources"; -import {Fonts} from "eterna/util"; -import Band from "./Band"; -import PoseThumbnail, {PoseThumbnailType} from "./PoseThumbnail"; -import TextBalloon from "./TextBalloon"; +} from 'flashbang/util'; +import {RegistrationGroup} from 'signals'; +import EPars from 'eterna/EPars'; +import {ConstraintType} from 'eterna/puzzle'; +import {BitmapManager, Bitmaps} from 'eterna/resources'; +import {Fonts} from 'eterna/util'; +import Band from './Band'; +import PoseThumbnail, {PoseThumbnailType} from './PoseThumbnail'; +import TextBalloon from './TextBalloon'; export enum ConstraintBoxType { - DEFAULT = "DEFAULT", - MISSION_SCREEN = "MISSION_SCREEN" // slightly minimized, requirements text on the right + DEFAULT = 'DEFAULT', + MISSION_SCREEN = 'MISSION_SCREEN' // slightly minimized, requirements text on the right } export default class ConstraintBox extends ContainerObject implements Enableable { - public constructor(type: ConstraintBoxType = ConstraintBoxType.DEFAULT) { + constructor(type: ConstraintBoxType = ConstraintBoxType.DEFAULT) { super(); this._boxType = type; @@ -80,43 +80,43 @@ export default class ConstraintBox extends ContainerObject implements Enableable this._enlarged = false; - this._valText = new MultiStyleText("", { + this._valText = new MultiStyleText('', { default: { fontFamily: Fonts.ARIAL, fontSize: 18, fill: 0xffffff, - fontStyle: "bold", + fontStyle: 'bold', letterSpacing: -0.5 } }); this._valText.visible = false; this.container.addChild(this._valText); - this._bigText = new MultiStyleText("", { + this._bigText = new MultiStyleText('', { default: { fontFamily: Fonts.ARIAL, fontSize: 23, fill: 0xffffff, - fontStyle: "bold", + fontStyle: 'bold', letterSpacing: -0.5 } }); this._bigText.visible = false; this.container.addChild(this._bigText); - this._noText = Fonts.arial("NO", 16).color(0xffffff).bold().letterSpacing(-0.5) + this._noText = Fonts.arial('NO', 16).color(0xffffff).bold().letterSpacing(-0.5) .build(); this._noText.position = new Point(35, 0); this._noText.visible = false; this.container.addChild(this._noText); - this._stateText = Fonts.arial("", 18).color(0xffffff).bold().letterSpacing(-0.5) + this._stateText = Fonts.arial('', 18).color(0xffffff).bold().letterSpacing(-0.5) .build(); this._stateText.position = new Point(3, 45); this._stateText.visible = false; this.container.addChild(this._stateText); - this._reqClarifyText = new MultiStyleText("", { + this._reqClarifyText = new MultiStyleText('', { default: { fontFamily: Fonts.ARIAL, fontSize: 11, @@ -128,7 +128,7 @@ export default class ConstraintBox extends ContainerObject implements Enableable this._reqClarifyText.visible = false; this.container.addChild(this._reqClarifyText); - this._reqStatTxt = new MultiStyleText("", { + this._reqStatTxt = new MultiStyleText('', { default: { fontFamily: Fonts.ARIAL, fontSize: 11, @@ -158,7 +158,7 @@ export default class ConstraintBox extends ContainerObject implements Enableable this.container.addChild(this._flag); if (this._boxType === ConstraintBoxType.MISSION_SCREEN) { - this._sideTxt = new MultiStyleText("", { + this._sideTxt = new MultiStyleText('', { default: { fontFamily: Fonts.STDFONT_REGULAR, fontSize: 16, @@ -227,41 +227,43 @@ export default class ConstraintBox extends ContainerObject implements Enableable return this._constraintType; } - public getWrongPairs(native_pairs: number[], target_pairs: number[], structure_constraints: any[], satisfied: boolean): number[] { - let wrong_pairs: number[] = new Array(native_pairs.length); + public getWrongPairs( + naturalPairs: number[], targetPairs: number[], structureConstraints: any[], satisfied: boolean + ): number[] { + let wrongPairs: number[] = new Array(naturalPairs.length); if (this._constraintType === ConstraintType.SHAPE) { - for (let ii = 0; ii < wrong_pairs.length; ii++) { - wrong_pairs[ii] = -1; + for (let ii = 0; ii < wrongPairs.length; ii++) { + wrongPairs[ii] = -1; } - for (let ii = 0; ii < wrong_pairs.length; ii++) { - if (native_pairs[ii] !== target_pairs[ii]) { - if (structure_constraints == null || structure_constraints[ii]) { - wrong_pairs[ii] = 1; + for (let ii = 0; ii < wrongPairs.length; ii++) { + if (naturalPairs[ii] !== targetPairs[ii]) { + if (structureConstraints == null || structureConstraints[ii]) { + wrongPairs[ii] = 1; } else { - wrong_pairs[ii] = 0; + wrongPairs[ii] = 0; } - } else if (structure_constraints == null || structure_constraints[ii]) { - wrong_pairs[ii] = -1; + } else if (structureConstraints == null || structureConstraints[ii]) { + wrongPairs[ii] = -1; } else { - wrong_pairs[ii] = 0; + wrongPairs[ii] = 0; } } } else if (this._constraintType === ConstraintType.ANTISHAPE) { - for (let ii = 0; ii < wrong_pairs.length; ii++) { - wrong_pairs[ii] = 0; + for (let ii = 0; ii < wrongPairs.length; ii++) { + wrongPairs[ii] = 0; } - for (let ii = 0; ii < wrong_pairs.length; ii++) { - if (structure_constraints == null || structure_constraints[ii]) { + for (let ii = 0; ii < wrongPairs.length; ii++) { + if (structureConstraints == null || structureConstraints[ii]) { if (satisfied) { - wrong_pairs[ii] = -1; + wrongPairs[ii] = -1; } else { - wrong_pairs[ii] = 1; + wrongPairs[ii] = 1; } } } } - return wrong_pairs; + return wrongPairs; } public set flagged(vis: boolean) { @@ -330,17 +332,17 @@ export default class ConstraintBox extends ContainerObject implements Enableable this._reqStatTxt.visible = true; if (isMissionScreen) { - tooltip.pushStyle("altTextMain"); + tooltip.pushStyle('altTextMain'); } tooltip.append(`You must have ${val.toString()} or `); if (isMissionScreen) { - tooltip.append("more", "altText"); + tooltip.append('more', 'altText'); } else { - tooltip.append("more"); + tooltip.append('more'); } - tooltip.append("boosted loops."); + tooltip.append('boosted loops.'); if (isMissionScreen) { tooltip.popStyle(); @@ -361,23 +363,23 @@ export default class ConstraintBox extends ContainerObject implements Enableable this._reqStatTxt.visible = true; if (isMissionScreen) { - tooltip.pushStyle("altTextMain"); + tooltip.pushStyle('altTextMain'); } - tooltip.append("You must have"); + tooltip.append('You must have'); if (isMissionScreen) { - tooltip.append(" no ", "altText"); + tooltip.append(' no ', 'altText'); } else { - tooltip.append(" no "); + tooltip.append(' no '); } - tooltip.append(`${EPars.getColoredLetter("U")}-${EPars.getColoredLetter("G")} pairs.`); + tooltip.append(`${EPars.getColoredLetter('U')}-${EPars.getColoredLetter('G')} pairs.`); if (isMissionScreen) { tooltip.popStyle(); } - this._reqClarifyText.text = "NO UG PAIRS"; + this._reqClarifyText.text = 'NO UG PAIRS'; this._reqStatTxt.text = stat.toString(); this._req.texture = isMissionScreen @@ -392,17 +394,17 @@ export default class ConstraintBox extends ContainerObject implements Enableable this._reqStatTxt.visible = true; if (isMissionScreen) { - tooltip.pushStyle("altTextMain"); + tooltip.pushStyle('altTextMain'); } tooltip.append(`You must have ${val.toString()} or `); if (isMissionScreen) { - tooltip.append("more ", "altText"); + tooltip.append('more ', 'altText'); } else { - tooltip.append("more "); + tooltip.append('more '); } - tooltip.append(`${EPars.getColoredLetter("U")}-${EPars.getColoredLetter("G")} pairs.`); + tooltip.append(`${EPars.getColoredLetter('U')}-${EPars.getColoredLetter('G')} pairs.`); if (isMissionScreen) { tooltip.popStyle(); } @@ -424,24 +426,24 @@ export default class ConstraintBox extends ContainerObject implements Enableable this._reqStatTxt.visible = true; if (isMissionScreen) { - tooltip.pushStyle("altTextMain"); + tooltip.pushStyle('altTextMain'); } - tooltip.append("You must have "); + tooltip.append('You must have '); - let newClarifyText = ""; + let newClarifyText = ''; if (constraintType === ConstraintType.GCMIN) { tooltip.append(`${val.toString()} or more`); newClarifyText += `${(Number(val)).toString()} OR MORE`; } else if (constraintType === ConstraintType.GC) { - tooltip.append("at most", "altText").append(` ${(Number(val)).toString()}`); + tooltip.append('at most', 'altText').append(` ${(Number(val)).toString()}`); newClarifyText += `${(Number(val)).toString()} OR FEWER`; } else if (constraintType === ConstraintType.NOGC) { - tooltip.append("no"); - newClarifyText += "NO GC PAIRS"; + tooltip.append('no'); + newClarifyText += 'NO GC PAIRS'; } - tooltip.append(` ${EPars.getColoredLetter("G")}-${EPars.getColoredLetter("C")} pairs.`); + tooltip.append(` ${EPars.getColoredLetter('G')}-${EPars.getColoredLetter('C')} pairs.`); if (isMissionScreen) { tooltip.popStyle(); } @@ -467,19 +469,19 @@ export default class ConstraintBox extends ContainerObject implements Enableable this._reqStatTxt.visible = true; if (isMissionScreen) { - tooltip.pushStyle("altTextMain"); + tooltip.pushStyle('altTextMain'); } - tooltip.append("You must have "); + tooltip.append('You must have '); - let newClarifyText = ""; + let newClarifyText = ''; if (constraintType === ConstraintType.AU) { tooltip.append(`${val.toString()} or more`); newClarifyText += `${(Number(val)).toString()} OR MORE`; } else if (constraintType === ConstraintType.AUMAX) { - tooltip.append("at most", "altText").append((Number(val)).toString()); + tooltip.append('at most', 'altText').append((Number(val)).toString()); newClarifyText += `${(Number(val)).toString()} OR FEWER`; } - tooltip.append(` ${EPars.getColoredLetter("A")}-${EPars.getColoredLetter("U")} pairs.`); + tooltip.append(` ${EPars.getColoredLetter('A')}-${EPars.getColoredLetter('U')} pairs.`); if (isMissionScreen) { tooltip.popStyle(); } @@ -502,28 +504,34 @@ export default class ConstraintBox extends ContainerObject implements Enableable this._stateText.visible = true; this._stateText.text = val.index + 1; } else { - tooltip.append("Your RNA must fold into the outlined structure."); + tooltip.append('Your RNA must fold into the outlined structure.'); } - let target_pairs: number[] = val.target; - let native_pairs: number[] = val.native; - let {structure_constraints} = val; - let wrong_pairs: number[] = this.getWrongPairs(native_pairs, target_pairs, structure_constraints, satisfied); + let targetPairs: number[] = val.target; + let naturalPairs: number[] = val.native; + let {structureConstraints} = val; + let wrongPairs: number[] = this.getWrongPairs(naturalPairs, targetPairs, structureConstraints, satisfied); - let sequence: number[] = new Array(native_pairs.length); - for (let ii = 0; ii < wrong_pairs.length; ii++) { + let sequence: number[] = new Array(naturalPairs.length); + for (let ii = 0; ii < wrongPairs.length; ii++) { sequence[ii] = EPars.RNABASE_ADENINE; } if (this._enlarged) { this._smallThumbnail.visible = false; this._bigThumbnail.visible = true; - PoseThumbnail.drawToSprite(this._bigThumbnail, sequence, target_pairs, 7, PoseThumbnailType.WRONG_COLORED, 0, wrong_pairs, false, 0); + PoseThumbnail.drawToSprite( + this._bigThumbnail, sequence, targetPairs, + 7, PoseThumbnailType.WRONG_COLORED, 0, wrongPairs, false, 0 + ); DisplayUtil.center(this._bigThumbnail, this._bg); } else { this._bigThumbnail.visible = false; this._smallThumbnail.visible = true; - PoseThumbnail.drawToSprite(this._smallThumbnail, sequence, target_pairs, 3, PoseThumbnailType.WRONG_COLORED, 0, wrong_pairs, false, 0); + PoseThumbnail.drawToSprite( + this._smallThumbnail, sequence, targetPairs, + 3, PoseThumbnailType.WRONG_COLORED, 0, wrongPairs, false, 0 + ); DisplayUtil.center(this._smallThumbnail, this._bg); } @@ -537,28 +545,34 @@ export default class ConstraintBox extends ContainerObject implements Enableable this._stateText.visible = true; this._stateText.text = val.index + 1; } else { - tooltip.append("Your RNA must NOT have the structure in white outline."); + tooltip.append('Your RNA must NOT have the structure in white outline.'); } - let target_pairs: number[] = val.target; - let native_pairs: number[] = val.native; - let {structure_constraints} = val; - let wrong_pairs: number[] = this.getWrongPairs(native_pairs, target_pairs, structure_constraints, satisfied); + let targetPairs: number[] = val.target; + let naturalPairs: number[] = val.native; + let {structureConstraints} = val; + let wrongPairs: number[] = this.getWrongPairs(naturalPairs, targetPairs, structureConstraints, satisfied); - let sequence: number[] = new Array(native_pairs.length); - for (let ii = 0; ii < wrong_pairs.length; ii++) { + let sequence: number[] = new Array(naturalPairs.length); + for (let ii = 0; ii < wrongPairs.length; ii++) { sequence[ii] = EPars.RNABASE_ADENINE; } if (this._enlarged) { this._smallThumbnail.visible = false; this._bigThumbnail.visible = true; - PoseThumbnail.drawToSprite(this._bigThumbnail, sequence, target_pairs, 7, PoseThumbnailType.WRONG_COLORED, 0, wrong_pairs, false, 0); + PoseThumbnail.drawToSprite( + this._bigThumbnail, sequence, targetPairs, + 7, PoseThumbnailType.WRONG_COLORED, 0, wrongPairs, false, 0 + ); DisplayUtil.center(this._bigThumbnail, this._bg); } else { this._bigThumbnail.visible = false; this._smallThumbnail.visible = true; - PoseThumbnail.drawToSprite(this._smallThumbnail, sequence, target_pairs, 3, PoseThumbnailType.WRONG_COLORED, 0, wrong_pairs, false, 0); + PoseThumbnail.drawToSprite( + this._smallThumbnail, sequence, targetPairs, + 3, PoseThumbnailType.WRONG_COLORED, 0, wrongPairs, false, 0 + ); DisplayUtil.center(this._smallThumbnail, this._bg); } @@ -569,25 +583,25 @@ export default class ConstraintBox extends ContainerObject implements Enableable this._reqClarifyText.visible = true; if (isMissionScreen) { - tooltip.pushStyle("altTextMain"); + tooltip.pushStyle('altTextMain'); } tooltip.append(`In state ${(Number(val.index) + 1).toString()}, your RNA must:\n`); let clarifyTextBuilder = new StyledTextBuilder(this._reqClarifyText.style); for (let ii = 0; ii < val.bind.length; ii++) { - tooltip.append("- "); + tooltip.append('- '); if (isMissionScreen) { - tooltip.pushStyle("altText"); + tooltip.pushStyle('altText'); } - tooltip.append(val.bind[ii] ? "bind" : "NOT bind"); + tooltip.append(val.bind[ii] ? 'bind' : 'NOT bind'); if (isMissionScreen) { tooltip.popStyle(); } - tooltip.append(` with ${val.oligo_name[ii]}\n`); + tooltip.append(` with ${val.oligoNames[ii]}\n`); if (ii > 0) { - clarifyTextBuilder.append("\u2003"); + clarifyTextBuilder.append('\u2003'); } clarifyTextBuilder.append(` ${val.label[ii]}`, {fill: val.bind[ii] ? 0xffffff : 0x808080}); @@ -615,9 +629,9 @@ export default class ConstraintBox extends ContainerObject implements Enableable this._bgGraphics.lineTo((111 + tw) * 0.5, 27); for (let ii = 0; ii < val.bind.length; ii++) { - let ctrl_y: number = (val.bind[ii] ? 22 : 14); - this._bgGraphics.moveTo(orig + (ii * 2) * step, ctrl_y); - this._bgGraphics.lineTo(orig + (ii * 2 + 1) * step, ctrl_y); + let ctrlY: number = (val.bind[ii] ? 22 : 14); + this._bgGraphics.moveTo(orig + (ii * 2) * step, ctrlY); + this._bgGraphics.lineTo(orig + (ii * 2 + 1) * step, ctrlY); } this._bg.visible = true; @@ -630,15 +644,15 @@ export default class ConstraintBox extends ContainerObject implements Enableable || constraintType === ConstraintType.G || constraintType === ConstraintType.GMAX || constraintType === ConstraintType.U || constraintType === ConstraintType.UMAX) { if (isMissionScreen) { - tooltip.pushStyle("altTextMain"); + tooltip.pushStyle('altTextMain'); } - tooltip.append("You must have "); + tooltip.append('You must have '); let letter: string = constraintType.substr(0, 1); if (constraintType === letter) { tooltip.append(`${val.toString()} or more`); } else { - tooltip.append("at most", "altText").append(` ${(Number(val)).toString()}`); + tooltip.append('at most', 'altText').append(` ${(Number(val)).toString()}`); } tooltip.append(` ${EPars.getColoredLetter(letter)}s.`); if (isMissionScreen) { @@ -667,7 +681,7 @@ export default class ConstraintBox extends ContainerObject implements Enableable this._reqStatTxt.visible = true; if (isMissionScreen) { - tooltip.pushStyle("altTextMain"); + tooltip.pushStyle('altTextMain'); } tooltip.append(`You must have ${val.toString()} or more pairs`); if (isMissionScreen) { @@ -766,18 +780,18 @@ export default class ConstraintBox extends ContainerObject implements Enableable tooltip.append(`You must have a stack with ${val.toString()} or more pairs.`); tooltip.apply(this._bigText); - } else if (constraintType.lastIndexOf("CONSECUTIVE_") >= 0) { + } else if (constraintType.lastIndexOf('CONSECUTIVE_') >= 0) { this._valText.visible = true; this._reqClarifyText.visible = true; this._reqStatTxt.visible = true; if (isMissionScreen) { - tooltip.pushStyle("altTextMain"); + tooltip.pushStyle('altTextMain'); } - tooltip.append("You must have "); + tooltip.append('You must have '); let letter: string = constraintType.substr(12, 1); - tooltip.append("at most", "altText") + tooltip.append('at most', 'altText') .append(` ${(Number(val) - 1).toString()} ${EPars.getColoredLetter(letter)}s in a row.`); if (isMissionScreen) { tooltip.popStyle(); @@ -811,44 +825,44 @@ export default class ConstraintBox extends ContainerObject implements Enableable fill: 0xC0DCE7, letterSpacing: -0.5 }); - noGoodBuilder.addStyle("redText", {fill: 0xff0000}); + noGoodBuilder.addStyle('redText', {fill: 0xff0000}); - if (!(val.g_count < val.g_max)) { - noGoodBuilder.append((val.g_count).toString(), "redText").append("G"); + if (!(val.gCount < val.gMax)) { + noGoodBuilder.append((val.gCount).toString(), 'redText').append('G'); } - if (!(val.c_count < val.c_max)) { - noGoodBuilder.append((val.c_count).toString(), "redText").append("C"); + if (!(val.cCount < val.cMax)) { + noGoodBuilder.append((val.cCount).toString(), 'redText').append('C'); } - if (!(val.a_count < val.a_max)) { - noGoodBuilder.append((val.a_count).toString(), "redText").append("A"); + if (!(val.aCount < val.aMax)) { + noGoodBuilder.append((val.aCount).toString(), 'redText').append('A'); } this._reqStatTxt.visible = true; if (noGoodBuilder.text.length > 0) { noGoodBuilder.apply(this._reqStatTxt); } else { - this._reqStatTxt.text = "OK"; + this._reqStatTxt.text = 'OK'; } } else { this._reqStatTxt.visible = false; } if (isMissionScreen) { - tooltip.pushStyle("altTextMain"); + tooltip.pushStyle('altTextMain'); } - tooltip.append("You must have:\n") - .append("- ").append("at most", "altText").append(` ${val.g_max - 1} `) - .append(`${EPars.getColoredLetter("G")}s in a row\n`) - .append("- ") - .append("at most", "altText") - .append(` ${val.c_max - 1} `) - .append(`${EPars.getColoredLetter("C")}s in a row\n`) - .append("- ") - .append("at most", "altText") - .append(` ${val.a_max - 1} `) - .append(`${EPars.getColoredLetter("A")}s in a row\n`); + tooltip.append('You must have:\n') + .append('- ').append('at most', 'altText').append(` ${val.gMax - 1} `) + .append(`${EPars.getColoredLetter('G')}s in a row\n`) + .append('- ') + .append('at most', 'altText') + .append(` ${val.cMax - 1} `) + .append(`${EPars.getColoredLetter('C')}s in a row\n`) + .append('- ') + .append('at most', 'altText') + .append(` ${val.aMax - 1} `) + .append(`${EPars.getColoredLetter('A')}s in a row\n`); if (isMissionScreen) { tooltip.popStyle(); } @@ -858,22 +872,22 @@ export default class ConstraintBox extends ContainerObject implements Enableable this._reqClarifyText.visible = true; if (isMissionScreen) { - tooltip.pushStyle("altTextMain"); + tooltip.pushStyle('altTextMain'); } - tooltip.append("You must have a "); + tooltip.append('You must have a '); if (isMissionScreen) { - tooltip.append("unique ", "altText"); + tooltip.append('unique ', 'altText'); } else { - tooltip.append("unique "); + tooltip.append('unique '); } - tooltip.append("barcode."); + tooltip.append('barcode.'); if (isMissionScreen) { tooltip.popStyle(); } - this._reqClarifyText.text = "MUST BE UNIQUE"; + this._reqClarifyText.text = 'MUST BE UNIQUE'; this._req.texture = isMissionScreen ? BitmapManager.getBitmap(Bitmaps.NovaBarcodeMissionReq) @@ -881,30 +895,30 @@ export default class ConstraintBox extends ContainerObject implements Enableable this._req.visible = true; this._outline.visible = true; - } else if (constraintType.lastIndexOf("OLIGO_") >= 0) { + } else if (constraintType.lastIndexOf('OLIGO_') >= 0) { this._reqClarifyText.visible = true; - let binder: boolean = (constraintType.lastIndexOf("UNBOUND") < 0); + let binder: boolean = (constraintType.lastIndexOf('UNBOUND') < 0); if (isMissionScreen) { - tooltip.pushStyle("altTextMain"); + tooltip.pushStyle('altTextMain'); } tooltip.append(`In state ${(Number(val) + 1).toString()}, the oligo must `); if (isMissionScreen) { - tooltip.pushStyle("altText"); + tooltip.pushStyle('altText'); } - tooltip.append(binder ? "bind" : "NOT bind"); + tooltip.append(binder ? 'bind' : 'NOT bind'); if (isMissionScreen) { tooltip.popStyle(); } - tooltip.append(" with your RNA."); + tooltip.append(' with your RNA.'); if (isMissionScreen) { tooltip.popStyle(); } - this._reqClarifyText.text = binder ? "MUST BIND" : "MAY NOT BIND"; + this._reqClarifyText.text = binder ? 'MUST BIND' : 'MAY NOT BIND'; - const ico = binder ? "Bound" : "Unbound"; + const ico = binder ? 'Bound' : 'Unbound'; this._req.texture = isMissionScreen ? BitmapManager.getBitmapNamed(`Nova${ico}OligoMissionReq`) : BitmapManager.getBitmapNamed(`Nova${ico}OligoReq`); @@ -925,10 +939,10 @@ export default class ConstraintBox extends ContainerObject implements Enableable this._bgGraphics.drawRoundedRect(0, 0, 111, isMissionScreen ? 55 : 75, 20); this._bgGraphics.endFill(); - let {data_png} = val; - if (data_png != null) { + let dataPNG = val['dataPNG']; + if (dataPNG != null) { this._icon.visible = true; - TextureUtil.fromBase64PNG(data_png).then((tex) => { + TextureUtil.fromBase64PNG(dataPNG).then((tex) => { this._icon.texture = tex; this._icon.position = new Point((111 - this._icon.width) * 0.5, 2); }); @@ -969,7 +983,9 @@ export default class ConstraintBox extends ContainerObject implements Enableable this._outline.visible = false; tooltip.apply(this._sideTxt); if (this._req.visible) { - this._sideTxt.position = new Point(this._req.width + 18, this._req.height / 2 - this._sideTxt.height / 2); + this._sideTxt.position = new Point( + this._req.width + 18, this._req.height / 2 - this._sideTxt.height / 2 + ); } else { this._sideTxt.position = new Point(111 + 18, 55 / 2 - this._sideTxt.height / 2); } @@ -1082,10 +1098,10 @@ export default class ConstraintBox extends ContainerObject implements Enableable private setTooltip(styledText: StyledTextBuilder, satisfied: boolean): void { if (!satisfied) { - styledText = styledText.clone().append("\n").append("Unsatisfied", {fill: 0xff0000}); + styledText = styledText.clone().append('\n').append('Unsatisfied', {fill: 0xff0000}); } - let balloon = new TextBalloon("", 0x0, 0.8); + let balloon = new TextBalloon('', 0x0, 0.8); balloon.styledText = styledText; this.setMouseOverObject(balloon); } @@ -1109,7 +1125,7 @@ export default class ConstraintBox extends ContainerObject implements Enableable this._mouseOverObject = obj; - const MOUSE_OVER_ANIM = "MouseOverAnim"; + const MOUSE_OVER_ANIM = 'MouseOverAnim'; let isMouseOver = false; this._mouseOverRegs = new RegistrationGroup(); @@ -1144,10 +1160,10 @@ export default class ConstraintBox extends ContainerObject implements Enableable letterSpacing: -0.5, wordWrap: true, wordWrapWidth: 250 - }).addStyle("altText", { + }).addStyle('altText', { fontFamily: Fonts.STDFONT_MEDIUM, leading: 10 - }).addStyle("altTextMain", { + }).addStyle('altTextMain', { fontFamily: Fonts.STDFONT_REGULAR, leading: 5 }); @@ -1198,8 +1214,8 @@ export default class ConstraintBox extends ContainerObject implements Enableable private _mouseOverRegs: RegistrationGroup; private _mouseOverObject: SceneObject; - private static readonly LOCATION_ANIM = "AnimateLocation"; - private static readonly BIG_TEXT_FADE_ANIM = "BigTextFadeAnim"; - private static readonly BACKLIGHT_ANIM = "BacklightAnim"; - private static readonly FGLOW_ANIM = "FGlowAnim"; + private static readonly LOCATION_ANIM = 'AnimateLocation'; + private static readonly BIG_TEXT_FADE_ANIM = 'BigTextFadeAnim'; + private static readonly BACKLIGHT_ANIM = 'BacklightAnim'; + private static readonly FGLOW_ANIM = 'FGlowAnim'; } diff --git a/src/eterna/ui/ContextMenu.ts b/src/eterna/ui/ContextMenu.ts index f96194fe7..58b212b45 100644 --- a/src/eterna/ui/ContextMenu.ts +++ b/src/eterna/ui/ContextMenu.ts @@ -1,15 +1,15 @@ -import {HAlign} from "flashbang/core"; -import {VLayoutContainer} from "flashbang/layout"; -import {ContainerObject} from "flashbang/objects"; -import {UnitSignal} from "signals"; -import GameButton from "./GameButton"; -import GamePanel, {GamePanelType} from "./GamePanel"; +import {HAlign} from 'flashbang/core'; +import {VLayoutContainer} from 'flashbang/layout'; +import {ContainerObject} from 'flashbang/objects'; +import {UnitSignal} from 'signals'; +import GameButton from './GameButton'; +import GamePanel, {GamePanelType} from './GamePanel'; export default class ContextMenu extends ContainerObject { /** Emitted when the user interacts with the menu. */ public readonly menuItemSelected = new UnitSignal(); - public constructor() { + constructor() { super(); this._panel = new GamePanel(GamePanelType.NORMAL, 1.0, 0x152843, 1.0, 0xffffff); diff --git a/src/eterna/ui/Dialog.ts b/src/eterna/ui/Dialog.ts index a2341e3c2..cafab8891 100644 --- a/src/eterna/ui/Dialog.ts +++ b/src/eterna/ui/Dialog.ts @@ -1,9 +1,9 @@ -import {Graphics} from "pixi.js"; -import {Flashbang} from "flashbang/core"; +import {Graphics} from 'pixi.js'; +import {Flashbang} from 'flashbang/core'; import { InputUtil, KeyboardListener, MouseWheelListener, DisplayObjectPointerTarget -} from "flashbang/input"; -import {ContainerObject} from "flashbang/objects"; +} from 'flashbang/input'; +import {ContainerObject} from 'flashbang/objects'; /** Dialogs that expose a "confirmed" promise will reject with this error if the dialog is canceled */ export class DialogCanceledError extends Error {} @@ -13,9 +13,9 @@ export default abstract class Dialog extends ContainerObject implements Keybo /** A Promise that will resolve when the dialog is closed. */ public readonly closed: Promise; - public constructor() { + constructor() { super(); - this.closed = new Promise(resolve => this._resolvePromise = resolve); + this.closed = new Promise((resolve) => { this._resolvePromise = resolve; }); } protected added() { diff --git a/src/eterna/ui/EternaMenu.ts b/src/eterna/ui/EternaMenu.ts index d9bbdb627..f1d6ec162 100644 --- a/src/eterna/ui/EternaMenu.ts +++ b/src/eterna/ui/EternaMenu.ts @@ -1,18 +1,18 @@ -import {Point} from "pixi.js"; -import {PointerCapture} from "flashbang/input"; -import {Enableable} from "flashbang/objects"; -import {DisplayUtil} from "flashbang/util"; -import GameButton from "./GameButton"; -import GamePanel, {GamePanelType} from "./GamePanel"; +import {Point} from 'pixi.js'; +import {PointerCapture} from 'flashbang/input'; +import {Enableable} from 'flashbang/objects'; +import {DisplayUtil} from 'flashbang/util'; +import GameButton from './GameButton'; +import GamePanel, {GamePanelType} from './GamePanel'; export enum EternaMenuStyle { DEFAULT = 0, PULLUP } export default class EternaMenu extends GamePanel implements Enableable { - public constructor(menu_style: EternaMenuStyle = EternaMenuStyle.DEFAULT) { + constructor(menuStyle: EternaMenuStyle = EternaMenuStyle.DEFAULT) { super(); - this._style = menu_style; + this._style = menuStyle; } protected added() { @@ -26,7 +26,7 @@ export default class EternaMenu extends GamePanel implements Enableable { if (url != null && url.length > 0) { menuButton.label(`${label}`, 12); menuButton.clicked.connect(() => { - window.open(url, "_self"); + window.open(url, '_self'); }); } else { menuButton.label(label, 12); @@ -47,14 +47,14 @@ export default class EternaMenu extends GamePanel implements Enableable { return this._menus.length - 1; } - public addSubMenuButton(menuIdx: number, itemButton: GameButton, at_top: boolean = false): void { + public addSubMenuButton(menuIdx: number, itemButton: GameButton, atTop: boolean = false): void { let menu: Menu = this._menus[menuIdx]; if (menu.itemButtons.indexOf(itemButton) >= 0) { return; } menu.panel.addObject(itemButton, menu.panel.container); - if (at_top) { + if (atTop) { menu.itemButtons.unshift(itemButton); } else { menu.itemButtons.push(itemButton); @@ -102,8 +102,8 @@ export default class EternaMenu extends GamePanel implements Enableable { } } - public getWidth(use_margin: boolean = true): number { - return this._menuWidth + (use_margin ? this._rightMargin : 0); + public getWidth(useMargin: boolean = true): number { + return this._menuWidth + (useMargin ? this._rightMargin : 0); } public get width(): number { @@ -166,7 +166,7 @@ export default class EternaMenu extends GamePanel implements Enableable { this._activeCapture = new PointerCapture(menu.panel.display); this._activeCapture.beginCapture((e) => { - if (e.type === "pointerdown") { + if (e.type === 'pointerdown') { // Wait a bit before closing, so that if we tapped the button, // we don't just reopen the flyout setTimeout(() => { menu.panel.display.visible = false; }, 100); @@ -187,7 +187,7 @@ export default class EternaMenu extends GamePanel implements Enableable { } private doLayout(): void { - if (this._menus.length == 0) { + if (this._menus.length === 0) { this.setSize(0, 0); return; } @@ -198,46 +198,46 @@ export default class EternaMenu extends GamePanel implements Enableable { continue; } - let height_walker = 7; - let width_walker = 0; + let heightWalker = 7; + let widthWalker = 0; for (let button of menu.itemButtons) { if (button == null) { continue; } - button.display.position = new Point(7, height_walker); - height_walker += DisplayUtil.height(button.display) + 7; - width_walker = Math.max(width_walker, DisplayUtil.width(button.display) + 14); + button.display.position = new Point(7, heightWalker); + heightWalker += DisplayUtil.height(button.display) + 7; + widthWalker = Math.max(widthWalker, DisplayUtil.width(button.display) + 14); } - menu.panel.setSize(width_walker, height_walker); + menu.panel.setSize(widthWalker, heightWalker); } let space: number = (this._style === EternaMenuStyle.PULLUP ? 1 : 10); - let width_offset: number = space; + let widthOffset: number = space; this._menuHeight = 0; for (let menu of this._menus) { let buttonWidth: number = menu.menuButton.container.width; let buttonHeight: number = menu.menuButton.container.height; - menu.menuButton.display.position = new Point(width_offset, 0); + menu.menuButton.display.position = new Point(widthOffset, 0); if (this._style === EternaMenuStyle.DEFAULT) { menu.panel.display.position = new Point(0, buttonHeight - 1); } else if (this._style === EternaMenuStyle.PULLUP) { menu.panel.display.position = new Point(0, -menu.panel.height); } - width_offset += buttonWidth + space; + widthOffset += buttonWidth + space; this._menuHeight = Math.max(this._menuHeight, buttonHeight); } let lastIdx = this._menus.length - 1; let lastButtonWidth = this._menus[lastIdx].menuButton.container.width; - this._menuWidth = (width_offset + space); + this._menuWidth = (widthOffset + space); this._rightMargin = Math.max(lastButtonWidth, this._menus[lastIdx].panel.width) - lastButtonWidth; - this.setSize(width_offset, this._menuHeight + 1); + this.setSize(widthOffset, this._menuHeight + 1); } private readonly _style: EternaMenuStyle; diff --git a/src/eterna/ui/EternaViewOptionsDialog.ts b/src/eterna/ui/EternaViewOptionsDialog.ts index b45abeadf..3b6e19792 100644 --- a/src/eterna/ui/EternaViewOptionsDialog.ts +++ b/src/eterna/ui/EternaViewOptionsDialog.ts @@ -1,21 +1,21 @@ -import {Point} from "pixi.js"; -import {HAlign, VAlign} from "flashbang/core"; -import {HLayoutContainer, VLayoutContainer} from "flashbang/layout"; -import {Setting} from "flashbang/settings"; -import {DisplayUtil} from "flashbang/util"; -import Eterna from "eterna/Eterna"; -import {Bitmaps} from "eterna/resources"; -import Dialog from "./Dialog"; -import GameButton from "./GameButton"; -import GameCheckbox from "./GameCheckbox"; -import GamePanel, {GamePanelType} from "./GamePanel"; +import {Point} from 'pixi.js'; +import {HAlign, VAlign} from 'flashbang/core'; +import {HLayoutContainer, VLayoutContainer} from 'flashbang/layout'; +import {Setting} from 'flashbang/settings'; +import {DisplayUtil} from 'flashbang/util'; +import Eterna from 'eterna/Eterna'; +import {Bitmaps} from 'eterna/resources'; +import Dialog from './Dialog'; +import GameButton from './GameButton'; +import GameCheckbox from './GameCheckbox'; +import GamePanel, {GamePanelType} from './GamePanel'; export enum EternaViewOptionsMode { PUZZLE = 0, PUZZLEMAKER, LAB } export default class EternaViewOptionsDialog extends Dialog { - public constructor(mode: EternaViewOptionsMode) { + constructor(mode: EternaViewOptionsMode) { super(); this._optionsMode = mode; } @@ -29,25 +29,25 @@ export default class EternaViewOptionsDialog extends Dialog { this.addObject(EternaViewOptionsDialog.createCheckbox(name, setting), settingsLayout); }; - bind(Eterna.settings.showNumbers, "Show nucleotides numbers (N)"); - bind(Eterna.settings.showLetters, "Show nucleotides letters"); - bind(Eterna.settings.displayFreeEnergies, "Display free energies for all structures (G)"); - bind(Eterna.settings.highlightRestricted, "Highlight restricted sequences"); - bind(Eterna.settings.showChat, "In-game chat"); - bind(Eterna.settings.simpleGraphics, "Use simpler, less animated graphics"); - bind(Eterna.settings.autohideToolbar, "Autohide toolbar"); + bind(Eterna.settings.showNumbers, 'Show nucleotides numbers (N)'); + bind(Eterna.settings.showLetters, 'Show nucleotides letters'); + bind(Eterna.settings.displayFreeEnergies, 'Display free energies for all structures (G)'); + bind(Eterna.settings.highlightRestricted, 'Highlight restricted sequences'); + bind(Eterna.settings.showChat, 'In-game chat'); + bind(Eterna.settings.simpleGraphics, 'Use simpler, less animated graphics'); + bind(Eterna.settings.autohideToolbar, 'Autohide toolbar'); if (this._optionsMode !== EternaViewOptionsMode.PUZZLEMAKER) { - bind(Eterna.settings.freezeButtonAlwaysVisible, "Freeze button always visible"); + bind(Eterna.settings.freezeButtonAlwaysVisible, 'Freeze button always visible'); } if (this._optionsMode !== EternaViewOptionsMode.PUZZLE) { - bind(Eterna.settings.multipleFoldingEngines, "Multiple folding engines"); + bind(Eterna.settings.multipleFoldingEngines, 'Multiple folding engines'); } if (this._optionsMode === EternaViewOptionsMode.LAB) { - bind(Eterna.settings.useContinuousColors, "Use continuous colors for the exp. data (advanced)"); - bind(Eterna.settings.useExtendedColors, "Use extended 4-color scale for the exp. data (advanced)"); - bind(Eterna.settings.displayAuxInfo, "Display auxiliary information about RNAs"); + bind(Eterna.settings.useContinuousColors, 'Use continuous colors for the exp. data (advanced)'); + bind(Eterna.settings.useExtendedColors, 'Use extended 4-color scale for the exp. data (advanced)'); + bind(Eterna.settings.displayAuxInfo, 'Display auxiliary information about RNAs'); } const NUM_VOLUME_BUTTONS = 5; @@ -85,14 +85,14 @@ export default class EternaViewOptionsDialog extends Dialog { let viewLayout = new VLayoutContainer(22, HAlign.CENTER); viewLayout.addChild(settingsLayout); - let okButton: GameButton = new GameButton().label("Done", 14); + let okButton: GameButton = new GameButton().label('Done', 14); this.addObject(okButton, viewLayout); okButton.clicked.connect(() => this.close(null)); viewLayout.layout(); let panel = new GamePanel(GamePanelType.NORMAL, 1, 0x152843, 0.27, 0xC0DCE7); - panel.title = "Game options"; + panel.title = 'Game options'; panel.setSize(viewLayout.width + 40, viewLayout.height + 40 + panel.titleHeight); this.addObject(panel, this.container); diff --git a/src/eterna/ui/FancyGamePanel.ts b/src/eterna/ui/FancyGamePanel.ts index 1ad60d004..21a76e7a2 100644 --- a/src/eterna/ui/FancyGamePanel.ts +++ b/src/eterna/ui/FancyGamePanel.ts @@ -1,13 +1,19 @@ -import {Graphics, Point, Text} from "pixi.js"; -import {Fonts} from "eterna/util"; -import BaseGamePanel from "./BaseGamePanel"; +import {Graphics, Point, Text} from 'pixi.js'; +import {Fonts} from 'eterna/util'; +import BaseGamePanel from './BaseGamePanel'; export enum FancyGamePanelType { NORMAL, INVISIBLE, NEW_NOVA } export default class FancyGamePanel extends BaseGamePanel { - constructor(type: FancyGamePanelType = FancyGamePanelType.NORMAL, alpha: number = 0.07, color: number = 0xffffff, outlineColor: number = 0xffffff, outlineAlpha: number = 0.2) { + constructor( + type: FancyGamePanelType = FancyGamePanelType.NORMAL, + alpha: number = 0.07, + color: number = 0xffffff, + outlineColor: number = 0xffffff, + outlineAlpha: number = 0.2 + ) { super(); this._background = new Graphics(); diff --git a/src/eterna/ui/FancyTextBalloon.ts b/src/eterna/ui/FancyTextBalloon.ts index 2b216dc35..0b4659c3a 100644 --- a/src/eterna/ui/FancyTextBalloon.ts +++ b/src/eterna/ui/FancyTextBalloon.ts @@ -1,15 +1,15 @@ -import {Point} from "pixi.js"; -import {HAlign, VAlign, Updatable} from "flashbang/core"; -import {Vector2} from "flashbang/geom"; -import {DisplayUtil} from "flashbang/util"; -import {Bitmaps} from "eterna/resources"; -import {RScriptArrow} from "eterna/rscript"; -import FancyGamePanel from "./FancyGamePanel"; -import GameButton from "./GameButton"; -import TextBalloon from "./TextBalloon"; +import {Point} from 'pixi.js'; +import {HAlign, VAlign, Updatable} from 'flashbang/core'; +import {Vector2} from 'flashbang/geom'; +import {DisplayUtil} from 'flashbang/util'; +import {Bitmaps} from 'eterna/resources'; +import {RScriptArrow} from 'eterna/rscript'; +import FancyGamePanel from './FancyGamePanel'; +import GameButton from './GameButton'; +import TextBalloon from './TextBalloon'; export default class FancyTextBalloon extends TextBalloon implements Updatable { - public constructor(balloonColor: number = 0xFFFFFF, balloonAlpha: number = 0.07, + constructor(balloonColor: number = 0xFFFFFF, balloonAlpha: number = 0.07, showOutline: boolean = false, outlineColor: number = 0xFFFFFF, outlineAlpha: number = 0.70) { super(null, balloonColor, balloonAlpha); @@ -45,8 +45,8 @@ export default class FancyTextBalloon extends TextBalloon implements Updatable { this.updateView(); } - public set fixedWidth(in_width: number) { - this._fixedWidth = in_width; + public set fixedWidth(inWidth: number) { + this._fixedWidth = inWidth; this._hasFixedWidth = true; if (this.isLiveObject) { diff --git a/src/eterna/ui/FixedWidthTextField.ts b/src/eterna/ui/FixedWidthTextField.ts index f3fdf44e6..078c52293 100644 --- a/src/eterna/ui/FixedWidthTextField.ts +++ b/src/eterna/ui/FixedWidthTextField.ts @@ -1,15 +1,16 @@ import { Container, Graphics, Text, TextStyle -} from "pixi.js"; -import {HAlign} from "flashbang/core"; +} from 'pixi.js'; +import {HAlign} from 'flashbang/core'; +import {Assert} from 'flashbang/util'; export default class FixedWidthTextField extends Container { - public constructor(text: string, style: TextStyle, width: number, hAlign: HAlign = HAlign.LEFT) { + constructor(text: string, style: TextStyle, width: number, hAlign: HAlign = HAlign.LEFT) { super(); this._width = width; this._halign = hAlign; - this._tf = new Text("", style); + this._tf = new Text('', style); this.addChild(new Graphics().beginFill(0x0, 0).drawRect(0, 0, width, this._tf.height).endFill()); this.addChild(this._tf); @@ -28,15 +29,17 @@ export default class FixedWidthTextField extends Container { } switch (this._halign) { - case HAlign.LEFT: - this._tf.x = 0; - break; - case HAlign.CENTER: - this._tf.x = (this._width - this._tf.width) * 0.5; - break; - case HAlign.RIGHT: - this._tf.x = this._width - this._tf.width; - break; + case HAlign.LEFT: + this._tf.x = 0; + break; + case HAlign.CENTER: + this._tf.x = (this._width - this._tf.width) * 0.5; + break; + case HAlign.RIGHT: + this._tf.x = this._width - this._tf.width; + break; + default: + Assert.unreachable(this._halign); } } diff --git a/src/eterna/ui/GameButton.ts b/src/eterna/ui/GameButton.ts index 7c7ae3c91..70ce2ce67 100644 --- a/src/eterna/ui/GameButton.ts +++ b/src/eterna/ui/GameButton.ts @@ -1,19 +1,19 @@ import { Container, DisplayObject, Graphics, Point, Rectangle, Sprite, Text, Texture -} from "pixi.js"; -import {HAlign, VAlign} from "flashbang/core"; -import {KeyboardEventType, KeyboardListener} from "flashbang/input"; -import {Button, ButtonState} from "flashbang/objects"; -import {DisplayUtil, TextBuilder} from "flashbang/util"; -import {Registration, Registrations, Value} from "signals"; -import {ROPWait, RScriptUIElementID} from "eterna/rscript"; -import {Fonts} from "eterna/util"; -import Tooltips from "./Tooltips"; +} from 'pixi.js'; +import {HAlign, VAlign} from 'flashbang/core'; +import {KeyboardEventType, KeyboardListener} from 'flashbang/input'; +import {Button, ButtonState} from 'flashbang/objects'; +import {DisplayUtil, TextBuilder} from 'flashbang/util'; +import {Registration, Registrations, Value} from 'signals'; +import {ROPWait, RScriptUIElementID} from 'eterna/rscript'; +import {Fonts} from 'eterna/util'; +import Tooltips from './Tooltips'; export default class GameButton extends Button implements KeyboardListener { public readonly toggled: Value = new Value(false); - public constructor() { + constructor() { super(); this._content = new Container(); @@ -78,7 +78,7 @@ export default class GameButton extends Button implements KeyboardListener { } public label(text: string | TextBuilder, fontSize?: number): GameButton { - if (typeof (text) === "string") { + if (typeof (text) === 'string') { this._labelBuilder = Fonts.arial(text as string).fontSize(fontSize || 22).bold().color(0xFFFFFF); } else { this._labelBuilder = text as TextBuilder; @@ -88,7 +88,7 @@ export default class GameButton extends Button implements KeyboardListener { } public fixedLabelWidth(width: number): GameButton { - if (this._fixedLabelWidth != width) { + if (this._fixedLabelWidth !== width) { this._fixedLabelWidth = width; this.needsRedraw(); } @@ -102,7 +102,7 @@ export default class GameButton extends Button implements KeyboardListener { } public tooltip(text: string): GameButton { - if (this._tooltip != text) { + if (this._tooltip !== text) { this._tooltip = text; if (this.isLiveObject) { this.setupTooltip(); @@ -149,7 +149,7 @@ export default class GameButton extends Button implements KeyboardListener { this._content.alpha = 1; let icon = this.getIconForState(state, this.isSelected); - if (icon == null && state == ButtonState.DISABLED) { + if (icon == null && state === ButtonState.DISABLED) { // If we're missing the disabled state, use the UP state at 50% alpha icon = this.getIconForState(ButtonState.UP, this.isSelected); this._content.alpha = 0.5; @@ -254,7 +254,7 @@ export default class GameButton extends Button implements KeyboardListener { } private getIconForState(state: ButtonState, selected: boolean): DisplayObject { - if (state != ButtonState.DISABLED && selected && this._selectedState != null) { + if (state !== ButtonState.DISABLED && selected && this._selectedState != null) { return this._selectedState; } else { return this._buttonIcons != null && this._buttonIcons.length > state @@ -268,7 +268,7 @@ export default class GameButton extends Button implements KeyboardListener { return displayOrTex; } else if (displayOrTex instanceof Texture) { return new Sprite(displayOrTex); - } else if (typeof (displayOrTex) === "string") { + } else if (typeof (displayOrTex) === 'string') { return Sprite.fromImage(displayOrTex); } else { return null; diff --git a/src/eterna/ui/GameCheckbox.ts b/src/eterna/ui/GameCheckbox.ts index 2f22f0bb4..b651f61db 100644 --- a/src/eterna/ui/GameCheckbox.ts +++ b/src/eterna/ui/GameCheckbox.ts @@ -1,8 +1,8 @@ -import {Graphics} from "pixi.js"; -import {HAlign, VAlign} from "flashbang/core"; -import {ButtonState, ToggleButton} from "flashbang/objects"; -import {DisplayUtil} from "flashbang/util"; -import {Fonts} from "eterna/util"; +import {Graphics} from 'pixi.js'; +import {HAlign, VAlign} from 'flashbang/core'; +import {ButtonState, ToggleButton} from 'flashbang/objects'; +import {DisplayUtil} from 'flashbang/util'; +import {Fonts} from 'eterna/util'; export default class GameCheckbox extends ToggleButton { constructor(size: number, txt: string) { diff --git a/src/eterna/ui/GamePanel.ts b/src/eterna/ui/GamePanel.ts index 4ffa6f785..98558a807 100644 --- a/src/eterna/ui/GamePanel.ts +++ b/src/eterna/ui/GamePanel.ts @@ -1,15 +1,21 @@ import { Graphics, Point, Text, Rectangle -} from "pixi.js"; -import {Fonts} from "eterna/util"; -import BaseGamePanel from "./BaseGamePanel"; +} from 'pixi.js'; +import {Fonts} from 'eterna/util'; +import BaseGamePanel from './BaseGamePanel'; export enum GamePanelType { NORMAL, INVISIBLE } export default class GamePanel extends BaseGamePanel { - public constructor(type: GamePanelType = GamePanelType.NORMAL, alpha: number = 0.07, color: number = 0xffffff, borderAlpha: number = 0.0, borderColor: number = 0) { + constructor( + type: GamePanelType = GamePanelType.NORMAL, + alpha: number = 0.07, + color: number = 0xffffff, + borderAlpha: number = 0.0, + borderColor: number = 0 + ) { super(); // Clicks should not pass through the panel diff --git a/src/eterna/ui/HTMLTextObject.ts b/src/eterna/ui/HTMLTextObject.ts index e159f3abc..a54ca0281 100644 --- a/src/eterna/ui/HTMLTextObject.ts +++ b/src/eterna/ui/HTMLTextObject.ts @@ -1,19 +1,19 @@ -import {DOMObject} from "flashbang/objects"; -import Eterna from "eterna/Eterna"; +import {DOMObject} from 'flashbang/objects'; +import Eterna from 'eterna/Eterna'; /** A

object in the DOM that contains the given HTML. Floats on top of the PIXI canvas. */ export default class HTMLTextObject extends DOMObject { - public constructor(htmlText: string, width?: number) { - super(Eterna.OVERLAY_DIV_ID, document.createElement("p")); + constructor(htmlText: string, width?: number) { + super(Eterna.OVERLAY_DIV_ID, document.createElement('p')); this._obj.innerHTML = htmlText; - this._obj.style.margin = "0px"; + this._obj.style.margin = '0px'; if (width) { this.width = width; } else { // If a width isn't specified, we want the element's width to match its content. // I'm using `white-space=pre`, which seems to work across browsers. "width: max-content" // works on Firefox, Safari, and Chrome, but Edge doesn't have support for it. - this._obj.style.whiteSpace = "pre"; + this._obj.style.whiteSpace = 'pre'; // this._obj.style.cssText += // "width: max-content;" + // "width: -moz-max-content;"; @@ -21,18 +21,18 @@ export default class HTMLTextObject extends DOMObject { } public lineHeight(percentOrString: number | string): HTMLTextObject { - let lineHeight: string = (typeof (percentOrString) === "number") + let lineHeight: string = (typeof (percentOrString) === 'number') ? `${Math.floor(percentOrString * 100)}%` : percentOrString; - DOMObject.applyStyleRecursive(this._obj, {"line-height": lineHeight}, false, HTMLTextObject.STYLE_NODE_NAMES); + DOMObject.applyStyleRecursive(this._obj, {'line-height': lineHeight}, false, HTMLTextObject.STYLE_NODE_NAMES); this.onSizeChanged(); return this; } public selectable(value: boolean): HTMLTextObject { - this._obj.style.userSelect = value ? undefined : "none"; - this._obj.style.webkitUserSelect = value ? undefined : "none"; - this._obj.style.msUserSelect = value ? undefined : "none"; + this._obj.style.userSelect = value ? undefined : 'none'; + this._obj.style.webkitUserSelect = value ? undefined : 'none'; + this._obj.style.msUserSelect = value ? undefined : 'none'; return this; } @@ -43,29 +43,29 @@ export default class HTMLTextObject extends DOMObject { } public font(fontFamily: string): HTMLTextObject { - DOMObject.applyStyleRecursive(this._obj, {"font-family": fontFamily}, false, HTMLTextObject.STYLE_NODE_NAMES); + DOMObject.applyStyleRecursive(this._obj, {'font-family': fontFamily}, false, HTMLTextObject.STYLE_NODE_NAMES); this.onSizeChanged(); return this; } public fontSize(size: number): HTMLTextObject { - DOMObject.applyStyleRecursive(this._obj, {"font-size": `${size}px`}, false, HTMLTextObject.STYLE_NODE_NAMES); + DOMObject.applyStyleRecursive(this._obj, {'font-size': `${size}px`}, false, HTMLTextObject.STYLE_NODE_NAMES); this.onSizeChanged(); return this; } public fontWeight(weight: string): HTMLTextObject { - DOMObject.applyStyleRecursive(this._obj, {"font-weight": weight}, false, HTMLTextObject.STYLE_NODE_NAMES); + DOMObject.applyStyleRecursive(this._obj, {'font-weight': weight}, false, HTMLTextObject.STYLE_NODE_NAMES); this.onSizeChanged(); return this; } public bold(): HTMLTextObject { - return this.fontWeight("bold"); + return this.fontWeight('bold'); } - public hAlign(align: "left" | "center" | "right" | "justify"): HTMLTextObject { - DOMObject.applyStyleRecursive(this._obj, {"text-align": align}, false, HTMLTextObject.STYLE_NODE_NAMES); + public hAlign(align: 'left' | 'center' | 'right' | 'justify'): HTMLTextObject { + DOMObject.applyStyleRecursive(this._obj, {'text-align': align}, false, HTMLTextObject.STYLE_NODE_NAMES); this.onSizeChanged(); return this; } @@ -76,10 +76,6 @@ export default class HTMLTextObject extends DOMObject { return this; } - public get width(): number { - return this._obj.getBoundingClientRect().width; - } - public get height(): number { return this._obj.getBoundingClientRect().height; } @@ -89,7 +85,11 @@ export default class HTMLTextObject extends DOMObject { this.onSizeChanged(); } + public get width(): number { + return this._obj.getBoundingClientRect().width; + } + private static readonly STYLE_NODE_NAMES: string[] = [ - "div", "p", "span", "a" + 'div', 'p', 'span', 'a' ]; } diff --git a/src/eterna/ui/NotificationDialog.ts b/src/eterna/ui/NotificationDialog.ts index 99a7ba3d8..8f1e41765 100644 --- a/src/eterna/ui/NotificationDialog.ts +++ b/src/eterna/ui/NotificationDialog.ts @@ -1,15 +1,15 @@ -import {Point} from "pixi.js"; -import {Flashbang} from "flashbang/core"; -import {HLayoutContainer} from "flashbang/layout"; -import Dialog from "./Dialog"; -import GameButton from "./GameButton"; -import TextBalloon from "./TextBalloon"; +import {Point} from 'pixi.js'; +import {Flashbang} from 'flashbang/core'; +import {HLayoutContainer} from 'flashbang/layout'; +import Dialog from './Dialog'; +import GameButton from './GameButton'; +import TextBalloon from './TextBalloon'; export default class NotificationDialog extends Dialog { /** Non-null if extraButtonTitle is specified */ public extraButton: GameButton; - public constructor(message: string, okButtonTitle: string = "Ok", extraButtonTitle?: string) { + constructor(message: string, okButtonTitle: string = 'Ok', extraButtonTitle?: string) { super(); this._message = message; this._okButtonTitle = okButtonTitle; @@ -19,8 +19,8 @@ export default class NotificationDialog extends Dialog { protected added() { super.added(); - let box = new TextBalloon("", 0x152843, 1.0, 0xC0DCE7, 0.27); - box.title = "Notice"; + let box = new TextBalloon('', 0x152843, 1.0, 0xC0DCE7, 0.27); + box.title = 'Notice'; box.setText(`${this._message}\n\n\n`); this.addObject(box, this.container); diff --git a/src/eterna/ui/NucleotidePalette.ts b/src/eterna/ui/NucleotidePalette.ts index 66b5f7d0a..d5482d446 100644 --- a/src/eterna/ui/NucleotidePalette.ts +++ b/src/eterna/ui/NucleotidePalette.ts @@ -1,17 +1,17 @@ import { Point, Rectangle, Sprite, Text, Texture -} from "pixi.js"; +} from 'pixi.js'; import { InputUtil, KeyboardEventType, KeyboardListener, KeyCode -} from "flashbang/input"; -import {ContainerObject, Enableable} from "flashbang/objects"; -import {StyledTextBuilder} from "flashbang/util"; -import {Signal} from "signals"; -import EPars from "eterna/EPars"; -import {BitmapManager, Bitmaps} from "eterna/resources"; -import {ROPWait, RScriptUIElementID} from "eterna/rscript"; -import {Fonts} from "eterna/util"; -import Tooltips from "./Tooltips"; +} from 'flashbang/input'; +import {ContainerObject, Enableable} from 'flashbang/objects'; +import {StyledTextBuilder, Assert} from 'flashbang/util'; +import {Signal} from 'signals'; +import EPars from 'eterna/EPars'; +import {BitmapManager, Bitmaps} from 'eterna/resources'; +import {ROPWait, RScriptUIElementID} from 'eterna/rscript'; +import {Fonts} from 'eterna/util'; +import Tooltips from './Tooltips'; type InteractionEvent = PIXI.interaction.InteractionEvent; @@ -21,26 +21,27 @@ export enum PaletteTargetType { export function GetPaletteTargetBaseType(type: PaletteTargetType): number { switch (type) { - case PaletteTargetType.A: return EPars.RNABASE_ADENINE; - case PaletteTargetType.U: return EPars.RNABASE_URACIL; - case PaletteTargetType.G: return EPars.RNABASE_GUANINE; - case PaletteTargetType.C: return EPars.RNABASE_CYTOSINE; - case PaletteTargetType.AU: return EPars.RNABASE_AU_PAIR; - case PaletteTargetType.UG: return EPars.RNABASE_GU_PAIR; - case PaletteTargetType.GC: return EPars.RNABASE_GC_PAIR; + case PaletteTargetType.A: return EPars.RNABASE_ADENINE; + case PaletteTargetType.U: return EPars.RNABASE_URACIL; + case PaletteTargetType.G: return EPars.RNABASE_GUANINE; + case PaletteTargetType.C: return EPars.RNABASE_CYTOSINE; + case PaletteTargetType.AU: return EPars.RNABASE_AU_PAIR; + case PaletteTargetType.UG: return EPars.RNABASE_GU_PAIR; + case PaletteTargetType.GC: return EPars.RNABASE_GC_PAIR; + default: return Assert.unreachable(type); } } export function StringToPaletteTargetType(value: string): PaletteTargetType { switch (value.toUpperCase()) { - case "A": return PaletteTargetType.A; - case "U": return PaletteTargetType.U; - case "G": return PaletteTargetType.G; - case "C": return PaletteTargetType.C; - case "AU": case "UA": return PaletteTargetType.AU; - case "GC": case "CG": return PaletteTargetType.GC; - case "UG": case "GU": return PaletteTargetType.UG; - default: return null; + case 'A': return PaletteTargetType.A; + case 'U': return PaletteTargetType.U; + case 'G': return PaletteTargetType.G; + case 'C': return PaletteTargetType.C; + case 'AU': case 'UA': return PaletteTargetType.AU; + case 'GC': case 'CG': return PaletteTargetType.GC; + case 'UG': case 'GU': return PaletteTargetType.UG; + default: return null; } } @@ -59,7 +60,7 @@ export default class NucleotidePalette extends ContainerObject implements Keyboa return builder; } - public constructor() { + constructor() { super(); this.display.interactive = true; @@ -75,11 +76,11 @@ export default class NucleotidePalette extends ContainerObject implements Keyboa this._selection = new Sprite(); this.container.addChild(this._selection); - this._numAU = Fonts.arial("", 12).color(0xffffff).bold().build(); + this._numAU = Fonts.arial('', 12).color(0xffffff).bold().build(); this.container.addChild(this._numAU); - this._numUG = Fonts.arial("", 12).color(0xffffff).bold().build(); + this._numUG = Fonts.arial('', 12).color(0xffffff).bold().build(); this.container.addChild(this._numUG); - this._numGC = Fonts.arial("", 12).color(0xffffff).bold().build(); + this._numGC = Fonts.arial('', 12).color(0xffffff).bold().build(); this.container.addChild(this._numGC); this._targets = new Array(7); @@ -87,43 +88,43 @@ export default class NucleotidePalette extends ContainerObject implements Keyboa this._targets[PaletteTargetType.A] = new PaletteTarget( PaletteTargetType.A, RScriptUIElementID.A, false, KeyCode.Digit1, [new Rectangle(9, 7, 25, 25)], - NucleotidePalette.createTooltip("Mutate to A (Adenine). (1)") + NucleotidePalette.createTooltip('Mutate to A (Adenine). (1)') ); this._targets[PaletteTargetType.U] = new PaletteTarget( PaletteTargetType.U, RScriptUIElementID.U, false, KeyCode.Digit2, [new Rectangle(58, 7, 25, 25)], - NucleotidePalette.createTooltip("Mutate to U (Uracil). (2)") + NucleotidePalette.createTooltip('Mutate to U (Uracil). (2)') ); this._targets[PaletteTargetType.G] = new PaletteTarget( PaletteTargetType.G, RScriptUIElementID.G, false, KeyCode.Digit3, [new Rectangle(107, 7, 25, 25)], - NucleotidePalette.createTooltip("Mutate to G (Guanine). (3)") + NucleotidePalette.createTooltip('Mutate to G (Guanine). (3)') ); this._targets[PaletteTargetType.C] = new PaletteTarget( PaletteTargetType.C, RScriptUIElementID.C, false, KeyCode.Digit4, [new Rectangle(156, 7, 25, 25)], - NucleotidePalette.createTooltip("Mutate to C (Cytosine). (4)") + NucleotidePalette.createTooltip('Mutate to C (Cytosine). (4)') ); this._targets[PaletteTargetType.AU] = new PaletteTarget( PaletteTargetType.AU, RScriptUIElementID.AU, true, KeyCode.KeyQ, [new Rectangle(31, 29, 30, 20), new Rectangle(37, 15, 22, 20)], - NucleotidePalette.createTooltip("Mutate to pair (A, U). (Q)") + NucleotidePalette.createTooltip('Mutate to pair (A, U). (Q)') ); this._targets[PaletteTargetType.UG] = new PaletteTarget( PaletteTargetType.UG, RScriptUIElementID.UG, true, KeyCode.KeyW, [new Rectangle(80, 29, 30, 20), new Rectangle(87, 15, 22, 20)], - NucleotidePalette.createTooltip("Mutate to pair (G, U). (W)") + NucleotidePalette.createTooltip('Mutate to pair (G, U). (W)') ); this._targets[PaletteTargetType.GC] = new PaletteTarget( PaletteTargetType.GC, RScriptUIElementID.GC, true, KeyCode.KeyE, [new Rectangle(129, 29, 30, 20), new Rectangle(137, 15, 22, 20)], - NucleotidePalette.createTooltip("Mutate to pair (G, C). (E)") + NucleotidePalette.createTooltip('Mutate to pair (G, C). (E)') ); } @@ -190,27 +191,29 @@ export default class NucleotidePalette extends ContainerObject implements Keyboa if (e.type === KeyboardEventType.KEY_DOWN) { switch (e.code) { - case KeyCode.Digit1: - this.clickTarget(PaletteTargetType.A); - return true; - case KeyCode.Digit2: - this.clickTarget(PaletteTargetType.U); - return true; - case KeyCode.Digit3: - this.clickTarget(PaletteTargetType.G); - return true; - case KeyCode.Digit4: - this.clickTarget(PaletteTargetType.C); - return true; - case KeyCode.KeyQ: - this.clickTarget(PaletteTargetType.AU); - return true; - case KeyCode.KeyW: - this.clickTarget(PaletteTargetType.UG); - return true; - case KeyCode.KeyE: - this.clickTarget(PaletteTargetType.GC); - return true; + case KeyCode.Digit1: + this.clickTarget(PaletteTargetType.A); + return true; + case KeyCode.Digit2: + this.clickTarget(PaletteTargetType.U); + return true; + case KeyCode.Digit3: + this.clickTarget(PaletteTargetType.G); + return true; + case KeyCode.Digit4: + this.clickTarget(PaletteTargetType.C); + return true; + case KeyCode.KeyQ: + this.clickTarget(PaletteTargetType.AU); + return true; + case KeyCode.KeyW: + this.clickTarget(PaletteTargetType.UG); + return true; + case KeyCode.KeyE: + this.clickTarget(PaletteTargetType.GC); + return true; + default: + return false; } } @@ -251,16 +254,16 @@ export default class NucleotidePalette extends ContainerObject implements Keyboa } } - private showSelection(selected_box: Rectangle, is_pair: boolean, do_show: boolean): void { - if (selected_box == null) { + private showSelection(selectedBox: Rectangle, isPair: boolean, doShow: boolean): void { + if (selectedBox == null) { return; } - if (!do_show) { + if (!doShow) { this.clearSelection(); } else { - this._selection.texture = is_pair ? this._selectPairData : this._selectBaseData; - this._selection.position = new Point(selected_box.x, selected_box.y); + this._selection.texture = isPair ? this._selectPairData : this._selectBaseData; + this._selection.position = new Point(selectedBox.x, selectedBox.y); this._selection.visible = true; } } @@ -348,7 +351,14 @@ class PaletteTarget { public readonly tooltip: StyledTextBuilder; public enabled: boolean = true; - public constructor(type: PaletteTargetType, id: RScriptUIElementID, isPair: boolean, keyCode: string, hitboxes: Rectangle[], tooltip: StyledTextBuilder) { + constructor( + type: PaletteTargetType, + id: RScriptUIElementID, + isPair: boolean, + keyCode: string, + hitboxes: Rectangle[], + tooltip: StyledTextBuilder + ) { this.type = type; this.id = id; this.isPair = isPair; diff --git a/src/eterna/ui/PasteSequenceDialog.ts b/src/eterna/ui/PasteSequenceDialog.ts index af1e39606..dd230f354 100644 --- a/src/eterna/ui/PasteSequenceDialog.ts +++ b/src/eterna/ui/PasteSequenceDialog.ts @@ -1,8 +1,8 @@ -import {Flashbang} from "flashbang/core"; -import {KeyCode} from "flashbang/input"; -import {GameMode} from "eterna/mode"; -import Dialog from "./Dialog"; -import TextInputPanel from "./TextInputPanel"; +import {Flashbang} from 'flashbang/core'; +import {KeyCode} from 'flashbang/input'; +import {GameMode} from 'eterna/mode'; +import Dialog from './Dialog'; +import TextInputPanel from './TextInputPanel'; /** * Prompts the user to paste a sequence. @@ -12,11 +12,11 @@ export default class PasteSequenceDialog extends Dialog { protected added(): void { super.added(); - const SEQUENCE = "Sequence"; + const SEQUENCE = 'Sequence'; let inputPanel = new TextInputPanel(); let sequenceField = inputPanel.addField(SEQUENCE, 200); - inputPanel.title = "Write down a sequence"; + inputPanel.title = 'Write down a sequence'; this.addObject(inputPanel, this.container); sequenceField.setFocus(true); @@ -39,8 +39,8 @@ export default class PasteSequenceDialog extends Dialog { for (let ii = 0; ii < sequence.length; ii++) { let char = sequence.substr(ii, 1); - if (char !== "A" && char !== "U" && char !== "G" && char !== "C") { - (this.mode as GameMode).showNotification("You can only use characters A, U, G, and C"); + if (char !== 'A' && char !== 'U' && char !== 'G' && char !== 'C') { + (this.mode as GameMode).showNotification('You can only use characters A, U, G, and C'); return; } } diff --git a/src/eterna/ui/PoseThumbnail.ts b/src/eterna/ui/PoseThumbnail.ts index d0e18ce14..22b775df5 100644 --- a/src/eterna/ui/PoseThumbnail.ts +++ b/src/eterna/ui/PoseThumbnail.ts @@ -1,37 +1,71 @@ import { Container, DisplayObject, Graphics, Sprite, Texture -} from "pixi.js"; -import {DisplayUtil, TextureUtil} from "flashbang/util"; -import Constants from "eterna/Constants"; -import EPars from "eterna/EPars"; -import ExpPainter from "eterna/ExpPainter"; -import {RNALayout} from "eterna/pose2D"; -import {Bitmaps} from "eterna/resources"; +} from 'pixi.js'; +import {DisplayUtil, TextureUtil} from 'flashbang/util'; +import Constants from 'eterna/Constants'; +import EPars from 'eterna/EPars'; +import ExpPainter from 'eterna/ExpPainter'; +import {RNALayout} from 'eterna/pose2D'; +import {Bitmaps} from 'eterna/resources'; export enum PoseThumbnailType { - BASE_COLORED = "BASE_COLORED", - WHITE = "WHITE", - EXP_COLORED = "EXP_COLORED", - WRONG_COLORED = "WRONG_COLORED", + BASE_COLORED = 'BASE_COLORED', + WHITE = 'WHITE', + EXP_COLORED = 'EXP_COLORED', + WRONG_COLORED = 'WRONG_COLORED', } export default class PoseThumbnail { - public static createFramedBitmap(sequence: number[], pairs: number[], size: number = 1, type: PoseThumbnailType = PoseThumbnailType.BASE_COLORED, exp_start_index: number = 0, wrong_pairs: number[] = null, exp_use_threshold: boolean = false, exp_threshold: number = 0): Texture { - let disp: DisplayObject = PoseThumbnail.create(sequence, pairs, size, type, exp_start_index, wrong_pairs, exp_use_threshold, exp_threshold); + public static createFramedBitmap( + sequence: number[], + pairs: number[], + size: number = 1, + type: PoseThumbnailType = PoseThumbnailType.BASE_COLORED, + expStartIndex: number = 0, + wrongPairs: number[] = null, + expUseThreshold: boolean = false, + expThreshold: number = 0 + ): Texture { + let disp: DisplayObject = PoseThumbnail.create( + sequence, pairs, size, type, + expStartIndex, wrongPairs, expUseThreshold, expThreshold + ); return TextureUtil.renderToTexture(disp); } - public static drawToSprite(sprite: Sprite, sequence: number[], pairs: number[], size: number = 1, type: PoseThumbnailType = PoseThumbnailType.BASE_COLORED, exp_start_index: number = 0, wrong_pairs: number[] = null, exp_use_threshold: boolean = false, exp_threshold: number = 0): void { + public static drawToSprite( + sprite: Sprite, + sequence: number[], + pairs: number[], + size: number = 1, + type: PoseThumbnailType = PoseThumbnailType.BASE_COLORED, + expStartIndex: number = 0, + wrongPairs: number[] = null, + expUseThreshold: boolean = false, + expThreshold: number = 0 + ): void { sprite.removeChildren(); const graphics = new Graphics(); - PoseThumbnail.create(sequence, pairs, size, type, exp_start_index, wrong_pairs, exp_use_threshold, exp_threshold, graphics); + PoseThumbnail.create( + sequence, pairs, size, type, expStartIndex, wrongPairs, expUseThreshold, expThreshold, graphics + ); let bounds = graphics.getLocalBounds(); graphics.x = -bounds.left; graphics.y = -bounds.top; sprite.addChild(graphics); } - private static create(sequence: number[], pairs: number[], size: number, type: PoseThumbnailType, exp_start_index: number, wrong_pairs: number[], exp_use_threshold: boolean, exp_threshold: number, canvas: Graphics = null): DisplayObject { + private static create( + sequence: number[], + pairs: number[], + size: number, + type: PoseThumbnailType, + expStartIndex: number, + wrongPairs: number[], + expUseThreshold: boolean, + expThreshold: number, + canvas: Graphics = null + ): DisplayObject { let frame: DisplayObject; if (size === 1) { @@ -66,10 +100,10 @@ export default class PoseThumbnail { let xarray: number[] = new Array(n); let yarray: number[] = new Array(n); - let rna_drawer: RNALayout = new RNALayout(45, 45); - rna_drawer.setupTree(pairs); - rna_drawer.drawTree(); - rna_drawer.getCoords(xarray, yarray); + let rnaDrawer: RNALayout = new RNALayout(45, 45); + rnaDrawer.setupTree(pairs); + rnaDrawer.drawTree(); + rnaDrawer.getCoords(xarray, yarray); let xmin: number = xarray[0]; let xmax: number = xarray[0]; @@ -108,16 +142,16 @@ export default class PoseThumbnail { canvas.clear(); canvas.lineStyle(0, 0x0, 0); - let exp_painter: ExpPainter = null; + let expPainter: ExpPainter = null; if (type === PoseThumbnailType.EXP_COLORED) { - exp_painter = new ExpPainter(sequence, exp_start_index); + expPainter = new ExpPainter(sequence, expStartIndex); } - let small_xmax: number = (xarray[0] - xmin) * scale; - let small_xmin: number = (xarray[0] - xmin) * scale; - let small_ymax: number = (yarray[0] - ymin) * scale; - let small_ymin: number = (yarray[0] - ymin) * scale; + let smallXMax: number = (xarray[0] - xmin) * scale; + let smallXMin: number = (xarray[0] - xmin) * scale; + let smallYMax: number = (yarray[0] - ymin) * scale; + let smallYMin: number = (yarray[0] - ymin) * scale; let xpos: number; let ypos: number; @@ -126,22 +160,22 @@ export default class PoseThumbnail { xpos = (xarray[ii] - xmin) * scale; ypos = (yarray[ii] - ymin) * scale; - if (xpos > small_xmax) small_xmax = xpos; - if (xpos < small_xmin) small_xmin = xpos; + if (xpos > smallXMax) smallXMax = xpos; + if (xpos < smallXMin) smallXMin = xpos; - if (ypos > small_ymax) small_ymax = ypos; - if (ypos < small_ymin) small_ymin = ypos; + if (ypos > smallYMax) smallYMax = ypos; + if (ypos < smallYMin) smallYMin = ypos; } - let x_offset: number = ((w) - (small_xmax - small_xmin)) / 2.0 + frameBounds.width * 0.1; - let y_offset: number = ((h) - (small_ymax - small_ymin)) / 2.0 + frameBounds.height * 0.1; + let xOffset: number = ((w) - (smallXMax - smallXMin)) / 2.0 + frameBounds.width * 0.1; + let yOffset: number = ((h) - (smallYMax - smallYMin)) / 2.0 + frameBounds.height * 0.1; - let wrong_xcoords: number[] = []; - let wrong_ycoords: number[] = []; - let right_xcoords: number[] = []; - let right_ycoords: number[] = []; - let dontcare_xcoords: number[] = []; - let dontcare_ycoords: number[] = []; + let wrongXCoords: number[] = []; + let wrongYCoords: number[] = []; + let rightXCoords: number[] = []; + let rightYCoords: number[] = []; + let dontcareXCoords: number[] = []; + let dontcareYCoords: number[] = []; const COLOR_WHITE = 0xffffff; @@ -161,98 +195,98 @@ export default class PoseThumbnail { if (type === PoseThumbnailType.WHITE) { color = COLOR_WHITE; } else if (type === PoseThumbnailType.WRONG_COLORED) { - if (wrong_pairs[ii] === 1) { + if (wrongPairs[ii] === 1) { color = COLOR_WRONG; if (ii === 0 || (ii > 0 && sequence[ii - 1] === EPars.RNABASE_CUT)) { - wrong_xcoords.push((xarray[ii] - xmin) * scale + x_offset); - wrong_ycoords.push((yarray[ii] - ymin) * scale + y_offset); + wrongXCoords.push((xarray[ii] - xmin) * scale + xOffset); + wrongYCoords.push((yarray[ii] - ymin) * scale + yOffset); - wrong_xcoords.push((xarray[ii] - xmin) * scale + x_offset); - wrong_ycoords.push((yarray[ii] - ymin) * scale + y_offset); + wrongXCoords.push((xarray[ii] - xmin) * scale + xOffset); + wrongYCoords.push((yarray[ii] - ymin) * scale + yOffset); - wrong_xcoords.push(((xarray[ii] + xarray[ii + 1]) / 2.0 - xmin) * scale + x_offset); - wrong_ycoords.push(((yarray[ii] + yarray[ii + 1]) / 2.0 - ymin) * scale + y_offset); + wrongXCoords.push(((xarray[ii] + xarray[ii + 1]) / 2.0 - xmin) * scale + xOffset); + wrongYCoords.push(((yarray[ii] + yarray[ii + 1]) / 2.0 - ymin) * scale + yOffset); } else if (ii === n - 1 || (ii < n - 1 && sequence[ii + 1] === EPars.RNABASE_CUT)) { - wrong_xcoords.push(((xarray[ii] + xarray[ii - 1]) / 2.0 - xmin) * scale + x_offset); - wrong_ycoords.push(((yarray[ii] + yarray[ii - 1]) / 2.0 - ymin) * scale + y_offset); + wrongXCoords.push(((xarray[ii] + xarray[ii - 1]) / 2.0 - xmin) * scale + xOffset); + wrongYCoords.push(((yarray[ii] + yarray[ii - 1]) / 2.0 - ymin) * scale + yOffset); - wrong_xcoords.push(((xarray[ii] + xarray[ii - 1]) / 2.0 - xmin) * scale + x_offset); - wrong_ycoords.push(((yarray[ii] + yarray[ii - 1]) / 2.0 - ymin) * scale + y_offset); + wrongXCoords.push(((xarray[ii] + xarray[ii - 1]) / 2.0 - xmin) * scale + xOffset); + wrongYCoords.push(((yarray[ii] + yarray[ii - 1]) / 2.0 - ymin) * scale + yOffset); - wrong_xcoords.push((xarray[ii] - xmin) * scale + x_offset); - wrong_ycoords.push((yarray[ii] - ymin) * scale + y_offset); + wrongXCoords.push((xarray[ii] - xmin) * scale + xOffset); + wrongYCoords.push((yarray[ii] - ymin) * scale + yOffset); } else { - wrong_xcoords.push(((xarray[ii] + xarray[ii - 1]) / 2.0 - xmin) * scale + x_offset); - wrong_ycoords.push(((yarray[ii] + yarray[ii - 1]) / 2.0 - ymin) * scale + y_offset); + wrongXCoords.push(((xarray[ii] + xarray[ii - 1]) / 2.0 - xmin) * scale + xOffset); + wrongYCoords.push(((yarray[ii] + yarray[ii - 1]) / 2.0 - ymin) * scale + yOffset); - wrong_xcoords.push(((xarray[ii]) - xmin) * scale + x_offset); - wrong_ycoords.push(((yarray[ii]) - ymin) * scale + y_offset); + wrongXCoords.push(((xarray[ii]) - xmin) * scale + xOffset); + wrongYCoords.push(((yarray[ii]) - ymin) * scale + yOffset); - wrong_xcoords.push(((xarray[ii] + xarray[ii + 1]) / 2.0 - xmin) * scale + x_offset); - wrong_ycoords.push(((yarray[ii] + yarray[ii + 1]) / 2.0 - ymin) * scale + y_offset); + wrongXCoords.push(((xarray[ii] + xarray[ii + 1]) / 2.0 - xmin) * scale + xOffset); + wrongYCoords.push(((yarray[ii] + yarray[ii + 1]) / 2.0 - ymin) * scale + yOffset); } - } else if (wrong_pairs[ii] === -1) { + } else if (wrongPairs[ii] === -1) { color = COLOR_RIGHT; if (ii === 0 || (ii > 0 && sequence[ii - 1] === EPars.RNABASE_CUT)) { - right_xcoords.push((xarray[ii] - xmin) * scale + x_offset); - right_ycoords.push((yarray[ii] - ymin) * scale + y_offset); + rightXCoords.push((xarray[ii] - xmin) * scale + xOffset); + rightYCoords.push((yarray[ii] - ymin) * scale + yOffset); - right_xcoords.push((xarray[ii] - xmin) * scale + x_offset); - right_ycoords.push((yarray[ii] - ymin) * scale + y_offset); + rightXCoords.push((xarray[ii] - xmin) * scale + xOffset); + rightYCoords.push((yarray[ii] - ymin) * scale + yOffset); - right_xcoords.push(((xarray[ii] + xarray[ii + 1]) / 2.0 - xmin) * scale + x_offset); - right_ycoords.push(((yarray[ii] + yarray[ii + 1]) / 2.0 - ymin) * scale + y_offset); + rightXCoords.push(((xarray[ii] + xarray[ii + 1]) / 2.0 - xmin) * scale + xOffset); + rightYCoords.push(((yarray[ii] + yarray[ii + 1]) / 2.0 - ymin) * scale + yOffset); } else if (ii === n - 1 || (ii < n - 1 && sequence[ii + 1] === EPars.RNABASE_CUT)) { - right_xcoords.push(((xarray[ii] + xarray[ii - 1]) / 2.0 - xmin) * scale + x_offset); - right_ycoords.push(((yarray[ii] + yarray[ii - 1]) / 2.0 - ymin) * scale + y_offset); + rightXCoords.push(((xarray[ii] + xarray[ii - 1]) / 2.0 - xmin) * scale + xOffset); + rightYCoords.push(((yarray[ii] + yarray[ii - 1]) / 2.0 - ymin) * scale + yOffset); - right_xcoords.push(((xarray[ii] + xarray[ii - 1]) / 2.0 - xmin) * scale + x_offset); - right_ycoords.push(((yarray[ii] + yarray[ii - 1]) / 2.0 - ymin) * scale + y_offset); + rightXCoords.push(((xarray[ii] + xarray[ii - 1]) / 2.0 - xmin) * scale + xOffset); + rightYCoords.push(((yarray[ii] + yarray[ii - 1]) / 2.0 - ymin) * scale + yOffset); - right_xcoords.push((xarray[ii] - xmin) * scale + x_offset); - right_ycoords.push((yarray[ii] - ymin) * scale + y_offset); + rightXCoords.push((xarray[ii] - xmin) * scale + xOffset); + rightYCoords.push((yarray[ii] - ymin) * scale + yOffset); } else { - right_xcoords.push(((xarray[ii] + xarray[ii - 1]) / 2.0 - xmin) * scale + x_offset); - right_ycoords.push(((yarray[ii] + yarray[ii - 1]) / 2.0 - ymin) * scale + y_offset); + rightXCoords.push(((xarray[ii] + xarray[ii - 1]) / 2.0 - xmin) * scale + xOffset); + rightYCoords.push(((yarray[ii] + yarray[ii - 1]) / 2.0 - ymin) * scale + yOffset); - right_xcoords.push((xarray[ii] - xmin) * scale + x_offset); - right_ycoords.push((yarray[ii] - ymin) * scale + y_offset); + rightXCoords.push((xarray[ii] - xmin) * scale + xOffset); + rightYCoords.push((yarray[ii] - ymin) * scale + yOffset); - right_xcoords.push(((xarray[ii] + xarray[ii + 1]) / 2.0 - xmin) * scale + x_offset); - right_ycoords.push(((yarray[ii] + yarray[ii + 1]) / 2.0 - ymin) * scale + y_offset); + rightXCoords.push(((xarray[ii] + xarray[ii + 1]) / 2.0 - xmin) * scale + xOffset); + rightYCoords.push(((yarray[ii] + yarray[ii + 1]) / 2.0 - ymin) * scale + yOffset); } } else { color = COLOR_DONTCARE; if (ii === 0 || (ii > 0 && sequence[ii - 1] === EPars.RNABASE_CUT)) { - dontcare_xcoords.push((xarray[ii] - xmin) * scale + x_offset); - dontcare_ycoords.push((yarray[ii] - ymin) * scale + y_offset); + dontcareXCoords.push((xarray[ii] - xmin) * scale + xOffset); + dontcareYCoords.push((yarray[ii] - ymin) * scale + yOffset); - dontcare_xcoords.push((xarray[ii] - xmin) * scale + x_offset); - dontcare_ycoords.push((yarray[ii] - ymin) * scale + y_offset); + dontcareXCoords.push((xarray[ii] - xmin) * scale + xOffset); + dontcareYCoords.push((yarray[ii] - ymin) * scale + yOffset); - dontcare_xcoords.push(((xarray[ii] + xarray[ii + 1]) / 2.0 - xmin) * scale + x_offset); - dontcare_ycoords.push(((yarray[ii] + yarray[ii + 1]) / 2.0 - ymin) * scale + y_offset); + dontcareXCoords.push(((xarray[ii] + xarray[ii + 1]) / 2.0 - xmin) * scale + xOffset); + dontcareYCoords.push(((yarray[ii] + yarray[ii + 1]) / 2.0 - ymin) * scale + yOffset); } else if (ii === n - 1 || (ii < n - 1 && sequence[ii + 1] === EPars.RNABASE_CUT)) { - dontcare_xcoords.push(((xarray[ii] + xarray[ii - 1]) / 2.0 - xmin) * scale + x_offset); - dontcare_ycoords.push(((yarray[ii] + yarray[ii - 1]) / 2.0 - ymin) * scale + y_offset); + dontcareXCoords.push(((xarray[ii] + xarray[ii - 1]) / 2.0 - xmin) * scale + xOffset); + dontcareYCoords.push(((yarray[ii] + yarray[ii - 1]) / 2.0 - ymin) * scale + yOffset); - dontcare_xcoords.push(((xarray[ii] + xarray[ii - 1]) / 2.0 - xmin) * scale + x_offset); - dontcare_ycoords.push(((yarray[ii] + yarray[ii - 1]) / 2.0 - ymin) * scale + y_offset); + dontcareXCoords.push(((xarray[ii] + xarray[ii - 1]) / 2.0 - xmin) * scale + xOffset); + dontcareYCoords.push(((yarray[ii] + yarray[ii - 1]) / 2.0 - ymin) * scale + yOffset); - dontcare_xcoords.push((xarray[ii] - xmin) * scale + x_offset); - dontcare_ycoords.push((yarray[ii] - ymin) * scale + y_offset); + dontcareXCoords.push((xarray[ii] - xmin) * scale + xOffset); + dontcareYCoords.push((yarray[ii] - ymin) * scale + yOffset); } else { - dontcare_xcoords.push(((xarray[ii] + xarray[ii - 1]) / 2.0 - xmin) * scale + x_offset); - dontcare_ycoords.push(((yarray[ii] + yarray[ii - 1]) / 2.0 - ymin) * scale + y_offset); + dontcareXCoords.push(((xarray[ii] + xarray[ii - 1]) / 2.0 - xmin) * scale + xOffset); + dontcareYCoords.push(((yarray[ii] + yarray[ii - 1]) / 2.0 - ymin) * scale + yOffset); - dontcare_xcoords.push((xarray[ii] - xmin) * scale + x_offset); - dontcare_ycoords.push((yarray[ii] - ymin) * scale + y_offset); + dontcareXCoords.push((xarray[ii] - xmin) * scale + xOffset); + dontcareYCoords.push((yarray[ii] - ymin) * scale + yOffset); - dontcare_xcoords.push(((xarray[ii] + xarray[ii + 1]) / 2.0 - xmin) * scale + x_offset); - dontcare_ycoords.push(((yarray[ii] + yarray[ii + 1]) / 2.0 - ymin) * scale + y_offset); + dontcareXCoords.push(((xarray[ii] + xarray[ii + 1]) / 2.0 - xmin) * scale + xOffset); + dontcareYCoords.push(((yarray[ii] + yarray[ii + 1]) / 2.0 - ymin) * scale + yOffset); } } } else if (type === PoseThumbnailType.BASE_COLORED) { @@ -268,14 +302,14 @@ export default class PoseThumbnail { color = COLOR_WHITE; } } else if (type === PoseThumbnailType.EXP_COLORED) { - if (exp_use_threshold) color = exp_painter.getColorWithMidpoint(ii, exp_threshold); - else color = exp_painter.getColor(ii); + if (expUseThreshold) color = expPainter.getColorWithMidpoint(ii, expThreshold); + else color = expPainter.getColor(ii); } canvas.lineStyle(Math.min(size, 3), color, 1); - xpos = (xarray[ii] - xmin) * scale + x_offset; - ypos = (yarray[ii] - ymin) * scale + y_offset; + xpos = (xarray[ii] - xmin) * scale + xOffset; + ypos = (yarray[ii] - ymin) * scale + yOffset; if (ii === 0 || sequence[ii] === EPars.RNABASE_CUT) { canvas.moveTo(xpos, ypos); @@ -288,45 +322,45 @@ export default class PoseThumbnail { color = COLOR_RIGHT; canvas.lineStyle(Math.min(size, 3), color, 1); - for (let jj = 0; jj < right_xcoords.length; jj++) { + for (let jj = 0; jj < rightXCoords.length; jj++) { if (jj % 3 === 0) { if (sequence[jj / 3] === EPars.RNABASE_CUT) { jj += 2; } else { - canvas.moveTo(right_xcoords[jj], right_ycoords[jj]); + canvas.moveTo(rightXCoords[jj], rightYCoords[jj]); } } else { - canvas.lineTo(right_xcoords[jj], right_ycoords[jj]); + canvas.lineTo(rightXCoords[jj], rightYCoords[jj]); } } color = COLOR_WRONG; canvas.lineStyle(Math.min(size, 3), color, 1); - for (let jj = 0; jj < wrong_xcoords.length; jj++) { + for (let jj = 0; jj < wrongXCoords.length; jj++) { if (jj % 3 === 0) { if (sequence[jj / 3] === EPars.RNABASE_CUT) { jj += 2; } else { - canvas.moveTo(wrong_xcoords[jj], wrong_ycoords[jj]); + canvas.moveTo(wrongXCoords[jj], wrongYCoords[jj]); } } else { - canvas.lineTo(wrong_xcoords[jj], wrong_ycoords[jj]); + canvas.lineTo(wrongXCoords[jj], wrongYCoords[jj]); } } color = COLOR_DONTCARE; canvas.lineStyle(Math.min(size, 3), color, 0.65); - for (let jj = 0; jj < dontcare_xcoords.length; jj++) { + for (let jj = 0; jj < dontcareXCoords.length; jj++) { if (jj % 3 === 0) { if (sequence[jj / 3] === EPars.RNABASE_CUT) { jj += 2; } else { - canvas.moveTo(dontcare_xcoords[jj], dontcare_ycoords[jj]); + canvas.moveTo(dontcareXCoords[jj], dontcareYCoords[jj]); } } else { - canvas.lineTo(dontcare_xcoords[jj], dontcare_ycoords[jj]); + canvas.lineTo(dontcareXCoords[jj], dontcareYCoords[jj]); } } } diff --git a/src/eterna/ui/ScrollContainer.ts b/src/eterna/ui/ScrollContainer.ts index 309642ea6..b58f06c52 100644 --- a/src/eterna/ui/ScrollContainer.ts +++ b/src/eterna/ui/ScrollContainer.ts @@ -1,10 +1,10 @@ -import {Container, Graphics} from "pixi.js"; -import {MathUtil} from "flashbang/util"; +import {Container, Graphics} from 'pixi.js'; +import {MathUtil} from 'flashbang/util'; export default class ScrollContainer extends Container { public readonly content = new Container(); - public constructor(width: number, height: number) { + constructor(width: number, height: number) { super(); this.addChild(this.content); diff --git a/src/eterna/ui/SliderBar.ts b/src/eterna/ui/SliderBar.ts index b0aca7304..006436654 100644 --- a/src/eterna/ui/SliderBar.ts +++ b/src/eterna/ui/SliderBar.ts @@ -1,8 +1,8 @@ -import {Graphics, Point} from "pixi.js"; -import {Flashbang, GameObjectRef} from "flashbang/core"; -import {DisplayObjectPointerTarget} from "flashbang/input"; -import {ContainerObject, Dragger} from "flashbang/objects"; -import {Signal} from "signals"; +import {Graphics, Point} from 'pixi.js'; +import {Flashbang, GameObjectRef} from 'flashbang/core'; +import {DisplayObjectPointerTarget} from 'flashbang/input'; +import {ContainerObject, Dragger} from 'flashbang/objects'; +import {Signal} from 'signals'; export default class SliderBar extends ContainerObject { // The width (or height, for a horizontal SliderBar) of the thumb @@ -28,7 +28,7 @@ export default class SliderBar extends ContainerObject { this.container.addChild(this._barRect); - this._current_val = 1; + this._currentVal = 1; let barPointerTarget = new DisplayObjectPointerTarget(this._barRect); let linePointerTarget = new DisplayObjectPointerTarget(this._sliderLine); @@ -47,17 +47,17 @@ export default class SliderBar extends ContainerObject { } } - public get_progress(): number { - return this._current_val; + public getProgress(): number { + return this._currentVal; } - public set_progress(prog: number): void { + public setProgress(prog: number): void { if (this._vertical) { - this._current_val = prog; - this._barRect.y = this._current_val * (this._height - 10) + 10; + this._currentVal = prog; + this._barRect.y = this._currentVal * (this._height - 10) + 10; } else { - this._current_val = prog; - this._barRect.x = this._current_val * (this._width - 10) + 10; + this._currentVal = prog; + this._barRect.x = this._currentVal * (this._width - 10) + 10; } this.scrollChanged.emit(prog); @@ -81,9 +81,9 @@ export default class SliderBar extends ContainerObject { } if (this._vertical) { - this._barRect.y = this._current_val * (this._height - 10) + 10; + this._barRect.y = this._currentVal * (this._height - 10) + 10; } else { - this._barRect.x = this._current_val * (this._width - 10) + 10; + this._barRect.x = this._currentVal * (this._width - 10) + 10; } } @@ -98,31 +98,31 @@ export default class SliderBar extends ContainerObject { let mouse = this.container.toLocal(new Point(dragger.curX, dragger.curY)); if (this._vertical) { if (mouse.y < 0) { - this._current_val = 0; + this._currentVal = 0; } else if (mouse.y > this._height) { - this._current_val = 1; + this._currentVal = 1; } else if (this._height > 0) { - this._current_val = mouse.y / this._height; + this._currentVal = mouse.y / this._height; } else { - this._current_val = 1; + this._currentVal = 1; } - this._barRect.y = this._current_val * (this._height - 10) + 10; + this._barRect.y = this._currentVal * (this._height - 10) + 10; } else { if (mouse.x < 0) { - this._current_val = 0; + this._currentVal = 0; } else if (mouse.x > this._width) { - this._current_val = 1; + this._currentVal = 1; } else if (this._width > 0) { - this._current_val = mouse.x / this._width; + this._currentVal = mouse.x / this._width; } else { - this._current_val = 1; + this._currentVal = 1; } - this._barRect.x = this._current_val * (this._width - 10) + 10; + this._barRect.x = this._currentVal * (this._width - 10) + 10; } - this.scrollChanged.emit(this.get_progress()); + this.scrollChanged.emit(this.getProgress()); }); } @@ -131,21 +131,21 @@ export default class SliderBar extends ContainerObject { if (this._vertical) { if (this._height > 0) { - this._current_val = mouse.y / this._height; + this._currentVal = mouse.y / this._height; } else { - this._current_val = 1; + this._currentVal = 1; } - this._barRect.y = this._current_val * (this._height - 10) + 10; + this._barRect.y = this._currentVal * (this._height - 10) + 10; } else { if (this._width > 0) { - this._current_val = mouse.x / this._width; + this._currentVal = mouse.x / this._width; } else { - this._current_val = 1; + this._currentVal = 1; } - this._barRect.x = this._current_val * (this._width - 10) + 10; + this._barRect.x = this._currentVal * (this._width - 10) + 10; } - this.scrollChanged.emit(this.get_progress()); + this.scrollChanged.emit(this.getProgress()); } private readonly _vertical: boolean; @@ -153,7 +153,7 @@ export default class SliderBar extends ContainerObject { private readonly _sliderLine: Graphics; private _draggerRef: GameObjectRef = GameObjectRef.NULL; - private _current_val: number = 1; + private _currentVal: number = 1; private _width: number; private _height: number; diff --git a/src/eterna/ui/SpecBox.ts b/src/eterna/ui/SpecBox.ts index 164aa9612..e3e513a7e 100644 --- a/src/eterna/ui/SpecBox.ts +++ b/src/eterna/ui/SpecBox.ts @@ -1,23 +1,23 @@ -import * as log from "loglevel"; -import MultiStyleText from "pixi-multistyle-text"; +import * as log from 'loglevel'; +import MultiStyleText from 'pixi-multistyle-text'; import { Graphics, Point, Sprite, Text -} from "pixi.js"; -import {HAlign, VAlign} from "flashbang/core"; -import {DisplayObjectPointerTarget, InputUtil, KeyCode} from "flashbang/input"; -import {ContainerObject} from "flashbang/objects"; -import {DisplayUtil, StyledTextBuilder} from "flashbang/util"; -import {UnitSignal} from "signals"; -import EPars from "eterna/EPars"; -import Plot from "eterna/Plot"; -import {EternaURL} from "eterna/net"; -import {Bitmaps} from "eterna/resources"; -import {default as UndoBlock, UndoBlockParam} from "eterna/UndoBlock"; -import {Fonts} from "eterna/util"; -import GameButton from "./GameButton"; -import GamePanel from "./GamePanel"; -import HTMLTextObject from "./HTMLTextObject"; -import TextBalloon from "./TextBalloon"; +} from 'pixi.js'; +import {HAlign, VAlign} from 'flashbang/core'; +import {DisplayObjectPointerTarget, InputUtil, KeyCode} from 'flashbang/input'; +import {ContainerObject} from 'flashbang/objects'; +import {DisplayUtil, StyledTextBuilder} from 'flashbang/util'; +import {UnitSignal} from 'signals'; +import EPars from 'eterna/EPars'; +import Plot from 'eterna/Plot'; +import {EternaURL} from 'eterna/net'; +import {Bitmaps} from 'eterna/resources'; +import UndoBlock, {UndoBlockParam} from 'eterna/UndoBlock'; +import {Fonts} from 'eterna/util'; +import GameButton from './GameButton'; +import GamePanel from './GamePanel'; +import HTMLTextObject from './HTMLTextObject'; +import TextBalloon from './TextBalloon'; type InteractionEvent = PIXI.interaction.InteractionEvent; @@ -41,14 +41,14 @@ export default class SpecBox extends ContainerObject { this._dotplotScaleLevel = 1; // / Dotplot h0 - this._h0 = Fonts.arial("A", 12).color(0xffffff).build(); + this._h0 = Fonts.arial('A', 12).color(0xffffff).build(); // / Meltplot h0 - this._h0Melt = Fonts.arial("37°C", 12).color(0xffffff).build(); - this._hnMelt = Fonts.arial("97°C", 12).color(0xffffff).build(); - this._v0 = Fonts.arial("1", 12).color(0xffffff).build(); - this._v0Melt = Fonts.arial("0%", 12).color(0xffffff).build(); - this._vnMelt = Fonts.arial("100%", 12).color(0xffffff).build(); + this._h0Melt = Fonts.arial('37°C', 12).color(0xffffff).build(); + this._hnMelt = Fonts.arial('97°C', 12).color(0xffffff).build(); + this._v0 = Fonts.arial('1', 12).color(0xffffff).build(); + this._v0Melt = Fonts.arial('0%', 12).color(0xffffff).build(); + this._vnMelt = Fonts.arial('100%', 12).color(0xffffff).build(); this.container.addChild(this._h0); this.container.addChild(this._h0Melt); @@ -67,12 +67,12 @@ export default class SpecBox extends ContainerObject { if (this._docked) { this._maximizeButton = new GameButton() .allStates(Bitmaps.ImgMaximize) - .tooltip("Re-maximize") + .tooltip('Re-maximize') .hotkey(KeyCode.KeyM); this.addObject(this._maximizeButton, this.container); this._maximizeButton.clicked.connect(() => this.shouldMaximize.emit()); } else { - this._stattext = new MultiStyleText("", { + this._stattext = new MultiStyleText('', { default: { fontFamily: Fonts.ARIAL, fontSize: 14, @@ -81,27 +81,27 @@ export default class SpecBox extends ContainerObject { }); this.container.addChild(this._stattext); - let url = EternaURL.createURL({page: "manual"}); - let helpText = `What are these parameters?`; + let url = EternaURL.createURL({page: 'manual'}); + let helpText = `What are these parameters?`; this._helpText = new HTMLTextObject(helpText).font(Fonts.ARIAL).fontSize(14).color(0xffffff); this.addObject(this._helpText, this.container); - this._dotplottext = Fonts.arial("Pairing probabilities plot", 12).color(0xffffff).build(); + this._dotplottext = Fonts.arial('Pairing probabilities plot', 12).color(0xffffff).build(); this.container.addChild(this._dotplottext); - this._meltplottext = Fonts.arial("Melt plot (% of unpaired bases)", 12).color(0xffffff).build(); + this._meltplottext = Fonts.arial('Melt plot (% of unpaired bases)', 12).color(0xffffff).build(); this.container.addChild(this._meltplottext); this._zoomInButton = new GameButton() .allStates(Bitmaps.PlusImg) - .tooltip("Zoom In") + .tooltip('Zoom In') .hotkey(KeyCode.KeyI); this._zoomInButton.clicked.connect(() => this.dotPlotZoomIn()); this.addObject(this._zoomInButton, this.container); this._zoomOutButton = new GameButton() .allStates(Bitmaps.MinusImg) - .tooltip("Zoom out") + .tooltip('Zoom out') .hotkey(KeyCode.KeyO); this._zoomOutButton.clicked.connect(() => this.dotPlotZoomOut()); this.addObject(this._zoomOutButton, this.container); @@ -148,21 +148,21 @@ export default class SpecBox extends ContainerObject { fontFamily: Fonts.ARIAL, fontSize: 14, fill: 0xffffff - }).addStyle("bold", { - fontStyle: "bold" + }).addStyle('bold', { + fontStyle: 'bold' }); EPars.addLetterStyles(statString); statString - .append(`${EPars.getColoredLetter("A")}-${EPars.getColoredLetter("U")} pairs : `, "bold") + .append(`${EPars.getColoredLetter('A')}-${EPars.getColoredLetter('U')} pairs : `, 'bold') .append(`${datablock.getParam(UndoBlockParam.AU, TEMPERATURE)} `) - .append(`${EPars.getColoredLetter("G")}-${EPars.getColoredLetter("C")} pairs : `, "bold") + .append(`${EPars.getColoredLetter('G')}-${EPars.getColoredLetter('C')} pairs : `, 'bold') .append(`${datablock.getParam(UndoBlockParam.GC, TEMPERATURE)} `) - .append(`${EPars.getColoredLetter("G")}-${EPars.getColoredLetter("U")} pairs : `, "bold") + .append(`${EPars.getColoredLetter('G')}-${EPars.getColoredLetter('U')} pairs : `, 'bold') .append(`${datablock.getParam(UndoBlockParam.GU, TEMPERATURE)}\n`) - .append("Melting point : ", "bold") + .append('Melting point : ', 'bold') .append(`${datablock.getParam(UndoBlockParam.MELTING_POINT, TEMPERATURE)}°C\n`) - .append("Free energy : ", "bold") + .append('Free energy : ', 'bold') .append(`${Number(datablock.getParam(UndoBlockParam.FE, TEMPERATURE) / 100).toFixed(1)}kcal\n`); statString.apply(this._stattext); @@ -217,23 +217,23 @@ export default class SpecBox extends ContainerObject { } public get plotSize(): number { - let plot_w: number; - let plot_h: number; + let plotW: number; + let plotH: number; if (this._docked) { - plot_w = this._width - 55; - plot_h = (this._height - 51) / 2.0; + plotW = this._width - 55; + plotH = (this._height - 51) / 2.0; } else { - plot_w = (this._width - 100) / 2.0; - plot_h = this._height - 200; + plotW = (this._width - 100) / 2.0; + plotH = this._height - 200; } - return Math.min(plot_w, plot_h); + return Math.min(plotW, plotH); } public scaleDotPlot(level: number = 1): void { if (level < 1) { - log.warn("scale dotplot level under 1"); + log.warn('scale dotplot level under 1'); return; } if (Number.isNaN(this._dotplotOriginX)) { @@ -273,7 +273,7 @@ export default class SpecBox extends ContainerObject { this._meltPlotSprite.position = new Point(20, (this._height * 0.5) + 8); this._maximizeButton.display.position = new Point(this._width - 22, 5); } else { - this._panel.title = "RNA Spec"; + this._panel.title = 'RNA Spec'; this._v0.position = new Point(40 - this._v0.width - 3, 70); @@ -421,12 +421,12 @@ export default class SpecBox extends ContainerObject { } } - private updateDotplotLabel(ref_x: number, ref_y: number): void { + private updateDotplotLabel(refX: number, refY: number): void { let {plotSize} = this; let h0DefaultX: number = this._docked ? 20 : SpecBox.H0_DEFAULT_X; let h0DefaultY: number = this._docked ? 0 : SpecBox.H0_DEFAULT_Y; - let h0XStart: number = h0DefaultX + ref_x; + let h0XStart: number = h0DefaultX + refX; let h0YStart: number = h0DefaultY; this._h0.position = new Point(h0XStart, h0YStart); @@ -438,21 +438,21 @@ export default class SpecBox extends ContainerObject { this._hvec[ii].visible = !(pos.x >= plotSize + h0DefaultX - this._hvec[ii].width || pos.x < h0DefaultX); } - let v0_default_x: number = this._docked ? 10 : SpecBox.V0_DEFAULT_X; - let v0_default_y: number = this._docked ? 15 : SpecBox.V0_DEFAULT_Y; + let v0DefaultX: number = this._docked ? 10 : SpecBox.V0_DEFAULT_X; + let v0DefaultY: number = this._docked ? 15 : SpecBox.V0_DEFAULT_Y; - let v0_x_start: number = v0_default_x; - let v0_y_start: number = v0_default_y + ref_y; + let v0XStart: number = v0DefaultX; + let v0YStart: number = v0DefaultY + refY; - this._v0.position = new Point(v0_x_start, v0_y_start); + this._v0.position = new Point(v0XStart, v0YStart); - this._v0.visible = !(v0_y_start < v0_default_y); + this._v0.visible = !(v0YStart < v0DefaultY); for (let ii = 0; ii < this._vvec.length; ++ii) { let pos = this.calculateCoordPosition(this._v0, ii, SpecBox.VERTICAL); pos.set(pos.x - this._vvec[ii].width, pos.y); this._vvec[ii].position = pos; - this._vvec[ii].visible = !((pos.y >= plotSize + v0_default_y - this._vvec[ii].height || pos.y < v0_default_y)); + this._vvec[ii].visible = !((pos.y >= plotSize + v0DefaultY - this._vvec[ii].height || pos.y < v0DefaultY)); } } diff --git a/src/eterna/ui/SpecBoxDialog.ts b/src/eterna/ui/SpecBoxDialog.ts index b65eb47b5..163396ba6 100644 --- a/src/eterna/ui/SpecBoxDialog.ts +++ b/src/eterna/ui/SpecBoxDialog.ts @@ -1,11 +1,11 @@ -import {Point} from "pixi.js"; -import {Flashbang, HAlign, VAlign} from "flashbang/core"; -import {KeyCode} from "flashbang/input"; -import {DisplayUtil} from "flashbang/util"; -import UndoBlock from "eterna/UndoBlock"; -import Dialog from "./Dialog"; -import GameButton from "./GameButton"; -import SpecBox from "./SpecBox"; +import {Point} from 'pixi.js'; +import {Flashbang, HAlign, VAlign} from 'flashbang/core'; +import {KeyCode} from 'flashbang/input'; +import {DisplayUtil} from 'flashbang/util'; +import UndoBlock from 'eterna/UndoBlock'; +import Dialog from './Dialog'; +import GameButton from './GameButton'; +import SpecBox from './SpecBox'; /** * Displays a SpecBox in a modal dialog. @@ -13,7 +13,7 @@ import SpecBox from "./SpecBox"; * should display a docked SpecBox. */ export default class SpecBoxDialog extends Dialog { - public constructor(datablock: UndoBlock, showMinimizeButton: boolean = true) { + constructor(datablock: UndoBlock, showMinimizeButton: boolean = true) { super(); this._datablock = datablock; this._showMinimizeButton = showMinimizeButton; @@ -27,15 +27,15 @@ export default class SpecBoxDialog extends Dialog { specBox.setSpec(this._datablock); - let cancelButton = new GameButton().label("Ok", 14).hotkey(KeyCode.KeyS); + let cancelButton = new GameButton().label('Ok', 14).hotkey(KeyCode.KeyS); specBox.addObject(cancelButton, specBox.container); cancelButton.clicked.connect(() => this.close(false)); let minimizeButton: GameButton; if (this._showMinimizeButton) { minimizeButton = new GameButton() - .label("Minimize Window", 14) - .tooltip("Minimize") + .label('Minimize Window', 14) + .tooltip('Minimize') .hotkey(KeyCode.KeyM); specBox.addObject(minimizeButton, specBox.container); minimizeButton.clicked.connect(() => this.close(true)); diff --git a/src/eterna/ui/TextBalloon.ts b/src/eterna/ui/TextBalloon.ts index ba9727adb..66ef79fbe 100644 --- a/src/eterna/ui/TextBalloon.ts +++ b/src/eterna/ui/TextBalloon.ts @@ -1,20 +1,26 @@ -import MultiStyleText from "pixi-multistyle-text"; -import {Point, Text} from "pixi.js"; -import {ContainerObject} from "flashbang/objects"; -import {DisplayUtil, StyledTextBuilder} from "flashbang/util"; -import {Fonts} from "eterna/util"; -import BaseGamePanel from "./BaseGamePanel"; -import GameButton from "./GameButton"; -import GamePanel, {GamePanelType} from "./GamePanel"; +import MultiStyleText from 'pixi-multistyle-text'; +import {Point, Text} from 'pixi.js'; +import {ContainerObject} from 'flashbang/objects'; +import {DisplayUtil, StyledTextBuilder} from 'flashbang/util'; +import {Fonts} from 'eterna/util'; +import BaseGamePanel from './BaseGamePanel'; +import GameButton from './GameButton'; +import GamePanel, {GamePanelType} from './GamePanel'; export default class TextBalloon extends ContainerObject { - public constructor(text: string = "", balloonColor: number = 0xFFFFFF, balloonAlpha: number = 0.07, borderColor: number = 0, borderAlpha: number = 0) { + constructor( + text: string = '', + balloonColor: number = 0xFFFFFF, + balloonAlpha: number = 0.07, + borderColor: number = 0, + borderAlpha: number = 0 + ) { super(); this._panel = new GamePanel(GamePanelType.NORMAL, balloonAlpha, balloonColor, borderAlpha, borderColor); this.addObject(this._panel, this.container); - this._button = new GameButton().label("Next", 12); + this._button = new GameButton().label('Next', 12); this.addObject(this._button, this.container); this._button.display.visible = false; @@ -61,11 +67,11 @@ export default class TextBalloon extends ContainerObject { } } - public setText(text: string, fontsize: number = 15, font_color: number = 0xC0DCE7): void { + public setText(text: string, fontsize: number = 15, fontColor: number = 0xC0DCE7): void { this.styledText = new StyledTextBuilder({ fontFamily: Fonts.ARIAL, fontSize: fontsize, - fill: font_color + fill: fontColor }).append(text); } @@ -78,24 +84,24 @@ export default class TextBalloon extends ContainerObject { } public get width(): number { - let whole_width: number = this._text != null ? this._text.width : 0; + let wholeWidth: number = this._text != null ? this._text.width : 0; if (this._button != null && this._button.display.visible) { - whole_width += TextBalloon.W_MARGIN; - whole_width += DisplayUtil.width(this._button.display); + wholeWidth += TextBalloon.W_MARGIN; + wholeWidth += DisplayUtil.width(this._button.display); } - return whole_width + 2 * TextBalloon.W_MARGIN; + return wholeWidth + 2 * TextBalloon.W_MARGIN; } public get height(): number { - let whole_height = 0; - whole_height += this._text != null ? this._text.height : 0; + let wholeHeight = 0; + wholeHeight += this._text != null ? this._text.height : 0; if (this._button != null && this._button.display.visible) { - whole_height = Math.max(whole_height, DisplayUtil.height(this._button.display)); + wholeHeight = Math.max(wholeHeight, DisplayUtil.height(this._button.display)); } - return whole_height + 2 * TextBalloon.H_MARGIN + this._panel.titleHeight; + return wholeHeight + 2 * TextBalloon.H_MARGIN + this._panel.titleHeight; } protected updateView(): void { @@ -107,35 +113,35 @@ export default class TextBalloon extends ContainerObject { let {height} = this; this._panel.setSize(width, height); - let whole_width: number = width - 2 * TextBalloon.W_MARGIN; - let title_space: number = this._panel.titleHeight; + let wholeWidth: number = width - 2 * TextBalloon.W_MARGIN; + let titleSpace: number = this._panel.titleHeight; if (!this._centered) { if (this._text != null) { - this._text.position = new Point(TextBalloon.W_MARGIN, TextBalloon.H_MARGIN + title_space); + this._text.position = new Point(TextBalloon.W_MARGIN, TextBalloon.H_MARGIN + titleSpace); } if (this._button.display.visible) { this._button.display.position = new Point( TextBalloon.W_MARGIN + this._text.width + TextBalloon.W_MARGIN, - TextBalloon.H_MARGIN + title_space + this._text.height - DisplayUtil.height(this._button.display) + TextBalloon.H_MARGIN + titleSpace + this._text.height - DisplayUtil.height(this._button.display) ); } this._panel.display.position = new Point(0, 0); } else { if (this._text != null) { - this._text.position = new Point(-whole_width / 2, TextBalloon.H_MARGIN + title_space); + this._text.position = new Point(-wholeWidth / 2, TextBalloon.H_MARGIN + titleSpace); } if (this._button.display.visible) { this._button.display.position = new Point( - -whole_width / 2 + this._text.width + TextBalloon.W_MARGIN, - TextBalloon.H_MARGIN + title_space + this._text.height - DisplayUtil.height(this._button.display) + -wholeWidth / 2 + this._text.width + TextBalloon.W_MARGIN, + TextBalloon.H_MARGIN + titleSpace + this._text.height - DisplayUtil.height(this._button.display) ); } - this._panel.display.position = new Point(-whole_width / 2, 0); + this._panel.display.position = new Point(-wholeWidth / 2, 0); } } diff --git a/src/eterna/ui/TextInputObject.ts b/src/eterna/ui/TextInputObject.ts index edca516b7..3c9b58798 100644 --- a/src/eterna/ui/TextInputObject.ts +++ b/src/eterna/ui/TextInputObject.ts @@ -1,10 +1,10 @@ -import {Graphics, Point, Sprite} from "pixi.js"; -import {DisplayObjectPointerTarget} from "flashbang/input"; -import {DOMObject} from "flashbang/objects"; -import {TextBuilder} from "flashbang/util"; -import {Signal} from "signals"; -import Eterna from "eterna/Eterna"; -import {Fonts} from "eterna/util"; +import {Graphics, Point, Sprite} from 'pixi.js'; +import {DisplayObjectPointerTarget} from 'flashbang/input'; +import {DOMObject} from 'flashbang/objects'; +import {TextBuilder} from 'flashbang/util'; +import {Signal} from 'signals'; +import Eterna from 'eterna/Eterna'; +import {Fonts} from 'eterna/util'; /** * A text input object in the DOM. Floats on top of the PIXI canvas. @@ -13,8 +13,11 @@ import {Fonts} from "eterna/util"; export default class TextInputObject extends DOMObject { public readonly valueChanged: Signal = new Signal(); - public constructor(fontSize: number, width: number = 100, rows: number = 1) { - super(Eterna.OVERLAY_DIV_ID, rows === 1 ? TextInputObject.createTextInput() : TextInputObject.createTextArea(rows)); + constructor(fontSize: number, width: number = 100, rows: number = 1) { + super( + Eterna.OVERLAY_DIV_ID, rows === 1 + ? TextInputObject.createTextInput() : TextInputObject.createTextArea(rows) + ); this._fontSize = fontSize; this._rows = rows; @@ -37,7 +40,7 @@ export default class TextInputObject extends DOMObject { this.destroyFakeTextInput(); - this._obj.style.visibility = "visible"; + this._obj.style.visibility = 'visible'; this._obj.focus(); }); } @@ -64,7 +67,7 @@ export default class TextInputObject extends DOMObject> = new Signal(); - public constructor(inputFontSize: number = 14) { + constructor(inputFontSize: number = 14) { super(); this._fontSize = inputFontSize; this.setup(0, 1.0, 0x152843, 0.27, 0xC0DCE7); - this._okButton = new GameButton().label("Ok", 14); + this._okButton = new GameButton().label('Ok', 14); this.addObject(this._okButton, this.container); this._okButton.clicked.connect(() => { this.okClicked.emit(this.getFieldValues()); this.resetHotkeys(); }); - this._cancelButton = new GameButton().label("Cancel", 14); + this._cancelButton = new GameButton().label('Cancel', 14); this.addObject(this._cancelButton, this.container); this._cancelButton.clicked.connect(() => { this.cancelClicked.emit(); @@ -79,7 +79,7 @@ export default class TextInputPanel extends GamePanel { public addField(name: string, width: number, multiline: boolean = false): TextInputObject { if (this.isLiveObject) { - throw new Error("Add all fields before adding object to mode"); + throw new Error('Add all fields before adding object to mode'); } let input = new TextInputObject(this._fontSize, width, multiline ? 3 : 1).font(Fonts.ARIAL); @@ -93,9 +93,11 @@ export default class TextInputPanel extends GamePanel { return input; } - public setHotkeys(ok_key: string = null, ok_txt: string = "", cancel_key: string = null, cancel_txt: string = ""): void { - this._okButton.hotkey(ok_key, false).tooltip(ok_txt); - this._cancelButton.hotkey(cancel_key, false).tooltip(cancel_txt); + public setHotkeys( + okKey: string = null, okText: string = '', cancelKey: string = null, cancelText: string = '' + ): void { + this._okButton.hotkey(okKey, false).tooltip(okText); + this._cancelButton.hotkey(cancelKey, false).tooltip(cancelText); } public resetHotkeys(): void { @@ -113,7 +115,7 @@ export default class TextInputPanel extends GamePanel { public clearFields(): void { for (let field of this._fields) { - field.input.text = ""; + field.input.text = ''; } } diff --git a/src/eterna/ui/ToggleBar.ts b/src/eterna/ui/ToggleBar.ts index 8bdebc751..a348f9765 100644 --- a/src/eterna/ui/ToggleBar.ts +++ b/src/eterna/ui/ToggleBar.ts @@ -1,13 +1,13 @@ -import {Graphics, Point, Text} from "pixi.js"; -import {KeyboardEventType, KeyboardListener, KeyCode} from "flashbang/input"; -import {ContainerObject, Enableable} from "flashbang/objects"; -import {LocationTask} from "flashbang/tasks"; -import {Easing} from "flashbang/util"; -import {Signal} from "signals"; -import Eterna from "eterna/Eterna"; -import {Sounds} from "eterna/resources"; -import {ROPWait, RScriptUIElementID} from "eterna/rscript"; -import {Fonts} from "eterna/util"; +import {Graphics, Point, Text} from 'pixi.js'; +import {KeyboardEventType, KeyboardListener, KeyCode} from 'flashbang/input'; +import {ContainerObject, Enableable} from 'flashbang/objects'; +import {LocationTask} from 'flashbang/tasks'; +import {Easing} from 'flashbang/util'; +import {Signal} from 'signals'; +import Eterna from 'eterna/Eterna'; +import {Sounds} from 'eterna/resources'; +import {ROPWait, RScriptUIElementID} from 'eterna/rscript'; +import {Fonts} from 'eterna/util'; type InteractionEvent = PIXI.interaction.InteractionEvent; @@ -26,7 +26,11 @@ export default class ToggleBar extends ContainerObject implements KeyboardListen this._bg.clear(); this._bg.beginFill(ToggleBar.COLOR_DARK, 0.6); this._bg.lineStyle(2, ToggleBar.COLOR_LIGHT, 0.85); - this._bg.drawRoundedRect(0, 0, ToggleBar.BUTTON_SIZE * this._numStates, ToggleBar.BUTTON_SIZE, ToggleBar.ROUND_RECT_RADIUS); + this._bg.drawRoundedRect( + 0, 0, + ToggleBar.BUTTON_SIZE * this._numStates, ToggleBar.BUTTON_SIZE, + ToggleBar.ROUND_RECT_RADIUS + ); this._bg.endFill(); this._hoverHilite = new Graphics(); @@ -34,7 +38,11 @@ export default class ToggleBar extends ContainerObject implements KeyboardListen this._hoverHilite.clear(); this._hoverHilite.beginFill(ToggleBar.COLOR_MEDIUM, 0.45); - this._hoverHilite.drawRoundedRect(0, 0, ToggleBar.BUTTON_SIZE, ToggleBar.BUTTON_SIZE, ToggleBar.ROUND_RECT_RADIUS); + this._hoverHilite.drawRoundedRect( + 0, 0, + ToggleBar.BUTTON_SIZE, ToggleBar.BUTTON_SIZE, + ToggleBar.ROUND_RECT_RADIUS + ); this._hoverHilite.endFill(); this._hoverHilite.visible = false; @@ -43,7 +51,11 @@ export default class ToggleBar extends ContainerObject implements KeyboardListen this._selectedHilite.clear(); this._selectedHilite.beginFill(ToggleBar.COLOR_LIGHT, 0.85); - this._selectedHilite.drawRoundedRect(0, 0, ToggleBar.BUTTON_SIZE, ToggleBar.BUTTON_SIZE, ToggleBar.ROUND_RECT_RADIUS); + this._selectedHilite.drawRoundedRect( + 0, 0, + ToggleBar.BUTTON_SIZE, ToggleBar.BUTTON_SIZE, + ToggleBar.ROUND_RECT_RADIUS + ); this._selectedHilite.endFill(); for (let ii = 0; ii < this._numStates; ii++) { @@ -72,8 +84,13 @@ export default class ToggleBar extends ContainerObject implements KeyboardListen } this._selectedState = newState; - this.replaceNamedObject("BGSelectedAnim", - new LocationTask(this._selectedState * ToggleBar.BUTTON_SIZE, 0, 0.5, Easing.easeInOut, this._selectedHilite)); + this.replaceNamedObject( + 'BGSelectedAnim', + new LocationTask( + this._selectedState * ToggleBar.BUTTON_SIZE, 0, + 0.5, Easing.easeInOut, this._selectedHilite + ) + ); this._labels[this._selectedState].style.fill = ToggleBar.COLOR_HIGH; Eterna.sound.playSound(Sounds.SoundSwitch); diff --git a/src/eterna/ui/Toolbar.ts b/src/eterna/ui/Toolbar.ts index e1e4d976e..761d2b5e1 100644 --- a/src/eterna/ui/Toolbar.ts +++ b/src/eterna/ui/Toolbar.ts @@ -1,22 +1,22 @@ -import {Graphics, Container, Point} from "pixi.js"; -import {RegistrationGroup} from "signals"; -import {Flashbang, HAlign, VAlign} from "flashbang/core"; -import {KeyCode} from "flashbang/input"; -import {HLayoutContainer, VLayoutContainer} from "flashbang/layout"; -import {ContainerObject} from "flashbang/objects"; -import {LocationTask} from "flashbang/tasks"; -import {Easing, DisplayUtil} from "flashbang/util"; -import Eterna from "eterna/Eterna"; +import {Graphics, Point} from 'pixi.js'; +import {RegistrationGroup} from 'signals'; +import {Flashbang, HAlign, VAlign} from 'flashbang/core'; +import {KeyCode} from 'flashbang/input'; +import {HLayoutContainer, VLayoutContainer} from 'flashbang/layout'; +import {ContainerObject} from 'flashbang/objects'; +import {LocationTask} from 'flashbang/tasks'; +import {Easing, DisplayUtil} from 'flashbang/util'; +import Eterna from 'eterna/Eterna'; // Stupid cyclic dependancy - TODO: Fix later once this can get refactored -import Booster from "eterna/mode/PoseEdit/Booster"; -import PoseEditMode from "eterna/mode/PoseEdit/PoseEditMode"; -import {Bitmaps} from "eterna/resources"; -import {RScriptUIElementID} from "eterna/rscript"; -import {BoostersData} from "eterna/puzzle"; -import NucleotidePalette from "./NucleotidePalette"; -import GameButton from "./GameButton"; -import ToggleBar from "./ToggleBar"; -import EternaMenu, {EternaMenuStyle} from "./EternaMenu"; +import Booster from 'eterna/mode/PoseEdit/Booster'; +import PoseEditMode from 'eterna/mode/PoseEdit/PoseEditMode'; +import {Bitmaps} from 'eterna/resources'; +import {RScriptUIElementID} from 'eterna/rscript'; +import {BoostersData} from 'eterna/puzzle'; +import NucleotidePalette from './NucleotidePalette'; +import GameButton from './GameButton'; +import ToggleBar from './ToggleBar'; +import EternaMenu, {EternaMenuStyle} from './EternaMenu'; export enum ToolbarType { PUZZLE, @@ -83,8 +83,10 @@ export default class Toolbar extends ContainerObject { // Puzzle Maker + Lab public submitButton: GameButton; - constructor(type: ToolbarType, - {states = 1, showHint = false, boosters = null}: {states?: number; showHint?: boolean; boosters?: BoostersData}) { + constructor( + type: ToolbarType, + {states = 1, showHint = false, boosters = null}: {states?: number; showHint?: boolean; boosters?: BoostersData} + ) { super(); this._type = type; this._states = states; @@ -110,7 +112,11 @@ export default class Toolbar extends ContainerObject { this.container.addChild(this._content); this.stateToggle = new ToggleBar(this._states); - if (this._states > 1 && this._type !== ToolbarType.PUZZLEMAKER && this._type !== ToolbarType.PUZZLEMAKER_EMBEDDED) { + if ( + this._states > 1 + && this._type !== ToolbarType.PUZZLEMAKER + && this._type !== ToolbarType.PUZZLEMAKER_EMBEDDED + ) { // We create the stateToggle even if we don't add it to the mode, // as scripts may rely on its existence this.addObject(this.stateToggle, this._content); @@ -118,7 +124,7 @@ export default class Toolbar extends ContainerObject { // UPPER TOOLBAR (structure editing tools) let upperToolbarLayout = new HLayoutContainer(SPACE_NARROW); - if (this._type == ToolbarType.PUZZLEMAKER || this._type == ToolbarType.PUZZLEMAKER_EMBEDDED) { + if (this._type === ToolbarType.PUZZLEMAKER || this._type === ToolbarType.PUZZLEMAKER_EMBEDDED) { this._content.addChild(upperToolbarLayout); } @@ -128,7 +134,7 @@ export default class Toolbar extends ContainerObject { .down(Bitmaps.ImgAddBaseSelect) .selected(Bitmaps.ImgAddBaseSelect) .hotkey(KeyCode.Digit6) - .tooltip("Add a single base."); + .tooltip('Add a single base.'); this.addpairButton = new GameButton() .up(Bitmaps.ImgAddPair) @@ -136,7 +142,7 @@ export default class Toolbar extends ContainerObject { .down(Bitmaps.ImgAddPairSelect) .selected(Bitmaps.ImgAddPairSelect) .hotkey(KeyCode.Digit7) - .tooltip("Add a pair."); + .tooltip('Add a pair.'); this.deleteButton = new GameButton() .up(Bitmaps.ImgErase) @@ -144,7 +150,7 @@ export default class Toolbar extends ContainerObject { .down(Bitmaps.ImgEraseSelect) .selected(Bitmaps.ImgEraseSelect) .hotkey(KeyCode.Digit8) - .tooltip("Delete a base or a pair."); + .tooltip('Delete a base or a pair.'); this.lockButton = new GameButton() .up(Bitmaps.ImgLock) @@ -152,7 +158,7 @@ export default class Toolbar extends ContainerObject { .down(Bitmaps.ImgLockSelect) .selected(Bitmaps.ImgLockSelect) .hotkey(KeyCode.Digit9) - .tooltip("Lock or unlock a base."); + .tooltip('Lock or unlock a base.'); this.moleculeButton = new GameButton() .up(Bitmaps.ImgMolecule) @@ -160,9 +166,9 @@ export default class Toolbar extends ContainerObject { .down(Bitmaps.ImgMoleculeSelect) .selected(Bitmaps.ImgMoleculeSelect) .hotkey(KeyCode.Digit0) - .tooltip("Create or remove a molecular binding site."); + .tooltip('Create or remove a molecular binding site.'); - if (this._type == ToolbarType.PUZZLEMAKER || this._type == ToolbarType.PUZZLEMAKER_EMBEDDED) { + if (this._type === ToolbarType.PUZZLEMAKER || this._type === ToolbarType.PUZZLEMAKER_EMBEDDED) { this.addObject(this.addbaseButton, upperToolbarLayout); this.addObject(this.addpairButton, upperToolbarLayout); this.addObject(this.deleteButton, upperToolbarLayout); @@ -202,49 +208,49 @@ export default class Toolbar extends ContainerObject { this.screenshotButton = new GameButton() .allStates(Bitmaps.ImgScreenshot) .disabled(null) - .label("Screenshot", 14) + .label('Screenshot', 14) .scaleBitmapToLabel() - .tooltip("Screenshot"); + .tooltip('Screenshot'); this.actionMenu.addSubMenuButton(0, this.screenshotButton); this.viewOptionsButton = new GameButton() .allStates(Bitmaps.ImgSettings) .disabled(null) - .label("Settings", 14) + .label('Settings', 14) .scaleBitmapToLabel() - .tooltip("Game options"); + .tooltip('Game options'); this.actionMenu.addSubMenuButton(0, this.viewOptionsButton); this.viewSolutionsButton = new GameButton() .allStates(Bitmaps.ImgFile) .disabled(null) - .label("Designs", 14) + .label('Designs', 14) .scaleBitmapToLabel() - .tooltip("View all submitted designs for this puzzle."); + .tooltip('View all submitted designs for this puzzle.'); - if (this._type == ToolbarType.LAB || this._type == ToolbarType.FEEDBACK) { + if (this._type === ToolbarType.LAB || this._type === ToolbarType.FEEDBACK) { this.actionMenu.addSubMenuButton(0, this.viewSolutionsButton); } this.specButton = new GameButton() .allStates(Bitmaps.ImgSpec) .disabled(null) - .label("Specs", 14) + .label('Specs', 14) .scaleBitmapToLabel() .tooltip("View RNA's melting point, dotplot and other specs") .hotkey(KeyCode.KeyS); - if (this._type == ToolbarType.FEEDBACK || this._type == ToolbarType.LAB) { + if (this._type === ToolbarType.FEEDBACK || this._type === ToolbarType.LAB) { this.actionMenu.addSubMenuButton(0, this.specButton); } - let resetTooltip = this._type == ToolbarType.PUZZLEMAKER || this._type == ToolbarType.PUZZLEMAKER_EMBEDDED - ? "Reset all bases to A" : "Reset and try this puzzle again."; + let resetTooltip = this._type === ToolbarType.PUZZLEMAKER || this._type === ToolbarType.PUZZLEMAKER_EMBEDDED + ? 'Reset all bases to A' : 'Reset and try this puzzle again.'; this.resetButton = new GameButton() .allStates(Bitmaps.ImgReset) .disabled(null) - .label("Reset", 14) + .label('Reset', 14) .scaleBitmapToLabel() .tooltip(resetTooltip) .rscriptID(RScriptUIElementID.RESET); @@ -252,25 +258,25 @@ export default class Toolbar extends ContainerObject { this.copyButton = new GameButton() .allStates(Bitmaps.ImgCopy) .disabled(null) - .label("Copy", 14) + .label('Copy', 14) .scaleBitmapToLabel() - .tooltip("Copy the current sequence"); + .tooltip('Copy the current sequence'); this.pasteButton = new GameButton() .allStates(Bitmaps.ImgPaste) .disabled(null) - .label("Paste", 14) + .label('Paste', 14) .scaleBitmapToLabel() - .tooltip("Type in a sequence"); + .tooltip('Type in a sequence'); - if (this._type != ToolbarType.FEEDBACK) { + if (this._type !== ToolbarType.FEEDBACK) { this.actionMenu.addSubMenuButton(0, this.resetButton); this.actionMenu.addSubMenuButton(0, this.copyButton); this.actionMenu.addSubMenuButton(0, this.pasteButton); } + this.boostersMenu = new GameButton().allStates(Bitmaps.NovaBoosters).disabled(null); if (this._boostersData != null && this._boostersData.actions != null) { - this.boostersMenu = new GameButton().allStates(Bitmaps.NovaBoosters).disabled(null); let boosterMenuIdx = this.actionMenu.addMenuButton(this.boostersMenu); for (let ii = 0; ii < this._boostersData.actions.length; ii++) { let data = this._boostersData.actions[ii]; @@ -287,9 +293,9 @@ export default class Toolbar extends ContainerObject { .up(Bitmaps.ImgSubmit) .over(Bitmaps.ImgSubmitOver) .down(Bitmaps.ImgSubmitHit) - .tooltip("Publish your solution!"); + .tooltip('Publish your solution!'); - if (this._type == ToolbarType.LAB) { + if (this._type === ToolbarType.LAB) { lowerToolbarLayout.addHSpacer(SPACE_NARROW); this.addObject(this.submitButton, lowerToolbarLayout); } @@ -301,11 +307,11 @@ export default class Toolbar extends ContainerObject { .over(Bitmaps.ImgFreezeOver) .down(Bitmaps.ImgFreezeSelected) .selected(Bitmaps.ImgFreezeSelected) - .tooltip("Frozen mode. Suspends/resumes folding engine calculations.") + .tooltip('Frozen mode. Suspends/resumes folding engine calculations.') .hotkey(KeyCode.KeyF) .rscriptID(RScriptUIElementID.FREEZE); - if (this._type == ToolbarType.LAB || this._type == ToolbarType.PUZZLE) { + if (this._type === ToolbarType.LAB || this._type === ToolbarType.PUZZLE) { this.addObject(this.freezeButton, lowerToolbarLayout); lowerToolbarLayout.addHSpacer(SPACE_NARROW); this.freezeButton.display.visible = Eterna.settings.freezeButtonAlwaysVisible.value; @@ -319,11 +325,14 @@ export default class Toolbar extends ContainerObject { .up(Bitmaps.ImgPip) .over(Bitmaps.ImgPipOver) .down(Bitmaps.ImgPipHit) - .tooltip("Set PiP mode") + .tooltip('Set PiP mode') .hotkey(KeyCode.KeyP) .rscriptID(RScriptUIElementID.PIP); - if (this._states > 1 && this._type !== ToolbarType.PUZZLEMAKER && this._type !== ToolbarType.PUZZLEMAKER_EMBEDDED) { + if ( + this._states > 1 + && this._type !== ToolbarType.PUZZLEMAKER && this._type !== ToolbarType.PUZZLEMAKER_EMBEDDED + ) { this.addObject(this.pipButton, lowerToolbarLayout); lowerToolbarLayout.addHSpacer(SPACE_NARROW); } @@ -333,7 +342,7 @@ export default class Toolbar extends ContainerObject { .over(Bitmaps.ImgNativeOver) .down(Bitmaps.ImgNativeSelected) .selected(Bitmaps.ImgNativeSelected) - .tooltip("Natural Mode. RNA folds into the most stable shape.") + .tooltip('Natural Mode. RNA folds into the most stable shape.') .rscriptID(RScriptUIElementID.TOGGLENATURAL); this.estimateButton = new GameButton() @@ -341,18 +350,18 @@ export default class Toolbar extends ContainerObject { .over(Bitmaps.ImgEstimateOver) .down(Bitmaps.ImgEstimateSelected) .selected(Bitmaps.ImgEstimateSelected) - .tooltip("Estimate Mode. The game approximates how the RNA actually folded in a test tube."); + .tooltip('Estimate Mode. The game approximates how the RNA actually folded in a test tube.'); this.targetButton = new GameButton() .up(Bitmaps.ImgTarget) .over(Bitmaps.ImgTargetOver) .down(Bitmaps.ImgTargetSelected) .selected(Bitmaps.ImgTargetSelected) - .tooltip("Target Mode. RNA freezes into the desired shape.") + .tooltip('Target Mode. RNA freezes into the desired shape.') .rscriptID(RScriptUIElementID.TOGGLETARGET); - if (this._type != ToolbarType.PUZZLEMAKER_EMBEDDED) { - if (this._type != ToolbarType.FEEDBACK) { + if (this._type !== ToolbarType.PUZZLEMAKER_EMBEDDED) { + if (this._type !== ToolbarType.FEEDBACK) { this.addObject(this.naturalButton, lowerToolbarLayout); } else { this.addObject(this.estimateButton, lowerToolbarLayout); @@ -366,16 +375,16 @@ export default class Toolbar extends ContainerObject { .over(Bitmaps.ImgColoringOver) .down(Bitmaps.ImgColoringSelected) .selected(Bitmaps.ImgColoringSelected) - .tooltip("Color sequences based on base colors as in the game."); + .tooltip('Color sequences based on base colors as in the game.'); this.expColorButton = new GameButton() .up(Bitmaps.ImgFlask) .over(Bitmaps.ImgFlaskOver) .down(Bitmaps.ImgFlaskSelected) .selected(Bitmaps.ImgFlaskSelected) - .tooltip("Color sequences based on experimental data."); + .tooltip('Color sequences based on experimental data.'); - if (this._type == ToolbarType.FEEDBACK) { + if (this._type === ToolbarType.FEEDBACK) { lowerToolbarLayout.addHSpacer(SPACE_NARROW); this.letterColorButton.toggled.value = false; @@ -397,10 +406,10 @@ export default class Toolbar extends ContainerObject { .down(Bitmaps.ImgSwapOver) .selected(Bitmaps.ImgSwapSelect) .hotkey(KeyCode.Digit5) - .tooltip("Swap paired bases.") + .tooltip('Swap paired bases.') .rscriptID(RScriptUIElementID.SWAP); - if (this._type != ToolbarType.FEEDBACK) { + if (this._type !== ToolbarType.FEEDBACK) { lowerToolbarLayout.addHSpacer(SPACE_WIDE); this.addObject(this.palette, lowerToolbarLayout); @@ -443,7 +452,7 @@ export default class Toolbar extends ContainerObject { .over(Bitmaps.ImgZoomInOver) .down(Bitmaps.ImgZoomInHit) .disabled(Bitmaps.ImgZoomInDisable) - .tooltip("Zoom in") + .tooltip('Zoom in') .hotkey(KeyCode.Equal) .rscriptID(RScriptUIElementID.ZOOMIN); this.addObject(this.zoomInButton, lowerToolbarLayout); @@ -453,7 +462,7 @@ export default class Toolbar extends ContainerObject { .over(Bitmaps.ImgZoomOutOver) .down(Bitmaps.ImgZoomOutHit) .disabled(Bitmaps.ImgZoomOutDisable) - .tooltip("Zoom out") + .tooltip('Zoom out') .hotkey(KeyCode.Minus) .rscriptID(RScriptUIElementID.ZOOMOUT); this.addObject(this.zoomOutButton, lowerToolbarLayout); @@ -464,7 +473,7 @@ export default class Toolbar extends ContainerObject { .up(Bitmaps.ImgUndo) .over(Bitmaps.ImgUndoOver) .down(Bitmaps.ImgUndoHit) - .tooltip("Undo") + .tooltip('Undo') .hotkey(KeyCode.KeyZ) .rscriptID(RScriptUIElementID.UNDO); @@ -472,11 +481,11 @@ export default class Toolbar extends ContainerObject { .up(Bitmaps.ImgRedo) .over(Bitmaps.ImgRedoOver) .down(Bitmaps.ImgRedoHit) - .tooltip("Redo") + .tooltip('Redo') .hotkey(KeyCode.KeyY) .rscriptID(RScriptUIElementID.REDO); - if (this._type != ToolbarType.FEEDBACK) { + if (this._type !== ToolbarType.FEEDBACK) { this.addObject(this.undoButton, lowerToolbarLayout); this.addObject(this.redoButton, lowerToolbarLayout); } @@ -486,7 +495,7 @@ export default class Toolbar extends ContainerObject { .over(Bitmaps.ImgHintOver) .down(Bitmaps.ImgHintHit) .hotkey(KeyCode.KeyH) - .tooltip("Hint") + .tooltip('Hint') .rscriptID(RScriptUIElementID.HINT); if (this._showHint) { @@ -497,9 +506,9 @@ export default class Toolbar extends ContainerObject { .up(Bitmaps.ImgSubmit) .over(Bitmaps.ImgSubmitOver) .down(Bitmaps.ImgSubmitHit) - .tooltip("Publish your puzzle!"); + .tooltip('Publish your puzzle!'); - if (this._type == ToolbarType.PUZZLEMAKER) { + if (this._type === ToolbarType.PUZZLEMAKER) { this.addObject(this.submitButton, lowerToolbarLayout); } @@ -517,7 +526,7 @@ export default class Toolbar extends ContainerObject { // the boosters button. The tutorial hardcodes screen locations for its // point-at-toolbar-buttons tips, so everything needs to be laid out *just so*, // unfortunately. - let hOffset = (this.boostersMenu == null && this._type == ToolbarType.PUZZLE ? 27 : 0); + let hOffset = (this.boostersMenu == null && this._type === ToolbarType.PUZZLE ? 27 : 0); DisplayUtil.positionRelative( this._content, HAlign.CENTER, VAlign.BOTTOM, @@ -527,7 +536,7 @@ export default class Toolbar extends ContainerObject { } private setToolbarAutohide(enabled: boolean): void { - const COLLAPSE_ANIM = "CollapseAnim"; + const COLLAPSE_ANIM = 'CollapseAnim'; if (enabled) { this.display.interactive = true; diff --git a/src/eterna/ui/Tooltips.ts b/src/eterna/ui/Tooltips.ts index ad7bfa3f9..90c144c38 100644 --- a/src/eterna/ui/Tooltips.ts +++ b/src/eterna/ui/Tooltips.ts @@ -1,13 +1,13 @@ -import {ExtendedTextStyle} from "pixi-multistyle-text"; +import {ExtendedTextStyle} from 'pixi-multistyle-text'; import { Container, DisplayObject, Graphics, Point, Rectangle, Text -} from "pixi.js"; -import {Flashbang, GameObject, GameObjectRef} from "flashbang/core"; -import {Button} from "flashbang/objects"; -import {AlphaTask, DelayTask, SerialTask} from "flashbang/tasks"; -import {Easing, StyledTextBuilder} from "flashbang/util"; -import {Registration, RegistrationGroup} from "signals"; -import {Fonts} from "eterna/util"; +} from 'pixi.js'; +import {Flashbang, GameObject, GameObjectRef} from 'flashbang/core'; +import {Button} from 'flashbang/objects'; +import {AlphaTask, DelayTask, SerialTask} from 'flashbang/tasks'; +import {Easing, StyledTextBuilder} from 'flashbang/util'; +import {Registration, RegistrationGroup} from 'signals'; +import {Fonts} from 'eterna/util'; /** A tooltip can be a string, styled text, or a function that creates a DisplayObject */ export type Tooltip = (() => DisplayObject) | string | StyledTextBuilder; @@ -24,7 +24,7 @@ export default class Tooltips extends GameObject { return Flashbang.curMode.getObjectWithId(Tooltips); } - public constructor(layer: Container) { + constructor(layer: Container) { super(); this._layer = layer; } @@ -39,7 +39,7 @@ export default class Tooltips extends GameObject { } public showTooltip(key: any, loc: Point, tooltip: Tooltip): void { - if (this._curTooltipKey == key) { + if (this._curTooltipKey === key) { return; } @@ -62,7 +62,7 @@ export default class Tooltips extends GameObject { } public showTooltipFor(target: DisplayObject, key: any, tooltip: Tooltip): void { - if (this._curTooltipKey == key) { + if (this._curTooltipKey === key) { return; } @@ -73,7 +73,7 @@ export default class Tooltips extends GameObject { } public removeTooltip(key: any): void { - if (this._curTooltipKey == key) { + if (this._curTooltipKey === key) { this.removeCurTooltip(); } } @@ -111,9 +111,9 @@ export default class Tooltips extends GameObject { } private static createTooltip(tooltip: Tooltip): DisplayObject { - if (typeof (tooltip) === "string" || tooltip instanceof StyledTextBuilder) { + if (typeof (tooltip) === 'string' || tooltip instanceof StyledTextBuilder) { let textField: Container; - if (typeof (tooltip) === "string") { + if (typeof (tooltip) === 'string') { textField = new Text(tooltip, Tooltips.DEFAULT_STYLE); } else { textField = tooltip.build(); diff --git a/src/eterna/ui/UILockDialog.ts b/src/eterna/ui/UILockDialog.ts index 2882423bb..13d8015be 100644 --- a/src/eterna/ui/UILockDialog.ts +++ b/src/eterna/ui/UILockDialog.ts @@ -1,6 +1,6 @@ -import * as log from "loglevel"; -import {AlphaTask} from "flashbang/tasks"; -import Dialog from "./Dialog"; +import * as log from 'loglevel'; +import {AlphaTask} from 'flashbang/tasks'; +import Dialog from './Dialog'; /** A "dialog" that simply dims the screen and eats UI events */ export default class UILockDialog extends Dialog { diff --git a/src/eterna/ui/URLButton.ts b/src/eterna/ui/URLButton.ts index 31e4cc1b7..8dade8b31 100644 --- a/src/eterna/ui/URLButton.ts +++ b/src/eterna/ui/URLButton.ts @@ -1,9 +1,9 @@ -import {Graphics} from "pixi.js"; -import HTMLTextObject from "./HTMLTextObject"; +import {Graphics} from 'pixi.js'; +import HTMLTextObject from './HTMLTextObject'; /** A DOM-based underlined text link with some background styling. */ export default class URLButton extends HTMLTextObject { - public constructor(text: string, url: string) { + constructor(text: string, url: string) { super(URLButton.createHTML(text, url)); } diff --git a/src/eterna/ui/VScrollBox.ts b/src/eterna/ui/VScrollBox.ts index db4772b9a..36851c88c 100644 --- a/src/eterna/ui/VScrollBox.ts +++ b/src/eterna/ui/VScrollBox.ts @@ -1,20 +1,20 @@ -import {Container} from "pixi.js"; -import {SceneObject} from "flashbang/objects"; -import {MathUtil} from "flashbang/util"; -import ScrollContainer from "./ScrollContainer"; -import SliderBar from "./SliderBar"; +import {Container} from 'pixi.js'; +import {SceneObject} from 'flashbang/objects'; +import {MathUtil} from 'flashbang/util'; +import ScrollContainer from './ScrollContainer'; +import SliderBar from './SliderBar'; /** Contains scrollable content and a vertical sliderbar */ export default class VScrollBox extends SceneObject { - public constructor(width: number, height: number) { + constructor(width: number, height: number) { super(new ScrollContainer(width - SliderBar.THUMB_SIZE, height)); this._width = width; this._height = height; this._sliderBar = new SliderBar(true); this.addObject(this._sliderBar, this._display); - this._sliderBar.set_progress(0); - this._sliderBar.scrollChanged.connect(progress => this.scrollProgress = progress); + this._sliderBar.setProgress(0); + this._sliderBar.scrollChanged.connect((progress) => { this.scrollProgress = progress; }); } /** Attach scrollable content here */ @@ -46,7 +46,7 @@ export default class VScrollBox extends SceneObject { } public scrollTo(value: number) { - this._sliderBar.set_progress(MathUtil.clamp(value, 0, 1)); + this._sliderBar.setProgress(MathUtil.clamp(value, 0, 1)); } private readonly _sliderBar: SliderBar; diff --git a/src/eterna/ui/index.ts b/src/eterna/ui/index.ts index 0db2c5dde..a58634d1d 100644 --- a/src/eterna/ui/index.ts +++ b/src/eterna/ui/index.ts @@ -1,36 +1,36 @@ -export {default as BaseGamePanel} from "./BaseGamePanel"; -export {default as GamePanel, GamePanelType} from "./GamePanel"; -export {default as ActionBar} from "./ActionBar"; -export {default as Dialog, DialogCanceledError} from "./Dialog"; -export {default as TextBalloon} from "./TextBalloon"; -export {default as AsyncProcessDialog} from "./AsyncProcessDialog"; -export {default as Band} from "./Band"; -export {default as ConfirmDialog} from "./ConfirmDialog"; -export {default as ConstraintBox, ConstraintBoxType} from "./ConstraintBox"; -export {default as ContextMenu} from "./ContextMenu"; -export {default as EternaMenu, EternaMenuStyle} from "./EternaMenu"; -export {default as EternaViewOptionsDialog, EternaViewOptionsMode} from "./EternaViewOptionsDialog"; -export {default as FancyGamePanel, FancyGamePanelType} from "./FancyGamePanel"; -export {default as FancyTextBalloon} from "./FancyTextBalloon"; -export {default as FixedWidthTextField} from "./FixedWidthTextField"; -export {default as GameButton} from "./GameButton"; -export {default as GameCheckbox} from "./GameCheckbox"; -export {default as HTMLTextObject} from "./HTMLTextObject"; -export {default as NotificationDialog} from "./NotificationDialog"; +export {default as BaseGamePanel} from './BaseGamePanel'; +export {default as GamePanel, GamePanelType} from './GamePanel'; +export {default as ActionBar} from './ActionBar'; +export {default as Dialog, DialogCanceledError} from './Dialog'; +export {default as TextBalloon} from './TextBalloon'; +export {default as AsyncProcessDialog} from './AsyncProcessDialog'; +export {default as Band} from './Band'; +export {default as ConfirmDialog} from './ConfirmDialog'; +export {default as ConstraintBox, ConstraintBoxType} from './ConstraintBox'; +export {default as ContextMenu} from './ContextMenu'; +export {default as EternaMenu, EternaMenuStyle} from './EternaMenu'; +export {default as EternaViewOptionsDialog, EternaViewOptionsMode} from './EternaViewOptionsDialog'; +export {default as FancyGamePanel, FancyGamePanelType} from './FancyGamePanel'; +export {default as FancyTextBalloon} from './FancyTextBalloon'; +export {default as FixedWidthTextField} from './FixedWidthTextField'; +export {default as GameButton} from './GameButton'; +export {default as GameCheckbox} from './GameCheckbox'; +export {default as HTMLTextObject} from './HTMLTextObject'; +export {default as NotificationDialog} from './NotificationDialog'; export { default as NucleotidePalette, PaletteTargetType, GetPaletteTargetBaseType, StringToPaletteTargetType -} from "./NucleotidePalette"; -export {default as PasteSequenceDialog} from "./PasteSequenceDialog"; -export {default as PoseThumbnail, PoseThumbnailType} from "./PoseThumbnail"; -export {default as ScrollContainer} from "./ScrollContainer"; -export {default as SliderBar} from "./SliderBar"; -export {default as SpecBox} from "./SpecBox"; -export {default as SpecBoxDialog} from "./SpecBoxDialog"; -export {default as TextInputObject} from "./TextInputObject"; -export {default as TextInputPanel} from "./TextInputPanel"; -export {default as ToggleBar} from "./ToggleBar"; -export {default as Tooltips, Tooltip} from "./Tooltips"; -export {default as UILockDialog} from "./UILockDialog"; -export {default as URLButton} from "./URLButton"; -export {default as VScrollBox} from "./VScrollBox"; -export {default as Toolbar, ToolbarType} from "./Toolbar"; +} from './NucleotidePalette'; +export {default as PasteSequenceDialog} from './PasteSequenceDialog'; +export {default as PoseThumbnail, PoseThumbnailType} from './PoseThumbnail'; +export {default as ScrollContainer} from './ScrollContainer'; +export {default as SliderBar} from './SliderBar'; +export {default as SpecBox} from './SpecBox'; +export {default as SpecBoxDialog} from './SpecBoxDialog'; +export {default as TextInputObject} from './TextInputObject'; +export {default as TextInputPanel} from './TextInputPanel'; +export {default as ToggleBar} from './ToggleBar'; +export {default as Tooltips, Tooltip} from './Tooltips'; +export {default as UILockDialog} from './UILockDialog'; +export {default as URLButton} from './URLButton'; +export {default as VScrollBox} from './VScrollBox'; +export {default as Toolbar, ToolbarType} from './Toolbar'; diff --git a/src/eterna/util/CSVParser.ts b/src/eterna/util/CSVParser.ts deleted file mode 100644 index fcbc637a2..000000000 --- a/src/eterna/util/CSVParser.ts +++ /dev/null @@ -1,41 +0,0 @@ -export default class CSVParser { - public static splitOnComma(csl: string): string[] { - let vals: string[] = []; - let last_comma = -1; - let ii: number; - - for (ii = 0; ii < csl.length; ii++) { - if (csl.charAt(ii) === ",") { - vals.push(csl.substr(last_comma + 1, ii - (last_comma + 1))); - last_comma = ii; - } - } - - if (last_comma < ii) { - vals.push(csl.substr(last_comma + 1, ii - (last_comma + 1))); - } - - return vals; - } - - public static splitOnWhitespace(csl: string): string[] { - let vals: string[] = []; - let last_comma = -1; - let ii: number; - - for (ii = 0; ii < csl.length; ii++) { - if (csl.charAt(ii) === " ") { - if (last_comma < ii - 1) { - vals.push(csl.substr(last_comma + 1, ii - (last_comma + 1))); - last_comma = ii; - } - } - } - - if (last_comma < ii - 1) { - vals.push(csl.substr(last_comma + 1, ii - (last_comma + 1))); - } - - return vals; - } -} diff --git a/src/eterna/util/EternaTextureUtil.ts b/src/eterna/util/EternaTextureUtil.ts index 269d95243..75bde4181 100644 --- a/src/eterna/util/EternaTextureUtil.ts +++ b/src/eterna/util/EternaTextureUtil.ts @@ -1,5 +1,5 @@ -import {Matrix, Sprite, Texture} from "pixi.js"; -import {ColorUtil, MathUtil, TextureUtil} from "flashbang/util"; +import {Matrix, Sprite, Texture} from 'pixi.js'; +import {ColorUtil, MathUtil, TextureUtil} from 'flashbang/util'; export default class EternaTextureUtil { /** @@ -9,19 +9,19 @@ export default class EternaTextureUtil { * @param numScaleLevels number of scale levels to create versions of */ public static createScaled(textures: Texture[], scaleFactor: number, numScaleLevels: number): void { - let orig_length: number = textures.length; - let size_scaler: number = scaleFactor; - let scaler_mat: Matrix = new Matrix(); + let origLength: number = textures.length; + let sizeScaler: number = scaleFactor; + let scalerMat: Matrix = new Matrix(); for (let ss = 1; ss < numScaleLevels; ss++) { - scaler_mat.identity(); - scaler_mat.scale(size_scaler, size_scaler); + scalerMat.identity(); + scalerMat.scale(sizeScaler, sizeScaler); - for (let ii = 0; ii < orig_length; ii++) { - textures.push(EternaTextureUtil.scaleBy(textures[ii], size_scaler)); + for (let ii = 0; ii < origLength; ii++) { + textures.push(EternaTextureUtil.scaleBy(textures[ii], sizeScaler)); } - size_scaler *= scaleFactor; + sizeScaler *= scaleFactor; } } @@ -29,13 +29,13 @@ export default class EternaTextureUtil { * Creates 360-degree rotated versions of the given texture. * @return an Array containing the original texture and its rotated versions. */ - public static createRotated(texture: Texture, step_size: number): Texture[] { + public static createRotated(texture: Texture, stepSize: number): Texture[] { let rotated: Texture[] = [texture]; - let end_index: number = 360 / step_size; + let endIndex: number = 360 / stepSize; - for (let ii = 1; ii < end_index; ii++) { + for (let ii = 1; ii < endIndex; ii++) { let sprite: Sprite = new Sprite(texture); - sprite.rotation = step_size * ii * MathUtil.deg2Rad; + sprite.rotation = stepSize * ii * MathUtil.deg2Rad; rotated.push(TextureUtil.renderToTexture(sprite)); } @@ -46,30 +46,36 @@ export default class EternaTextureUtil { * Create versions of the given texture with successively lower alpha values, to 0. * @return an Array containing the original texture and its faded-out versions */ - public static createTransparent(texture: Texture, num_levels: number): Texture[] { + public static createTransparent(texture: Texture, numLevels: number): Texture[] { let transparent: Texture[] = [texture]; - for (let ss = 1; ss < num_levels; ss++) { - let col_trans = ColorUtil.colorTransform(1, 1, 1, 1 - (ss / num_levels), 0, 0, 0, 0); + for (let ss = 1; ss < numLevels; ss++) { + let colTrans = ColorUtil.colorTransform(1, 1, 1, 1 - (ss / numLevels), 0, 0, 0, 0); let sprite: Sprite = new Sprite(texture); - sprite.filters = [col_trans]; + sprite.filters = [colTrans]; transparent.push(TextureUtil.renderToTexture(sprite)); } return transparent; } - public static colorTransform(texture: Texture, rs: number, gs: number, bs: number, rt: number, gt: number, bt: number): Texture { - let color_transform = ColorUtil.colorTransform(rs / 255.0, gs / 255.0, bs / 255.0, 1, rt, gt, bt, 0); + public static colorTransform( + texture: Texture, rs: number, gs: number, bs: number, rt: number, gt: number, bt: number + ): Texture { + let colorTransform = ColorUtil.colorTransform(rs / 255.0, gs / 255.0, bs / 255.0, 1, rt, gt, bt, 0); let sprite: Sprite = new Sprite(texture); - sprite.filters = [color_transform]; + sprite.filters = [colorTransform]; return TextureUtil.renderToTexture(sprite); } - public static colorTransformAlpha(texture: Texture, rs: number, gs: number, bs: number, als: number, rt: number, gt: number, bt: number, alt: number): Texture { - let color_transform = ColorUtil.colorTransform(rs / 255.0, gs / 255.0, bs / 255.0, als, rt, gt, bt, alt); + public static colorTransformAlpha( + texture: Texture, + rs: number, gs: number, bs: number, als: number, + rt: number, gt: number, bt: number, alt: number + ): Texture { + let colorTransform = ColorUtil.colorTransform(rs / 255.0, gs / 255.0, bs / 255.0, als, rt, gt, bt, alt); let sprite: Sprite = new Sprite(texture); - sprite.filters = [color_transform]; + sprite.filters = [colorTransform]; return TextureUtil.renderToTexture(sprite); } diff --git a/src/eterna/util/ExternalInterface.ts b/src/eterna/util/ExternalInterface.ts index 37dc8a98d..f2234c23d 100644 --- a/src/eterna/util/ExternalInterface.ts +++ b/src/eterna/util/ExternalInterface.ts @@ -1,6 +1,6 @@ -import * as log from "loglevel"; -import {Assert, Deferred} from "flashbang/util"; -import {Registration, UnitSignal} from "signals"; +import * as log from 'loglevel'; +import {Assert, Deferred} from 'flashbang/util'; +import {Registration, UnitSignal} from 'signals'; /** * A collection of externally registered callbacks. @@ -31,6 +31,23 @@ export interface RunScriptOptions { checkValid?: () => boolean; } +function getDeepProperty(obj: any, name: string): [any, any] { + if (name === '') { + return [obj, undefined]; + } else { + let prop = obj; + let parent; + for (let component of name.split('.')) { + if (prop === undefined) { + throw new Error(`'${name}' is not a property of ${obj}`); + } + parent = prop; + prop = prop[component]; + } + return [parent, prop]; + } +} + /** * Exposes named functions to external scripts. * This mirrors Flash's ExternalInterface class: it installs functions on the "maingame"

that the Eterna @@ -39,7 +56,7 @@ export interface RunScriptOptions { */ export default class ExternalInterface { public static init(scriptRoot: HTMLElement) { - Assert.isTrue(this._scriptRoot === undefined, "Already initialized"); + Assert.isTrue(this._scriptRoot === undefined, 'Already initialized'); this._scriptRoot = scriptRoot; } @@ -115,7 +132,9 @@ export default class ExternalInterface { * @return true if the script ran to completion, and false if it couldn't run synchronously and is instead * queued to be executed asynchronously. */ - public static runScriptMaybeSynchronously(scriptID: string | number, options: RunScriptOptions, callback: (result: any, error: any) => void): boolean { + public static runScriptMaybeSynchronously( + scriptID: string | number, options: RunScriptOptions, callback: (result: any, error: any) => void + ): boolean { let completed = false; const complete = (result: any, error: any) => { if (completed) { @@ -198,7 +217,7 @@ export default class ExternalInterface { log.warn(`Script ${script.scriptID}: error: ${error}`); script.reject(error); } else { - log.info(`Completed ${isAsync ? "async" : ""} script ${script.scriptID}`); + log.info(`Completed ${isAsync ? 'async' : ''} script ${script.scriptID}`); script.resolve(successValue); } @@ -232,7 +251,7 @@ export default class ExternalInterface { try { this.call( - "ScriptInterface.evaluate_script_with_nid", + 'ScriptInterface.evaluate_script_with_nid', script.scriptID, script.options.params || {}, null, @@ -250,7 +269,7 @@ export default class ExternalInterface { return ( Boolean(returnValue.cause.async) === true - || (typeof returnValue.cause.async === "string" && returnValue.cause.async.toLowerCase() === "true") + || (typeof returnValue.cause.async === 'string' && returnValue.cause.async.toLowerCase() === 'true') ); } @@ -290,20 +309,3 @@ interface RegisteredCtx { ctx: ExternalInterfaceCtx; reg: Registration; } - -function getDeepProperty(obj: any, name: string): [any, any] { - if (name === "") { - return [obj, undefined]; - } else { - let prop = obj; - let parent; - for (let component of name.split(".")) { - if (prop === undefined) { - throw new Error(`'${name}' is not a property of ${obj}`); - } - parent = prop; - prop = prop[component]; - } - return [parent, prop]; - } -} diff --git a/src/eterna/util/Fonts.ts b/src/eterna/util/Fonts.ts index ebb4c25bb..9789c52ec 100644 --- a/src/eterna/util/Fonts.ts +++ b/src/eterna/util/Fonts.ts @@ -1,46 +1,46 @@ -import * as log from "loglevel"; -import {FontLoader} from "flashbang/resources"; -import {TextBuilder} from "flashbang/util"; +import * as log from 'loglevel'; +import {FontLoader} from 'flashbang/resources'; +import {TextBuilder} from 'flashbang/util'; export default class Fonts { - public static readonly ARIAL = "Arial"; - public static readonly MONOSPACE = "monospace"; + public static readonly ARIAL = 'Arial'; + public static readonly MONOSPACE = 'monospace'; - public static readonly STDFONT_LIGHT = "OpenSans-Light"; - public static readonly STDFONT_REGULAR = "OpenSans-Regular"; - public static readonly STDFONT_MEDIUM = "OpenSans-SemiBold"; - public static readonly STDFONT_BOLD = "OpenSans-Bold"; + public static readonly STDFONT_LIGHT = 'OpenSans-Light'; + public static readonly STDFONT_REGULAR = 'OpenSans-Regular'; + public static readonly STDFONT_MEDIUM = 'OpenSans-SemiBold'; + public static readonly STDFONT_BOLD = 'OpenSans-Bold'; public static loadFonts(): Promise { - log.info("Loading fonts..."); + log.info('Loading fonts...'); let loaders = Fonts.LOCAL.map(fontFamily => FontLoader.load(fontFamily)); return Promise.all(loaders) - .then(() => log.info("Fonts loaded")) - .catch(e => log.error("Error loading fonts: ", e)); + .then(() => log.info('Fonts loaded')) + .catch(e => log.error('Error loading fonts: ', e)); } - public static monospace(text: string = "", fontSize: number = 12): TextBuilder { + public static monospace(text: string = '', fontSize: number = 12): TextBuilder { return new TextBuilder(text).font(this.MONOSPACE).fontSize(fontSize); } - public static arial(text: string = "", fontSize: number = 12): TextBuilder { + public static arial(text: string = '', fontSize: number = 12): TextBuilder { return new TextBuilder(text).font(this.ARIAL).fontSize(fontSize); } - public static stdLight(text: string = "", fontSize: number = 12): TextBuilder { + public static stdLight(text: string = '', fontSize: number = 12): TextBuilder { return new TextBuilder(text).font(this.STDFONT_LIGHT).fontSize(fontSize); } - public static stdRegular(text: string = "", fontSize: number = 12): TextBuilder { + public static stdRegular(text: string = '', fontSize: number = 12): TextBuilder { return new TextBuilder(text).font(this.STDFONT_REGULAR).fontSize(fontSize); } - public static stdMedium(text: string = "", fontSize: number = 12): TextBuilder { + public static stdMedium(text: string = '', fontSize: number = 12): TextBuilder { return new TextBuilder(text).font(this.STDFONT_MEDIUM).fontSize(fontSize); } - public static stdBold(text: string = "", fontSize: number = 12): TextBuilder { + public static stdBold(text: string = '', fontSize: number = 12): TextBuilder { return new TextBuilder(text).font(this.STDFONT_BOLD).fontSize(fontSize); } diff --git a/src/eterna/util/GraphicsUtil.ts b/src/eterna/util/GraphicsUtil.ts index a1b1fa3d3..61ff0ca08 100644 --- a/src/eterna/util/GraphicsUtil.ts +++ b/src/eterna/util/GraphicsUtil.ts @@ -1,9 +1,11 @@ -import {Graphics, Point} from "pixi.js"; -import {Vector2} from "flashbang/geom"; +import {Graphics, Point} from 'pixi.js'; +import {Vector2} from 'flashbang/geom'; export default class GraphicsUtil { /** Draw a left-facing arrow, with its tip anchored at (0, 0) */ - public static drawArrow(triSize: number, baseLength: number, outlineColor: number, fillColor: number, graphics: Graphics = null): Graphics { + public static drawArrow( + triSize: number, baseLength: number, outlineColor: number, fillColor: number, graphics: Graphics = null + ): Graphics { if (graphics == null) { graphics = new Graphics(); } @@ -13,12 +15,12 @@ export default class GraphicsUtil { let triHeight = triWidth / 2 * Math.sqrt(2); let dir = new Vector2(1, 0); - let perp_dir = new Vector2(-1 * dir.y, dir.x); + let perpDir = new Vector2(-1 * dir.y, dir.x); let endPoint = new Vector2(0, 0); let basePoint = endPoint.offset(dir.x * triHeight, dir.y * triHeight); - let n1 = basePoint.offset(perp_dir.x * triWidth * 0.5, perp_dir.y * triWidth * 0.5); - let n2 = basePoint.offset(perp_dir.x * triWidth * -0.5, perp_dir.y * triWidth * -0.5); + let n1 = basePoint.offset(perpDir.x * triWidth * 0.5, perpDir.y * triWidth * 0.5); + let n2 = basePoint.offset(perpDir.x * triWidth * -0.5, perpDir.y * triWidth * -0.5); graphics.clear(); graphics.lineStyle(1, outlineColor); @@ -27,13 +29,13 @@ export default class GraphicsUtil { // draw rectangle const rectHeight = triSize - 20; - let r_start = basePoint.offset(-perp_dir.x * rectHeight * 0.5, -perp_dir.y * rectHeight * 0.5); - graphics.drawRect(r_start.x, r_start.y, baseLength, rectHeight); + let rStart = basePoint.offset(-perpDir.x * rectHeight * 0.5, -perpDir.y * rectHeight * 0.5); + graphics.drawRect(rStart.x, rStart.y, baseLength, rectHeight); graphics.endFill(); graphics.lineStyle(undefined, undefined); graphics.beginFill(fillColor, 1); - graphics.drawRect(r_start.x - 5, r_start.y + 1, 20, rectHeight - 1); + graphics.drawRect(rStart.x - 5, rStart.y + 1, 20, rectHeight - 1); graphics.endFill(); return graphics; diff --git a/src/eterna/util/Utility.ts b/src/eterna/util/Utility.ts index 6c7a35ce7..0a096fb88 100644 --- a/src/eterna/util/Utility.ts +++ b/src/eterna/util/Utility.ts @@ -1,23 +1,23 @@ -import {Point} from "pixi.js"; +import {Point} from 'pixi.js'; export default class Utility { public static roundTo(num: number, floating: number): number { - let div: number = Math.pow(10, floating); + let div: number = 10 ** floating; let temp: number = num * div; return Number(temp) / div; } public static stripHtmlTags(str: string): string { let newlinereg = //g; - str = str.replace(newlinereg, ">"); + str = str.replace(newlinereg, '>'); return str; } public static stripQuotationsAndNewlines(str: string): string { let newlinereg = /\n/g; - str = str.replace(newlinereg, " "); + str = str.replace(newlinereg, ' '); newlinereg = /"/g; str = str.replace(newlinereg, "'"); return str; @@ -25,43 +25,30 @@ export default class Utility { public static generateParameterString(obj: any): string { if (obj == null) { - return ""; + return ''; } - let res = ""; - let first = true; - let key: string; - for (key in obj) { - if (first) { - first = false; - } else { - res += "&"; - } - - res += `${key}=${(obj as any)[key]}`; - } - - return res; + return Object.entries(obj).map(([key, val]) => `${key}=${val}`).join('&'); } - public static isPointWithin(p: Point, polygon: Point[], stretch_length: number = 10000): boolean { - let hit_count = 0; + public static isPointWithin(p: Point, polygon: Point[], stretchLength: number = 10000): boolean { + let hitCount = 0; - let p_to: Point = new Point(p.x + stretch_length, p.y + stretch_length); + let pTo: Point = new Point(p.x + stretchLength, p.y + stretchLength); for (let ii = 0; ii < polygon.length; ii++) { let a: Point = polygon[ii]; let b: Point = polygon[(ii + 1) % polygon.length]; - if (Utility.findIntersection(a, b, p, p_to) != null) { - hit_count++; + if (Utility.findIntersection(a, b, p, pTo) != null) { + hitCount++; } } - return (hit_count % 2) === 1; + return (hitCount % 2) === 1; } - public static findIntersection(A: Point, B: Point, E: Point, F: Point, as_seg: boolean = true): Point { + public static findIntersection(A: Point, B: Point, E: Point, F: Point, asSeg: boolean = true): Point { let ip: Point; let a1: number; let a2: number; @@ -92,20 +79,20 @@ export default class Utility { // Return null if it is with any. //--------------------------------------------------- - if (as_seg) { - if (Math.pow(ip.x - B.x, 2) + Math.pow(ip.y - B.y, 2) > Math.pow(A.x - B.x, 2) + Math.pow(A.y - B.y, 2)) { + if (asSeg) { + if (((ip.x - B.x) ** 2) + ((ip.y - B.y) ** 2) > ((A.x - B.x) ** 2) + ((A.y - B.y) ** 2)) { return null; } - if (Math.pow(ip.x - A.x, 2) + Math.pow(ip.y - A.y, 2) > Math.pow(A.x - B.x, 2) + Math.pow(A.y - B.y, 2)) { + if (((ip.x - A.x) ** 2) + ((ip.y - A.y) ** 2) > ((A.x - B.x) ** 2) + ((A.y - B.y) ** 2)) { return null; } - if (Math.pow(ip.x - F.x, 2) + Math.pow(ip.y - F.y, 2) > Math.pow(E.x - F.x, 2) + Math.pow(E.y - F.y, 2)) { + if (((ip.x - F.x) ** 2) + ((ip.y - F.y) ** 2) > ((E.x - F.x) ** 2) + ((E.y - F.y) ** 2)) { return null; } - if (Math.pow(ip.x - E.x, 2) + Math.pow(ip.y - E.y, 2) > Math.pow(E.x - F.x, 2) + Math.pow(E.y - F.y, 2)) { + if (((ip.x - E.x) ** 2) + ((ip.y - E.y) ** 2) > ((E.x - F.x) ** 2) + ((E.y - F.y) ** 2)) { return null; } } @@ -121,4 +108,32 @@ export default class Utility { return new Array(stop - start).fill(0).map((_, i) => i + start); } + + /** + * Similar to `string.split(' ')`, but acts differently with multiple consecutive spaces + * E.g., two spaces results in the second space being placed in the following entry, + * three results in one entry of a single space, four both, five two single space entried, etc + * + * @param csl string to split + */ + public static splitOnWhitespace(csl: string): string[] { + let vals: string[] = []; + let lastComma = -1; + let ii: number; + + for (ii = 0; ii < csl.length; ii++) { + if (csl.charAt(ii) === ' ') { + if (lastComma < ii - 1) { + vals.push(csl.substr(lastComma + 1, ii - (lastComma + 1))); + lastComma = ii; + } + } + } + + if (lastComma < ii - 1) { + vals.push(csl.substr(lastComma + 1, ii - (lastComma + 1))); + } + + return vals; + } } diff --git a/src/eterna/util/index.ts b/src/eterna/util/index.ts index d75e13a42..e62d948d1 100644 --- a/src/eterna/util/index.ts +++ b/src/eterna/util/index.ts @@ -1,7 +1,6 @@ -export {default as CSVParser} from "./CSVParser"; -export {default as EternaTextureUtil} from "./EternaTextureUtil"; -export {default as ExternalInterface, ExternalInterfaceCtx, RunScriptOptions} from "./ExternalInterface"; -export {default as Fonts} from "./Fonts"; -export {default as GraphicsUtil} from "./GraphicsUtil"; -export {default as int} from "./int"; -export {default as Utility} from "./Utility"; +export {default as EternaTextureUtil} from './EternaTextureUtil'; +export {default as ExternalInterface, ExternalInterfaceCtx, RunScriptOptions} from './ExternalInterface'; +export {default as Fonts} from './Fonts'; +export {default as GraphicsUtil} from './GraphicsUtil'; +export {default as int} from './int'; +export {default as Utility} from './Utility'; diff --git a/src/eterna/vfx/Background.ts b/src/eterna/vfx/Background.ts index dafc1ac3c..4d8e97fb2 100644 --- a/src/eterna/vfx/Background.ts +++ b/src/eterna/vfx/Background.ts @@ -1,6 +1,6 @@ -import {ContainerObject} from "flashbang/objects"; -import Eterna from "eterna/Eterna"; -import Bubble from "./Bubble"; +import {ContainerObject} from 'flashbang/objects'; +import Eterna from 'eterna/Eterna'; +import Bubble from './Bubble'; export default class Background extends ContainerObject { constructor(bubbleCount: number = 20, foreground: boolean = false) { @@ -53,11 +53,11 @@ export default class Background extends ContainerObject { let lightBlue: string; let darkBlue: string; if (this._isFrozen) { - lightBlue = "rgb(67, 93, 146) 0%"; - darkBlue = "rgb(10, 43, 87) 70%"; + lightBlue = 'rgb(67, 93, 146) 0%'; + darkBlue = 'rgb(10, 43, 87) 70%'; } else { - lightBlue = "rgb(45, 64, 102) 0%"; - darkBlue = "rgb(6, 26, 52) 70%"; + lightBlue = 'rgb(45, 64, 102) 0%'; + darkBlue = 'rgb(6, 26, 52) 70%'; } Eterna.gameDiv.style.backgroundImage = `radial-gradient(ellipse, ${lightBlue}, ${darkBlue})`; } diff --git a/src/eterna/vfx/BaseGlow.ts b/src/eterna/vfx/BaseGlow.ts index 6565ec832..418c5a6e7 100644 --- a/src/eterna/vfx/BaseGlow.ts +++ b/src/eterna/vfx/BaseGlow.ts @@ -1,9 +1,9 @@ -import {Point, Sprite, Texture} from "pixi.js"; -import {BitmapManager, Bitmaps} from "eterna/resources"; -import {EternaTextureUtil} from "eterna/util"; +import {Point, Sprite, Texture} from 'pixi.js'; +import {BitmapManager, Bitmaps} from 'eterna/resources'; +import {EternaTextureUtil} from 'eterna/util'; export default class BaseGlow extends Sprite { - public constructor() { + constructor() { super(); BaseGlow.initTextures(); } @@ -16,21 +16,21 @@ export default class BaseGlow extends Sprite { this._backward = backward; } - public updateView(zoom_level: number, x: number, y: number, current_time: number): void { + public updateView(zoomLevel: number, x: number, y: number, currentTime: number): void { if (this._animStartTime < 0) { - this._animStartTime = current_time; + this._animStartTime = currentTime; } - let diff: number = current_time - this._animStartTime; + let diff: number = currentTime - this._animStartTime; diff -= Math.floor(diff / BaseGlow.ANIMATION_SPAN) * BaseGlow.ANIMATION_SPAN; let prog: number = diff / BaseGlow.ANIMATION_SPAN; - let prog_ind: number = Math.floor(prog * BaseGlow.NUM_ANIMATION_STEPS) % BaseGlow.NUM_ANIMATION_STEPS; - if (this._backward) prog_ind = BaseGlow.NUM_ANIMATION_STEPS - 1 - prog_ind; + let progInd: number = Math.floor(prog * BaseGlow.NUM_ANIMATION_STEPS) % BaseGlow.NUM_ANIMATION_STEPS; + if (this._backward) progInd = BaseGlow.NUM_ANIMATION_STEPS - 1 - progInd; let bodyTex: Texture = this._isWrong - ? BaseGlow._texturesWrong[zoom_level][prog_ind] - : BaseGlow._textures[zoom_level][prog_ind]; + ? BaseGlow._texturesWrong[zoomLevel][progInd] + : BaseGlow._textures[zoomLevel][progInd]; this.texture = bodyTex; this.position = new Point(x - bodyTex.width / 2, y - bodyTex.height / 2); @@ -43,26 +43,26 @@ export default class BaseGlow extends Sprite { BaseGlow._textures = []; BaseGlow._texturesWrong = []; - let original_data: Texture = BitmapManager.getBitmap(Bitmaps.ImgBindingBaseGlow); + let originalData: Texture = BitmapManager.getBitmap(Bitmaps.ImgBindingBaseGlow); for (let zz = 0; zz < 5; zz++) { - let bitmaps_in_zoom: Texture[] = []; - let wrong_bitmaps_in_zoom: Texture[] = []; - let zoom_factor: number = 1.0 - zz * 0.1; - let base_data: Texture = EternaTextureUtil.scaleBy(original_data, zoom_factor); + let bitmapsInZoom: Texture[] = []; + let wrongBitmapsInZoom: Texture[] = []; + let zoomFactor: number = 1.0 - zz * 0.1; + let baseData: Texture = EternaTextureUtil.scaleBy(originalData, zoomFactor); for (let ii = 0; ii < BaseGlow.NUM_ANIMATION_STEPS; ii++) { - let new_base_data: Texture = EternaTextureUtil.colorTransformAlpha( - base_data, 255, 255, 255, 1.0 - ii / BaseGlow.NUM_ANIMATION_STEPS, 0, 0, 0, 0 + let newBaseData: Texture = EternaTextureUtil.colorTransformAlpha( + baseData, 255, 255, 255, 1.0 - ii / BaseGlow.NUM_ANIMATION_STEPS, 0, 0, 0, 0 ); - new_base_data = EternaTextureUtil.scaleBy(new_base_data, 0.5 + (ii + 1) / BaseGlow.NUM_ANIMATION_STEPS); - bitmaps_in_zoom.push(new_base_data); + newBaseData = EternaTextureUtil.scaleBy(newBaseData, 0.5 + (ii + 1) / BaseGlow.NUM_ANIMATION_STEPS); + bitmapsInZoom.push(newBaseData); - let wrong_new_base_data: Texture = EternaTextureUtil.colorTransform(new_base_data, 255, 0, 0, 0, 0, 0); - wrong_bitmaps_in_zoom.push(wrong_new_base_data); + let wrongNewBaseData: Texture = EternaTextureUtil.colorTransform(newBaseData, 255, 0, 0, 0, 0, 0); + wrongBitmapsInZoom.push(wrongNewBaseData); } - BaseGlow._textures.push(bitmaps_in_zoom); - BaseGlow._texturesWrong.push(wrong_bitmaps_in_zoom); + BaseGlow._textures.push(bitmapsInZoom); + BaseGlow._texturesWrong.push(wrongBitmapsInZoom); } } diff --git a/src/eterna/vfx/Bubble.ts b/src/eterna/vfx/Bubble.ts index 33aa06e19..06d982c06 100644 --- a/src/eterna/vfx/Bubble.ts +++ b/src/eterna/vfx/Bubble.ts @@ -1,9 +1,9 @@ -import {Point, Texture} from "pixi.js"; -import {Flashbang, Updatable} from "flashbang/core"; -import {SpriteObject} from "flashbang/objects"; -import {AlphaTask, ParallelTask, ScaleTask} from "flashbang/tasks"; -import {Easing} from "flashbang/util"; -import {Bitmaps} from "eterna/resources"; +import {Point, Texture} from 'pixi.js'; +import {Flashbang, Updatable} from 'flashbang/core'; +import {SpriteObject} from 'flashbang/objects'; +import {AlphaTask, ParallelTask, ScaleTask} from 'flashbang/tasks'; +import {Easing} from 'flashbang/util'; +import {Bitmaps} from 'eterna/resources'; export default class Bubble extends SpriteObject implements Updatable { public isPaused: boolean = false; @@ -21,9 +21,9 @@ export default class Bubble extends SpriteObject implements Updatable { } else { useBlueBubble = (Math.random() < 0.5); - let size_number: number = Math.random(); - if (size_number < 0.33) this._bubbleSize = 0; - else if (size_number < 0.66) this._bubbleSize = 1; + let sizeNumber: number = Math.random(); + if (sizeNumber < 0.33) this._bubbleSize = 0; + else if (sizeNumber < 0.66) this._bubbleSize = 1; else this._bubbleSize = 2; } @@ -53,7 +53,7 @@ export default class Bubble extends SpriteObject implements Updatable { this.display.x = Math.random() * Flashbang.stageWidth; this.display.y = Math.random() * Flashbang.stageHeight; - this.replaceNamedObject("InitAnim", new ParallelTask( + this.replaceNamedObject('InitAnim', new ParallelTask( new ScaleTask(1, 1, 1), new AlphaTask(1, 1, Easing.easeOut) )); @@ -65,9 +65,9 @@ export default class Bubble extends SpriteObject implements Updatable { this._lastTime = -1; } - public setForce(force_x: number, force_y: number): void { - this._accX = force_x; - this._accY = force_y; + public setForce(forceX: number, forceY: number): void { + this._accX = forceX; + this._accY = forceY; } public set autoHide(value: boolean) { @@ -80,29 +80,29 @@ export default class Bubble extends SpriteObject implements Updatable { return; } - const current_time = this._lastTime + dt; + const currentTime = this._lastTime + dt; const tex = this.display.texture; if (this.isPaused || (this.display.y < -tex.height)) { - this._lastTime = current_time; + this._lastTime = currentTime; return; } let mouseLoc = this.display.toLocal(Flashbang.globalMouse, undefined, Bubble.P); - let m_x = mouseLoc.x - tex.width / 2.0; - let m_y = mouseLoc.y - tex.height / 2.0; - let dist = Math.max(m_x * m_x + m_y * m_y, 0.01); + let mX = mouseLoc.x - tex.width / 2.0; + let mY = mouseLoc.y - tex.height / 2.0; + let dist = Math.max(mX * mX + mY * mY, 0.01); if (dist < 10000) { if (this._foreground) { - this._accX += -500 * m_x * 2 / (dist); - this._accY += -500 * m_y * 2 / (dist); + this._accX += -500 * mX * 2 / (dist); + this._accY += -500 * mY * 2 / (dist); } else { - this._accX += -500 * m_x * (3 - this._bubbleSize) / (dist); - this._accY += -500 * m_y * (3 - this._bubbleSize) / (dist); + this._accX += -500 * mX * (3 - this._bubbleSize) / (dist); + this._accY += -500 * mY * (3 - this._bubbleSize) / (dist); } } - if (this._lastTime < 0) this._lastTime = current_time; + if (this._lastTime < 0) this._lastTime = currentTime; if (!this.isPaused) { if (this._bubbleSize === 0) { @@ -124,9 +124,9 @@ export default class Bubble extends SpriteObject implements Updatable { this.display.y += dvy; this.display.x += dvx; - this._lastTime = current_time; + this._lastTime = currentTime; - if (this.display.y < -tex.height && (this._hideTime < 0 || this._hideTime >= current_time)) { + if (this.display.y < -tex.height && (this._hideTime < 0 || this._hideTime >= currentTime)) { this.init(); } diff --git a/src/eterna/vfx/BubbleSweep.ts b/src/eterna/vfx/BubbleSweep.ts index e0e35c29d..a97613a2d 100644 --- a/src/eterna/vfx/BubbleSweep.ts +++ b/src/eterna/vfx/BubbleSweep.ts @@ -1,8 +1,8 @@ -import {ContainerObject} from "flashbang/objects"; -import Bubble from "./Bubble"; +import {ContainerObject} from 'flashbang/objects'; +import Bubble from './Bubble'; export default class BubbleSweep extends ContainerObject { - public constructor(numBubbles: number) { + constructor(numBubbles: number) { super(); this._bubbles = []; for (let ii = 0; ii < numBubbles; ii++) { diff --git a/src/eterna/vfx/LightRay.ts b/src/eterna/vfx/LightRay.ts index 1822bc6fb..81e6ddc8d 100644 --- a/src/eterna/vfx/LightRay.ts +++ b/src/eterna/vfx/LightRay.ts @@ -1,8 +1,8 @@ -import {Graphics} from "pixi.js"; -import {Vector2} from "flashbang/geom"; -import {SceneObject} from "flashbang/objects"; -import {AlphaTask, SerialTask, VisibleTask} from "flashbang/tasks"; -import EPars from "eterna/EPars"; +import {Graphics} from 'pixi.js'; +import {Vector2} from 'flashbang/geom'; +import {SceneObject} from 'flashbang/objects'; +import {AlphaTask, SerialTask, VisibleTask} from 'flashbang/tasks'; +import EPars from 'eterna/EPars'; export default class LightRay extends SceneObject { constructor() { @@ -58,5 +58,5 @@ export default class LightRay extends SceneObject { } } - private static readonly ANIM = "Anim"; + private static readonly ANIM = 'Anim'; } diff --git a/src/eterna/vfx/VibrateTask.ts b/src/eterna/vfx/VibrateTask.ts index 63108001f..4cd7c41bd 100644 --- a/src/eterna/vfx/VibrateTask.ts +++ b/src/eterna/vfx/VibrateTask.ts @@ -1,9 +1,9 @@ -import {DisplayObject, Point} from "pixi.js"; -import {DisplayObjectTask} from "flashbang/tasks"; -import {Easing} from "flashbang/util"; +import {DisplayObject, Point} from 'pixi.js'; +import {DisplayObjectTask} from 'flashbang/tasks'; +import {Easing} from 'flashbang/util'; export default class VibrateTask extends DisplayObjectTask { - public constructor(duration: number, target: DisplayObject = null) { + constructor(duration: number, target: DisplayObject = null) { super(duration, Easing.linear, target); } diff --git a/src/eterna/vfx/index.ts b/src/eterna/vfx/index.ts index d91d700b0..6d6cc17e6 100644 --- a/src/eterna/vfx/index.ts +++ b/src/eterna/vfx/index.ts @@ -1,6 +1,6 @@ -export {default as Background} from "./Background"; -export {default as BaseGlow} from "./BaseGlow"; -export {default as Bubble} from "./Bubble"; -export {default as BubbleSweep} from "./BubbleSweep"; -export {default as LightRay} from "./LightRay"; -export {default as VibrateTask} from "./VibrateTask"; +export {default as Background} from './Background'; +export {default as BaseGlow} from './BaseGlow'; +export {default as Bubble} from './Bubble'; +export {default as BubbleSweep} from './BubbleSweep'; +export {default as LightRay} from './LightRay'; +export {default as VibrateTask} from './VibrateTask'; diff --git a/src/flashbang/core/AppMode.ts b/src/flashbang/core/AppMode.ts index 60486c4f5..c18abaa16 100644 --- a/src/flashbang/core/AppMode.ts +++ b/src/flashbang/core/AppMode.ts @@ -1,15 +1,15 @@ -import {Container} from "pixi.js"; +import {Container} from 'pixi.js'; import { RegistrationGroup, Signal, SignalView, UnitSignal -} from "signals"; -import {KeyboardInput, MouseWheelInput} from "../input"; -import {Assert} from "../util"; -import GameObject from "./GameObject"; -import GameObjectBase from "./GameObjectBase"; -import GameObjectRef from "./GameObjectRef"; -import LateUpdatable from "./LateUpdatable"; -import ModeStack from "./ModeStack"; -import Updatable from "./Updatable"; +} from 'signals'; +import {KeyboardInput, MouseWheelInput} from '../input'; +import {Assert} from '../util'; +import GameObject from './GameObject'; +import GameObjectBase from './GameObjectBase'; +import GameObjectRef from './GameObjectRef'; +import LateUpdatable from './LateUpdatable'; +import ModeStack from './ModeStack'; +import Updatable from './Updatable'; export default class AppMode { /** Default keyboard input processor */ @@ -49,7 +49,7 @@ export default class AppMode { return objs; } - public constructor() { + constructor() { this._rootObject = new RootObject(this); this.container.interactiveChildren = false; } @@ -99,7 +99,7 @@ export default class AppMode { */ public waitTillActive(): Promise { if (this._isDiposed) { - return Promise.reject("Mode is already disposed"); + return Promise.reject(new Error('Mode is already disposed')); } else if (this._isActive) { return Promise.resolve(); } else { @@ -118,7 +118,7 @@ export default class AppMode { let fn = reject; resolve = null; reject = null; - fn("Mode was disposed"); + fn('Mode was disposed'); } }); }); @@ -129,11 +129,15 @@ export default class AppMode { return this._rootObject.addObject(obj, displayParent, displayIdx); } - public addNamedObject(name: string, obj: GameObjectBase, displayParent: Container = null, displayIdx: number = -1): GameObjectRef { + public addNamedObject( + name: string, obj: GameObjectBase, displayParent: Container = null, displayIdx: number = -1 + ): GameObjectRef { return this._rootObject.addNamedObject(name, obj, displayParent, displayIdx); } - public replaceNamedObject(name: string, obj: GameObjectBase, displayParent: Container = null, displayIdx: number = -1): GameObjectRef { + public replaceNamedObject( + name: string, obj: GameObjectBase, displayParent: Container = null, displayIdx: number = -1 + ): GameObjectRef { return this._rootObject.replaceNamedObject(name, obj, displayParent, displayIdx); } @@ -208,14 +212,14 @@ export default class AppMode { } /* internal */ - setupInternal(modeStack: ModeStack): void { + public setupInternal(modeStack: ModeStack): void { this._modeStack = modeStack; this.setup(); } /* internal */ - disposeInternal(): void { - Assert.isTrue(!this._isDiposed, "already disposed"); + public disposeInternal(): void { + Assert.isTrue(!this._isDiposed, 'already disposed'); this._isDiposed = true; this.dispose(); @@ -240,7 +244,7 @@ export default class AppMode { } /* internal */ - enterInternal(): void { + public enterInternal(): void { this._isActive = true; this.container.interactiveChildren = true; this.enter(); @@ -253,7 +257,7 @@ export default class AppMode { } /* internal */ - exitInternal(): void { + public exitInternal(): void { this._exited.emit(); this._isActive = false; this.container.interactiveChildren = false; @@ -261,13 +265,13 @@ export default class AppMode { } /* internal */ - updateInternal(dt: number): void { + public updateInternal(dt: number): void { this.update(dt); this._updateComplete.emit(); } /* internal */ - registerObjectInternal(obj: GameObjectBase): void { + public registerObjectInternal(obj: GameObjectBase): void { obj._mode = this; // Handle IDs @@ -280,7 +284,7 @@ export default class AppMode { })); for (let id of ids) { - Assert.isFalse(this._idObjects.has(id), "two objects with the same ID added to the AppMode"); + Assert.isFalse(this._idObjects.has(id), 'two objects with the same ID added to the AppMode'); this._idObjects.set(id, obj); } } @@ -299,7 +303,8 @@ export default class AppMode { this.registerObject(obj); } - resizeInternal(): void { + /* internal */ + public resizeInternal(): void { if (this._isActive) { this.onResized(); } else { diff --git a/src/flashbang/core/Flashbang.ts b/src/flashbang/core/Flashbang.ts index d55c476a9..3774a7299 100644 --- a/src/flashbang/core/Flashbang.ts +++ b/src/flashbang/core/Flashbang.ts @@ -1,8 +1,7 @@ -import * as PIXI from "pixi.js"; -import {Point} from "pixi.js"; -import {Assert} from "../util"; -import FlashbangApp from "./FlashbangApp"; -import AppMode from "./AppMode"; +import * as PIXI from 'pixi.js'; +import {Assert} from '../util'; +import FlashbangApp from './FlashbangApp'; +import AppMode from './AppMode'; type InteractionManager = PIXI.interaction.InteractionManager; @@ -28,13 +27,13 @@ export default class Flashbang { } /** Global mouse location */ - public static get globalMouse(): Point { + public static get globalMouse(): PIXI.Point { return this._interaction.mouse.global; } /* internal */ - static registerApp(app: FlashbangApp): void { - Assert.isTrue(Flashbang._app == null, "A FlashbangApp has already been registered"); + public static registerApp(app: FlashbangApp): void { + Assert.isTrue(Flashbang._app == null, 'A FlashbangApp has already been registered'); Flashbang._app = app; Flashbang._interaction = app.pixi.renderer.plugins.interaction; } diff --git a/src/flashbang/core/FlashbangApp.ts b/src/flashbang/core/FlashbangApp.ts index 21b0c1025..bf05d5e28 100644 --- a/src/flashbang/core/FlashbangApp.ts +++ b/src/flashbang/core/FlashbangApp.ts @@ -1,12 +1,12 @@ -import * as log from "loglevel"; -import {RegistrationGroup, Value} from "signals"; -import {KeyboardEventType, KeyCode} from "../input"; -import Flashbang from "./Flashbang"; -import ModeStack from "./ModeStack"; -import Updatable from "./Updatable"; +import * as log from 'loglevel'; +import {RegistrationGroup, Value} from 'signals'; +import {KeyboardEventType, KeyCode} from '../input'; +import Flashbang from './Flashbang'; +import ModeStack from './ModeStack'; +import Updatable from './Updatable'; // Adds KeyboardEvent.code support to Edge -import "js-polyfills/keyboard"; +import 'js-polyfills/keyboard'; export default class FlashbangApp { /** True if the app is foregrounded */ @@ -21,7 +21,7 @@ export default class FlashbangApp { } public run(): void { - window.addEventListener("error", (e: ErrorEvent) => this.onUncaughtError(e)); + window.addEventListener('error', (e: ErrorEvent) => this.onUncaughtError(e)); this._pixi = this.createPixi(); this.pixiParent.appendChild(this._pixi.view); @@ -37,10 +37,10 @@ export default class FlashbangApp { window.addEventListener(KeyboardEventType.KEY_DOWN, e => this.onKeyboardEvent(e)); window.addEventListener(KeyboardEventType.KEY_UP, e => this.onKeyboardEvent(e)); - window.addEventListener("wheel", e => this.onMouseWheelEvent(e)); - window.addEventListener("contextmenu", e => this.onContextMenuEvent(e)); - window.addEventListener("focus", () => this.isActive.value = true); - window.addEventListener("blur", () => this.isActive.value = false); + window.addEventListener('wheel', e => this.onMouseWheelEvent(e)); + window.addEventListener('contextmenu', e => this.onContextMenuEvent(e)); + window.addEventListener('focus', () => { this.isActive.value = true; }); + window.addEventListener('blur', () => { this.isActive.value = false; }); this.isActive.connect(value => this.onIsActiveChanged(value)); } @@ -50,7 +50,7 @@ export default class FlashbangApp { } public resize(width: number, height: number): void { - if (width != this._pixi.renderer.screen.width || height != this._pixi.renderer.screen.height) { + if (width !== this._pixi.renderer.screen.width || height !== this._pixi.renderer.screen.height) { this._pixi.renderer.resize(width, height); this._modeStack.onResized(); } diff --git a/src/flashbang/core/GameObject.ts b/src/flashbang/core/GameObject.ts index 319c0309e..2444c8c19 100644 --- a/src/flashbang/core/GameObject.ts +++ b/src/flashbang/core/GameObject.ts @@ -1,8 +1,8 @@ -import * as log from "loglevel"; -import {Container, DisplayObject} from "pixi.js"; -import Assert from "../util/Assert"; -import GameObjectBase from "./GameObjectBase"; -import GameObjectRef from "./GameObjectRef"; +import * as log from 'loglevel'; +import {Container, DisplayObject} from 'pixi.js'; +import Assert from '../util/Assert'; +import GameObjectBase from './GameObjectBase'; +import GameObjectRef from './GameObjectRef'; export default class GameObject extends GameObjectBase { /** The DisplayObject that this GameObject manages, if any */ @@ -14,11 +14,15 @@ export default class GameObject extends GameObjectBase { return this._addObjectInternal(obj, null, false, displayParent, displayIdx); } - public addNamedObject(name: string, obj: GameObjectBase, displayParent: Container = null, displayIdx: number = -1): GameObjectRef { + public addNamedObject( + name: string, obj: GameObjectBase, displayParent: Container = null, displayIdx: number = -1 + ): GameObjectRef { return this._addObjectInternal(obj, name, false, displayParent, displayIdx); } - public replaceNamedObject(name: string, obj: GameObjectBase, displayParent: Container = null, displayIdx: number = -1): GameObjectRef { + public replaceNamedObject( + name: string, obj: GameObjectBase, displayParent: Container = null, displayIdx: number = -1 + ): GameObjectRef { return this._addObjectInternal(obj, name, true, displayParent, displayIdx); } @@ -88,14 +92,14 @@ export default class GameObject extends GameObjectBase { } /* internal */ - _addObjectInternal(obj: GameObjectBase, + public _addObjectInternal(obj: GameObjectBase, name: string, replaceExisting: boolean, displayParent: Container, displayIdx: number = -1): GameObjectRef { // Object initialization happens here. // Uninitialization happens in GameObjectBase._removedInternal Assert.isTrue(!this._wasRemoved, "cannot add to an object that's been removed"); - Assert.isTrue(obj._ref == null, "cannot re-parent GameObjects"); + Assert.isTrue(obj._ref == null, 'cannot re-parent GameObjects'); if (name != null && replaceExisting) { this.removeNamedObjects(name); @@ -136,10 +140,13 @@ export default class GameObject extends GameObjectBase { } /* internal */ - _attachToDisplayList(displayParent: Container, displayIdx: number): void { + public _attachToDisplayList(displayParent: Container, displayIdx: number): void { // Attach the object to a display parent. // (This is purely a convenience - the client is free to do the attaching themselves) - Assert.isTrue(this.display != null, "obj must manage a non-null DisplayObject to be attached to a display parent"); + Assert.isTrue( + this.display != null, + 'obj must manage a non-null DisplayObject to be attached to a display parent' + ); if (displayIdx < 0 || displayIdx >= displayParent.children.length) { displayParent.addChild(this.display); @@ -149,7 +156,7 @@ export default class GameObject extends GameObjectBase { } /* internal */ - _registerObject(obj: GameObjectBase): void { + public _registerObject(obj: GameObjectBase): void { this._mode.registerObjectInternal(obj); obj._addedInternal(); } @@ -157,7 +164,7 @@ export default class GameObject extends GameObjectBase { /* override */ /* internal */ - _addedInternal(): void { + public _addedInternal(): void { // Add pending children first if (this._pendingChildren != null) { for (let ref of this._pendingChildren) { @@ -172,7 +179,7 @@ export default class GameObject extends GameObjectBase { /* override */ /* internal */ - _removedInternal(): void { + public _removedInternal(): void { // null out ref immediately - so that we're not considered "live" // while children are being removed - rather than waiting for // GameObjectBase._removedInternal to do it at the end of the function @@ -196,7 +203,7 @@ export default class GameObject extends GameObjectBase { /* override */ /* internal */ - _disposeInternal(): void { + public _disposeInternal(): void { this._ref._obj = null; // dispose our children let cur: GameObjectRef = this._children; @@ -214,7 +221,7 @@ export default class GameObject extends GameObjectBase { try { (this.display as Container).destroy({children: true}); } catch (e) { - log.warn("GameObject.display.destroy blew up", e); + log.warn('GameObject.display.destroy blew up', e); } } else { this.display.destroy(); diff --git a/src/flashbang/core/GameObjectBase.ts b/src/flashbang/core/GameObjectBase.ts index ef53b7268..ee848e81e 100644 --- a/src/flashbang/core/GameObjectBase.ts +++ b/src/flashbang/core/GameObjectBase.ts @@ -1,9 +1,9 @@ -import {Container} from "pixi.js"; -import {RegistrationGroup, UnitSignal} from "signals"; -import AppMode from "./AppMode"; -import ModeStack from "./ModeStack"; -import GameObject from "./GameObject"; -import GameObjectRef from "./GameObjectRef"; +import {Container} from 'pixi.js'; +import {RegistrationGroup, UnitSignal} from 'signals'; +import AppMode from './AppMode'; +import ModeStack from './ModeStack'; +import GameObject from './GameObject'; +import GameObjectRef from './GameObjectRef'; export default class GameObjectBase { public get destroyed(): UnitSignal { @@ -114,17 +114,17 @@ export default class GameObjectBase { } /* internal */ - _attachToDisplayList(displayParent: Container, displayIdx: number): void { + public _attachToDisplayList(displayParent: Container, displayIdx: number): void { // implemented by subclasses } /* internal */ - _addedInternal(): void { + public _addedInternal(): void { this.added(); } /* internal */ - _removedInternal(): void { + public _removedInternal(): void { this._ref._obj = null; this._parent = null; this._mode = null; @@ -137,7 +137,7 @@ export default class GameObjectBase { } /* internal */ - _disposeInternal(): void { + public _disposeInternal(): void { this._ref._obj = null; this.dispose(); if (this._regs != null) { @@ -147,7 +147,7 @@ export default class GameObjectBase { } /* internal */ - get _wasRemoved(): boolean { + public get _wasRemoved(): boolean { return (this._ref != null && this._ref._obj == null); } @@ -155,10 +155,10 @@ export default class GameObjectBase { private _regs: RegistrationGroup; private _destroyed: UnitSignal; - /* internal */ _name: string; - /* internal */ _ref: GameObjectRef; - /* internal */ _parent: GameObject; - /* internal */ _mode: AppMode; + /* internal */ public _name: string; + /* internal */ public _ref: GameObjectRef; + /* internal */ public _parent: GameObject; + /* internal */ public _mode: AppMode; private static readonly EMPTY_ARRAY: any[] = []; } diff --git a/src/flashbang/core/GameObjectRef.ts b/src/flashbang/core/GameObjectRef.ts index 78e215872..2dd7003e7 100644 --- a/src/flashbang/core/GameObjectRef.ts +++ b/src/flashbang/core/GameObjectRef.ts @@ -1,5 +1,5 @@ -import GameObject from "./GameObject"; -import GameObjectBase from "./GameObjectBase"; +import GameObject from './GameObject'; +import GameObjectBase from './GameObjectBase'; export default class GameObjectRef { public static readonly NULL: GameObjectRef = new GameObjectRef(); @@ -28,7 +28,7 @@ export default class GameObjectRef { } // managed by ObjectDB - _obj: GameObjectBase; - _next: GameObjectRef; - _prev: GameObjectRef; + /* internal */ public _obj: GameObjectBase; + /* internal */ public _next: GameObjectRef; + /* internal */ public _prev: GameObjectRef; } diff --git a/src/flashbang/core/ModeStack.ts b/src/flashbang/core/ModeStack.ts index 0945d2c4d..2c3a87157 100644 --- a/src/flashbang/core/ModeStack.ts +++ b/src/flashbang/core/ModeStack.ts @@ -1,7 +1,17 @@ -import {Container} from "pixi.js"; -import {UnitSignal} from "signals"; -import {Assert, MathUtil} from "../util"; -import AppMode from "./AppMode"; +import {Container} from 'pixi.js'; +import {UnitSignal} from 'signals'; +import {Assert, MathUtil} from '../util'; +import AppMode from './AppMode'; + +export enum ModeTransition { + PUSH, UNWIND, INSERT, REMOVE, CHANGE, SET_INDEX, +} + +class PendingTransition { + public mode: AppMode; + public type: ModeTransition; + public index: number; +} /** * A stack of AppModes. Only the top-most mode in the stack gets updates @@ -152,7 +162,7 @@ export default class ModeStack { } /* internal */ - handleModeTransitions(): void { + public handleModeTransitions(): void { if (this._pendingModeTransitionQueue.length <= 0) { return; } @@ -230,7 +240,7 @@ export default class ModeStack { newIdx = this._modeStack.length + newIdx; } newIdx = MathUtil.clamp(newIdx, 0, this._modeStack.length - 1); - if (prevIdx != newIdx) { + if (prevIdx !== newIdx) { // Rearrange the modestack this._modeStack.splice(prevIdx, 1); this._modeStack.splice(newIdx, 0, mode); @@ -286,6 +296,9 @@ export default class ModeStack { case ModeTransition.SET_INDEX: doSetIndex(mode, transition.index); break; + + default: + Assert.unreachable(transition.type); } } @@ -313,7 +326,7 @@ export default class ModeStack { } /* internal */ - clearModeStackNow(): void { + public clearModeStackNow(): void { this._pendingModeTransitionQueue.length = 0; if (this._modeStack.length > 0) { this.popAllModes(); @@ -322,7 +335,7 @@ export default class ModeStack { } /* internal */ - dispose(): void { + public dispose(): void { this.clearModeStackNow(); this._modeStack = null; this._pendingModeTransitionQueue = null; @@ -334,13 +347,3 @@ export default class ModeStack { protected _modeStack: AppMode[] = []; protected _pendingModeTransitionQueue: PendingTransition[] = []; } - -export enum ModeTransition { - PUSH, UNWIND, INSERT, REMOVE, CHANGE, SET_INDEX, -} - -class PendingTransition { - public mode: AppMode; - public type: ModeTransition; - public index: number; -} diff --git a/src/flashbang/core/ObjectTask.ts b/src/flashbang/core/ObjectTask.ts index 6a45e819a..6102fcd06 100644 --- a/src/flashbang/core/ObjectTask.ts +++ b/src/flashbang/core/ObjectTask.ts @@ -1,9 +1,9 @@ -import {Container} from "pixi.js"; -import GameObjectBase from "./GameObjectBase"; +import {Container} from 'pixi.js'; +import GameObjectBase from './GameObjectBase'; export default class ObjectTask extends GameObjectBase { /* internal */ - _attachToDisplayList(displayParent: Container, displayIdx: number): void { - throw new Error("Tasks cannot manage DisplayObjects"); + public _attachToDisplayList(displayParent: Container, displayIdx: number): void { + throw new Error('Tasks cannot manage DisplayObjects'); } } diff --git a/src/flashbang/core/index.ts b/src/flashbang/core/index.ts index 6266d4ead..380e1ca76 100644 --- a/src/flashbang/core/index.ts +++ b/src/flashbang/core/index.ts @@ -1,11 +1,11 @@ -export {HAlign, VAlign} from "./Align"; -export {default as GameObjectBase} from "./GameObjectBase"; -export {default as GameObject} from "./GameObject"; -export {default as AppMode} from "./AppMode"; -export {default as Flashbang} from "./Flashbang"; -export {default as FlashbangApp} from "./FlashbangApp"; -export {default as GameObjectRef} from "./GameObjectRef"; -export {default as LateUpdatable} from "./LateUpdatable"; -export {default as ModeStack} from "./ModeStack"; -export {default as ObjectTask} from "./ObjectTask"; -export {default as Updatable} from "./Updatable"; +export {HAlign, VAlign} from './Align'; +export {default as GameObjectBase} from './GameObjectBase'; +export {default as GameObject} from './GameObject'; +export {default as AppMode} from './AppMode'; +export {default as Flashbang} from './Flashbang'; +export {default as FlashbangApp} from './FlashbangApp'; +export {default as GameObjectRef} from './GameObjectRef'; +export {default as LateUpdatable} from './LateUpdatable'; +export {default as ModeStack} from './ModeStack'; +export {default as ObjectTask} from './ObjectTask'; +export {default as Updatable} from './Updatable'; diff --git a/src/flashbang/geom/Vector2.ts b/src/flashbang/geom/Vector2.ts index 06e05be1f..e62748952 100644 --- a/src/flashbang/geom/Vector2.ts +++ b/src/flashbang/geom/Vector2.ts @@ -1,4 +1,4 @@ -import {Point} from "pixi.js"; +import {Point} from 'pixi.js'; /** A 2D vector */ export default class Vector2 { diff --git a/src/flashbang/geom/index.ts b/src/flashbang/geom/index.ts index 65c8820b3..68a9951db 100644 --- a/src/flashbang/geom/index.ts +++ b/src/flashbang/geom/index.ts @@ -1 +1,2 @@ -export {default as Vector2} from "./Vector2"; +/* eslint-disable import/prefer-default-export */ +export {default as Vector2} from './Vector2'; diff --git a/src/flashbang/input/DisplayObjectPointerTarget.ts b/src/flashbang/input/DisplayObjectPointerTarget.ts index 70f7c3e24..5bb9af2fb 100644 --- a/src/flashbang/input/DisplayObjectPointerTarget.ts +++ b/src/flashbang/input/DisplayObjectPointerTarget.ts @@ -1,56 +1,56 @@ -import {DisplayObject} from "pixi.js"; -import {SignalView} from "signals"; -import {EventSignal} from "../util"; -import PointerTarget from "./PointerTarget"; +import {DisplayObject} from 'pixi.js'; +import {SignalView} from 'signals'; +import {EventSignal} from '../util'; +import PointerTarget from './PointerTarget'; type InteractionEvent = PIXI.interaction.InteractionEvent; export default class DisplayObjectPointerTarget implements PointerTarget { public readonly target: DisplayObject; - public constructor(disp: DisplayObject) { + constructor(disp: DisplayObject) { this.target = disp; disp.interactive = true; } public get pointerOver(): SignalView { if (this._pointerOver == null) { - this._pointerOver = new EventSignal(this.target, "pointerover"); + this._pointerOver = new EventSignal(this.target, 'pointerover'); } return this._pointerOver; } public get pointerOut(): SignalView { if (this._pointerOut == null) { - this._pointerOut = new EventSignal(this.target, "pointerout"); + this._pointerOut = new EventSignal(this.target, 'pointerout'); } return this._pointerOut; } public get pointerDown(): SignalView { if (this._pointerDown == null) { - this._pointerDown = new EventSignal(this.target, "pointerdown"); + this._pointerDown = new EventSignal(this.target, 'pointerdown'); } return this._pointerDown; } public get pointerMove(): SignalView { if (this._pointerMoved == null) { - this._pointerMoved = new EventSignal(this.target, "pointermove"); + this._pointerMoved = new EventSignal(this.target, 'pointermove'); } return this._pointerMoved; } public get pointerUp(): SignalView { if (this._pointerUp == null) { - this._pointerUp = new EventSignal(this.target, "pointerup"); + this._pointerUp = new EventSignal(this.target, 'pointerup'); } return this._pointerUp; } public get pointerTap(): SignalView { if (this._pointerTap == null) { - this._pointerTap = new EventSignal(this.target, "pointertap"); + this._pointerTap = new EventSignal(this.target, 'pointertap'); } return this._pointerTap; } diff --git a/src/flashbang/input/KeyCode.ts b/src/flashbang/input/KeyCode.ts index 2e2790048..ac1ef7550 100644 --- a/src/flashbang/input/KeyCode.ts +++ b/src/flashbang/input/KeyCode.ts @@ -10,173 +10,173 @@ */ enum KeyCode { // 3.1.1.1. Writing System Keys - Backquote = "Backquote", // `~ on a US keyboard. This is the 半角/全角/漢字 (hankaku/zenkaku/kanji) key on Japanese keyboards - Backslash = "Backslash", // Used for both the US \| (on the 101-key layout) and also for the key located between the " and Enter keys on row C of the 102-, 104- and 106-key layouts. Labelled #~ on a UK (102) keyboard. - Backspace = "Backspace", // Backspace or ⌫. Labelled Delete on Apple keyboards. - BracketLeft = "BracketLeft", // [{ on a US keyboard. - BracketRight = "BracketRight", // ]} on a US keyboard. - - Comma = "Comma", // ,< on a US keyboard. - - Digit0 = "Digit0", // 0) on a US keyboard. - Digit1 = "Digit1", // 1! on a US keyboard. - Digit2 = "Digit2", // 2@ on a US keyboard. - Digit3 = "Digit3", // 3# on a US keyboard. - Digit4 = "Digit4", // 4$ on a US keyboard. - Digit5 = "Digit5", // 5% on a US keyboard. - Digit6 = "Digit6", // 6^ on a US keyboard. - Digit7 = "Digit7", // 7& on a US keyboard. - Digit8 = "Digit8", // 8* on a US keyboard. - Digit9 = "Digit9", // 9( on a US keyboard. - - Equal = "Equal", // =+ on a US keyboard. - IntlBackslash = "IntlBackslash", // Located between the left Shift and Z keys. Labelled \| on a UK keyboard. - IntlRo = "IntlRo", // Located between the / and right Shift keys. Labelled \ろ (ro) on a Japanese keyboard. - IntlYen = "IntlYen", // Located between the = and Backspace keys. Labelled ¥ (yen) on a Japanese keyboard. \/ on a Russian keyboard. - - KeyA = "KeyA", // a on a US keyboard. Labelled q on an AZERTY (e.g., French) keyboard. - KeyB = "KeyB", // b on a US keyboard. - KeyC = "KeyC", // c on a US keyboard. - KeyD = "KeyD", // d on a US keyboard. - KeyE = "KeyE", // e on a US keyboard. - KeyF = "KeyF", // f on a US keyboard. - KeyG = "KeyG", // g on a US keyboard. - KeyH = "KeyH", // h on a US keyboard. - KeyI = "KeyI", // i on a US keyboard. - KeyJ = "KeyJ", // j on a US keyboard. - KeyK = "KeyK", // k on a US keyboard. - KeyL = "KeyL", // l on a US keyboard. - KeyM = "KeyM", // m on a US keyboard. - KeyN = "KeyN", // n on a US keyboard. - KeyO = "KeyO", // o on a US keyboard. - KeyP = "KeyP", // p on a US keyboard. - KeyQ = "KeyQ", // q on a US keyboard. Labelled a on an AZERTY (e.g., French) keyboard. - KeyR = "KeyR", // r on a US keyboard. - KeyS = "KeyS", // s on a US keyboard. - KeyT = "KeyT", // t on a US keyboard. - KeyU = "KeyU", // u on a US keyboard. - KeyV = "KeyV", // v on a US keyboard. - KeyW = "KeyW", // w on a US keyboard. Labelled z on an AZERTY (e.g., French) keyboard. - KeyX = "KeyX", // x on a US keyboard. - KeyY = "KeyY", // y on a US keyboard. Labelled z on a QWERTZ (e.g., German) keyboard. - KeyZ = "KeyZ", // z on a US keyboard. Labelled w on an AZERTY (e.g., French) keyboard, and y on a QWERTZ (e.g., German) keyboard. - - Minus = "Minus", // -_ on a US keyboard. - Period = "Period", // .> on a US keyboard. - Quote = "Quote", // '" on a US keyboard. - Semicolon = "Semicolon", // ;: on a US keyboard. - Slash = "Slash", // /? on a US keyboard. + Backquote = 'Backquote', // `~ on a US keyboard. This is the 半角/全角/漢字 (hankaku/zenkaku/kanji) key on Japanese keyboards + Backslash = 'Backslash', // Used for both the US \| (on the 101-key layout) and also for the key located between the " and Enter keys on row C of the 102-, 104- and 106-key layouts. Labelled #~ on a UK (102) keyboard. + Backspace = 'Backspace', // Backspace or ⌫. Labelled Delete on Apple keyboards. + BracketLeft = 'BracketLeft', // [{ on a US keyboard. + BracketRight = 'BracketRight', // ]} on a US keyboard. + + Comma = 'Comma', // ,< on a US keyboard. + + Digit0 = 'Digit0', // 0) on a US keyboard. + Digit1 = 'Digit1', // 1! on a US keyboard. + Digit2 = 'Digit2', // 2@ on a US keyboard. + Digit3 = 'Digit3', // 3# on a US keyboard. + Digit4 = 'Digit4', // 4$ on a US keyboard. + Digit5 = 'Digit5', // 5% on a US keyboard. + Digit6 = 'Digit6', // 6^ on a US keyboard. + Digit7 = 'Digit7', // 7& on a US keyboard. + Digit8 = 'Digit8', // 8* on a US keyboard. + Digit9 = 'Digit9', // 9( on a US keyboard. + + Equal = 'Equal', // =+ on a US keyboard. + IntlBackslash = 'IntlBackslash', // Located between the left Shift and Z keys. Labelled \| on a UK keyboard. + IntlRo = 'IntlRo', // Located between the / and right Shift keys. Labelled \ろ (ro) on a Japanese keyboard. + IntlYen = 'IntlYen', // Located between the = and Backspace keys. Labelled ¥ (yen) on a Japanese keyboard. \/ on a Russian keyboard. + + KeyA = 'KeyA', // a on a US keyboard. Labelled q on an AZERTY (e.g., French) keyboard. + KeyB = 'KeyB', // b on a US keyboard. + KeyC = 'KeyC', // c on a US keyboard. + KeyD = 'KeyD', // d on a US keyboard. + KeyE = 'KeyE', // e on a US keyboard. + KeyF = 'KeyF', // f on a US keyboard. + KeyG = 'KeyG', // g on a US keyboard. + KeyH = 'KeyH', // h on a US keyboard. + KeyI = 'KeyI', // i on a US keyboard. + KeyJ = 'KeyJ', // j on a US keyboard. + KeyK = 'KeyK', // k on a US keyboard. + KeyL = 'KeyL', // l on a US keyboard. + KeyM = 'KeyM', // m on a US keyboard. + KeyN = 'KeyN', // n on a US keyboard. + KeyO = 'KeyO', // o on a US keyboard. + KeyP = 'KeyP', // p on a US keyboard. + KeyQ = 'KeyQ', // q on a US keyboard. Labelled a on an AZERTY (e.g., French) keyboard. + KeyR = 'KeyR', // r on a US keyboard. + KeyS = 'KeyS', // s on a US keyboard. + KeyT = 'KeyT', // t on a US keyboard. + KeyU = 'KeyU', // u on a US keyboard. + KeyV = 'KeyV', // v on a US keyboard. + KeyW = 'KeyW', // w on a US keyboard. Labelled z on an AZERTY (e.g., French) keyboard. + KeyX = 'KeyX', // x on a US keyboard. + KeyY = 'KeyY', // y on a US keyboard. Labelled z on a QWERTZ (e.g., German) keyboard. + KeyZ = 'KeyZ', // z on a US keyboard. Labelled w on an AZERTY (e.g., French) keyboard, and y on a QWERTZ (e.g., German) keyboard. + + Minus = 'Minus', // -_ on a US keyboard. + Period = 'Period', // .> on a US keyboard. + Quote = 'Quote', // '" on a US keyboard. + Semicolon = 'Semicolon', // ;: on a US keyboard. + Slash = 'Slash', // /? on a US keyboard. // 3.1.1.2. Functional Keys - AltLeft = "AltLeft", // Alt, Option or ⌥. - AltRight = "AltRight", // Alt, Option or ⌥. This is labelled AltGr key on many keyboard layouts. - CapsLock = "CapsLock", // CapsLock or ⇪ - ContextMenu = "ContextMenu", // The application context menu key, which is typically found between the right Meta key and the right Control key. - ControlLeft = "ControlLeft", // Control or ⌃ - ControlRight = "ControlRight", // Control or ⌃ - Enter = "Enter", // Enter or ↵. Labelled Return on Apple keyboards. - MetaLeft = "MetaLeft", // The Windows, ⌘, Command or other OS symbol key. - MetaRight = "MetaRight", // The Windows, ⌘, Command or other OS symbol key. - ShiftLeft = "ShiftLeft", // Shift or ⇧ - ShiftRight = "ShiftRight", // Shift or ⇧ - Space = "Space", // (space) - Tab = "Tab", // Tab or ⇥ + AltLeft = 'AltLeft', // Alt, Option or ⌥. + AltRight = 'AltRight', // Alt, Option or ⌥. This is labelled AltGr key on many keyboard layouts. + CapsLock = 'CapsLock', // CapsLock or ⇪ + ContextMenu = 'ContextMenu', // The application context menu key, which is typically found between the right Meta key and the right Control key. + ControlLeft = 'ControlLeft', // Control or ⌃ + ControlRight = 'ControlRight', // Control or ⌃ + Enter = 'Enter', // Enter or ↵. Labelled Return on Apple keyboards. + MetaLeft = 'MetaLeft', // The Windows, ⌘, Command or other OS symbol key. + MetaRight = 'MetaRight', // The Windows, ⌘, Command or other OS symbol key. + ShiftLeft = 'ShiftLeft', // Shift or ⇧ + ShiftRight = 'ShiftRight', // Shift or ⇧ + Space = 'Space', // (space) + Tab = 'Tab', // Tab or ⇥ // 3.1.2. Control Pad Section - Delete = "Delete", // ⌦. The forward delete key. Note that on Apple keyboards, the key labelled Delete on the main part of the keyboard should be encoded as "Backspace". - End = "End", // Page Down, End or ↘ - Help = "Help", // Help. Not present on standard PC keyboards. - Home = "Home", // Home or ↖ - Insert = "Insert", // Insert or Ins. Not present on Apple keyboards. - PageDown = "PageDown", // Page Down, PgDn or ⇟ - PageUp = "PageUp", // Page Up, PgUp or ⇞ + Delete = 'Delete', // ⌦. The forward delete key. Note that on Apple keyboards, the key labelled Delete on the main part of the keyboard should be encoded as "Backspace". + End = 'End', // Page Down, End or ↘ + Help = 'Help', // Help. Not present on standard PC keyboards. + Home = 'Home', // Home or ↖ + Insert = 'Insert', // Insert or Ins. Not present on Apple keyboards. + PageDown = 'PageDown', // Page Down, PgDn or ⇟ + PageUp = 'PageUp', // Page Up, PgUp or ⇞ // Arrow Pad Section - ArrowDown = "ArrowDown", // ↓ - ArrowLeft = "ArrowLeft", // ← - ArrowRight = "ArrowRight", // → - ArrowUp = "ArrowUp", // ↑ + ArrowDown = 'ArrowDown', // ↓ + ArrowLeft = 'ArrowLeft', // ← + ArrowRight = 'ArrowRight', // → + ArrowUp = 'ArrowUp', // ↑ // 3.1.4. Numpad Section - NumLock = "NumLock", // On the Mac, the "NumLock" code should be used for the numpad Clear key. - - Numpad0 = "Numpad0", // 0 Ins on a keyboard; 0 on a phone or remote control - Numpad1 = "Numpad1", // 1 End on a keyboard; 1 or 1 QZ on a phone or remote control - Numpad2 = "Numpad2", // 2 ↓ on a keyboard; 2 ABC on a phone or remote control - Numpad3 = "Numpad3", // 3 PgDn on a keyboard; 3 DEF on a phone or remote control - Numpad4 = "Numpad4", // 4 ← on a keyboard; 4 GHI on a phone or remote control - Numpad5 = "Numpad5", // 5 on a keyboard; 5 JKL on a phone or remote control - Numpad6 = "Numpad6", // 6 → on a keyboard; 6 MNO on a phone or remote control - Numpad7 = "Numpad7", // 7 Home on a keyboard; 7 PQRS or 7 PRS on a phone or remote control - Numpad8 = "Numpad8", // 8 ↑ on a keyboard; 8 TUV on a phone or remote control - Numpad9 = "Numpad9", // 9 PgUp on a keyboard; 9 WXYZ or 9 WXY on a phone or remote control - - NumpadAdd = "NumpadAdd", // + - NumpadBackspace = "NumpadBackspace", // Found on the Microsoft Natural Keyboard. - NumpadClear = "NumpadClear", // C or AC (All Clear). Also for use with numpads that have a Clear key that is separate from the NumLock key. On the Mac, the numpad Clear key should always be encoded as "NumLock". - NumpadClearEntry = "NumpadClearEntry", // CE (Clear Entry) - NumpadComma = "NumpadComma", // , (thousands separator). For locales where the thousands separator is a "." (e.g., Brazil), this key may generate a .. - NumpadDecimal = "NumpadDecimal", // . Del. For locales where the decimal separator is "," (e.g., Brazil), this key may generate a ,. - NumpadDivide = "NumpadDivide", // / - NumpadEnter = "NumpadEnter", - NumpadEqual = "NumpadEqual", // = - NumpadHash = "NumpadHash", // # on a phone or remote control device. This key is typically found below the 9 key and to the right of the 0 key. - NumpadMemoryAdd = "NumpadMemoryAdd", // M+ Add current entry to the value stored in memory. - NumpadMemoryClear = "NumpadMemoryClear", // MC Clear the value stored in memory. - NumpadMemoryRecall = "NumpadMemoryRecall", // MR Replace the current entry with the value stored in memory. - NumpadMemoryStore = "NumpadMemoryStore", // MS Replace the value stored in memory with the current entry. - NumpadMemorySubtract = "NumpadMemorySubtract", // M- Subtract current entry from the value stored in memory. - NumpadMultiply = "NumpadMultiply", // * on a keyboard. For use with numpads that provide mathematical operations (+, -, * and /). Use "NumpadStar" for the * key on phones and remote controls. - NumpadParenLeft = "NumpadParenLeft", // ( Found on the Microsoft Natural Keyboard. - NumpadParenRight = "NumpadParenRight", // ) Found on the Microsoft Natural Keyboard. - NumpadStar = "NumpadStar", // * on a phone or remote control device. This key is typically found below the 7 key and to the left of the 0 key. Use "NumpadMultiply" for the * key on numeric keypads. - NumpadSubtract = "NumpadSubtract", // - + NumLock = 'NumLock', // On the Mac, the "NumLock" code should be used for the numpad Clear key. + + Numpad0 = 'Numpad0', // 0 Ins on a keyboard; 0 on a phone or remote control + Numpad1 = 'Numpad1', // 1 End on a keyboard; 1 or 1 QZ on a phone or remote control + Numpad2 = 'Numpad2', // 2 ↓ on a keyboard; 2 ABC on a phone or remote control + Numpad3 = 'Numpad3', // 3 PgDn on a keyboard; 3 DEF on a phone or remote control + Numpad4 = 'Numpad4', // 4 ← on a keyboard; 4 GHI on a phone or remote control + Numpad5 = 'Numpad5', // 5 on a keyboard; 5 JKL on a phone or remote control + Numpad6 = 'Numpad6', // 6 → on a keyboard; 6 MNO on a phone or remote control + Numpad7 = 'Numpad7', // 7 Home on a keyboard; 7 PQRS or 7 PRS on a phone or remote control + Numpad8 = 'Numpad8', // 8 ↑ on a keyboard; 8 TUV on a phone or remote control + Numpad9 = 'Numpad9', // 9 PgUp on a keyboard; 9 WXYZ or 9 WXY on a phone or remote control + + NumpadAdd = 'NumpadAdd', // + + NumpadBackspace = 'NumpadBackspace', // Found on the Microsoft Natural Keyboard. + NumpadClear = 'NumpadClear', // C or AC (All Clear). Also for use with numpads that have a Clear key that is separate from the NumLock key. On the Mac, the numpad Clear key should always be encoded as "NumLock". + NumpadClearEntry = 'NumpadClearEntry', // CE (Clear Entry) + NumpadComma = 'NumpadComma', // , (thousands separator). For locales where the thousands separator is a "." (e.g., Brazil), this key may generate a .. + NumpadDecimal = 'NumpadDecimal', // . Del. For locales where the decimal separator is "," (e.g., Brazil), this key may generate a ,. + NumpadDivide = 'NumpadDivide', // / + NumpadEnter = 'NumpadEnter', + NumpadEqual = 'NumpadEqual', // = + NumpadHash = 'NumpadHash', // # on a phone or remote control device. This key is typically found below the 9 key and to the right of the 0 key. + NumpadMemoryAdd = 'NumpadMemoryAdd', // M+ Add current entry to the value stored in memory. + NumpadMemoryClear = 'NumpadMemoryClear', // MC Clear the value stored in memory. + NumpadMemoryRecall = 'NumpadMemoryRecall', // MR Replace the current entry with the value stored in memory. + NumpadMemoryStore = 'NumpadMemoryStore', // MS Replace the value stored in memory with the current entry. + NumpadMemorySubtract = 'NumpadMemorySubtract', // M- Subtract current entry from the value stored in memory. + NumpadMultiply = 'NumpadMultiply', // * on a keyboard. For use with numpads that provide mathematical operations (+, -, * and /). Use "NumpadStar" for the * key on phones and remote controls. + NumpadParenLeft = 'NumpadParenLeft', // ( Found on the Microsoft Natural Keyboard. + NumpadParenRight = 'NumpadParenRight', // ) Found on the Microsoft Natural Keyboard. + NumpadStar = 'NumpadStar', // * on a phone or remote control device. This key is typically found below the 7 key and to the left of the 0 key. Use "NumpadMultiply" for the * key on numeric keypads. + NumpadSubtract = 'NumpadSubtract', // - // 3.1.5. Function Section - Escape = "Escape", // Esc or ⎋ - - F1 = "F1", // F1 - F2 = "F2", // F2 - F3 = "F3", // F3 - F4 = "F4", // F4 - F5 = "F5", // F5 - F6 = "F6", // F6 - F7 = "F7", // F7 - F8 = "F8", // F8 - F9 = "F9", // F9 - F10 = "F10", // F10 - F11 = "F11", // F11 - F12 = "F12", // F12 - - Fn = "Fn", // Fn This is typically a hardware key that does not generate a separate code. Most keyboards do not place this key in the function section, but it is included here to keep it with related keys. - FnLock = "FnLock", // FLock or FnLock. Function Lock key. Found on the Microsoft Natural Keyboard. - PrintScreen = "PrintScreen", // PrtScr SysRq or Print Screen - ScrollLock = "ScrollLock", // Scroll Lock - Pause = "Pause", // Pause Break + Escape = 'Escape', // Esc or ⎋ + + F1 = 'F1', // F1 + F2 = 'F2', // F2 + F3 = 'F3', // F3 + F4 = 'F4', // F4 + F5 = 'F5', // F5 + F6 = 'F6', // F6 + F7 = 'F7', // F7 + F8 = 'F8', // F8 + F9 = 'F9', // F9 + F10 = 'F10', // F10 + F11 = 'F11', // F11 + F12 = 'F12', // F12 + + Fn = 'Fn', // Fn This is typically a hardware key that does not generate a separate code. Most keyboards do not place this key in the function section, but it is included here to keep it with related keys. + FnLock = 'FnLock', // FLock or FnLock. Function Lock key. Found on the Microsoft Natural Keyboard. + PrintScreen = 'PrintScreen', // PrtScr SysRq or Print Screen + ScrollLock = 'ScrollLock', // Scroll Lock + Pause = 'Pause', // Pause Break // 3.1.6. Media Keys - BrowserBack = "BrowserBack", // Some laptops place this key to the left of the ↑ key. - BrowserFavorites = "BrowserFavorites", - BrowserForward = "BrowserForward", // Some laptops place this key to the right of the ↑ key. - BrowserHome = "BrowserHome", - BrowserRefresh = "BrowserRefresh", - BrowserSearch = "BrowserSearch", - BrowserStop = "BrowserStop", - Eject = "Eject", // Eject or ⏏. This key is placed in the function section on some Apple keyboards. - LaunchApp1 = "LaunchApp1", // Sometimes labelled My Computer on the keyboard - LaunchApp2 = "LaunchApp2", // Sometimes labelled Calculator on the keyboard - LaunchMail = "LaunchMail", - MediaPlayPause = "MediaPlayPause", - MediaSelect = "MediaSelect", - MediaStop = "MediaStop", - MediaTrackNext = "MediaTrackNext", - MediaTrackPrevious = "MediaTrackPrevious", - Power = "Power", // This key is placed in the function section on some Apple keyboards, replacing the Eject key. - Sleep = "Sleep", - AudioVolumeDown = "AudioVolumeDown", - AudioVolumeMute = "AudioVolumeMute", - AudioVolumeUp = "AudioVolumeUp", - WakeUp = "WakeUp", + BrowserBack = 'BrowserBack', // Some laptops place this key to the left of the ↑ key. + BrowserFavorites = 'BrowserFavorites', + BrowserForward = 'BrowserForward', // Some laptops place this key to the right of the ↑ key. + BrowserHome = 'BrowserHome', + BrowserRefresh = 'BrowserRefresh', + BrowserSearch = 'BrowserSearch', + BrowserStop = 'BrowserStop', + Eject = 'Eject', // Eject or ⏏. This key is placed in the function section on some Apple keyboards. + LaunchApp1 = 'LaunchApp1', // Sometimes labelled My Computer on the keyboard + LaunchApp2 = 'LaunchApp2', // Sometimes labelled Calculator on the keyboard + LaunchMail = 'LaunchMail', + MediaPlayPause = 'MediaPlayPause', + MediaSelect = 'MediaSelect', + MediaStop = 'MediaStop', + MediaTrackNext = 'MediaTrackNext', + MediaTrackPrevious = 'MediaTrackPrevious', + Power = 'Power', // This key is placed in the function section on some Apple keyboards, replacing the Eject key. + Sleep = 'Sleep', + AudioVolumeDown = 'AudioVolumeDown', + AudioVolumeMute = 'AudioVolumeMute', + AudioVolumeUp = 'AudioVolumeUp', + WakeUp = 'WakeUp', } export default KeyCode; diff --git a/src/flashbang/input/KeyboardEventType.ts b/src/flashbang/input/KeyboardEventType.ts index d2018563e..95e02ca20 100644 --- a/src/flashbang/input/KeyboardEventType.ts +++ b/src/flashbang/input/KeyboardEventType.ts @@ -1,6 +1,6 @@ enum KeyboardEventType { - KEY_DOWN = "keydown", - KEY_UP = "keyup" + KEY_DOWN = 'keydown', + KEY_UP = 'keyup' } export default KeyboardEventType; diff --git a/src/flashbang/input/KeyboardInput.ts b/src/flashbang/input/KeyboardInput.ts index 95c2ef98e..47f771b51 100644 --- a/src/flashbang/input/KeyboardInput.ts +++ b/src/flashbang/input/KeyboardInput.ts @@ -1,5 +1,5 @@ -import {Registration} from "signals"; -import {LinkedElement, LinkedList} from "../util"; +import {Registration} from 'signals'; +import {LinkedElement, LinkedList} from '../util'; export interface KeyboardListener { /** @@ -18,7 +18,11 @@ export default class KeyboardInput { public handleKeyboardEvent(e: KeyboardEvent): boolean { let handled = false; try { - for (let elt: LinkedElement = this._listeners.beginIteration(); elt != null; elt = elt.next) { + for ( + let elt: LinkedElement = this._listeners.beginIteration(); + elt != null; + elt = elt.next + ) { handled = elt.data.onKeyboardEvent(e); if (handled) { break; diff --git a/src/flashbang/input/MouseWheelInput.ts b/src/flashbang/input/MouseWheelInput.ts index 7a5053142..4f08834ee 100644 --- a/src/flashbang/input/MouseWheelInput.ts +++ b/src/flashbang/input/MouseWheelInput.ts @@ -1,5 +1,5 @@ -import {Registration} from "signals"; -import {LinkedElement, LinkedList} from "../util"; +import {Registration} from 'signals'; +import {LinkedElement, LinkedList} from '../util'; export interface MouseWheelListener { /** @@ -18,7 +18,11 @@ export default class MouseWheelInput { public handleMouseWheelEvent(e: WheelEvent): boolean { let handled = false; try { - for (let elt: LinkedElement = this._listeners.beginIteration(); elt != null; elt = elt.next) { + for ( + let elt: LinkedElement = this._listeners.beginIteration(); + elt != null; + elt = elt.next + ) { handled = elt.data.onMouseWheelEvent(e); if (handled) { break; diff --git a/src/flashbang/input/PointerCapture.ts b/src/flashbang/input/PointerCapture.ts index 24c14b93b..859acb675 100644 --- a/src/flashbang/input/PointerCapture.ts +++ b/src/flashbang/input/PointerCapture.ts @@ -1,11 +1,11 @@ -import {DisplayObject} from "pixi.js"; -import {Flashbang} from "../core"; +import {DisplayObject} from 'pixi.js'; +import {Flashbang} from '../core'; type InteractionPointerEvents = PIXI.interaction.InteractionPointerEvents; type InteractionEvent = PIXI.interaction.InteractionEvent; export default class PointerCapture { - public constructor(root: DisplayObject) { + constructor(root: DisplayObject) { this._root = root; } @@ -72,8 +72,8 @@ export default class PointerCapture { private static _captures: PointerCapture[] = []; private static readonly POINTER_EVENTS: InteractionPointerEvents[] = [ - "pointerdown", "pointercancel", "pointerup", - "pointertap", "pointerupoutside", "pointermove", - "pointerover", "pointerout" + 'pointerdown', 'pointercancel', 'pointerup', + 'pointertap', 'pointerupoutside', 'pointermove', + 'pointerover', 'pointerout' ]; } diff --git a/src/flashbang/input/PointerTarget.ts b/src/flashbang/input/PointerTarget.ts index dd4d9f317..9c3f606b3 100644 --- a/src/flashbang/input/PointerTarget.ts +++ b/src/flashbang/input/PointerTarget.ts @@ -1,5 +1,5 @@ -import {DisplayObject} from "pixi.js"; -import {SignalView} from "signals"; +import {DisplayObject} from 'pixi.js'; +import {SignalView} from 'signals'; type InteractionEvent = PIXI.interaction.InteractionEvent; diff --git a/src/flashbang/input/index.ts b/src/flashbang/input/index.ts index 3671d39e2..0a335f2e1 100644 --- a/src/flashbang/input/index.ts +++ b/src/flashbang/input/index.ts @@ -1,8 +1,8 @@ -export {default as DisplayObjectPointerTarget} from "./DisplayObjectPointerTarget"; -export {default as InputUtil} from "./InputUtil"; -export {default as KeyboardEventType} from "./KeyboardEventType"; -export {default as KeyboardInput, KeyboardListener} from "./KeyboardInput"; -export {default as KeyCode} from "./KeyCode"; -export {default as MouseWheelInput, MouseWheelListener} from "./MouseWheelInput"; -export {default as PointerCapture} from "./PointerCapture"; -export {default as PointerTarget} from "./PointerTarget"; +export {default as DisplayObjectPointerTarget} from './DisplayObjectPointerTarget'; +export {default as InputUtil} from './InputUtil'; +export {default as KeyboardEventType} from './KeyboardEventType'; +export {default as KeyboardInput, KeyboardListener} from './KeyboardInput'; +export {default as KeyCode} from './KeyCode'; +export {default as MouseWheelInput, MouseWheelListener} from './MouseWheelInput'; +export {default as PointerCapture} from './PointerCapture'; +export {default as PointerTarget} from './PointerTarget'; diff --git a/src/flashbang/layout/HLayoutContainer.ts b/src/flashbang/layout/HLayoutContainer.ts index d2b239650..bc4f8b7c1 100644 --- a/src/flashbang/layout/HLayoutContainer.ts +++ b/src/flashbang/layout/HLayoutContainer.ts @@ -1,14 +1,14 @@ -import {Rectangle} from "pixi.js"; -import {VAlign} from "../core"; -import {DisplayUtil} from "../util"; -import LayoutContainer from "./LayoutContainer"; +import {Rectangle} from 'pixi.js'; +import {VAlign} from '../core'; +import {DisplayUtil} from '../util'; +import LayoutContainer from './LayoutContainer'; /** * A Container that arranges its children horizontally. * Call layout() after adding or removing children to update the sprite's layout. */ export default class HLayoutContainer extends LayoutContainer { - public constructor(hOffset: number = 0, vAlign: VAlign = VAlign.CENTER) { + constructor(hOffset: number = 0, vAlign: VAlign = VAlign.CENTER) { super(); this._hOffset = hOffset; this._vAlign = vAlign; diff --git a/src/flashbang/layout/LayoutContainer.ts b/src/flashbang/layout/LayoutContainer.ts index 7a479122e..c4044e2ff 100644 --- a/src/flashbang/layout/LayoutContainer.ts +++ b/src/flashbang/layout/LayoutContainer.ts @@ -1,4 +1,4 @@ -import {Container, DisplayObject, Sprite} from "pixi.js"; +import {Container, DisplayObject, Sprite} from 'pixi.js'; /** A base class for Containers that arrange their children automatically. */ export default abstract class LayoutContainer extends Container { @@ -76,7 +76,7 @@ export default abstract class LayoutContainer extends Container { } class Spacer extends Container { - public constructor(width: number, height: number) { + constructor(width: number, height: number) { super(); // For some reasons, spacers have zero-width bounds diff --git a/src/flashbang/layout/VLayoutContainer.ts b/src/flashbang/layout/VLayoutContainer.ts index 2e2645264..fa8c2bb40 100644 --- a/src/flashbang/layout/VLayoutContainer.ts +++ b/src/flashbang/layout/VLayoutContainer.ts @@ -1,14 +1,14 @@ -import {Rectangle} from "pixi.js"; -import {HAlign} from "../core"; -import {DisplayUtil} from "../util"; -import LayoutContainer from "./LayoutContainer"; +import {Rectangle} from 'pixi.js'; +import {HAlign} from '../core'; +import {DisplayUtil} from '../util'; +import LayoutContainer from './LayoutContainer'; /** * A Container that arranges its children vertically. * Call layout() after adding or removing children to update the sprite's layout. */ export default class VLayoutContainer extends LayoutContainer { - public constructor(vOffset: number = 0, hAlign: HAlign = HAlign.CENTER) { + constructor(vOffset: number = 0, hAlign: HAlign = HAlign.CENTER) { super(); this._vOffset = vOffset; this._hAlign = hAlign; diff --git a/src/flashbang/layout/index.ts b/src/flashbang/layout/index.ts index 67d6f99b7..a53bb1d74 100644 --- a/src/flashbang/layout/index.ts +++ b/src/flashbang/layout/index.ts @@ -1,3 +1,3 @@ -export {default as LayoutContainer} from "./LayoutContainer"; -export {default as HLayoutContainer} from "./HLayoutContainer"; -export {default as VLayoutContainer} from "./VLayoutContainer"; +export {default as LayoutContainer} from './LayoutContainer'; +export {default as HLayoutContainer} from './HLayoutContainer'; +export {default as VLayoutContainer} from './VLayoutContainer'; diff --git a/src/flashbang/objects/Button.ts b/src/flashbang/objects/Button.ts index c8191ef8f..f147144a4 100644 --- a/src/flashbang/objects/Button.ts +++ b/src/flashbang/objects/Button.ts @@ -1,15 +1,19 @@ -import {Point} from "pixi.js"; -import Eterna from "eterna/Eterna"; -import {Sounds} from "eterna/resources"; -import {UnitSignal} from "signals"; -import {InputUtil, PointerCapture} from "../input"; -import {CallbackTask, DelayTask, SerialTask} from "../tasks"; -import {DisplayUtil} from "../util"; -import ContainerObject from "./ContainerObject"; -import Enableable from "./Enableable"; +import {Point} from 'pixi.js'; +import Eterna from 'eterna/Eterna'; +import {Sounds} from 'eterna/resources'; +import {UnitSignal} from 'signals'; +import {InputUtil, PointerCapture} from '../input'; +import {CallbackTask, DelayTask, SerialTask} from '../tasks'; +import {DisplayUtil} from '../util'; +import ContainerObject from './ContainerObject'; +import Enableable from './Enableable'; type InteractionEvent = PIXI.interaction.InteractionEvent; +export enum ButtonState { + UP = 0, OVER, DOWN, DISABLED +} + /** A button base class. */ export default abstract class Button extends ContainerObject implements Enableable { public static readonly DEFAULT_DOWN_SOUND: string = Sounds.SoundButtonClick; @@ -26,10 +30,6 @@ export default abstract class Button extends ContainerObject implements Enableab /** Sound played when the button is pressed while disabled (null for no sound) */ public disabledSound: string = null; - protected constructor() { - super(); - } - /* override */ protected added(): void { super.added(); @@ -130,9 +130,9 @@ export default abstract class Button extends ContainerObject implements Enableab this._pointerCapture.beginCapture((e: InteractionEvent) => { e.stopPropagation(); - if (InputUtil.IsLeftMouse(e) && (e.type === "pointerup" || e.type === "pointerupoutside")) { + if (InputUtil.IsLeftMouse(e) && (e.type === 'pointerup' || e.type === 'pointerupoutside')) { this.onPointerUp(false); - } else if (e.type === "pointercancel") { + } else if (e.type === 'pointercancel') { this.endCapture(true); } else { this.onPointerMove(e); @@ -221,7 +221,3 @@ export default abstract class Button extends ContainerObject implements Enableab protected _isPointerDown: boolean; protected _pointerCapture: PointerCapture; } - -export enum ButtonState { - UP = 0, OVER, DOWN, DISABLED -} diff --git a/src/flashbang/objects/ContainerObject.ts b/src/flashbang/objects/ContainerObject.ts index 4bf919ce9..eb324c4a4 100644 --- a/src/flashbang/objects/ContainerObject.ts +++ b/src/flashbang/objects/ContainerObject.ts @@ -1,9 +1,9 @@ -import {Container} from "pixi.js"; -import SceneObject from "./SceneObject"; +import {Container} from 'pixi.js'; +import SceneObject from './SceneObject'; /** A GameObject that manages a PIXI Container */ export default class ContainerObject extends SceneObject { - public constructor(container?: Container) { + constructor(container?: Container) { super(container || new Container()); } diff --git a/src/flashbang/objects/DOMObject.ts b/src/flashbang/objects/DOMObject.ts index c4815bcc0..4deae5619 100644 --- a/src/flashbang/objects/DOMObject.ts +++ b/src/flashbang/objects/DOMObject.ts @@ -1,6 +1,6 @@ -import {DisplayObject, Graphics, Matrix} from "pixi.js"; -import {Flashbang, GameObject} from "../core"; -import {MatrixUtil} from "../util"; +import {DisplayObject, Graphics, Matrix} from 'pixi.js'; +import {Flashbang, GameObject} from '../core'; +import {MatrixUtil} from '../util'; /** * Wraps an HTML element that lives in the DOM and is drawn on top of the PIXI canvas. @@ -13,7 +13,12 @@ export default abstract class DOMObject extends GameObjec * * If elementNames is non-null, the style will only be applied to elements with the given names. */ - public static applyStyleRecursive(element: HTMLElement, styles: any, replaceIfExists: boolean = false, elementNames: string[] = null): void { + public static applyStyleRecursive( + element: HTMLElement, + styles: {[property: string]: string}, + replaceIfExists: boolean = false, + elementNames: string[] = null + ): void { let isValidElement = true; if (elementNames != null) { isValidElement = false; @@ -27,17 +32,17 @@ export default abstract class DOMObject extends GameObjec } if (isValidElement) { - for (let styleName in styles) { + for (let [property, value] of Object.entries(styles)) { let applyStyle = true; if (!replaceIfExists) { - let cur = element.style.getPropertyValue(styleName); + let cur = element.style.getPropertyValue(property); if (cur != null && cur.length > 0) { applyStyle = false; } } if (applyStyle) { - element.style.setProperty(styleName, styles[styleName]); + element.style.setProperty(property, value); } } } @@ -54,13 +59,13 @@ export default abstract class DOMObject extends GameObjec super(); this._obj = obj; - this._obj.style.position = "absolute"; - this._obj.style.transformOrigin = "0 0"; + this._obj.style.position = 'absolute'; + this._obj.style.transformOrigin = '0 0'; // Set the initial opacity to 0 so that the object will be hidden // until the first postrender event. This prevents it from flickering // briefly on the frame it's added. - this._obj.style.opacity = "0"; + this._obj.style.opacity = '0'; this._domParent = document.getElementById(domParentID); } @@ -117,12 +122,12 @@ export default abstract class DOMObject extends GameObjec // Update the HTML element's transform during the PIXI postrender event - // this is the point where the dummy display object's transform will be up to date. - Flashbang.pixi.renderer.addListener("postrender", this.updateElementProperties, this); + Flashbang.pixi.renderer.addListener('postrender', this.updateElementProperties, this); } protected dispose(): void { this._domParent.removeChild(this._obj); - Flashbang.pixi.renderer.removeListener("postrender", this.updateElementProperties, this); + Flashbang.pixi.renderer.removeListener('postrender', this.updateElementProperties, this); super.dispose(); } @@ -134,7 +139,7 @@ export default abstract class DOMObject extends GameObjec m.copy(this._lastTransform); } - this._obj.style.visibility = this.display.worldVisible ? "visible" : "hidden"; + this._obj.style.visibility = this.display.worldVisible ? 'visible' : 'hidden'; this._obj.style.opacity = this.display.worldAlpha.toString(); } @@ -162,7 +167,7 @@ export default abstract class DOMObject extends GameObjec } protected static stringToSize(value: string): number { - let idx = value.indexOf("px"); + let idx = value.indexOf('px'); if (idx >= 0) { value = value.substr(0, idx); } diff --git a/src/flashbang/objects/Dragger.ts b/src/flashbang/objects/Dragger.ts index d623e8774..a3e556ece 100644 --- a/src/flashbang/objects/Dragger.ts +++ b/src/flashbang/objects/Dragger.ts @@ -1,7 +1,7 @@ -import {Container, Graphics} from "pixi.js"; -import {UnitSignal} from "signals"; -import {Flashbang, GameObject} from "../core"; -import {DisplayObjectPointerTarget} from "../input"; +import {Container, Graphics} from 'pixi.js'; +import {UnitSignal} from 'signals'; +import {Flashbang, GameObject} from '../core'; +import {DisplayObjectPointerTarget} from '../input'; /** A utility object that captures mouse input and dispatches update events until a mouseUp occurs */ export default class Dragger extends GameObject { @@ -14,7 +14,7 @@ export default class Dragger extends GameObject { public curX: number = 0; public curY: number = 0; - public constructor(displayParent: Container = null) { + constructor(displayParent: Container = null) { super(); this._displayParent = displayParent; } @@ -34,8 +34,10 @@ export default class Dragger extends GameObject { parent.addChild(this._disp); this.updateSize(); - this.startX = this.curX = Flashbang.globalMouse.x; - this.startY = this.curY = Flashbang.globalMouse.y; + this.startX = Flashbang.globalMouse.x; + this.curX = Flashbang.globalMouse.x; + this.startY = Flashbang.globalMouse.y; + this.curY = Flashbang.globalMouse.y; let touchable = new DisplayObjectPointerTarget(this._disp); this.regs.add(touchable.pointerMove.connect((e) => { diff --git a/src/flashbang/objects/ImageButton.ts b/src/flashbang/objects/ImageButton.ts index 023069034..9a402b73a 100644 --- a/src/flashbang/objects/ImageButton.ts +++ b/src/flashbang/objects/ImageButton.ts @@ -1,8 +1,8 @@ -import {Texture, Sprite} from "pixi.js"; -import Button, {ButtonState} from "./Button"; +import {Texture, Sprite} from 'pixi.js'; +import Button, {ButtonState} from './Button'; export default class ImageButton extends Button { - public constructor(textures: Texture[]) { + constructor(textures: Texture[]) { super(); this._sprite = new Sprite(); diff --git a/src/flashbang/objects/SceneObject.ts b/src/flashbang/objects/SceneObject.ts index 115c686ee..5ae3ea37d 100644 --- a/src/flashbang/objects/SceneObject.ts +++ b/src/flashbang/objects/SceneObject.ts @@ -1,7 +1,7 @@ -import {DisplayObject} from "pixi.js"; -import {SignalView} from "signals"; -import {GameObject} from "../core"; -import {PointerTarget, DisplayObjectPointerTarget} from "../input"; +import {DisplayObject} from 'pixi.js'; +import {SignalView} from 'signals'; +import {GameObject} from '../core'; +import {PointerTarget, DisplayObjectPointerTarget} from '../input'; type InteractionEvent = PIXI.interaction.InteractionEvent; diff --git a/src/flashbang/objects/SimpleTextButton.ts b/src/flashbang/objects/SimpleTextButton.ts index 5f4946e4a..43246bb33 100644 --- a/src/flashbang/objects/SimpleTextButton.ts +++ b/src/flashbang/objects/SimpleTextButton.ts @@ -1,10 +1,10 @@ -import {Graphics, Text} from "pixi.js"; -import {TextBuilder} from "../util"; -import Button, {ButtonState} from "./Button"; +import {Graphics, Text} from 'pixi.js'; +import {TextBuilder} from '../util'; +import Button, {ButtonState} from './Button'; /** A deliberately unstylish button that displays text on a rectangle. (For debugging.) */ export default class SimpleTextButton extends Button { - constructor(text: string, fontSize: number = 24, fontName: string = "Arial") { + constructor(text: string, fontSize: number = 24, fontName: string = 'Arial') { super(); this._tf = new TextBuilder() diff --git a/src/flashbang/objects/SpriteObject.ts b/src/flashbang/objects/SpriteObject.ts index bb507bdb3..c082cc516 100644 --- a/src/flashbang/objects/SpriteObject.ts +++ b/src/flashbang/objects/SpriteObject.ts @@ -1,9 +1,9 @@ -import {Sprite} from "pixi.js"; -import SceneObject from "./SceneObject"; +import {Sprite} from 'pixi.js'; +import SceneObject from './SceneObject'; /** A GameObject that manages a PIXI Sprite */ export default class SpriteObject extends SceneObject { - public constructor(sprite?: Sprite) { + constructor(sprite?: Sprite) { super(sprite || new Sprite()); } } diff --git a/src/flashbang/objects/ToggleButton.ts b/src/flashbang/objects/ToggleButton.ts index e7b3ad0db..16400e932 100644 --- a/src/flashbang/objects/ToggleButton.ts +++ b/src/flashbang/objects/ToggleButton.ts @@ -1,5 +1,5 @@ -import {Value} from "signals"; -import Button from "./Button"; +import {Value} from 'signals'; +import Button from './Button'; /** A two-state Button whose value is toggled on click (e.g. a checkbox). */ export default abstract class ToggleButton extends Button { diff --git a/src/flashbang/objects/index.ts b/src/flashbang/objects/index.ts index 68b69beb1..b5ee36b13 100644 --- a/src/flashbang/objects/index.ts +++ b/src/flashbang/objects/index.ts @@ -1,10 +1,10 @@ -export {default as Enableable} from "./Enableable"; -export {default as SceneObject} from "./SceneObject"; -export {default as ContainerObject} from "./ContainerObject"; -export {default as Button, ButtonState} from "./Button"; -export {default as DOMObject} from "./DOMObject"; -export {default as ImageButton} from "./ImageButton"; -export {default as SimpleTextButton} from "./SimpleTextButton"; -export {default as SpriteObject} from "./SpriteObject"; -export {default as ToggleButton} from "./ToggleButton"; -export {default as Dragger} from "./Dragger"; +export {default as Enableable} from './Enableable'; +export {default as SceneObject} from './SceneObject'; +export {default as ContainerObject} from './ContainerObject'; +export {default as Button, ButtonState} from './Button'; +export {default as DOMObject} from './DOMObject'; +export {default as ImageButton} from './ImageButton'; +export {default as SimpleTextButton} from './SimpleTextButton'; +export {default as SpriteObject} from './SpriteObject'; +export {default as ToggleButton} from './ToggleButton'; +export {default as Dragger} from './Dragger'; diff --git a/src/flashbang/resources/FontLoader.ts b/src/flashbang/resources/FontLoader.ts index 05b08bfdd..208571460 100644 --- a/src/flashbang/resources/FontLoader.ts +++ b/src/flashbang/resources/FontLoader.ts @@ -1,4 +1,4 @@ -import * as WebFont from "webfontloader"; +import * as WebFont from 'webfontloader'; export default class FontLoader { /** @@ -13,7 +13,9 @@ export default class FontLoader { urls: cssURL ? [cssURL] : undefined }, fontactive: (familyName, fvd) => resolve(), - fontinactive: (familyName, fvd) => reject(`Font load failure [css=${cssURL}, family=${familyName}]`) + fontinactive: (familyName, fvd) => reject( + new Error(`Font load failure [css=${cssURL}, family=${familyName}]`) + ) }); }); } diff --git a/src/flashbang/resources/index.ts b/src/flashbang/resources/index.ts index 1b64debaf..93fec9b46 100644 --- a/src/flashbang/resources/index.ts +++ b/src/flashbang/resources/index.ts @@ -1 +1,2 @@ -export {default as FontLoader} from "./FontLoader"; +/* eslint-disable import/prefer-default-export */ +export {default as FontLoader} from './FontLoader'; diff --git a/src/flashbang/settings/SaveGameManager.ts b/src/flashbang/settings/SaveGameManager.ts index 6a2eb2767..24238ed46 100644 --- a/src/flashbang/settings/SaveGameManager.ts +++ b/src/flashbang/settings/SaveGameManager.ts @@ -1,4 +1,4 @@ -import * as localforage from "localforage"; +import * as localforage from 'localforage'; export default class SaveGameManager { constructor(namespace: string) { @@ -13,19 +13,19 @@ export default class SaveGameManager { } public async load(name: string): Promise { - return await this._store.getItem(name); + return this._store.getItem(name); } public async save(name: string, obj: any): Promise { - return await this._store.setItem(name, obj); + return this._store.setItem(name, obj); } public async remove(name: string): Promise { - return await this._store.removeItem(name); + return this._store.removeItem(name); } public async clear(): Promise { - return await this._store.clear(); + return this._store.clear(); } protected static readonly ALL_NAMESPACES: Set = new Set(); diff --git a/src/flashbang/settings/Setting.ts b/src/flashbang/settings/Setting.ts index 378353dea..1e9724e06 100644 --- a/src/flashbang/settings/Setting.ts +++ b/src/flashbang/settings/Setting.ts @@ -1,7 +1,7 @@ -import {AbstractValue, MappedValue, ValueView} from "signals"; +import {AbstractValue, MappedValue, ValueView} from 'signals'; export default class Setting extends AbstractValue { - public constructor(store: StoreJsAPI, name: string, defaultVal: T) { + constructor(store: StoreJsAPI, name: string, defaultVal: T) { super(); this._store = store; this._name = name; diff --git a/src/flashbang/settings/Settings.ts b/src/flashbang/settings/Settings.ts index 05f808450..527f6c3ca 100644 --- a/src/flashbang/settings/Settings.ts +++ b/src/flashbang/settings/Settings.ts @@ -1,5 +1,5 @@ -import * as storejs from "store"; -import Setting from "./Setting"; +import * as storejs from 'store'; +import Setting from './Setting'; export default abstract class Settings { protected constructor(namespace: string) { diff --git a/src/flashbang/settings/index.ts b/src/flashbang/settings/index.ts index 2e59ef748..c81ba310c 100644 --- a/src/flashbang/settings/index.ts +++ b/src/flashbang/settings/index.ts @@ -1,3 +1,3 @@ -export {default as SaveGameManager} from "./SaveGameManager"; -export {default as Setting} from "./Setting"; -export {default as Settings} from "./Settings"; +export {default as SaveGameManager} from './SaveGameManager'; +export {default as Setting} from './Setting'; +export {default as Settings} from './Settings'; diff --git a/src/flashbang/tasks/AlphaTask.ts b/src/flashbang/tasks/AlphaTask.ts index f9dc5e756..5d41abc63 100644 --- a/src/flashbang/tasks/AlphaTask.ts +++ b/src/flashbang/tasks/AlphaTask.ts @@ -1,6 +1,6 @@ -import {DisplayObject} from "pixi.js"; -import {EasingFunc} from "../util"; -import DisplayObjectTask from "./DisplayObjectTask"; +import {DisplayObject} from 'pixi.js'; +import {EasingFunc} from '../util'; +import DisplayObjectTask from './DisplayObjectTask'; export default class AlphaTask extends DisplayObjectTask { constructor(alpha: number, time: number = 0, easingFn: EasingFunc = null, target: DisplayObject = null) { diff --git a/src/flashbang/tasks/CallbackTask.ts b/src/flashbang/tasks/CallbackTask.ts index 707c8f2c8..84a41966f 100644 --- a/src/flashbang/tasks/CallbackTask.ts +++ b/src/flashbang/tasks/CallbackTask.ts @@ -1,4 +1,4 @@ -import {ObjectTask} from "../core"; +import {ObjectTask} from '../core'; /** A Task that calls a function once and then completes. */ export default class CallbackTask extends ObjectTask { diff --git a/src/flashbang/tasks/DelayTask.ts b/src/flashbang/tasks/DelayTask.ts index 11b1bad20..e4cf35861 100644 --- a/src/flashbang/tasks/DelayTask.ts +++ b/src/flashbang/tasks/DelayTask.ts @@ -1,4 +1,4 @@ -import {ObjectTask, Updatable} from "../core"; +import {ObjectTask, Updatable} from '../core'; export default class DelayTask extends ObjectTask implements Updatable { constructor(time: number) { diff --git a/src/flashbang/tasks/DisplayObjectTask.ts b/src/flashbang/tasks/DisplayObjectTask.ts index b3e1b4a17..0e7994531 100644 --- a/src/flashbang/tasks/DisplayObjectTask.ts +++ b/src/flashbang/tasks/DisplayObjectTask.ts @@ -1,6 +1,6 @@ -import {DisplayObject} from "pixi.js"; -import {Assert, EasingFunc} from "../util"; -import InterpolatingTask from "./InterpolatingTask"; +import {DisplayObject} from 'pixi.js'; +import {Assert, EasingFunc} from '../util'; +import InterpolatingTask from './InterpolatingTask'; export default class DisplayObjectTask extends InterpolatingTask { constructor(time: number, easing: EasingFunc, target: DisplayObject) { @@ -13,7 +13,7 @@ export default class DisplayObjectTask extends InterpolatingTask { super.added(); // If we weren't given a target, operate on our parent object if (this._target == null) { - Assert.notNull(this.parent.display, "parent does not have a DisplayObject"); + Assert.notNull(this.parent.display, 'parent does not have a DisplayObject'); this._target = this.parent.display; } } diff --git a/src/flashbang/tasks/FrameDelayTask.ts b/src/flashbang/tasks/FrameDelayTask.ts index e93ecf3fb..fd8c6d895 100644 --- a/src/flashbang/tasks/FrameDelayTask.ts +++ b/src/flashbang/tasks/FrameDelayTask.ts @@ -1,4 +1,4 @@ -import {ObjectTask, Updatable} from "../core"; +import {ObjectTask, Updatable} from '../core'; /** Delays for the given number of frames. (Unlike DelayTask, which delays for a specific amount of time.) */ export default class FrameDelayTask extends ObjectTask implements Updatable { diff --git a/src/flashbang/tasks/FunctionTask.ts b/src/flashbang/tasks/FunctionTask.ts index 303f670e9..8f71349ff 100644 --- a/src/flashbang/tasks/FunctionTask.ts +++ b/src/flashbang/tasks/FunctionTask.ts @@ -1,4 +1,4 @@ -import {ObjectTask, Updatable} from "../core"; +import {ObjectTask, Updatable} from '../core'; /** A Task that calls a function continuously until the function returns true */ export default class FunctionTask extends ObjectTask implements Updatable { diff --git a/src/flashbang/tasks/InterpolatingTask.ts b/src/flashbang/tasks/InterpolatingTask.ts index 04ee879c4..a7c961318 100644 --- a/src/flashbang/tasks/InterpolatingTask.ts +++ b/src/flashbang/tasks/InterpolatingTask.ts @@ -1,5 +1,5 @@ -import {ObjectTask, Updatable} from "../core"; -import {Easing, EasingFunc} from "../util"; +import {ObjectTask, Updatable} from '../core'; +import {Easing, EasingFunc} from '../util'; export default class InterpolatingTask extends ObjectTask implements Updatable { constructor(time: number = 0, easingFn: EasingFunc = null) { diff --git a/src/flashbang/tasks/LocationTask.ts b/src/flashbang/tasks/LocationTask.ts index 549d3a87c..e1451fdba 100644 --- a/src/flashbang/tasks/LocationTask.ts +++ b/src/flashbang/tasks/LocationTask.ts @@ -1,6 +1,6 @@ -import {DisplayObject} from "pixi.js"; -import {EasingFunc} from "../util"; -import DisplayObjectTask from "./DisplayObjectTask"; +import {DisplayObject} from 'pixi.js'; +import {EasingFunc} from '../util'; +import DisplayObjectTask from './DisplayObjectTask'; export default class LocationTask extends DisplayObjectTask { constructor(x: number, y: number, time: number = 0, easingFn: EasingFunc = null, target: DisplayObject = null) { diff --git a/src/flashbang/tasks/ParallelTask.ts b/src/flashbang/tasks/ParallelTask.ts index b648fc39c..fa2e72a8f 100644 --- a/src/flashbang/tasks/ParallelTask.ts +++ b/src/flashbang/tasks/ParallelTask.ts @@ -1,5 +1,5 @@ -import {ObjectTask} from "../core"; -import {Assert} from "../util"; +import {ObjectTask} from '../core'; +import {Assert} from '../util'; export default class ParallelTask extends ObjectTask { constructor(...tasks: ObjectTask[]) { diff --git a/src/flashbang/tasks/RepeatingTask.ts b/src/flashbang/tasks/RepeatingTask.ts index faf72f6bc..a476bf0f0 100644 --- a/src/flashbang/tasks/RepeatingTask.ts +++ b/src/flashbang/tasks/RepeatingTask.ts @@ -1,4 +1,4 @@ -import {ObjectTask} from "../core"; +import {ObjectTask} from '../core'; type TaskCreator = () => ObjectTask; diff --git a/src/flashbang/tasks/RotationTask.ts b/src/flashbang/tasks/RotationTask.ts index 6b41a0753..df7303d5a 100644 --- a/src/flashbang/tasks/RotationTask.ts +++ b/src/flashbang/tasks/RotationTask.ts @@ -1,6 +1,6 @@ -import {DisplayObject} from "pixi.js"; -import {EasingFunc} from "../util"; -import DisplayObjectTask from "./DisplayObjectTask"; +import {DisplayObject} from 'pixi.js'; +import {EasingFunc} from '../util'; +import DisplayObjectTask from './DisplayObjectTask'; export default class RotationTask extends DisplayObjectTask { constructor(radians: number, time: number = 0, easingFn: EasingFunc = null, target: DisplayObject = null) { diff --git a/src/flashbang/tasks/ScaleTask.ts b/src/flashbang/tasks/ScaleTask.ts index 4db27de60..11b086b94 100644 --- a/src/flashbang/tasks/ScaleTask.ts +++ b/src/flashbang/tasks/ScaleTask.ts @@ -1,6 +1,6 @@ -import {DisplayObject} from "pixi.js"; -import {EasingFunc} from "../util"; -import DisplayObjectTask from "./DisplayObjectTask"; +import {DisplayObject} from 'pixi.js'; +import {EasingFunc} from '../util'; +import DisplayObjectTask from './DisplayObjectTask'; export default class ScaleTask extends DisplayObjectTask { constructor(x: number, y: number, time: number = 0, easingFn: EasingFunc = null, target: DisplayObject = null) { diff --git a/src/flashbang/tasks/SelfDestructTask.ts b/src/flashbang/tasks/SelfDestructTask.ts index 5059450fb..f60541801 100644 --- a/src/flashbang/tasks/SelfDestructTask.ts +++ b/src/flashbang/tasks/SelfDestructTask.ts @@ -1,4 +1,4 @@ -import {ObjectTask} from "../core"; +import {ObjectTask} from '../core'; /** * A Task that destroys its parent. diff --git a/src/flashbang/tasks/SerialTask.ts b/src/flashbang/tasks/SerialTask.ts index b07901478..5376908eb 100644 --- a/src/flashbang/tasks/SerialTask.ts +++ b/src/flashbang/tasks/SerialTask.ts @@ -1,5 +1,5 @@ -import {ObjectTask} from "../core"; -import {Assert} from "../util"; +import {ObjectTask} from '../core'; +import {Assert} from '../util'; export default class SerialTask extends ObjectTask { constructor(...tasks: ObjectTask[]) { diff --git a/src/flashbang/tasks/VisibleTask.ts b/src/flashbang/tasks/VisibleTask.ts index e60818583..5cbd793e2 100644 --- a/src/flashbang/tasks/VisibleTask.ts +++ b/src/flashbang/tasks/VisibleTask.ts @@ -1,6 +1,6 @@ -import {DisplayObject} from "pixi.js"; -import {ObjectTask} from "../core"; -import {Assert} from "../util"; +import {DisplayObject} from 'pixi.js'; +import {ObjectTask} from '../core'; +import {Assert} from '../util'; export default class VisibleTask extends ObjectTask { constructor(visible: boolean, target: DisplayObject = null) { @@ -14,7 +14,7 @@ export default class VisibleTask extends ObjectTask { // If we weren't given a target, operate on our parent object let target = this._target; if (target == null) { - Assert.notNull(this.parent.display, "parent does not have a DisplayObject"); + Assert.notNull(this.parent.display, 'parent does not have a DisplayObject'); target = this.parent.display; } diff --git a/src/flashbang/tasks/index.ts b/src/flashbang/tasks/index.ts index c8a98b86a..44d0ee6fb 100644 --- a/src/flashbang/tasks/index.ts +++ b/src/flashbang/tasks/index.ts @@ -1,15 +1,15 @@ -export {default as InterpolatingTask} from "./InterpolatingTask"; -export {default as DisplayObjectTask} from "./DisplayObjectTask"; -export {default as AlphaTask} from "./AlphaTask"; -export {default as CallbackTask} from "./CallbackTask"; -export {default as DelayTask} from "./DelayTask"; -export {default as FrameDelayTask} from "./FrameDelayTask"; -export {default as FunctionTask} from "./FunctionTask"; -export {default as LocationTask} from "./LocationTask"; -export {default as ParallelTask} from "./ParallelTask"; -export {default as RepeatingTask, Repeat} from "./RepeatingTask"; -export {default as RotationTask} from "./RotationTask"; -export {default as ScaleTask} from "./ScaleTask"; -export {default as SelfDestructTask} from "./SelfDestructTask"; -export {default as SerialTask} from "./SerialTask"; -export {default as VisibleTask} from "./VisibleTask"; +export {default as InterpolatingTask} from './InterpolatingTask'; +export {default as DisplayObjectTask} from './DisplayObjectTask'; +export {default as AlphaTask} from './AlphaTask'; +export {default as CallbackTask} from './CallbackTask'; +export {default as DelayTask} from './DelayTask'; +export {default as FrameDelayTask} from './FrameDelayTask'; +export {default as FunctionTask} from './FunctionTask'; +export {default as LocationTask} from './LocationTask'; +export {default as ParallelTask} from './ParallelTask'; +export {default as RepeatingTask, Repeat} from './RepeatingTask'; +export {default as RotationTask} from './RotationTask'; +export {default as ScaleTask} from './ScaleTask'; +export {default as SelfDestructTask} from './SelfDestructTask'; +export {default as SerialTask} from './SerialTask'; +export {default as VisibleTask} from './VisibleTask'; diff --git a/src/flashbang/util/Assert.ts b/src/flashbang/util/Assert.ts index 27fa8c55f..c7db2ef66 100644 --- a/src/flashbang/util/Assert.ts +++ b/src/flashbang/util/Assert.ts @@ -1,7 +1,7 @@ export default class Assert { public static ok(predicate: () => boolean, message?: string): void { - if (process.env.NODE_ENV !== "production" && !predicate()) { - throw new Error(message || "assertion failure!"); + if (process.env.NODE_ENV !== 'production' && !predicate()) { + throw new Error(message || 'assertion failure!'); } } @@ -16,4 +16,13 @@ export default class Assert { public static notNull(arg: any, message?: string): void { Assert.ok(() => arg != null, message); } + + /** + * Avoid lint errors in switch statements over enums which have no use for a + * default case. Remove once https://github.com/typescript-eslint/typescript-eslint/issues/281 is resolved + * @param v The switch statement operand (should be an enum) + */ + public static unreachable(v: never): never { + return v; + } } diff --git a/src/flashbang/util/Base64.ts b/src/flashbang/util/Base64.ts index 151efb10f..6bb013ee8 100644 --- a/src/flashbang/util/Base64.ts +++ b/src/flashbang/util/Base64.ts @@ -1,6 +1,6 @@ -import * as base64js from "base64-js"; -import {DisplayObject, Sprite, Texture} from "pixi.js"; -import DisplayUtil from "./DisplayUtil"; +import * as base64js from 'base64-js'; +import {DisplayObject, Sprite, Texture} from 'pixi.js'; +import DisplayUtil from './DisplayUtil'; export default class Base64 { /** Renders a DisplayObject or Texture to a PNG and base64-encodes it */ diff --git a/src/flashbang/util/ColorUtil.ts b/src/flashbang/util/ColorUtil.ts index 290612d7f..58b333ac6 100644 --- a/src/flashbang/util/ColorUtil.ts +++ b/src/flashbang/util/ColorUtil.ts @@ -1,9 +1,9 @@ -import MathUtil from "./MathUtil"; -import StringUtil from "./StringUtil"; +import MathUtil from './MathUtil'; +import StringUtil from './StringUtil'; export default class ColorUtil { public static fromString(str: string): number { - if (str.length === 0 || str.charAt(0) !== "#") { + if (str.length === 0 || str.charAt(0) !== '#') { throw new Error(`Invalid color string: ${str}`); } diff --git a/src/flashbang/util/Deferred.ts b/src/flashbang/util/Deferred.ts index 07e7d615e..9fd660545 100644 --- a/src/flashbang/util/Deferred.ts +++ b/src/flashbang/util/Deferred.ts @@ -2,7 +2,7 @@ export default class Deferred { public readonly promise: Promise; - public constructor() { + constructor() { this.promise = new Promise((resolve, reject) => { this._resolve = resolve; this._reject = reject; diff --git a/src/flashbang/util/DisplayUtil.ts b/src/flashbang/util/DisplayUtil.ts index 2ff3e100d..b2d7fca22 100644 --- a/src/flashbang/util/DisplayUtil.ts +++ b/src/flashbang/util/DisplayUtil.ts @@ -1,11 +1,10 @@ import { DisplayObject, Graphics, Matrix, Point, Rectangle -} from "pixi.js"; -import {Flashbang, HAlign, VAlign} from "../core"; -import RectangleUtil from "./RectangleUtil"; - -// the @types file for upng-js is broken, so we just require it directly -const UPNG = require("upng-js"); +} from 'pixi.js'; +import * as UPNG from 'upng-js'; +import {Flashbang, HAlign, VAlign} from '../core'; +import RectangleUtil from './RectangleUtil'; +import {Assert} from '.'; export default class DisplayUtil { public static renderToPNG(target: DisplayObject): ArrayBuffer { @@ -14,7 +13,8 @@ export default class DisplayUtil { return UPNG.encode( [pixels.buffer], Math.floor(DisplayUtil.width(target)), - Math.floor(DisplayUtil.height(target)) + Math.floor(DisplayUtil.height(target)), + 0 ); } @@ -189,7 +189,9 @@ export default class DisplayUtil { } /** Transforms a Rectangle from one DisplayObject's coordinate space to another's. */ - public static transformRect(r: Rectangle, from: DisplayObject, to: DisplayObject, out: Rectangle = null): Rectangle { + public static transformRect( + r: Rectangle, from: DisplayObject, to: DisplayObject, out: Rectangle = null + ): Rectangle { let left: number = Number.MAX_VALUE; let top: number = Number.MAX_VALUE; let right: number = -Number.MAX_VALUE; @@ -298,26 +300,31 @@ export default class DisplayUtil { let y: number = yOffset; switch (targetHAlign) { - case HAlign.LEFT: - x += relativeTo.left; - break; - case HAlign.RIGHT: - x += relativeTo.right; - break; - case HAlign.CENTER: - x += relativeTo.left + (relativeTo.width * 0.5); - break; + case HAlign.LEFT: + x += relativeTo.left; + break; + case HAlign.RIGHT: + x += relativeTo.right; + break; + case HAlign.CENTER: + x += relativeTo.left + (relativeTo.width * 0.5); + break; + default: + Assert.unreachable(targetHAlign); } + switch (targetVAlign) { - case VAlign.TOP: - y += relativeTo.top; - break; - case VAlign.BOTTOM: - y += relativeTo.bottom; - break; - case VAlign.CENTER: - y += relativeTo.top + (relativeTo.height * 0.5); - break; + case VAlign.TOP: + y += relativeTo.top; + break; + case VAlign.BOTTOM: + y += relativeTo.bottom; + break; + case VAlign.CENTER: + y += relativeTo.top + (relativeTo.height * 0.5); + break; + default: + Assert.unreachable(targetVAlign); } disp.x = 0; @@ -326,26 +333,31 @@ export default class DisplayUtil { // should this be relative to self or parent? // let dispBounds = DisplayUtil.getBoundsRelative(disp, disp, DisplayUtil.POSITION_RELATIVE_TO_BOUNDS_RECT); switch (dispHAlign) { - case HAlign.LEFT: - x -= dispBounds.left; - break; - case HAlign.RIGHT: - x -= dispBounds.right; - break; - case HAlign.CENTER: - x -= dispBounds.left + (dispBounds.width * 0.5); - break; + case HAlign.LEFT: + x -= dispBounds.left; + break; + case HAlign.RIGHT: + x -= dispBounds.right; + break; + case HAlign.CENTER: + x -= dispBounds.left + (dispBounds.width * 0.5); + break; + default: + Assert.unreachable(dispHAlign); } + switch (dispVAlign) { - case VAlign.TOP: - y -= dispBounds.top; - break; - case VAlign.BOTTOM: - y -= dispBounds.bottom; - break; - case VAlign.CENTER: - y -= dispBounds.top + (dispBounds.height * 0.5); - break; + case VAlign.TOP: + y -= dispBounds.top; + break; + case VAlign.BOTTOM: + y -= dispBounds.bottom; + break; + case VAlign.CENTER: + y -= dispBounds.top + (dispBounds.height * 0.5); + break; + default: + Assert.unreachable(dispVAlign); } disp.x = x; @@ -370,7 +382,7 @@ export default class DisplayUtil { if (currentObject) { return currentObject; } else { - throw new Error("Object not connected to target"); + throw new Error('Object not connected to target'); } } diff --git a/src/flashbang/util/Easing.ts b/src/flashbang/util/Easing.ts index 51a2398cd..18f25e047 100644 --- a/src/flashbang/util/Easing.ts +++ b/src/flashbang/util/Easing.ts @@ -1,4 +1,4 @@ -import PowerEaser from "./PowerEaser"; +import PowerEaser from './PowerEaser'; export type EasingFunc = (from: number, to: number, dt: number, t: number) => number; diff --git a/src/flashbang/util/ErrorUtil.ts b/src/flashbang/util/ErrorUtil.ts index ab46ee73e..731bbda75 100644 --- a/src/flashbang/util/ErrorUtil.ts +++ b/src/flashbang/util/ErrorUtil.ts @@ -14,7 +14,7 @@ export default class ErrorUtil { public static getErrString(e: any, includeStack: boolean = true): string { try { if (e == null) { - return "Unknown error"; + return 'Unknown error'; } else if (e instanceof Error) { return includeStack ? e.stack : e.message; } else if (e instanceof ErrorEvent) { @@ -23,7 +23,7 @@ export default class ErrorUtil { return e.toString(); } } catch (errStringError) { - return "Unknown error"; + return 'Unknown error'; } } } diff --git a/src/flashbang/util/EventSignal.ts b/src/flashbang/util/EventSignal.ts index 9e733751a..e64225d5d 100644 --- a/src/flashbang/util/EventSignal.ts +++ b/src/flashbang/util/EventSignal.ts @@ -1,13 +1,13 @@ import { AbstractSignal, FilteredSignal, MappedSignal, SignalView -} from "signals"; +} from 'signals'; type InteractionEvent = PIXI.interaction.InteractionEvent; type EventEmitter = PIXI.utils.EventEmitter; /** Redispatches a pixi InteractionEvent as a Signal */ export default class EventSignal extends AbstractSignal implements SignalView { - public constructor(target: EventEmitter, eventType: string | symbol) { + constructor(target: EventEmitter, eventType: string | symbol) { super(); this._target = target; this._eventType = eventType; diff --git a/src/flashbang/util/JSONUtil.ts b/src/flashbang/util/JSONUtil.ts index 6fc671f9e..fa2855294 100644 --- a/src/flashbang/util/JSONUtil.ts +++ b/src/flashbang/util/JSONUtil.ts @@ -1,6 +1,6 @@ export default class JSONUtil { public static require(json: any, name: string): T { - if (!json.hasOwnProperty(name)) { + if (!Object.prototype.hasOwnProperty.call(json, name)) { throw new Error(`Missing required property '${name}'`); } return json[name]; diff --git a/src/flashbang/util/LinkedList.ts b/src/flashbang/util/LinkedList.ts index a9e7380b9..c796fcbb8 100644 --- a/src/flashbang/util/LinkedList.ts +++ b/src/flashbang/util/LinkedList.ts @@ -1,4 +1,4 @@ -import {Registration} from "signals"; +import {Registration} from 'signals'; export interface LinkedElement { next: LinkedElement; @@ -59,7 +59,7 @@ export default class LinkedList { public beginIteration(): LinkedElement { if (this._head === this.ITERATING) { - throw new Error("Initiated beginIteration while iterating"); + throw new Error('Initiated beginIteration while iterating'); } this._iterating = this._head; this._head = this.ITERATING; @@ -69,7 +69,7 @@ export default class LinkedList { public endIteration(): void { // note that we're no longer dispatching if (this._head !== this.ITERATING) { - throw new Error("Not iterating"); + throw new Error('Not iterating'); } this._head = this._iterating; @@ -93,7 +93,7 @@ export default class LinkedList { } /* internal */ - removeCons(cons: Cons): void { + public removeCons(cons: Cons): void { if (this.isIterating) { this._pendingRuns = LinkedList.pend(this._pendingRuns, new Runs(() => { this._head = Cons.remove(this._head, cons); diff --git a/src/flashbang/util/MathUtil.ts b/src/flashbang/util/MathUtil.ts index 34fbcff24..16e949b23 100644 --- a/src/flashbang/util/MathUtil.ts +++ b/src/flashbang/util/MathUtil.ts @@ -7,6 +7,8 @@ export default class MathUtil { /** Returns the value of n clamped to be within the range [min, max]. */ public static clamp(n: number, min: number, max: number): number { - return (n < min ? min : (n > max ? max : n)); + if (n < min) return min; + else if (n > max) return max; + else return n; } } diff --git a/src/flashbang/util/MatrixUtil.ts b/src/flashbang/util/MatrixUtil.ts index 9fb23446d..e897fb59f 100644 --- a/src/flashbang/util/MatrixUtil.ts +++ b/src/flashbang/util/MatrixUtil.ts @@ -8,7 +8,7 @@ // // ================================================================================================= -import {Matrix, Point} from "pixi.js"; +import {Matrix, Point} from 'pixi.js'; /** A utility class containing methods related to the Matrix class. */ export default class MatrixUtil { @@ -128,7 +128,7 @@ export default class MatrixUtil { } private static formatRawData(data: number[], numCols: number, numRows: number, - precision: number, indent: string = " "): string { + precision: number, indent: string = ' '): string { let result: string = indent; let numValues: number = numCols * numRows; let highestValue = 0.0; @@ -150,7 +150,7 @@ export default class MatrixUtil { while (valueString.length < numChars) valueString = ` ${valueString}`; result += valueString; - if (x !== numCols - 1) result += ", "; + if (x !== numCols - 1) result += ', '; } if (y !== numRows - 1) result += `\n${indent}`; diff --git a/src/flashbang/util/PowerEaser.ts b/src/flashbang/util/PowerEaser.ts index 171230dff..b1228bb69 100644 --- a/src/flashbang/util/PowerEaser.ts +++ b/src/flashbang/util/PowerEaser.ts @@ -7,14 +7,14 @@ export default class PowerEaser { if (t === 0) { return to; } - return from + ((to - from) * Math.pow(dt / t, this._pow)); + return from + ((to - from) * ((dt / t) ** this._pow)); }; public readonly easeOut = (from: number, to: number, dt: number, t: number): number => { if (t === 0) { return to; } - return from + ((to - from) * (1 - Math.pow(1 - dt / t, this._pow))); + return from + ((to - from) * (1 - ((1 - dt / t) ** this._pow))); }; public readonly easeInOut = (from: number, to: number, dt: number, t: number): number => { diff --git a/src/flashbang/util/RectangleUtil.ts b/src/flashbang/util/RectangleUtil.ts index 25581f0be..98e7a9a61 100644 --- a/src/flashbang/util/RectangleUtil.ts +++ b/src/flashbang/util/RectangleUtil.ts @@ -8,8 +8,8 @@ // // ================================================================================================= -import {Point, Rectangle, Matrix} from "pixi.js"; -import MatrixUtil from "./MatrixUtil"; +import {Point, Rectangle, Matrix} from 'pixi.js'; +import MatrixUtil from './MatrixUtil'; /** A utility class containing methods related to the Rectangle class. */ export default class RectangleUtil { diff --git a/src/flashbang/util/StringUtil.ts b/src/flashbang/util/StringUtil.ts index d41148861..5d328a186 100644 --- a/src/flashbang/util/StringUtil.ts +++ b/src/flashbang/util/StringUtil.ts @@ -16,12 +16,12 @@ export default class StringUtil { /** Is the specified string null, empty, or does it contain only whitespace? */ public static isBlank(str: string): boolean { - return (str == null) || (str.search("\\S") === -1); + return (str == null) || (str.search('\\S') === -1); } /** Return the specified String, or "" if it is null. */ public static deNull(str: string): string { - return (str == null) ? "" : str; + return (str == null) ? '' : str; } /** Does the specified string end with any of the specified substrings. */ @@ -107,26 +107,26 @@ export default class StringUtil { * @param prefix the prefix to place in front of it. @default "0x", other possibilities are * "#" or "". */ - public static toColorString(c: number, prefix: string = "0x"): string { - return prefix + StringUtil.prepad(c.toString(16), 6, "0"); + public static toColorString(c: number, prefix: string = '0x'): string { + return prefix + StringUtil.prepad(c.toString(16), 6, '0'); } /** Format the specified numbers as coordinates, (e.g. "+3-2" or "-7.4432-54.23+6.3"). */ public static toCoordsString(x: number, y: number, z: number = NaN): string { - let result: string = ((x >= 0) ? "+" : "") + x + ((y >= 0) ? "+" : "") + y; + let result: string = ((x >= 0) ? '+' : '') + x + ((y >= 0) ? '+' : '') + y; if (!Number.isNaN(z)) { - result += ((z >= 0) ? "+" : "") + z; + result += ((z >= 0) ? '+' : '') + z; } return result; } /** Format the specified number, nicely, with commas. */ public static formatNumber(n: number): string { - let postfix = ""; + let postfix = ''; let s: string = n.toString(); // use standard to-stringing // move any fractional portion to the postfix - const dex: number = s.lastIndexOf("."); + const dex: number = s.lastIndexOf('.'); if (dex !== -1) { postfix = s.substring(dex); s = s.substring(0, dex); @@ -151,19 +151,19 @@ export default class StringUtil { */ public static parseNumber(str: string): number { if (str == null) { - throw new Error("Cannot parseNumber(null)"); + throw new Error('Cannot parseNumber(null)'); } // deal with a few special cases - if (str === "Infinity") { + if (str === 'Infinity') { return Infinity; - } else if (str === "-Infinity") { + } else if (str === '-Infinity') { return -Infinity; - } else if (str === "NaN") { + } else if (str === 'NaN') { return NaN; } - const noCommas: string = str.replace(",", ""); + const noCommas: string = str.replace(',', ''); if (StringUtil.DECIMAL_REGEXP.exec(noCommas) == null) { throw new Error(`Could not convert '${str}' to Number`); @@ -186,9 +186,9 @@ export default class StringUtil { if (str != null) { str = str.toLowerCase(); - if (str === "true" || str === "1") { + if (str === 'true' || str === '1') { return true; - } else if (str === "false" || str === "0") { + } else if (str === 'false' || str === '0') { return false; } } @@ -200,7 +200,7 @@ export default class StringUtil { * Append 0 or more copies of the padChar String to the input String * until it is at least the specified length. */ - public static pad(str: string, length: number, padChar: string = " "): string { + public static pad(str: string, length: number, padChar: string = ' '): string { while (str.length < length) { str += padChar; } @@ -211,7 +211,7 @@ export default class StringUtil { * Prepend 0 or more copies of the padChar String to the input String * until it is at least the specified length. */ - public static prepad(str: string, length: number, padChar: string = " "): string { + public static prepad(str: string, length: number, padChar: string = ' '): string { while (str.length < length) { str = padChar + str; } @@ -223,7 +223,7 @@ export default class StringUtil { * the specified length. */ public static zeroPad(n: number, length: number = 2): string { - return StringUtil.prepad(n.toString(), length, "0"); + return StringUtil.prepad(n.toString(), length, '0'); } /** @@ -234,7 +234,7 @@ export default class StringUtil { // TODO: FIXME: this might be wrong, if your {0} replacement has a {1} in it, then // that'll get replaced next iteration. for (let ii = 0; ii < len; ii++) { - str = str.replace(new RegExp(`\\{${ii}\\}`, "g"), args[ii]); + str = str.replace(new RegExp(`\\{${ii}\\}`, 'g'), args[ii]); } return str; } @@ -283,15 +283,14 @@ export default class StringUtil { */ public static isWhitespace(character: string): boolean { switch (character) { - case " ": - case "\t": - case "\r": - case "\n": - case "\f": - return true; - - default: - return false; + case ' ': + case '\t': + case '\r': + case '\n': + case '\f': + return true; + default: + return false; } } @@ -304,7 +303,7 @@ export default class StringUtil { * truncation. */ public static truncate( - s: string, maxLength: number, append: string = "" + s: string, maxLength: number, append: string = '' ): string { if ((s == null) || (s.length <= maxLength)) { return s; @@ -348,13 +347,13 @@ export default class StringUtil { array.push(s.substring(0, index)); s = s.substring(index + url.length); // clean up the url if necessary - if (StringUtil.startsWith(url.toLowerCase(), "www.")) { + if (StringUtil.startsWith(url.toLowerCase(), 'www.')) { url = `http://${url}`; } array.push(url); } - if (s !== "" || array.length === 0) { // avoid putting an empty string on the end + if (s !== '' || array.length === 0) { // avoid putting an empty string on the end array.push(s); } return array; @@ -366,7 +365,7 @@ export default class StringUtil { * toHex(131, 4) -> "0083" */ public static toHex(n: number, width: number): string { - return StringUtil.prepad(n.toString(16), width, "0"); + return StringUtil.prepad(n.toString(16), width, '0'); } /** @@ -374,31 +373,31 @@ export default class StringUtil { */ private static parseInt0(str: string, radix: number, allowNegative: boolean): number { if (str == null) { - throw new Error("Cannot parseInt(null)"); + throw new Error('Cannot parseInt(null)'); } - let negative: boolean = (str.charAt(0) === "-"); + let negative: boolean = (str.charAt(0) === '-'); if (negative) { str = str.substring(1); } // handle this special case immediately, to prevent confusion about // a leading 0 meaning "parse as octal" - if (str === "0") { + if (str === '0') { return 0; } if (radix === 0) { - if (StringUtil.startsWith(str, "0x")) { + if (StringUtil.startsWith(str, '0x')) { str = str.substring(2); radix = 16; - } else if (StringUtil.startsWith(str, "0")) { + } else if (StringUtil.startsWith(str, '0')) { str = str.substring(1); radix = 8; } else { radix = 10; } - } else if (radix === 16 && StringUtil.startsWith(str, "0x")) { + } else if (radix === 16 && StringUtil.startsWith(str, '0x')) { str = str.substring(2); } else if (radix < 2 || radix > 16) { throw new Error(`Radix out of range: ${radix}`); @@ -408,14 +407,14 @@ export default class StringUtil { for (let ii = 0; ii < str.length; ii++) { let dex: number = StringUtil.HEX.indexOf(str.charAt(ii).toLowerCase()); if (dex === -1 || dex >= radix) { - throw new Error(`Invalid characters in String [string=${arguments[0]}, radix=${radix}`); + throw new Error(`Invalid characters in String [string=${str}, radix=${radix}`); } } let result: number = parseInt(str, radix); if (Number.isNaN(result)) { // this shouldn't happen.. - throw new Error(`Could not parseInt: ${arguments[0]}`); + throw new Error(`Could not parseInt: ${str}`); } if (negative) { result *= -1; @@ -424,8 +423,8 @@ export default class StringUtil { } /** Hexidecimal digits. */ - private static HEX: string[] = ["0", "1", "2", "3", "4", - "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"]; + private static HEX: string[] = ['0', '1', '2', '3', '4', + '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f']; private static DECIMAL_REGEXP: RegExp = /^-?[0-9]*\.?[0-9]+(e-?[0-9]+)?$/; diff --git a/src/flashbang/util/StyledTextBuilder.ts b/src/flashbang/util/StyledTextBuilder.ts index eb524dbf5..6e4c345ec 100644 --- a/src/flashbang/util/StyledTextBuilder.ts +++ b/src/flashbang/util/StyledTextBuilder.ts @@ -1,9 +1,9 @@ -import * as log from "loglevel"; -import {default as MultiStyleText, ExtendedTextStyle, TextStyleSet} from "pixi-multistyle-text"; -import ColorUtil from "./ColorUtil"; +import * as log from 'loglevel'; +import MultiStyleText, {ExtendedTextStyle, TextStyleSet} from 'pixi-multistyle-text'; +import ColorUtil from './ColorUtil'; export default class StyledTextBuilder { - public constructor(defaultStyle?: ExtendedTextStyle) { + constructor(defaultStyle?: ExtendedTextStyle) { if (defaultStyle !== undefined) { this.defaultStyle(defaultStyle); } @@ -16,7 +16,7 @@ export default class StyledTextBuilder { /** Creates a new MultiStyleText */ public build(): MultiStyleText { if (this._styleStack.length > 0) { - log.warn("Unpopped styles"); + log.warn('Unpopped styles'); } return new MultiStyleText(this._text, this.cloneStyles()); @@ -25,7 +25,7 @@ export default class StyledTextBuilder { /** Applies the styled text to an existing MultiSyleText object */ public apply(textField: MultiStyleText): void { if (this._styleStack.length > 0) { - log.warn("Unpopped styles"); + log.warn('Unpopped styles'); } textField.text = this._text; @@ -33,7 +33,7 @@ export default class StyledTextBuilder { } public defaultStyle(style: ExtendedTextStyle): StyledTextBuilder { - return this.addStyle("default", style); + return this.addStyle('default', style); } public addStyle(name: string, style: ExtendedTextStyle): StyledTextBuilder { @@ -46,7 +46,7 @@ export default class StyledTextBuilder { public pushStyle(style: ExtendedTextStyle | string): StyledTextBuilder { let styleName: string; - if (typeof (style) === "string") { + if (typeof (style) === 'string') { if (this._styles[style] == null) { log.warn(`Unrecognized style '${style}'`); } @@ -65,7 +65,7 @@ export default class StyledTextBuilder { public popStyle(): StyledTextBuilder { if (this._styleStack.length === 0) { - log.warn("Unbalanced popStyle"); + log.warn('Unbalanced popStyle'); } else { let lastStyle = this._styleStack.pop(); this._text += ``; @@ -92,9 +92,11 @@ export default class StyledTextBuilder { public appendHTMLStyledText(text: string): StyledTextBuilder { type CreateStyleCallback = (openTagMatch: RegExpExecArray) => [string, ExtendedTextStyle]; - const parseHTMLStyle = (text: string, openTag: RegExp, closeTag: RegExp, createStyle: CreateStyleCallback): string => { + const parseHTMLStyle = ( + rawText: string, openTag: RegExp, closeTag: RegExp, createStyle: CreateStyleCallback + ): string => { while (true) { - let openMatch = openTag.exec(text); + let openMatch = openTag.exec(rawText); if (openMatch == null) { break; } @@ -104,17 +106,17 @@ export default class StyledTextBuilder { this.addStyle(styleName, style); } - text = `${text.slice(0, openMatch.index)}<${styleName}>${text.slice(openMatch.index + openMatch[0].length)}`; + rawText = `${rawText.slice(0, openMatch.index)}<${styleName}>${rawText.slice(openMatch.index + openMatch[0].length)}`; - let closeMatch = closeTag.exec(text); + let closeMatch = closeTag.exec(rawText); if (closeMatch == null) { break; } - text = `${text.slice(0, closeMatch.index)}${text.slice(closeMatch.index + closeMatch[0].length)}`; + rawText = `${rawText.slice(0, closeMatch.index)}${rawText.slice(closeMatch.index + closeMatch[0].length)}`; } - return text; + return rawText; }; // Parse @@ -137,7 +139,7 @@ export default class StyledTextBuilder { // Parse const BOLD_OPEN = //i; const BOLD_CLOSE = /<\/b>/i; - text = parseHTMLStyle(text, BOLD_OPEN, BOLD_CLOSE, () => ["__bold", {fontStyle: "bold"}]); + text = parseHTMLStyle(text, BOLD_OPEN, BOLD_CLOSE, () => ['__bold', {fontStyle: 'bold'}]); return this.append(text); } @@ -161,15 +163,15 @@ export default class StyledTextBuilder { private cloneStyles(): TextStyleSet { let out: TextStyleSet = {}; - for (let key in this._styles) { - out[key] = this._styles[key]; + for (let [key, value] of Object.entries(this._styles)) { + out[key] = value; } return out; } private _styleStack: string[] = []; private _styles: TextStyleSet = {}; - private _text: string = ""; + private _text: string = ''; private _anonymousStyleCounter: number = 0; } diff --git a/src/flashbang/util/TextBuilder.ts b/src/flashbang/util/TextBuilder.ts index 536df9218..29d6d5b33 100644 --- a/src/flashbang/util/TextBuilder.ts +++ b/src/flashbang/util/TextBuilder.ts @@ -1,7 +1,7 @@ -import {Text, TextStyle, TextStyleOptions} from "pixi.js"; +import {Text, TextStyle, TextStyleOptions} from 'pixi.js'; export default class TextBuilder { - public constructor(text: string = "") { + constructor(text: string = '') { this.text(text); } @@ -15,7 +15,7 @@ export default class TextBuilder { public computeLineHeight(): number { let dummy = this.build(); - dummy.text = "A"; + dummy.text = 'A'; return dummy.height; } @@ -49,8 +49,8 @@ export default class TextBuilder { public bold(value: boolean = true): TextBuilder { if (value) { - this.fontWeight("bold"); - } else if (this._style.fontWeight === "bold") { + this.fontWeight('bold'); + } else if (this._style.fontWeight === 'bold') { this._style.fontWeight = undefined; } return this; @@ -63,24 +63,24 @@ export default class TextBuilder { } /** Horizontal alignment for multiline (wordwrapped) text. @default "center" */ - public hAlign(align: "left" | "center" | "right"): TextBuilder { + public hAlign(align: 'left' | 'center' | 'right'): TextBuilder { this._style.align = align; return this; } /** Equivalent to hAlign(HAlign.LEFT) */ public hAlignLeft(): TextBuilder { - return this.hAlign("left"); + return this.hAlign('left'); } /** Equivalent to hAlign(Align.CENTER) */ public hAlignCenter(): TextBuilder { - return this.hAlign("center"); + return this.hAlign('center'); } /** Equivalent to hAlign(HAlign.RIGHT) */ public hAlignRight(): TextBuilder { - return this.hAlign("right"); + return this.hAlign('right'); } /** Enables or disables word wrapping. @default false */ diff --git a/src/flashbang/util/TextUtil.ts b/src/flashbang/util/TextUtil.ts index 1b821322a..bc977655a 100644 --- a/src/flashbang/util/TextUtil.ts +++ b/src/flashbang/util/TextUtil.ts @@ -1,4 +1,4 @@ -import {Text} from "pixi.js"; +import {Text} from 'pixi.js'; export default class TextUtil { /** @@ -11,7 +11,7 @@ export default class TextUtil { return; } - trimmedPostfix = trimmedPostfix || ""; + trimmedPostfix = trimmedPostfix || ''; const originalString = text.text; const originalWidth = text.width; diff --git a/src/flashbang/util/TextureUtil.ts b/src/flashbang/util/TextureUtil.ts index be85e69d7..670de7bcf 100644 --- a/src/flashbang/util/TextureUtil.ts +++ b/src/flashbang/util/TextureUtil.ts @@ -1,25 +1,25 @@ import { BaseRenderTexture, BaseTexture, Container, DisplayObject, Rectangle, RenderTexture, Texture -} from "pixi.js"; -import {Flashbang} from "../core"; -import Assert from "./Assert"; +} from 'pixi.js'; +import {Flashbang} from '../core'; +import Assert from './Assert'; export default class TextureUtil { - public static fromBase64PNG(base64PNG: string): Promise { + public static async fromBase64PNG(base64PNG: string): Promise { // elements can be created from base64 strings. // We create an img, set its src data to the base64 string, // and then use that as the source for a new PIXI texture. - let img = document.createElement("img"); + let img = document.createElement('img'); img.src = `data:image/png;base64, ${base64PNG}`; let baseTex = new BaseTexture(img); let tex = new Texture(baseTex); if (baseTex.hasLoaded) { // The image may already be loaded - return Promise.resolve(tex); + return tex; } else { return new Promise((resolve) => { - tex.once("update", tex => resolve(tex)); + tex.once('update', () => resolve(tex)); }); } } @@ -27,7 +27,7 @@ export default class TextureUtil { public static load(source: Texture | string | string[]): Promise { if (source instanceof Texture) { return this.loadTexture(source as Texture).then(() => {}); - } else if (typeof source === "string") { + } else if (typeof source === 'string') { return this.loadURL(source as string).then(() => {}); } else { return this.loadURLs(source as string[]).then(() => {}); @@ -35,17 +35,16 @@ export default class TextureUtil { } /** Returns a promise that will resolve when the texture is loaded */ - public static loadTexture(tex: Texture): Promise { + public static async loadTexture(tex: Texture): Promise { let base: BaseTexture = tex.baseTexture; if (!base.isLoading) { - return base.hasLoaded - ? Promise.resolve(tex) - : Promise.reject(`texture failed to load [url=${base.imageUrl}]`); + if (base.hasLoaded) return tex; + else throw new Error(`texture failed to load [url=${base.imageUrl}]`); } else { // log.debug(`Loading image... [url=${base.imageUrl}]`); return new Promise((resolve, reject) => { - base.once("loaded", () => resolve(tex)); - base.once("error", () => reject(`texture failed to load [url=${base.imageUrl}]`)); + base.once('loaded', () => resolve(tex)); + base.once('error', () => reject(new Error(`texture failed to load [url=${base.imageUrl}]`))); }); } } @@ -68,7 +67,7 @@ export default class TextureUtil { * All textures in the DisplayObject's hierarchy should be loaded before calling this. */ public static renderToTexture(disp: DisplayObject): Texture { - Assert.isTrue(disp.parent == null, "TODO"); + Assert.isTrue(disp.parent == null, 'TODO'); let wrap: Container = new Container(); wrap.addChild(disp); diff --git a/src/flashbang/util/index.ts b/src/flashbang/util/index.ts index 502a48123..b5d481631 100644 --- a/src/flashbang/util/index.ts +++ b/src/flashbang/util/index.ts @@ -1,20 +1,20 @@ -export {default as Assert} from "./Assert"; -export {default as Arrays} from "./Arrays"; -export {default as Base64} from "./Base64"; -export {default as ColorUtil} from "./ColorUtil"; -export {default as Deferred} from "./Deferred"; -export {default as DisplayUtil} from "./DisplayUtil"; -export {default as PowerEaser} from "./PowerEaser"; -export {default as Easing, EasingFunc} from "./Easing"; -export {default as ErrorUtil} from "./ErrorUtil"; -export {default as EventSignal} from "./EventSignal"; -export {default as JSONUtil} from "./JSONUtil"; -export {default as LinkedList, LinkedElement} from "./LinkedList"; -export {default as MathUtil} from "./MathUtil"; -export {default as MatrixUtil} from "./MatrixUtil"; -export {default as RectangleUtil} from "./RectangleUtil"; -export {default as StringUtil} from "./StringUtil"; -export {default as StyledTextBuilder} from "./StyledTextBuilder"; -export {default as TextBuilder} from "./TextBuilder"; -export {default as TextureUtil} from "./TextureUtil"; -export {default as TextUtil} from "./TextUtil"; +export {default as Assert} from './Assert'; +export {default as Arrays} from './Arrays'; +export {default as Base64} from './Base64'; +export {default as ColorUtil} from './ColorUtil'; +export {default as Deferred} from './Deferred'; +export {default as DisplayUtil} from './DisplayUtil'; +export {default as PowerEaser} from './PowerEaser'; +export {default as Easing, EasingFunc} from './Easing'; +export {default as ErrorUtil} from './ErrorUtil'; +export {default as EventSignal} from './EventSignal'; +export {default as JSONUtil} from './JSONUtil'; +export {default as LinkedList, LinkedElement} from './LinkedList'; +export {default as MathUtil} from './MathUtil'; +export {default as MatrixUtil} from './MatrixUtil'; +export {default as RectangleUtil} from './RectangleUtil'; +export {default as StringUtil} from './StringUtil'; +export {default as StyledTextBuilder} from './StyledTextBuilder'; +export {default as TextBuilder} from './TextBuilder'; +export {default as TextureUtil} from './TextureUtil'; +export {default as TextUtil} from './TextUtil'; diff --git a/src/signals/AbstractSignal.ts b/src/signals/AbstractSignal.ts index 649593fa4..cc274fa03 100644 --- a/src/signals/AbstractSignal.ts +++ b/src/signals/AbstractSignal.ts @@ -1,6 +1,6 @@ -import Reactor from "./Reactor"; -import SignalView from "./SignalView"; -import Connection from "./Connection"; +import Reactor from './Reactor'; +import SignalView from './SignalView'; +import Connection from './Connection'; /** * Handles the machinery of connecting slots to a signal and emitting events to them, without diff --git a/src/signals/AbstractValue.ts b/src/signals/AbstractValue.ts index 3a2427a28..1404b8b1d 100644 --- a/src/signals/AbstractValue.ts +++ b/src/signals/AbstractValue.ts @@ -1,7 +1,7 @@ -import Connection from "./Connection"; -import Cons from "./Cons"; -import Reactor from "./Reactor"; -import ValueView from "./ValueView"; +import Connection from './Connection'; +import Cons from './Cons'; +import Reactor from './Reactor'; +import ValueView from './ValueView'; /** * Handles the machinery of connecting listeners to a value and notifying them, without exposing a @@ -82,7 +82,7 @@ export default abstract class AbstractValue extends Reactor implements ValueV * @return the previously stored value. */ protected updateLocal(value: T): T { - throw new Error("IllegalOperationError"); + throw new Error('IllegalOperationError'); } /** diff --git a/src/signals/Connection.ts b/src/signals/Connection.ts index 4e99428c4..cd96d19b1 100644 --- a/src/signals/Connection.ts +++ b/src/signals/Connection.ts @@ -1,4 +1,4 @@ -import Registration from "./Registration"; +import Registration from './Registration'; /** * Provides a mechanism to cancel a slot or listener registration, or to perform post-registration diff --git a/src/signals/Cons.ts b/src/signals/Cons.ts index 852b1a9ed..b49e63639 100644 --- a/src/signals/Cons.ts +++ b/src/signals/Cons.ts @@ -1,6 +1,6 @@ -import Reactor, {RListener} from "./Reactor"; +import Reactor, {RListener} from './Reactor'; -import Connection from "./Connection"; +import Connection from './Connection'; /** * Implements {@link Connection} and a linked-list style listener list for {@link Reactor}s. @@ -40,7 +40,7 @@ export default class Cons implements Connection { public atPriority(priority: number): Connection { if (this._owner == null) { - throw new Error("Cannot change priority of disconnected connection."); + throw new Error('Cannot change priority of disconnected connection.'); } this._owner._removeCons(this); this.next = null; @@ -50,7 +50,7 @@ export default class Cons implements Connection { } /* internal */ - static insert(head: Cons, cons: Cons): Cons { + public static insert(head: Cons, cons: Cons): Cons { if (head == null) { return cons; } else if (cons._priority > head._priority) { @@ -63,7 +63,7 @@ export default class Cons implements Connection { } /* internal */ - static remove(head: Cons, cons: Cons): Cons { + public static remove(head: Cons, cons: Cons): Cons { if (head == null) { return head; } else if (head === cons) { @@ -75,7 +75,7 @@ export default class Cons implements Connection { } /* internal */ - static removeAll(head: Cons, listener: RListener): Cons { + public static removeAll(head: Cons, listener: RListener): Cons { if (head == null) { return null; } else if (head.listener === listener) { diff --git a/src/signals/FilteredSignal.ts b/src/signals/FilteredSignal.ts index cceb465af..e6a4cf60d 100644 --- a/src/signals/FilteredSignal.ts +++ b/src/signals/FilteredSignal.ts @@ -1,6 +1,6 @@ -import MappedSignal from "./MappedSignal"; -import SignalView from "./SignalView"; -import Connection from "./Connection"; +import MappedSignal from './MappedSignal'; +import SignalView from './SignalView'; +import Connection from './Connection'; export default class FilteredSignal extends MappedSignal { constructor(source: SignalView, pred: (value: T) => boolean) { diff --git a/src/signals/MappedSignal.ts b/src/signals/MappedSignal.ts index 2c28e1144..b976990fc 100644 --- a/src/signals/MappedSignal.ts +++ b/src/signals/MappedSignal.ts @@ -1,7 +1,7 @@ -import AbstractSignal from "./AbstractSignal"; -import SignalView from "./SignalView"; -import Connection from "./Connection"; -import FilteredSignal from "./FilteredSignal"; +import AbstractSignal from './AbstractSignal'; +import SignalView from './SignalView'; +import Connection from './Connection'; +import FilteredSignal from './FilteredSignal'; /** * Plumbing to implement mapped signals in such a way that they automatically manage a connection diff --git a/src/signals/MappedValue.ts b/src/signals/MappedValue.ts index 94211c752..f7b0ed31a 100644 --- a/src/signals/MappedValue.ts +++ b/src/signals/MappedValue.ts @@ -1,6 +1,6 @@ -import AbstractValue from "./AbstractValue"; -import ValueView from "./ValueView"; -import Connection from "./Connection"; +import AbstractValue from './AbstractValue'; +import ValueView from './ValueView'; +import Connection from './Connection'; /** * Plumbing to implement mapped values in such a way that they automatically manage a connection to diff --git a/src/signals/MultiFailureError.ts b/src/signals/MultiFailureError.ts index 8b218ba97..8b4fc4e0f 100644 --- a/src/signals/MultiFailureError.ts +++ b/src/signals/MultiFailureError.ts @@ -16,14 +16,14 @@ export default class MultiFailureError extends Error { } public getMessage(): string { - let buf = ""; + let buf = ''; for (let failure of this._failures) { if (buf.length > 0) { - buf += ", "; + buf += ', '; } buf += MultiFailureError.getMessageInternal(failure, false); } - return `${this._failures.length}${this._failures.length !== 1 ? " failures: " : " failure: "}${buf}`; + return `${this._failures.length}${this._failures.length !== 1 ? ' failures: ' : ' failure: '}${buf}`; } private static getMessageInternal(error: any, wantStackTrace: boolean): string { @@ -31,11 +31,11 @@ export default class MultiFailureError extends Error { // Error() is a top-level function that creates a new error object, rather than performing // a class-cast, as expected. - if (typeof (error) === "string") { + if (typeof (error) === 'string') { return error as string; } else if (error instanceof Error) { let e: Error = ((error)); - return (wantStackTrace ? e.stack : e.message || ""); + return (wantStackTrace ? e.stack : e.message || ''); } else if (error instanceof ErrorEvent) { let ee: ErrorEvent = ((error)); return `${(ee as any).name diff --git a/src/signals/Reactor.ts b/src/signals/Reactor.ts index 43211489e..ad3f31c44 100644 --- a/src/signals/Reactor.ts +++ b/src/signals/Reactor.ts @@ -1,4 +1,4 @@ -import Cons from "./Cons"; +import Cons from './Cons'; export type RListener = (arg1?: any, arg2?: any, arg3?: any) => void; @@ -14,7 +14,7 @@ export default abstract class Reactor { protected addConnection(listener: RListener): Cons { if (listener == null) { - throw new Error("Null listener"); + throw new Error('Null listener'); } return this._addCons(new Cons(this, listener)); } @@ -39,7 +39,7 @@ export default abstract class Reactor { // Bail early if we have no listeners return; } else if (this._listeners === Reactor.DISPATCHING) { - throw new Error("Initiated notify while notifying"); + throw new Error('Initiated notify while notifying'); } let lners: Cons = this._listeners; @@ -101,7 +101,7 @@ export default abstract class Reactor { } /* internal */ - _addCons(cons: Cons): Cons { + public _addCons(cons: Cons): Cons { if (this.isDispatching) { this._pendingRuns = Reactor.insert(this._pendingRuns, new Runs(() => { this._listeners = Cons.insert(this._listeners, cons); @@ -115,7 +115,7 @@ export default abstract class Reactor { } /* internal */ - _removeCons(cons: Cons): void { + public _removeCons(cons: Cons): void { if (this.isDispatching) { this._pendingRuns = Reactor.insert(this._pendingRuns, new Runs(() => { this._listeners = Cons.remove(this._listeners, cons); diff --git a/src/signals/RegistrationGroup.ts b/src/signals/RegistrationGroup.ts index bc7ebc2bb..0b5b32fe1 100644 --- a/src/signals/RegistrationGroup.ts +++ b/src/signals/RegistrationGroup.ts @@ -1,5 +1,5 @@ -import MultiFailureError from "./MultiFailureError"; -import Registration from "./Registration"; +import MultiFailureError from './MultiFailureError'; +import Registration from './Registration'; /** Collects Registrations to allow mass operations on them. */ export default class RegistrationGroup implements Registration { diff --git a/src/signals/Registrations.ts b/src/signals/Registrations.ts index cf2eb012d..d4523d656 100644 --- a/src/signals/Registrations.ts +++ b/src/signals/Registrations.ts @@ -1,4 +1,4 @@ -import Registration from "./Registration"; +import Registration from './Registration'; export default class Registrations { /** Returns a Registration that will call the given function when disconnected */ diff --git a/src/signals/Signal.ts b/src/signals/Signal.ts index 80be80ab4..ea73eab6f 100644 --- a/src/signals/Signal.ts +++ b/src/signals/Signal.ts @@ -1,7 +1,7 @@ -import AbstractSignal from "./AbstractSignal"; -import FilteredSignal from "./FilteredSignal"; -import MappedSignal from "./MappedSignal"; -import SignalView from "./SignalView"; +import AbstractSignal from './AbstractSignal'; +import FilteredSignal from './FilteredSignal'; +import MappedSignal from './MappedSignal'; +import SignalView from './SignalView'; /** A signal that emits events of type {@code T}. */ export default class Signal extends AbstractSignal { diff --git a/src/signals/SignalView.ts b/src/signals/SignalView.ts index 13e54cb4e..1edd09c23 100644 --- a/src/signals/SignalView.ts +++ b/src/signals/SignalView.ts @@ -1,4 +1,4 @@ -import Connection from "./Connection"; +import Connection from './Connection'; /** * A view of a {@link Signal}, on which slots may listen, but to which one cannot emit events. This diff --git a/src/signals/UnitSignal.ts b/src/signals/UnitSignal.ts index 538f3de1c..a0cc7262f 100644 --- a/src/signals/UnitSignal.ts +++ b/src/signals/UnitSignal.ts @@ -1,7 +1,7 @@ -import AbstractSignal from "./AbstractSignal"; -import FilteredSignal from "./FilteredSignal"; -import MappedSignal from "./MappedSignal"; -import SignalView from "./SignalView"; +import AbstractSignal from './AbstractSignal'; +import FilteredSignal from './FilteredSignal'; +import MappedSignal from './MappedSignal'; +import SignalView from './SignalView'; /** A signal that emits an event with no associated data. */ export default class UnitSignal extends AbstractSignal { diff --git a/src/signals/Value.ts b/src/signals/Value.ts index bb188515d..8fca1012c 100644 --- a/src/signals/Value.ts +++ b/src/signals/Value.ts @@ -1,6 +1,6 @@ -import AbstractValue from "./AbstractValue"; -import MappedValue from "./MappedValue"; -import ValueView from "./ValueView"; +import AbstractValue from './AbstractValue'; +import MappedValue from './MappedValue'; +import ValueView from './ValueView'; export default class Value extends AbstractValue implements ValueView { /** Creates an instance with the supplied starting value. */ diff --git a/src/signals/ValueView.ts b/src/signals/ValueView.ts index 6b64ecb28..4e0e7dc6c 100644 --- a/src/signals/ValueView.ts +++ b/src/signals/ValueView.ts @@ -1,4 +1,4 @@ -import Connection from "./Connection"; +import Connection from './Connection'; /** * A view of a {@link AbstractValue} subclass, to which listeners may be added, but which one diff --git a/src/signals/index.ts b/src/signals/index.ts index 702a22285..73eb0fd43 100644 --- a/src/signals/index.ts +++ b/src/signals/index.ts @@ -1,17 +1,17 @@ -export {default as Cons} from "./Cons"; -export {default as Reactor, RListener} from "./Reactor"; -export {default as AbstractSignal} from "./AbstractSignal"; -export {default as AbstractValue} from "./AbstractValue"; -export {default as Connection} from "./Connection"; -export {default as FilteredSignal} from "./FilteredSignal"; -export {default as MappedSignal} from "./MappedSignal"; -export {default as MappedValue} from "./MappedValue"; -export {default as MultiFailureError} from "./MultiFailureError"; -export {default as Registration} from "./Registration"; -export {default as RegistrationGroup} from "./RegistrationGroup"; -export {default as Registrations} from "./Registrations"; -export {default as Signal} from "./Signal"; -export {default as SignalView} from "./SignalView"; -export {default as UnitSignal} from "./UnitSignal"; -export {default as Value} from "./Value"; -export {default as ValueView} from "./ValueView"; +export {default as Cons} from './Cons'; +export {default as Reactor, RListener} from './Reactor'; +export {default as AbstractSignal} from './AbstractSignal'; +export {default as AbstractValue} from './AbstractValue'; +export {default as Connection} from './Connection'; +export {default as FilteredSignal} from './FilteredSignal'; +export {default as MappedSignal} from './MappedSignal'; +export {default as MappedValue} from './MappedValue'; +export {default as MultiFailureError} from './MultiFailureError'; +export {default as Registration} from './Registration'; +export {default as RegistrationGroup} from './RegistrationGroup'; +export {default as Registrations} from './Registrations'; +export {default as Signal} from './Signal'; +export {default as SignalView} from './SignalView'; +export {default as UnitSignal} from './UnitSignal'; +export {default as Value} from './Value'; +export {default as ValueView} from './ValueView'; From 5956bc3b4dca973e5849a9d82152cf996e31b153 Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Fri, 5 Jul 2019 23:06:51 -0400 Subject: [PATCH 16/39] Fix tests, auto run lint + typecheck + tests on commit --- assets/__mocks__/fileMock.js | 1 + assets/__mocks__/styleMock.js | 1 + package-lock.json | 804 ++++++++++++++++++++ package.json | 28 +- src/eterna/folding/__tests__/Folder.test.ts | 5 +- 5 files changed, 836 insertions(+), 3 deletions(-) create mode 100644 assets/__mocks__/fileMock.js create mode 100644 assets/__mocks__/styleMock.js diff --git a/assets/__mocks__/fileMock.js b/assets/__mocks__/fileMock.js new file mode 100644 index 000000000..84c1da6fd --- /dev/null +++ b/assets/__mocks__/fileMock.js @@ -0,0 +1 @@ +module.exports = 'test-file-stub'; \ No newline at end of file diff --git a/assets/__mocks__/styleMock.js b/assets/__mocks__/styleMock.js new file mode 100644 index 000000000..a09954537 --- /dev/null +++ b/assets/__mocks__/styleMock.js @@ -0,0 +1 @@ +module.exports = {}; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 0b7c1ad5a..0dfe7e3e6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1276,6 +1276,15 @@ "resolved": "https://registry.npmjs.org/@pixi/filter-zoom-blur/-/filter-zoom-blur-2.7.0.tgz", "integrity": "sha512-m64jGei+C+Ndbi+B9twwWg3yk98x0gPBTqcFmagiJsAIf/LQYK5tP2l8ROJu/5OXlPE6WcVIKaf3VByaZ6kiWQ==" }, + "@samverschueren/stream-to-observable": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.0.tgz", + "integrity": "sha512-MI4Xx6LHs4Webyvi6EbspgyAb4D2Q2VtnCQ1blOJcoLS6mVa8lNN2rkIy1CVxfTUpoyIbCTkXES1rLXztFD1lg==", + "dev": true, + "requires": { + "any-observable": "^0.3.0" + } + }, "@types/babel__core": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.2.tgz", @@ -1329,6 +1338,23 @@ "integrity": "sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag==", "dev": true }, + "@types/events": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.0.tgz", + "integrity": "sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g==", + "dev": true + }, + "@types/glob": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.1.1.tgz", + "integrity": "sha512-1Bh06cbWJUHMC97acuD6UMG29nMt0Aqz1vF3guLfG+kHHJhy3AyohZFFxYk2f7Q1SQIrNwvncxAE0N/9s70F2w==", + "dev": true, + "requires": { + "@types/events": "*", + "@types/minimatch": "*", + "@types/node": "*" + } + }, "@types/istanbul-lib-coverage": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.1.tgz", @@ -1378,12 +1404,24 @@ "loglevel": "*" } }, + "@types/minimatch": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz", + "integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==", + "dev": true + }, "@types/node": { "version": "12.0.10", "resolved": "https://registry.npmjs.org/@types/node/-/node-12.0.10.tgz", "integrity": "sha512-LcsGbPomWsad6wmMNv7nBLw7YYYyfdYcz6xryKYQhx89c3XXan+8Q6AJ43G5XDIaklaVkK3mE4fCb0SBvMiPSQ==", "dev": true }, + "@types/normalize-package-data": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz", + "integrity": "sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==", + "dev": true + }, "@types/pixi.js": { "version": "4.8.8", "resolved": "https://registry.npmjs.org/@types/pixi.js/-/pixi.js-4.8.8.tgz", @@ -1775,6 +1813,12 @@ "color-convert": "^1.9.0" } }, + "any-observable": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/any-observable/-/any-observable-0.3.0.tgz", + "integrity": "sha512-/FQM1EDkTsf63Ub2C6O7GuYFDsSXUwsaZDurV0np41ocwq0jthUAYCmhBX9f+KwlaCgIuWyr/4WlUQUBfKfZog==", + "dev": true + }, "any-promise": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", @@ -1863,6 +1907,21 @@ "es-abstract": "^1.7.0" } }, + "array-union": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", + "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", + "dev": true, + "requires": { + "array-uniq": "^1.0.1" + } + }, + "array-uniq": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", + "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=", + "dev": true + }, "array-unique": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", @@ -2685,6 +2744,32 @@ "ylru": "^1.2.0" } }, + "caller-callsite": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/caller-callsite/-/caller-callsite-2.0.0.tgz", + "integrity": "sha1-hH4PzgoiN1CpoCfFSzNzGtMVQTQ=", + "dev": true, + "requires": { + "callsites": "^2.0.0" + }, + "dependencies": { + "callsites": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz", + "integrity": "sha1-BuuE8A7qQT2oav/vrL/7Ngk7PFA=", + "dev": true + } + } + }, + "caller-path": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-2.0.0.tgz", + "integrity": "sha1-Ro+DBE42mrIBD6xfBs7uFbsssfQ=", + "dev": true, + "requires": { + "caller-callsite": "^2.0.0" + } + }, "callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", @@ -2845,6 +2930,59 @@ "restore-cursor": "^2.0.0" } }, + "cli-truncate": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/cli-truncate/-/cli-truncate-0.2.1.tgz", + "integrity": "sha1-nxXPuwcFAFNpIWxiasfQWrkN1XQ=", + "dev": true, + "requires": { + "slice-ansi": "0.0.4", + "string-width": "^1.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "slice-ansi": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-0.0.4.tgz", + "integrity": "sha1-7b+JA/ZvfOL46v1s7tZeJkyDGzU=", + "dev": true + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + } + } + }, "cli-width": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", @@ -3167,6 +3305,36 @@ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, + "cosmiconfig": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.2.1.tgz", + "integrity": "sha512-H65gsXo1SKjf8zmrJ67eJk8aIRKV5ff2D4uKZIBZShbhGSpEmsQOPW/SKMKYhSTrqR7ufy6RP69rPogdaPh/kA==", + "dev": true, + "requires": { + "import-fresh": "^2.0.0", + "is-directory": "^0.3.1", + "js-yaml": "^3.13.1", + "parse-json": "^4.0.0" + }, + "dependencies": { + "import-fresh": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-2.0.0.tgz", + "integrity": "sha1-2BNVwVYS04bGH53dOSLUMEgipUY=", + "dev": true, + "requires": { + "caller-path": "^2.0.0", + "resolve-from": "^3.0.0" + } + }, + "resolve-from": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-3.0.0.tgz", + "integrity": "sha1-six699nWiBvItuZTM17rywoYh0g=", + "dev": true + } + } + }, "create-ecdh": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz", @@ -3286,6 +3454,12 @@ "integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==", "dev": true }, + "cssfontparser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/cssfontparser/-/cssfontparser-1.2.1.tgz", + "integrity": "sha1-9AIvyPlwDGgCnVQghK+69CWj8+M=", + "dev": true + }, "cssom": { "version": "0.3.6", "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.6.tgz", @@ -3373,6 +3547,12 @@ "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", "dev": true }, + "dedent": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz", + "integrity": "sha1-JJXduvbrh0q7Dhvp3yLS5aVEMmw=", + "dev": true + }, "deep-equal": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz", @@ -3441,6 +3621,21 @@ } } }, + "del": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/del/-/del-4.1.1.tgz", + "integrity": "sha512-QwGuEUouP2kVwQenAsOof5Fv8K9t3D8Ca8NxcXKrIpEHjTXK5J2nXLdP+ALI1cgv8wj7KuwBhTwBkOZSJKM5XQ==", + "dev": true, + "requires": { + "@types/glob": "^7.1.1", + "globby": "^6.1.0", + "is-path-cwd": "^2.0.0", + "is-path-in-cwd": "^2.0.0", + "p-map": "^2.0.0", + "pify": "^4.0.1", + "rimraf": "^2.6.3" + } + }, "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", @@ -3641,6 +3836,12 @@ "integrity": "sha512-WbKCYs7yAFOfpuoa2pK5kbOngriUtlPC+8mcQW5L/686wv04w7hYXfw5ScDrsl9kixFw1SPsALEob5V/gtlDxw==", "dev": true }, + "elegant-spinner": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/elegant-spinner/-/elegant-spinner-1.0.1.tgz", + "integrity": "sha1-2wQ1IcldfjA/2PNFvtwzSc+wcp4=", + "dev": true + }, "elliptic": { "version": "6.5.0", "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.0.tgz", @@ -5075,6 +5276,18 @@ "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==", "dev": true }, + "get-own-enumerable-property-symbols": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/get-own-enumerable-property-symbols/-/get-own-enumerable-property-symbols-3.0.0.tgz", + "integrity": "sha512-CIJYJC4GGF06TakLg8z4GQKvDsx9EMspVxOYih7LerEL/WosUnFIww45CGfxfeKHqlg3twgUrYRT1O3WQqjGCg==", + "dev": true + }, + "get-stdin": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-7.0.0.tgz", + "integrity": "sha512-zRKcywvrXlXsA0v0i9Io4KDRaAw7+a1ZpjRwl9Wox8PFlVCCHra7E9c4kqXCoCM9nR5tBkaTTZRBoCm60bFqTQ==", + "dev": true + }, "get-stream": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", @@ -5175,6 +5388,27 @@ "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", "dev": true }, + "globby": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-6.1.0.tgz", + "integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=", + "dev": true, + "requires": { + "array-union": "^1.0.1", + "glob": "^7.0.3", + "object-assign": "^4.0.1", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0" + }, + "dependencies": { + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + } + } + }, "graceful-fs": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.0.tgz", @@ -5261,6 +5495,23 @@ "function-bind": "^1.1.1" } }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + } + } + }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", @@ -5503,6 +5754,87 @@ "integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=", "dev": true }, + "husky": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/husky/-/husky-3.0.0.tgz", + "integrity": "sha512-lKMEn7bRK+7f5eWPNGclDVciYNQt0GIkAQmhKl+uHP1qFzoN0h92kmH9HZ8PCwyVA2EQPD8KHf0FYWqnTxau+Q==", + "dev": true, + "requires": { + "cosmiconfig": "^5.2.1", + "execa": "^1.0.0", + "get-stdin": "^7.0.0", + "is-ci": "^2.0.0", + "opencollective-postinstall": "^2.0.2", + "pkg-dir": "^4.2.0", + "please-upgrade-node": "^3.1.1", + "read-pkg": "^5.1.1", + "run-node": "^1.0.0", + "slash": "^3.0.0" + }, + "dependencies": { + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + } + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true + }, + "pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, + "requires": { + "find-up": "^4.0.0" + } + }, + "read-pkg": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.1.1.tgz", + "integrity": "sha512-dFcTLQi6BZ+aFUaICg7er+/usEoqFdQxiEBsEMNGoipenihtxxtdrQuBXvyANCEI8VuUIVYFgeHGx9sLLvim4w==", + "dev": true, + "requires": { + "@types/normalize-package-data": "^2.4.0", + "normalize-package-data": "^2.5.0", + "parse-json": "^4.0.0", + "type-fest": "^0.4.1" + } + }, + "slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true + } + } + }, "iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -5570,6 +5902,12 @@ "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", "dev": true }, + "indent-string": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-3.2.0.tgz", + "integrity": "sha1-Sl/W0nzDMvN+VBmlBNu4NxBckok=", + "dev": true + }, "indexes-of": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/indexes-of/-/indexes-of-1.0.1.tgz", @@ -5764,6 +6102,12 @@ } } }, + "is-directory": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/is-directory/-/is-directory-0.3.1.tgz", + "integrity": "sha1-YTObbyR1/Hcv2cnYP1yFddwVSuE=", + "dev": true + }, "is-extendable": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", @@ -5823,6 +6167,45 @@ } } }, + "is-obj": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", + "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=", + "dev": true + }, + "is-observable": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-observable/-/is-observable-1.1.0.tgz", + "integrity": "sha512-NqCa4Sa2d+u7BWc6CukaObG3Fh+CU9bvixbpcXYhy2VvYS7vVGIdAgnIS5Ks3A/cqk4rebLJ9s8zBstT2aKnIA==", + "dev": true, + "requires": { + "symbol-observable": "^1.1.0" + } + }, + "is-path-cwd": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-2.2.0.tgz", + "integrity": "sha512-w942bTcih8fdJPJmQHFzkS76NEP8Kzzvmw92cXsazb8intwLqPibPPdXf4ANdKV3rYMuuQYGIWtvz9JilB3NFQ==", + "dev": true + }, + "is-path-in-cwd": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-path-in-cwd/-/is-path-in-cwd-2.1.0.tgz", + "integrity": "sha512-rNocXHgipO+rvnP6dk3zI20RpOtrAM/kzbB258Uw5BWr3TpXi861yzjo16Dn4hUox07iw5AyeMLHWsujkjzvRQ==", + "dev": true, + "requires": { + "is-path-inside": "^2.1.0" + } + }, + "is-path-inside": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-2.1.0.tgz", + "integrity": "sha512-wiyhTzfDWsvwAW53OBWF5zuvaOGlZ6PwYxAbPVDhpm+gM09xKQGjBq/8uYN12aDvMxnAnq3dxTyoSoRNmg5YFg==", + "dev": true, + "requires": { + "path-is-inside": "^1.0.2" + } + }, "is-plain-obj": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", @@ -5853,6 +6236,12 @@ "has": "^1.0.1" } }, + "is-regexp": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-regexp/-/is-regexp-1.0.0.tgz", + "integrity": "sha1-/S2INUXEa6xaYz57mgnof6LLUGk=", + "dev": true + }, "is-stream": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", @@ -6044,6 +6433,16 @@ } } }, + "jest-canvas-mock": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/jest-canvas-mock/-/jest-canvas-mock-2.1.0.tgz", + "integrity": "sha512-1yWLNr6xcmhmADLc5ITOYjXnNl2EWUDlXYpplYqgGdATgZaP8IBp241ihVIfrORM8AhuZW8PXRPdzWBEQOpjBQ==", + "dev": true, + "requires": { + "cssfontparser": "^1.2.1", + "parse-color": "^1.0.0" + } + }, "jest-changed-files": { "version": "24.8.0", "resolved": "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-24.8.0.tgz", @@ -6890,6 +7289,267 @@ "immediate": "~3.0.5" } }, + "lint-staged": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-9.0.2.tgz", + "integrity": "sha512-2W9yBRADEzcGs6j/57JA0GVzSTByYgWbcU89/Xm0s/k+4qMp8032tZYPPmP422xZ79xtUaNisJ/0U5lbuYmaTA==", + "dev": true, + "requires": { + "chalk": "^2.4.2", + "commander": "^2.20.0", + "cosmiconfig": "^5.2.1", + "debug": "^4.1.1", + "dedent": "^0.7.0", + "del": "^4.1.1", + "execa": "^2.0.1", + "listr": "^0.14.3", + "log-symbols": "^3.0.0", + "micromatch": "^4.0.2", + "please-upgrade-node": "^3.1.1", + "string-argv": "^0.3.0", + "stringify-object": "^3.3.0" + }, + "dependencies": { + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "requires": { + "fill-range": "^7.0.1" + } + }, + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "execa": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/execa/-/execa-2.0.3.tgz", + "integrity": "sha512-iM124nlyGSrXmuyZF1EMe83ESY2chIYVyDRZKgmcDynid2Q2v/+GuE7gNMl6Sy9Niwf4MC0DDxagOxeMPjuLsw==", + "dev": true, + "requires": { + "cross-spawn": "^6.0.5", + "get-stream": "^5.0.0", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^3.0.0", + "onetime": "^5.1.0", + "p-finally": "^2.0.0", + "signal-exit": "^3.0.2", + "strip-final-newline": "^2.0.0" + } + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "get-stream": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.1.0.tgz", + "integrity": "sha512-EXr1FOzrzTfGeL0gQdeFEvOMm2mzMOglyiOXSTpPC+iAjAKftbr3jpCMWynogwYnM+eSj9sHGc6wjIcDvYiygw==", + "dev": true, + "requires": { + "pump": "^3.0.0" + } + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true + }, + "is-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.0.tgz", + "integrity": "sha512-XCoy+WlUr7d1+Z8GgSuXmpuUFC9fOhRXglJMx+dwLKTkL44Cjd4W1Z5P+BQZpr+cR93aGP4S/s7Ftw6Nd/kiEw==", + "dev": true + }, + "merge-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", + "dev": true + }, + "micromatch": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.2.tgz", + "integrity": "sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==", + "dev": true, + "requires": { + "braces": "^3.0.1", + "picomatch": "^2.0.5" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "npm-run-path": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-3.1.0.tgz", + "integrity": "sha512-Dbl4A/VfiVGLgQv29URL9xshU8XDY1GeLy+fsaZ1AA8JDSfjvr5P5+pzRbWqRSBxk6/DW7MIh8lTM/PaGnP2kg==", + "dev": true, + "requires": { + "path-key": "^3.0.0" + } + }, + "onetime": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.0.tgz", + "integrity": "sha512-5NcSkPHhwTVFIQN+TUqXoS5+dlElHXdpAWu9I0HP20YOtIi+aZ0Ct82jdlILDxjLEAWwvm+qj1m6aEtsDVmm6Q==", + "dev": true, + "requires": { + "mimic-fn": "^2.1.0" + } + }, + "p-finally": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-2.0.1.tgz", + "integrity": "sha512-vpm09aKwq6H9phqRQzecoDpD8TmVyGw70qmWlyq5onxY7tqyTTFVvxMykxQSQKILBSFlbXpypIw2T1Ml7+DDtw==", + "dev": true + }, + "path-key": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.0.tgz", + "integrity": "sha512-8cChqz0RP6SHJkMt48FW0A7+qUOn+OsnOsVtzI59tZ8m+5bCSk7hzwET0pulwOM2YMn9J1efb07KB9l9f30SGg==", + "dev": true + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "requires": { + "is-number": "^7.0.0" + } + } + } + }, + "listr": { + "version": "0.14.3", + "resolved": "https://registry.npmjs.org/listr/-/listr-0.14.3.tgz", + "integrity": "sha512-RmAl7su35BFd/xoMamRjpIE4j3v+L28o8CT5YhAXQJm1fD+1l9ngXY8JAQRJ+tFK2i5njvi0iRUKV09vPwA0iA==", + "dev": true, + "requires": { + "@samverschueren/stream-to-observable": "^0.3.0", + "is-observable": "^1.1.0", + "is-promise": "^2.1.0", + "is-stream": "^1.1.0", + "listr-silent-renderer": "^1.1.1", + "listr-update-renderer": "^0.5.0", + "listr-verbose-renderer": "^0.5.0", + "p-map": "^2.0.0", + "rxjs": "^6.3.3" + } + }, + "listr-silent-renderer": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/listr-silent-renderer/-/listr-silent-renderer-1.1.1.tgz", + "integrity": "sha1-kktaN1cVN3C/Go4/v3S4u/P5JC4=", + "dev": true + }, + "listr-update-renderer": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/listr-update-renderer/-/listr-update-renderer-0.5.0.tgz", + "integrity": "sha512-tKRsZpKz8GSGqoI/+caPmfrypiaq+OQCbd+CovEC24uk1h952lVj5sC7SqyFUm+OaJ5HN/a1YLt5cit2FMNsFA==", + "dev": true, + "requires": { + "chalk": "^1.1.3", + "cli-truncate": "^0.2.1", + "elegant-spinner": "^1.0.1", + "figures": "^1.7.0", + "indent-string": "^3.0.0", + "log-symbols": "^1.0.2", + "log-update": "^2.3.0", + "strip-ansi": "^3.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + }, + "figures": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", + "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", + "dev": true, + "requires": { + "escape-string-regexp": "^1.0.5", + "object-assign": "^4.1.0" + } + }, + "log-symbols": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-1.0.2.tgz", + "integrity": "sha1-N2/3tY6jCGoPCfrMdGF+ylAeGhg=", + "dev": true, + "requires": { + "chalk": "^1.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + } + } + }, + "listr-verbose-renderer": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/listr-verbose-renderer/-/listr-verbose-renderer-0.5.0.tgz", + "integrity": "sha512-04PDPqSlsqIOaaaGZ+41vq5FejI9auqTInicFRndCBgE3bXG8D6W1I+mWhk+1nqbHmyhla/6BUrd5OSiHwKRXw==", + "dev": true, + "requires": { + "chalk": "^2.4.1", + "cli-cursor": "^2.1.0", + "date-fns": "^1.27.2", + "figures": "^2.0.0" + } + }, "load-json-file": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", @@ -7059,6 +7719,38 @@ "integrity": "sha1-vyJJiGzlFM2hEvrpIYzcBlIR/Jw=", "dev": true }, + "log-symbols": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-3.0.0.tgz", + "integrity": "sha512-dSkNGuI7iG3mfvDzUuYZyvk5dD9ocYCYzNU6CYDE6+Xqd+gwme6Z00NS3dUh8mq/73HaEtT7m6W+yUPtU6BZnQ==", + "dev": true, + "requires": { + "chalk": "^2.4.2" + } + }, + "log-update": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/log-update/-/log-update-2.3.0.tgz", + "integrity": "sha1-iDKP19HOeTiykoN0bwsbwSayRwg=", + "dev": true, + "requires": { + "ansi-escapes": "^3.0.0", + "cli-cursor": "^2.0.0", + "wrap-ansi": "^3.0.1" + }, + "dependencies": { + "wrap-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-3.0.1.tgz", + "integrity": "sha1-KIoE2H7aXChuBg3+jxNc6NAH+Lo=", + "dev": true, + "requires": { + "string-width": "^2.1.1", + "strip-ansi": "^4.0.0" + } + } + } + }, "loglevel": { "version": "1.6.3", "resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.6.3.tgz", @@ -7886,6 +8578,12 @@ "is-wsl": "^1.1.0" } }, + "opencollective-postinstall": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/opencollective-postinstall/-/opencollective-postinstall-2.0.2.tgz", + "integrity": "sha512-pVOEP16TrAO2/fjej1IdOyupJY8KDUM1CvsaScRbw6oddvpQoOfGk4ywha0HKKVAD6RkW4x6Q+tNBwhf3Bgpuw==", + "dev": true + }, "optimist": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", @@ -7997,6 +8695,12 @@ "p-limit": "^2.0.0" } }, + "p-map": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/p-map/-/p-map-2.1.0.tgz", + "integrity": "sha512-y3b8Kpd8OAN444hxfBbFfj1FY/RjtTd8tzYwhUqNYXx0fXx2iX4maP4Qr6qhIKbQXI02wTLAda4fYUbDagTUFw==", + "dev": true + }, "p-reduce": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/p-reduce/-/p-reduce-1.0.0.tgz", @@ -8057,6 +8761,23 @@ "safe-buffer": "^5.1.1" } }, + "parse-color": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/parse-color/-/parse-color-1.0.0.tgz", + "integrity": "sha1-e3SLlag/A/FqlPU15S1/PZRlhhk=", + "dev": true, + "requires": { + "color-convert": "~0.5.0" + }, + "dependencies": { + "color-convert": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-0.5.3.tgz", + "integrity": "sha1-vbbGnOZg+t/+CwAHzER+G59ygr0=", + "dev": true + } + } + }, "parse-json": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", @@ -8120,6 +8841,12 @@ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, + "path-is-inside": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", + "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", + "dev": true + }, "path-key": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", @@ -8174,12 +8901,33 @@ "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", "dev": true }, + "picomatch": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.0.7.tgz", + "integrity": "sha512-oLHIdio3tZ0qH76NybpeneBhYVj0QFTfXEFTc/B3zKQspYfYYkWYgFsmzo+4kvId/bQRcNkVeguI3y+CD22BtA==", + "dev": true + }, "pify": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", "dev": true }, + "pinkie": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", + "dev": true + }, + "pinkie-promise": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "dev": true, + "requires": { + "pinkie": "^2.0.0" + } + }, "pirates": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.1.tgz", @@ -8266,6 +9014,15 @@ "find-up": "^3.0.0" } }, + "please-upgrade-node": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/please-upgrade-node/-/please-upgrade-node-3.1.1.tgz", + "integrity": "sha512-KY1uHnQ2NlQHqIJQpnh/i54rKkuxCEBx+voJIS/Mvb+L2iYd2NMotwduhKTMjfC1uKoX3VXOxLjIYG66dfJTVQ==", + "dev": true, + "requires": { + "semver-compare": "^1.0.0" + } + }, "pn": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/pn/-/pn-1.1.0.tgz", @@ -9068,6 +9825,12 @@ "is-promise": "^2.1.0" } }, + "run-node": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/run-node/-/run-node-1.0.0.tgz", + "integrity": "sha512-kc120TBlQ3mih1LSzdAJXo4xn/GWS2ec0l3S+syHDXP9uRr0JAT8Qd3mdMuyjqCzeZktgP3try92cEgf9Nks8A==", + "dev": true + }, "run-queue": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/run-queue/-/run-queue-1.0.3.tgz", @@ -9155,6 +9918,12 @@ "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==", "dev": true }, + "semver-compare": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/semver-compare/-/semver-compare-1.0.0.tgz", + "integrity": "sha1-De4hahyUGrN+nvsXiPavxf9VN/w=", + "dev": true + }, "serialize-javascript": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-1.7.0.tgz", @@ -9723,6 +10492,12 @@ "readable-stream": "2" } }, + "string-argv": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.3.0.tgz", + "integrity": "sha512-NGZHq3nkSXVtGZXTBjFru3MNfoZyIzN25T7BmvdgnSC0LCJczAGLLMQLyjywSIaAoqSemgLzBRHOsnrHbt60+Q==", + "dev": true + }, "string-length": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/string-length/-/string-length-2.0.0.tgz", @@ -9752,6 +10527,17 @@ "safe-buffer": "~5.1.0" } }, + "stringify-object": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/stringify-object/-/stringify-object-3.3.0.tgz", + "integrity": "sha512-rHqiFh1elqCQ9WPLIC8I0Q/g/wj5J1eMkyoiD6eoQApWHP0FtlK7rqnhmabL5VUY9JQCcqwwvlOaSuutekgyrw==", + "dev": true, + "requires": { + "get-own-enumerable-property-symbols": "^3.0.0", + "is-obj": "^1.0.1", + "is-regexp": "^1.0.0" + } + }, "strip-ansi": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", @@ -9773,6 +10559,12 @@ "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", "dev": true }, + "strip-final-newline": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", + "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", + "dev": true + }, "strip-json-comments": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", @@ -9798,6 +10590,12 @@ "has-flag": "^3.0.0" } }, + "symbol-observable": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz", + "integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==", + "dev": true + }, "symbol-tree": { "version": "3.2.4", "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", @@ -10221,6 +11019,12 @@ "prelude-ls": "~1.1.2" } }, + "type-fest": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.4.1.tgz", + "integrity": "sha512-IwzA/LSfD2vC1/YDYMv/zHP4rDF1usCwllsDpbolT3D4fUepIO7f9K70jjmUewU/LmGUKJcwcVtDCpnKk4BPMw==", + "dev": true + }, "type-is": { "version": "1.6.18", "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", diff --git a/package.json b/package.json index 3664a6452..e707bb7e4 100644 --- a/package.json +++ b/package.json @@ -15,11 +15,21 @@ "lint": "eslint src --ext .ts" }, "jest": { + "preset": "ts-jest", + "moduleDirectories": [ + "node_modules", + "src", + "" + ], "moduleFileExtensions": [ "ts", "tsx", "js" ], + "moduleNameMapper": { + "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "assets/__mocks__/fileMock.js", + "\\.(css|less)$": "assets/__mocks__/styleMock.js" + }, "rootDir": "src", "transform": { "\\.(ts|tsx)$": "ts-jest" @@ -30,7 +40,8 @@ "babelConfig": false, "tsConfig": "./tsconfig.jest.json" } - } + }, + "setupFiles": ["jest-canvas-mock", "dotenv/config"] }, "repository": { "type": "git", @@ -71,7 +82,10 @@ "file-loader": "^4.0.0", "hard-source-webpack-plugin": "0.13.1", "html-webpack-plugin": "^3.2.0", + "husky": "^3.0.0", "jest": "^24.8.0", + "jest-canvas-mock": "^2.1.0", + "lint-staged": "^9.0.2", "local-web-server": "^3.0.4", "source-map-loader": "^0.2.4", "style-loader": "^0.23.1", @@ -94,5 +108,17 @@ "store": "^2.0.12", "upng-js": "^2.1.0", "webfontloader": "^1.6.28" + }, + "lint-staged": { + "*.ts": [ + "npm run lint -- --fix", + "npm run test -- --findRelatedTests", + "git add" + ] + }, + "husky": { + "hooks": { + "pre-commit": "lint-staged && npm run typecheck" + } } } diff --git a/src/eterna/folding/__tests__/Folder.test.ts b/src/eterna/folding/__tests__/Folder.test.ts index ddcbc98e1..6c795870b 100644 --- a/src/eterna/folding/__tests__/Folder.test.ts +++ b/src/eterna/folding/__tests__/Folder.test.ts @@ -1,3 +1,6 @@ +// Build order issues +import "eterna/EternaApp"; + import EPars from "eterna/EPars"; import Folder from "../Folder"; import NuPACK from "../NuPACK"; @@ -123,5 +126,3 @@ for (let folderType of [Vienna, Vienna2, NuPACK]) { .resolves.toBeDeepCloseTo(expectedResult, 5); }); } - - From ec2dd678945102a34454c957a3f25a15e77aaa0c Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Fri, 5 Jul 2019 23:15:04 -0400 Subject: [PATCH 17/39] Package bump --- package-lock.json | 294 ++++++++++++++++++++++++++++++++++------------ package.json | 17 +-- 2 files changed, 231 insertions(+), 80 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0dfe7e3e6..7a3061d48 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,9 +5,9 @@ "requires": true, "dependencies": { "@babel/cli": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/cli/-/cli-7.4.4.tgz", - "integrity": "sha512-XGr5YjQSjgTa6OzQZY57FAJsdeVSAKR/u/KA5exWIz66IKtv/zXtHy+fIZcMry/EgYegwuHE7vzGnrFhjdIAsQ==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/cli/-/cli-7.5.0.tgz", + "integrity": "sha512-qNH55fWbKrEsCwID+Qc/3JDPnsSGpIIiMDbppnR8Z6PxLAqMQCFNqBctkIkBrMH49Nx+qqVTrHRWUR+ho2k+qQ==", "dev": true, "requires": { "chokidar": "^2.0.4", @@ -32,18 +32,18 @@ } }, "@babel/core": { - "version": "7.4.5", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.4.5.tgz", - "integrity": "sha512-OvjIh6aqXtlsA8ujtGKfC7LYWksYSX8yQcM8Ay3LuvVeQ63lcOKgoZWVqcpFwkd29aYU9rVx7jxhfhiEDV9MZA==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.5.0.tgz", + "integrity": "sha512-6Isr4X98pwXqHvtigw71CKgmhL1etZjPs5A67jL/w0TkLM9eqmFR40YrnJvEc1WnMZFsskjsmid8bHZyxKEAnw==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", - "@babel/generator": "^7.4.4", - "@babel/helpers": "^7.4.4", - "@babel/parser": "^7.4.5", + "@babel/generator": "^7.5.0", + "@babel/helpers": "^7.5.0", + "@babel/parser": "^7.5.0", "@babel/template": "^7.4.4", - "@babel/traverse": "^7.4.5", - "@babel/types": "^7.4.4", + "@babel/traverse": "^7.5.0", + "@babel/types": "^7.5.0", "convert-source-map": "^1.1.0", "debug": "^4.1.0", "json5": "^2.1.0", @@ -53,6 +53,53 @@ "source-map": "^0.5.0" }, "dependencies": { + "@babel/generator": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.5.0.tgz", + "integrity": "sha512-1TTVrt7J9rcG5PMjvO7VEG3FrEoEJNHxumRq66GemPmzboLWtIjjcJgk8rokuAS7IiRSpgVSu5Vb9lc99iJkOA==", + "dev": true, + "requires": { + "@babel/types": "^7.5.0", + "jsesc": "^2.5.1", + "lodash": "^4.17.11", + "source-map": "^0.5.0", + "trim-right": "^1.0.1" + } + }, + "@babel/parser": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.5.0.tgz", + "integrity": "sha512-I5nW8AhGpOXGCCNYGc+p7ExQIBxRFnS2fd/d862bNOKvmoEPjYPcfIjsfdy0ujagYOIYPczKgD9l3FsgTkAzKA==", + "dev": true + }, + "@babel/traverse": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.5.0.tgz", + "integrity": "sha512-SnA9aLbyOCcnnbQEGwdfBggnc142h/rbqqsXcaATj2hZcegCl903pUD/lfpsNBlBSuWow/YDfRyJuWi2EPR5cg==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "@babel/generator": "^7.5.0", + "@babel/helper-function-name": "^7.1.0", + "@babel/helper-split-export-declaration": "^7.4.4", + "@babel/parser": "^7.5.0", + "@babel/types": "^7.5.0", + "debug": "^4.1.0", + "globals": "^11.1.0", + "lodash": "^4.17.11" + } + }, + "@babel/types": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.5.0.tgz", + "integrity": "sha512-UFpDVqRABKsW01bvw7/wSUe56uy6RXM5+VJibVVAybDGxEW25jdwiFJEf7ASvSaC7sN7rbE/l3cLp2izav+CtQ==", + "dev": true, + "requires": { + "esutils": "^2.0.2", + "lodash": "^4.17.11", + "to-fast-properties": "^2.0.0" + } + }, "debug": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", @@ -114,9 +161,9 @@ } }, "@babel/helper-create-class-features-plugin": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.4.4.tgz", - "integrity": "sha512-UbBHIa2qeAGgyiNR9RszVF7bUHEdgS4JAUNT8SiqrAN6YJVxlOxeLr5pBzb5kan302dejJ9nla4RyKcR1XT6XA==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.5.0.tgz", + "integrity": "sha512-EAoMc3hE5vE5LNhMqDOwB1usHvmRjCDAnH8CD4PVkX9/Yr3W/tcz8xE8QvdZxfsFBDICwZnF2UTHIqslRpvxmA==", "dev": true, "requires": { "@babel/helper-function-name": "^7.1.0", @@ -290,14 +337,78 @@ } }, "@babel/helpers": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.4.4.tgz", - "integrity": "sha512-igczbR/0SeuPR8RFfC7tGrbdTbFL3QTvH6D+Z6zNxnTe//GyqmtHmDkzrqDmyZ3eSwPqB/LhyKoU5DXsp+Vp2A==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.5.0.tgz", + "integrity": "sha512-EgCUEa8cNwuMrwo87l2d7i2oShi8m2Q58H7h3t4TWtqATZalJYFwfL9DulRe02f3KdqM9xmMCw3v/7Ll+EiaWg==", "dev": true, "requires": { "@babel/template": "^7.4.4", - "@babel/traverse": "^7.4.4", - "@babel/types": "^7.4.4" + "@babel/traverse": "^7.5.0", + "@babel/types": "^7.5.0" + }, + "dependencies": { + "@babel/generator": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.5.0.tgz", + "integrity": "sha512-1TTVrt7J9rcG5PMjvO7VEG3FrEoEJNHxumRq66GemPmzboLWtIjjcJgk8rokuAS7IiRSpgVSu5Vb9lc99iJkOA==", + "dev": true, + "requires": { + "@babel/types": "^7.5.0", + "jsesc": "^2.5.1", + "lodash": "^4.17.11", + "source-map": "^0.5.0", + "trim-right": "^1.0.1" + } + }, + "@babel/parser": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.5.0.tgz", + "integrity": "sha512-I5nW8AhGpOXGCCNYGc+p7ExQIBxRFnS2fd/d862bNOKvmoEPjYPcfIjsfdy0ujagYOIYPczKgD9l3FsgTkAzKA==", + "dev": true + }, + "@babel/traverse": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.5.0.tgz", + "integrity": "sha512-SnA9aLbyOCcnnbQEGwdfBggnc142h/rbqqsXcaATj2hZcegCl903pUD/lfpsNBlBSuWow/YDfRyJuWi2EPR5cg==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "@babel/generator": "^7.5.0", + "@babel/helper-function-name": "^7.1.0", + "@babel/helper-split-export-declaration": "^7.4.4", + "@babel/parser": "^7.5.0", + "@babel/types": "^7.5.0", + "debug": "^4.1.0", + "globals": "^11.1.0", + "lodash": "^4.17.11" + } + }, + "@babel/types": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.5.0.tgz", + "integrity": "sha512-UFpDVqRABKsW01bvw7/wSUe56uy6RXM5+VJibVVAybDGxEW25jdwiFJEf7ASvSaC7sN7rbE/l3cLp2izav+CtQ==", + "dev": true, + "requires": { + "esutils": "^2.0.2", + "lodash": "^4.17.11", + "to-fast-properties": "^2.0.0" + } + }, + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + } } }, "@babel/highlight": { @@ -329,15 +440,25 @@ } }, "@babel/plugin-proposal-class-properties": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.4.4.tgz", - "integrity": "sha512-WjKTI8g8d5w1Bc9zgwSz2nfrsNQsXcCf9J9cdCvrJV6RF56yztwm4TmJC0MgJ9tvwO9gUA/mcYe89bLdGfiXFg==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.5.0.tgz", + "integrity": "sha512-9L/JfPCT+kShiiTTzcnBJ8cOwdKVmlC1RcCf9F0F9tERVrM4iWtWnXtjWCRqNm2la2BxO1MPArWNsU9zsSJWSQ==", "dev": true, "requires": { - "@babel/helper-create-class-features-plugin": "^7.4.4", + "@babel/helper-create-class-features-plugin": "^7.5.0", "@babel/helper-plugin-utils": "^7.0.0" } }, + "@babel/plugin-proposal-dynamic-import": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.5.0.tgz", + "integrity": "sha512-x/iMjggsKTFHYC6g11PL7Qy58IK8H5zqfm9e6hu4z1iH2IRyAp9u9dL80zA6R76yFovETFLKz2VJIC2iIPBuFw==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/plugin-syntax-dynamic-import": "^7.2.0" + } + }, "@babel/plugin-proposal-json-strings": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.2.0.tgz", @@ -349,9 +470,9 @@ } }, "@babel/plugin-proposal-object-rest-spread": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.4.4.tgz", - "integrity": "sha512-dMBG6cSPBbHeEBdFXeQ2QLc5gUpg4Vkaz8octD4aoW/ISO+jBOcsuxYL7bsb5WSu8RLP6boxrBIALEHgoHtO9g==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.5.0.tgz", + "integrity": "sha512-G1qy5EdcO3vYhbxlXjRSR2SXB8GsxYv9hoRKT1Jdn3qy/NUnFqUUnqymKZ00Pbj+3FXNh06B+BUZzecrp3sxNw==", "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.0.0", @@ -443,9 +564,9 @@ } }, "@babel/plugin-transform-async-to-generator": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.4.4.tgz", - "integrity": "sha512-YiqW2Li8TXmzgbXw+STsSqPBPFnGviiaSp6CYOq55X8GQ2SGVLrXB6pNid8HkqkZAzOH6knbai3snhP7v0fNwA==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.5.0.tgz", + "integrity": "sha512-mqvkzwIGkq0bEF1zLRRiTdjfomZJDV33AH3oQzHVGkI2VzEmXLpKKOBvEVaFZBJdN0XTyH38s9j/Kiqr68dggg==", "dev": true, "requires": { "@babel/helper-module-imports": "^7.0.0", @@ -498,9 +619,9 @@ } }, "@babel/plugin-transform-destructuring": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.4.4.tgz", - "integrity": "sha512-/aOx+nW0w8eHiEHm+BTERB2oJn5D127iye/SUQl7NjHy0lf+j7h4MKMMSOwdazGq9OxgiNADncE+SRJkCxjZpQ==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.5.0.tgz", + "integrity": "sha512-YbYgbd3TryYYLGyC7ZR+Tq8H/+bCmwoaxHfJHupom5ECstzbRLTch6gOQbhEY9Z4hiCNHEURgq06ykFv9JZ/QQ==", "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.0.0" @@ -518,9 +639,9 @@ } }, "@babel/plugin-transform-duplicate-keys": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.2.0.tgz", - "integrity": "sha512-q+yuxW4DsTjNceUiTzK0L+AfQ0zD9rWaTLiUqHA8p0gxx7lu1EylenfzjeIWNkPy6e/0VG/Wjw9uf9LueQwLOw==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.5.0.tgz", + "integrity": "sha512-igcziksHizyQPlX9gfSjHkE2wmoCH3evvD2qR5w29/Dk0SMKE/eOI7f1HhBdNhR/zxJDqrgpoDTq5YSLH/XMsQ==", "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.0.0" @@ -574,34 +695,37 @@ } }, "@babel/plugin-transform-modules-amd": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.2.0.tgz", - "integrity": "sha512-mK2A8ucqz1qhrdqjS9VMIDfIvvT2thrEsIQzbaTdc5QFzhDjQv2CkJJ5f6BXIkgbmaoax3zBr2RyvV/8zeoUZw==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.5.0.tgz", + "integrity": "sha512-n20UsQMKnWrltocZZm24cRURxQnWIvsABPJlw/fvoy9c6AgHZzoelAIzajDHAQrDpuKFFPPcFGd7ChsYuIUMpg==", "dev": true, "requires": { "@babel/helper-module-transforms": "^7.1.0", - "@babel/helper-plugin-utils": "^7.0.0" + "@babel/helper-plugin-utils": "^7.0.0", + "babel-plugin-dynamic-import-node": "^2.3.0" } }, "@babel/plugin-transform-modules-commonjs": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.4.4.tgz", - "integrity": "sha512-4sfBOJt58sEo9a2BQXnZq+Q3ZTSAUXyK3E30o36BOGnJ+tvJ6YSxF0PG6kERvbeISgProodWuI9UVG3/FMY6iw==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.5.0.tgz", + "integrity": "sha512-xmHq0B+ytyrWJvQTc5OWAC4ii6Dhr0s22STOoydokG51JjWhyYo5mRPXoi+ZmtHQhZZwuXNN+GG5jy5UZZJxIQ==", "dev": true, "requires": { "@babel/helper-module-transforms": "^7.4.4", "@babel/helper-plugin-utils": "^7.0.0", - "@babel/helper-simple-access": "^7.1.0" + "@babel/helper-simple-access": "^7.1.0", + "babel-plugin-dynamic-import-node": "^2.3.0" } }, "@babel/plugin-transform-modules-systemjs": { - "version": "7.4.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.4.4.tgz", - "integrity": "sha512-MSiModfILQc3/oqnG7NrP1jHaSPryO6tA2kOMmAQApz5dayPxWiHqmq4sWH2xF5LcQK56LlbKByCd8Aah/OIkQ==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.5.0.tgz", + "integrity": "sha512-Q2m56tyoQWmuNGxEtUyeEkm6qJYFqs4c+XyXH5RAuYxObRNz9Zgj/1g2GMnjYp2EUyEy7YTrxliGCXzecl/vJg==", "dev": true, "requires": { "@babel/helper-hoist-variables": "^7.4.4", - "@babel/helper-plugin-utils": "^7.0.0" + "@babel/helper-plugin-utils": "^7.0.0", + "babel-plugin-dynamic-import-node": "^2.3.0" } }, "@babel/plugin-transform-modules-umd": { @@ -749,39 +873,41 @@ } }, "@babel/preset-env": { - "version": "7.4.5", - "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.4.5.tgz", - "integrity": "sha512-f2yNVXM+FsR5V8UwcFeIHzHWgnhXg3NpRmy0ADvALpnhB0SLbCvrCRr4BLOUYbQNLS+Z0Yer46x9dJXpXewI7w==", + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.5.0.tgz", + "integrity": "sha512-/5oQ7cYg+6sH9Dt9yx5IiylnLPiUdyMHl5y+K0mKVNiW2wJ7FpU5bg8jKcT8PcCbxdYzfv6OuC63jLEtMuRSmQ==", "dev": true, "requires": { "@babel/helper-module-imports": "^7.0.0", "@babel/helper-plugin-utils": "^7.0.0", "@babel/plugin-proposal-async-generator-functions": "^7.2.0", + "@babel/plugin-proposal-dynamic-import": "^7.5.0", "@babel/plugin-proposal-json-strings": "^7.2.0", - "@babel/plugin-proposal-object-rest-spread": "^7.4.4", + "@babel/plugin-proposal-object-rest-spread": "^7.5.0", "@babel/plugin-proposal-optional-catch-binding": "^7.2.0", "@babel/plugin-proposal-unicode-property-regex": "^7.4.4", "@babel/plugin-syntax-async-generators": "^7.2.0", + "@babel/plugin-syntax-dynamic-import": "^7.2.0", "@babel/plugin-syntax-json-strings": "^7.2.0", "@babel/plugin-syntax-object-rest-spread": "^7.2.0", "@babel/plugin-syntax-optional-catch-binding": "^7.2.0", "@babel/plugin-transform-arrow-functions": "^7.2.0", - "@babel/plugin-transform-async-to-generator": "^7.4.4", + "@babel/plugin-transform-async-to-generator": "^7.5.0", "@babel/plugin-transform-block-scoped-functions": "^7.2.0", "@babel/plugin-transform-block-scoping": "^7.4.4", "@babel/plugin-transform-classes": "^7.4.4", "@babel/plugin-transform-computed-properties": "^7.2.0", - "@babel/plugin-transform-destructuring": "^7.4.4", + "@babel/plugin-transform-destructuring": "^7.5.0", "@babel/plugin-transform-dotall-regex": "^7.4.4", - "@babel/plugin-transform-duplicate-keys": "^7.2.0", + "@babel/plugin-transform-duplicate-keys": "^7.5.0", "@babel/plugin-transform-exponentiation-operator": "^7.2.0", "@babel/plugin-transform-for-of": "^7.4.4", "@babel/plugin-transform-function-name": "^7.4.4", "@babel/plugin-transform-literals": "^7.2.0", "@babel/plugin-transform-member-expression-literals": "^7.2.0", - "@babel/plugin-transform-modules-amd": "^7.2.0", - "@babel/plugin-transform-modules-commonjs": "^7.4.4", - "@babel/plugin-transform-modules-systemjs": "^7.4.4", + "@babel/plugin-transform-modules-amd": "^7.5.0", + "@babel/plugin-transform-modules-commonjs": "^7.5.0", + "@babel/plugin-transform-modules-systemjs": "^7.5.0", "@babel/plugin-transform-modules-umd": "^7.2.0", "@babel/plugin-transform-named-capturing-groups-regex": "^7.4.5", "@babel/plugin-transform-new-target": "^7.4.4", @@ -796,12 +922,25 @@ "@babel/plugin-transform-template-literals": "^7.4.4", "@babel/plugin-transform-typeof-symbol": "^7.2.0", "@babel/plugin-transform-unicode-regex": "^7.4.4", - "@babel/types": "^7.4.4", + "@babel/types": "^7.5.0", "browserslist": "^4.6.0", "core-js-compat": "^3.1.1", "invariant": "^2.2.2", "js-levenshtein": "^1.1.3", "semver": "^5.5.0" + }, + "dependencies": { + "@babel/types": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.5.0.tgz", + "integrity": "sha512-UFpDVqRABKsW01bvw7/wSUe56uy6RXM5+VJibVVAybDGxEW25jdwiFJEf7ASvSaC7sN7rbE/l3cLp2izav+CtQ==", + "dev": true, + "requires": { + "esutils": "^2.0.2", + "lodash": "^4.17.11", + "to-fast-properties": "^2.0.0" + } + } } }, "@babel/preset-typescript": { @@ -1411,9 +1550,9 @@ "dev": true }, "@types/node": { - "version": "12.0.10", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.0.10.tgz", - "integrity": "sha512-LcsGbPomWsad6wmMNv7nBLw7YYYyfdYcz6xryKYQhx89c3XXan+8Q6AJ43G5XDIaklaVkK3mE4fCb0SBvMiPSQ==", + "version": "12.0.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.0.12.tgz", + "integrity": "sha512-Uy0PN4R5vgBUXFoJrKryf5aTk3kJ8Rv3PdlHjl6UaX+Cqp1QE0yPQ68MPXGrZOfG7gZVNDIJZYyot0B9ubXUrQ==", "dev": true }, "@types/normalize-package-data": { @@ -2107,6 +2246,15 @@ "pify": "^4.0.1" } }, + "babel-plugin-dynamic-import-node": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-2.3.0.tgz", + "integrity": "sha512-o6qFkpeQEBxcqt0XYlWzAVxNCSCZdUgcR8IRlhD/8DylxjjO4foPcvTW0GGKa/cVt3rvxZ7o5ippJ+/0nvLhlQ==", + "dev": true, + "requires": { + "object.assign": "^4.1.0" + } + }, "babel-plugin-istanbul": { "version": "5.1.4", "resolved": "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-5.1.4.tgz", @@ -2793,9 +2941,9 @@ "dev": true }, "caniuse-lite": { - "version": "1.0.30000979", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000979.tgz", - "integrity": "sha512-gcu45yfq3B7Y+WB05fOMfr0EiSlq+1u+m6rPHyJli/Wy3PVQNGaU7VA4bZE5qw+AU2UVOBR/N5g1bzADUqdvFw==", + "version": "1.0.30000980", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000980.tgz", + "integrity": "sha512-as0PRtWHaX3gl2gpC7qA7bX88lr+qLacMMXm1QKLLQtBCwT/Ljbgrv5EXKMNBoeEX6yFZ4vIsBb4Nh+PEwW2Rw==", "dev": true }, "capture-exit": { @@ -3831,9 +3979,9 @@ "dev": true }, "electron-to-chromium": { - "version": "1.3.183", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.183.tgz", - "integrity": "sha512-WbKCYs7yAFOfpuoa2pK5kbOngriUtlPC+8mcQW5L/686wv04w7hYXfw5ScDrsl9kixFw1SPsALEob5V/gtlDxw==", + "version": "1.3.187", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.187.tgz", + "integrity": "sha512-XCEygaK7Fs35/RwS+67YbBWs/ydG+oUFPuy1wv558jC3Opd2DHwRyRqrCmhxpmPmCSVlZujYX4TOmOXuMz2GZA==", "dev": true }, "elegant-spinner": { @@ -8357,9 +8505,9 @@ "dev": true }, "node-releases": { - "version": "1.1.24", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.24.tgz", - "integrity": "sha512-wym2jptfuKowMmkZsfCSTsn8qAVo8zm+UiQA6l5dNqUcpfChZSnS/vbbpOeXczf+VdPhutxh+99lWHhdd6xKzg==", + "version": "1.1.25", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.25.tgz", + "integrity": "sha512-fI5BXuk83lKEoZDdH3gRhtsNgh05/wZacuXkgbiYkceE7+QIMXOg98n9ZV7mz27B+kFHnqHcUpscZZlGRSmTpQ==", "dev": true, "requires": { "semver": "^5.3.0" @@ -9484,9 +9632,9 @@ } }, "regexp-tree": { - "version": "0.1.10", - "resolved": "https://registry.npmjs.org/regexp-tree/-/regexp-tree-0.1.10.tgz", - "integrity": "sha512-K1qVSbcedffwuIslMwpe6vGlj+ZXRnGkvjAtFHfDZZZuEdA/h0dxljAPu9vhUo6Rrx2U2AwJ+nSQ6hK+lrP5MQ==", + "version": "0.1.11", + "resolved": "https://registry.npmjs.org/regexp-tree/-/regexp-tree-0.1.11.tgz", + "integrity": "sha512-7/l/DgapVVDzZobwMCCgMlqiqyLFJ0cduo/j+3BcDJIB+yJdsYCfKuI3l/04NV+H/rfNRdPIDbXNZHM9XvQatg==", "dev": true }, "regexpp": { diff --git a/package.json b/package.json index e707bb7e4..690f6709a 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,10 @@ "tsConfig": "./tsconfig.jest.json" } }, - "setupFiles": ["jest-canvas-mock", "dotenv/config"] + "setupFiles": [ + "jest-canvas-mock", + "dotenv/config" + ] }, "repository": { "type": "git", @@ -51,17 +54,17 @@ "author": "Tim Conkling", "license": "ISC", "devDependencies": { - "@babel/cli": "^7.4.4", - "@babel/core": "^7.4.5", - "@babel/plugin-proposal-class-properties": "^7.4.4", - "@babel/plugin-proposal-object-rest-spread": "^7.4.4", + "@babel/cli": "^7.5.0", + "@babel/core": "^7.5.0", + "@babel/plugin-proposal-class-properties": "^7.5.0", + "@babel/plugin-proposal-object-rest-spread": "^7.5.0", "@babel/plugin-syntax-dynamic-import": "^7.2.0", - "@babel/preset-env": "^7.4.5", + "@babel/preset-env": "^7.5.0", "@babel/preset-typescript": "^7.3.3", "@types/base64-js": "^1.2.5", "@types/jest": "^24.0.15", "@types/loglevel": "^1.6.3", - "@types/node": "^12.0.10", + "@types/node": "^12.0.12", "@types/pixi.js": "^4.8.8", "@types/storejs": "^2.0.3", "@types/upng-js": "^2.1.1", From d037a8562fbeedd4e90055d75b2dddc3b5becde8 Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Mon, 8 Jul 2019 10:56:58 -0400 Subject: [PATCH 18/39] Remove commented out portions of eslintrc --- .eslintrc.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index c3dac0e69..bb01c6cfe 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,12 +1,8 @@ module.exports = { 'extends': ['airbnb-base', 'plugin:@typescript-eslint/recommended'], - //'parser': '@typescript-eslint/parser', 'parserOptions': { 'project': './tsconfig.json' }, - /*'plugins': [ - '@typescript-eslint' - ],*/ // Some imports may be resolved via webpack aliases 'settings': { 'import/resolver': { From 5ac42e8599ac69d9732b24f5690a04fff7bef324 Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Mon, 8 Jul 2019 15:47:32 -0400 Subject: [PATCH 19/39] No index files for subpackages, decouple flashbang Button from Eterna by moving SoundManager into Flashbang (resolves #140) --- .eslintrc.js | 2 +- src/eterna/ChatManager.ts | 2 +- src/eterna/EPars.ts | 2 +- src/eterna/Eterna.ts | 12 +-- src/eterna/EternaApp.ts | 53 +++++++---- src/eterna/ExpPainter.ts | 2 +- src/eterna/Plot.ts | 4 +- src/eterna/UndoBlock.ts | 8 +- src/eterna/achievements/AchievementBox.ts | 16 ++-- src/eterna/achievements/AchievementManager.ts | 8 +- src/eterna/achievements/index.ts | 2 - src/eterna/debug/TestMode.ts | 11 ++- src/eterna/debug/index.ts | 2 - src/eterna/emscripten/index.ts | 2 - src/eterna/folding/Folder.ts | 2 +- src/eterna/folding/LinearFoldBase.ts | 2 +- src/eterna/folding/LinearFoldC.ts | 2 +- src/eterna/folding/LinearFoldV.ts | 2 +- src/eterna/folding/NuPACK.ts | 6 +- src/eterna/folding/Vienna.ts | 6 +- src/eterna/folding/Vienna2.ts | 6 +- src/eterna/folding/__tests__/Folder.test.ts | 3 - src/eterna/folding/index.ts | 10 -- src/eterna/mode/CopyTextDialogMode.ts | 5 +- .../CustomizeColumnOrderDialog.ts | 16 ++-- src/eterna/mode/DesignBrowser/DataCol.ts | 17 ++-- .../mode/DesignBrowser/DesignBrowserMode.ts | 47 +++++----- src/eterna/mode/DesignBrowser/LabComments.ts | 2 +- .../DesignBrowser/SequenceStringListView.ts | 4 +- .../mode/DesignBrowser/SolutionDescBox.ts | 25 ++--- src/eterna/mode/DesignBrowser/SortOptions.ts | 4 +- .../mode/DesignBrowser/SortOptionsDialog.ts | 18 ++-- .../mode/DesignBrowser/ViewSolutionDialog.ts | 18 ++-- .../mode/DesignBrowser/VoteProcessor.ts | 4 +- src/eterna/mode/DesignBrowser/index.ts | 16 ---- src/eterna/mode/ErrorDialogMode.ts | 11 ++- src/eterna/mode/FeedbackViewMode.ts | 27 +++--- src/eterna/mode/GameMode.ts | 26 ++++-- src/eterna/mode/LoadingMode.ts | 11 +-- src/eterna/mode/PoseEdit/Booster.ts | 19 ++-- .../mode/PoseEdit/MissionClearedPanel.ts | 18 ++-- src/eterna/mode/PoseEdit/MissionIntroMode.ts | 15 +-- src/eterna/mode/PoseEdit/PoseEditMode.ts | 92 +++++++++++-------- src/eterna/mode/PoseEdit/SubmitPoseDialog.ts | 6 +- src/eterna/mode/PoseEdit/SubmittingDialog.ts | 10 +- src/eterna/mode/PoseEdit/index.ts | 7 -- src/eterna/mode/PuzzleEdit/PuzzleEditMode.ts | 53 +++++++---- src/eterna/mode/PuzzleEdit/StructureInput.ts | 15 +-- .../mode/PuzzleEdit/SubmitPuzzleDialog.ts | 8 +- src/eterna/mode/PuzzleEdit/index.ts | 3 - src/eterna/mode/index.ts | 8 -- src/eterna/net/EternaURL.ts | 2 +- src/eterna/net/GameClient.ts | 2 +- src/eterna/net/index.ts | 2 - src/eterna/pose2D/Base.ts | 7 +- src/eterna/pose2D/BaseAssets.ts | 20 ++-- src/eterna/pose2D/BaseTextures.ts | 9 +- src/eterna/pose2D/EnergyScoreDisplay.ts | 5 +- src/eterna/pose2D/ExplosionFactorPanel.ts | 8 +- src/eterna/pose2D/HighlightBox.ts | 11 +-- src/eterna/pose2D/Molecule.ts | 6 +- src/eterna/pose2D/PaintCursor.ts | 2 +- src/eterna/pose2D/Pose2D.ts | 37 ++++---- src/eterna/pose2D/PoseField.ts | 9 +- src/eterna/pose2D/RNAAnchorObject.ts | 3 +- src/eterna/pose2D/RNALayout.ts | 2 +- src/eterna/pose2D/ScoreDisplayNode.ts | 2 +- src/eterna/pose2D/index.ts | 19 ---- src/eterna/puzzle/Puzzle.ts | 8 +- src/eterna/puzzle/PuzzleManager.ts | 3 +- src/eterna/puzzle/index.ts | 7 -- src/eterna/rank/RankBoard.ts | 3 +- src/eterna/rank/RankRowLayout.ts | 5 +- src/eterna/rank/RankScroll.ts | 19 ++-- src/eterna/rank/index.ts | 4 - src/eterna/resources/BitmapManager.ts | 4 +- src/eterna/resources/PlaySoundTask.ts | 4 +- src/eterna/resources/index.ts | 5 - src/eterna/rscript/NovaPaintHint.ts | 11 +-- src/eterna/rscript/RNAScript.ts | 4 +- src/eterna/rscript/ROPHighlight.ts | 16 ++-- src/eterna/rscript/ROPPre.ts | 2 +- src/eterna/rscript/ROPRNA.ts | 4 +- src/eterna/rscript/ROPTextbox.ts | 12 +-- src/eterna/rscript/RScriptArrow.ts | 5 +- src/eterna/rscript/RScriptEnv.ts | 13 +-- src/eterna/rscript/RScriptUIElement.ts | 3 +- src/eterna/rscript/index.ts | 14 --- src/eterna/settings/EternaSettings.ts | 4 +- src/eterna/settings/index.ts | 2 - src/eterna/ui/ActionBar.ts | 3 +- src/eterna/ui/AsyncProcessDialog.ts | 8 +- src/eterna/ui/Band.ts | 11 ++- src/eterna/ui/BaseGamePanel.ts | 2 +- src/eterna/ui/ConfirmDialog.ts | 8 +- src/eterna/ui/ConstraintBox.ts | 23 ++--- src/eterna/ui/ContextMenu.ts | 4 +- src/eterna/ui/Dialog.ts | 6 +- src/eterna/ui/EternaMenu.ts | 4 +- src/eterna/ui/EternaViewOptionsDialog.ts | 13 ++- src/eterna/ui/FancyGamePanel.ts | 2 +- src/eterna/ui/FancyTextBalloon.ts | 14 +-- src/eterna/ui/FixedWidthTextField.ts | 3 +- src/eterna/ui/GameButton.ts | 16 ++-- src/eterna/ui/GameCheckbox.ts | 11 ++- src/eterna/ui/GamePanel.ts | 2 +- src/eterna/ui/HTMLTextObject.ts | 2 +- src/eterna/ui/NotificationDialog.ts | 3 +- src/eterna/ui/NucleotidePalette.ts | 16 ++-- src/eterna/ui/PasteSequenceDialog.ts | 5 +- src/eterna/ui/PoseThumbnail.ts | 6 +- src/eterna/ui/ScrollContainer.ts | 2 +- src/eterna/ui/SliderBar.ts | 6 +- src/eterna/ui/SpecBox.ts | 15 ++- src/eterna/ui/SpecBoxDialog.ts | 6 +- src/eterna/ui/TextBalloon.ts | 5 +- src/eterna/ui/TextInputObject.ts | 6 +- src/eterna/ui/TextInputPanel.ts | 3 +- src/eterna/ui/ToggleBar.ts | 16 ++-- src/eterna/ui/Toolbar.ts | 17 ++-- src/eterna/ui/Tooltips.ts | 9 +- src/eterna/ui/UILockDialog.ts | 2 +- src/eterna/ui/VScrollBox.ts | 3 +- src/eterna/ui/index.ts | 36 -------- src/eterna/util/EternaTextureUtil.ts | 2 +- src/eterna/util/ExternalInterface.ts | 2 +- src/eterna/util/Fonts.ts | 3 +- src/eterna/util/GraphicsUtil.ts | 2 +- src/eterna/util/index.ts | 6 -- src/eterna/vfx/Background.ts | 2 +- src/eterna/vfx/BaseGlow.ts | 5 +- src/eterna/vfx/Bubble.ts | 9 +- src/eterna/vfx/BubbleSweep.ts | 2 +- src/eterna/vfx/LightRay.ts | 6 +- src/eterna/vfx/VibrateTask.ts | 3 +- src/eterna/vfx/index.ts | 6 -- src/flashbang/core/AppMode.ts | 5 +- src/flashbang/core/Flashbang.ts | 9 +- src/flashbang/core/FlashbangApp.ts | 3 +- src/flashbang/core/GameObject.ts | 2 +- src/flashbang/core/ModeStack.ts | 3 +- src/flashbang/core/index.ts | 11 --- src/flashbang/geom/index.ts | 2 - src/flashbang/index.js | 89 ++++++++++++++++++ .../input/DisplayObjectPointerTarget.ts | 2 +- src/flashbang/input/InputUtil.ts | 1 + src/flashbang/input/KeyboardInput.ts | 2 +- src/flashbang/input/MouseWheelInput.ts | 2 +- src/flashbang/input/PointerCapture.ts | 2 +- src/flashbang/input/index.ts | 8 -- src/flashbang/layout/HLayoutContainer.ts | 4 +- src/flashbang/layout/VLayoutContainer.ts | 4 +- src/flashbang/layout/index.ts | 3 - src/flashbang/objects/Button.ts | 22 ++--- src/flashbang/objects/DOMObject.ts | 5 +- src/flashbang/objects/Dragger.ts | 5 +- src/flashbang/objects/SceneObject.ts | 5 +- src/flashbang/objects/SimpleTextButton.ts | 2 +- src/flashbang/objects/index.ts | 10 -- .../resources/SoundManager.ts | 52 ++++++----- src/flashbang/resources/index.ts | 2 - src/flashbang/settings/index.ts | 3 - src/flashbang/tasks/AlphaTask.ts | 2 +- src/flashbang/tasks/CallbackTask.ts | 2 +- src/flashbang/tasks/DelayTask.ts | 3 +- src/flashbang/tasks/DisplayObjectTask.ts | 3 +- src/flashbang/tasks/FrameDelayTask.ts | 3 +- src/flashbang/tasks/FunctionTask.ts | 3 +- src/flashbang/tasks/InterpolatingTask.ts | 5 +- src/flashbang/tasks/LocationTask.ts | 2 +- src/flashbang/tasks/ParallelTask.ts | 4 +- src/flashbang/tasks/RepeatingTask.ts | 2 +- src/flashbang/tasks/RotationTask.ts | 2 +- src/flashbang/tasks/ScaleTask.ts | 2 +- src/flashbang/tasks/SelfDestructTask.ts | 2 +- src/flashbang/tasks/SerialTask.ts | 4 +- src/flashbang/tasks/VisibleTask.ts | 4 +- src/flashbang/tasks/index.ts | 15 --- src/flashbang/util/DisplayUtil.ts | 5 +- src/flashbang/util/TextureUtil.ts | 2 +- src/flashbang/util/index.ts | 20 ---- 181 files changed, 785 insertions(+), 862 deletions(-) delete mode 100644 src/eterna/achievements/index.ts delete mode 100644 src/eterna/debug/index.ts delete mode 100644 src/eterna/emscripten/index.ts delete mode 100644 src/eterna/folding/index.ts delete mode 100644 src/eterna/mode/DesignBrowser/index.ts delete mode 100644 src/eterna/mode/PoseEdit/index.ts delete mode 100644 src/eterna/mode/PuzzleEdit/index.ts delete mode 100644 src/eterna/mode/index.ts delete mode 100644 src/eterna/net/index.ts delete mode 100644 src/eterna/pose2D/index.ts delete mode 100644 src/eterna/puzzle/index.ts delete mode 100644 src/eterna/rank/index.ts delete mode 100644 src/eterna/resources/index.ts delete mode 100644 src/eterna/rscript/index.ts delete mode 100644 src/eterna/settings/index.ts delete mode 100644 src/eterna/ui/index.ts delete mode 100644 src/eterna/util/index.ts delete mode 100644 src/eterna/vfx/index.ts delete mode 100644 src/flashbang/core/index.ts delete mode 100644 src/flashbang/geom/index.ts create mode 100644 src/flashbang/index.js delete mode 100644 src/flashbang/input/index.ts delete mode 100644 src/flashbang/layout/index.ts delete mode 100644 src/flashbang/objects/index.ts rename src/{eterna => flashbang}/resources/SoundManager.ts (52%) delete mode 100644 src/flashbang/resources/index.ts delete mode 100644 src/flashbang/settings/index.ts delete mode 100644 src/flashbang/tasks/index.ts delete mode 100644 src/flashbang/util/index.ts diff --git a/.eslintrc.js b/.eslintrc.js index bb01c6cfe..7ba6666fa 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -3,8 +3,8 @@ module.exports = { 'parserOptions': { 'project': './tsconfig.json' }, - // Some imports may be resolved via webpack aliases 'settings': { + // Some imports may be resolved via webpack aliases 'import/resolver': { 'webpack': { 'config': 'webpack.common.js' diff --git a/src/eterna/ChatManager.ts b/src/eterna/ChatManager.ts index 1f2688516..de8532e91 100644 --- a/src/eterna/ChatManager.ts +++ b/src/eterna/ChatManager.ts @@ -1,5 +1,5 @@ -import {EternaSettings} from 'eterna/settings'; import * as log from 'loglevel'; +import EternaSettings from './settings/EternaSettings'; export default class ChatManager { constructor(chatboxID: string, settings: EternaSettings) { diff --git a/src/eterna/EPars.ts b/src/eterna/EPars.ts index 87d187a26..5efce1c11 100644 --- a/src/eterna/EPars.ts +++ b/src/eterna/EPars.ts @@ -1,4 +1,4 @@ -import {StyledTextBuilder} from 'flashbang/util'; +import {StyledTextBuilder} from 'flashbang'; import IntLoopPars from 'eterna/IntLoopPars'; export default class EPars { diff --git a/src/eterna/Eterna.ts b/src/eterna/Eterna.ts index 91c6ced98..aab47dcca 100644 --- a/src/eterna/Eterna.ts +++ b/src/eterna/Eterna.ts @@ -1,13 +1,10 @@ import * as log from 'loglevel'; -import {Flashbang} from 'flashbang/core'; -import {SaveGameManager} from 'flashbang/settings'; -import {ErrorUtil} from 'flashbang/util'; +import {SaveGameManager, ErrorUtil, Flashbang} from 'flashbang'; import ChatManager from 'eterna/ChatManager'; import EternaApp from 'eterna/EternaApp'; -import {ErrorDialogMode} from 'eterna/mode'; -import {GameClient} from 'eterna/net'; -import {EternaSettings} from 'eterna/settings'; -import {SoundManager} from 'eterna/resources'; +import EternaSettings from './settings/EternaSettings'; +import GameClient from './net/GameClient'; +import ErrorDialogMode from './mode/ErrorDialogMode'; /** Return env.APP_SERVER_URL; if unspecified, default to window.location.origin */ function GetServerURL(): string { @@ -34,7 +31,6 @@ export default class Eterna { public static settings: EternaSettings; public static saveManager: SaveGameManager; public static client: GameClient; - public static sound: SoundManager; public static chat: ChatManager; public static playerID: number; diff --git a/src/eterna/EternaApp.ts b/src/eterna/EternaApp.ts index 3d613d7a3..f6b6a269d 100644 --- a/src/eterna/EternaApp.ts +++ b/src/eterna/EternaApp.ts @@ -1,25 +1,33 @@ import 'assets/styles.css'; // css-loader will pick up on this and embed our stylesheet import * as log from 'loglevel'; -import {FlashbangApp} from 'flashbang/core'; -import {SaveGameManager} from 'flashbang/settings'; -import {ErrorUtil, TextureUtil} from 'flashbang/util'; +import { + FlashbangApp, SaveGameManager, TextureUtil, ErrorUtil, Flashbang +} from 'flashbang'; import ChatManager from 'eterna/ChatManager'; -import {TestMode} from 'eterna/debug'; import Eterna from 'eterna/Eterna'; -import { - Folder, FolderManager, LinearFoldC, LinearFoldV, NuPACK, RNAFoldBasic, Vienna, Vienna2 -} from 'eterna/folding'; -import { - LoadingMode, FeedbackViewMode, DesignBrowserFilter, DesignBrowserMode, - PoseEditMode, PoseEditParams, PuzzleEditMode, PuzzleEditPoseData -} from 'eterna/mode'; -import {GameClient} from 'eterna/net'; -import { - Puzzle, PuzzleManager, Solution, SolutionManager -} from 'eterna/puzzle'; -import {Bitmaps, SoundManager} from 'eterna/resources'; -import {EternaSettings} from 'eterna/settings'; -import {ExternalInterface, ExternalInterfaceCtx, Fonts} from 'eterna/util'; +import DesignBrowserMode, {DesignBrowserFilter} from './mode/DesignBrowser/DesignBrowserMode'; +import ExternalInterface, {ExternalInterfaceCtx} from './util/ExternalInterface'; +import EternaSettings from './settings/EternaSettings'; +import GameClient from './net/GameClient'; +import Bitmaps from './resources/Bitmaps'; +import Fonts from './util/Fonts'; +import TestMode from './debug/TestMode'; +import Puzzle from './puzzle/Puzzle'; +import PoseEditMode, {PoseEditParams} from './mode/PoseEdit/PoseEditMode'; +import PuzzleEditMode, {PuzzleEditPoseData} from './mode/PuzzleEdit/PuzzleEditMode'; +import FeedbackViewMode from './mode/FeedbackViewMode'; +import Solution from './puzzle/Solution'; +import PuzzleManager from './puzzle/PuzzleManager'; +import SolutionManager from './puzzle/SolutionManager'; +import LoadingMode from './mode/LoadingMode'; +import Vienna from './folding/Vienna'; +import Vienna2 from './folding/Vienna2'; +import NuPACK from './folding/NuPACK'; +import RNAFoldBasic from './folding/RNAFoldBasic'; +import FolderManager from './folding/FolderManager'; +import LinearFoldC from './folding/LinearFoldC'; +import LinearFoldV from './folding/LinearFoldV'; +import Folder from './folding/Folder'; enum PuzzleID { FunAndEasy = 4350940, @@ -115,10 +123,17 @@ export default class EternaApp extends FlashbangApp { Eterna.saveManager = new SaveGameManager('EternaSaveGame'); Eterna.settings = new EternaSettings(); Eterna.client = new GameClient(Eterna.SERVER_URL); - Eterna.sound = new SoundManager(Eterna.settings); Eterna.chat = new ChatManager(this._params.chatboxID, Eterna.settings); Eterna.gameDiv = document.getElementById(this._params.containerID); + this._regs.add(Eterna.settings.soundMute.connectNotify((mute) => { + Flashbang.sound.muted = mute; + })); + + this._regs.add(Eterna.settings.soundVolume.connectNotify((volume) => { + Flashbang.sound.volume = volume; + })); + this.setLoadingText('Authenticating...'); this.authenticate() diff --git a/src/eterna/ExpPainter.ts b/src/eterna/ExpPainter.ts index 3172ae27d..2c7bfada6 100644 --- a/src/eterna/ExpPainter.ts +++ b/src/eterna/ExpPainter.ts @@ -1,5 +1,5 @@ +import {MathUtil, ColorUtil} from 'flashbang'; import Constants from 'eterna/Constants'; -import {ColorUtil, MathUtil} from 'flashbang/util'; export default class ExpPainter { public static readonly NUM_COLORS = 5; diff --git a/src/eterna/Plot.ts b/src/eterna/Plot.ts index a2e4af8c1..e329a659a 100644 --- a/src/eterna/Plot.ts +++ b/src/eterna/Plot.ts @@ -1,6 +1,6 @@ import {Graphics, Text, Container} from 'pixi.js'; -import {ColorUtil} from 'flashbang/util'; -import {Fonts} from 'eterna/util'; +import {ColorUtil} from 'flashbang'; +import Fonts from './util/Fonts'; export enum PlotType { LINE, BAR, SCATTER diff --git a/src/eterna/UndoBlock.ts b/src/eterna/UndoBlock.ts index 4345b1ad9..f50585f01 100644 --- a/src/eterna/UndoBlock.ts +++ b/src/eterna/UndoBlock.ts @@ -1,9 +1,9 @@ -import {JSONUtil} from 'flashbang/util'; +import {JSONUtil} from 'flashbang'; import EPars from 'eterna/EPars'; -import {Folder} from 'eterna/folding'; import Plot, {PlotType} from 'eterna/Plot'; -import {Oligo, Pose2D} from 'eterna/pose2D'; -import {Utility} from './util'; +import Pose2D, {Oligo} from './pose2D/Pose2D'; +import Folder from './folding/Folder'; +import Utility from './util/Utility'; export enum UndoBlockParam { GU = 0, diff --git a/src/eterna/achievements/AchievementBox.ts b/src/eterna/achievements/AchievementBox.ts index 716c362fd..0d361ffc2 100644 --- a/src/eterna/achievements/AchievementBox.ts +++ b/src/eterna/achievements/AchievementBox.ts @@ -1,14 +1,14 @@ import * as log from 'loglevel'; import {Point, Sprite, Text} from 'pixi.js'; -import {ContainerObject} from 'flashbang/objects'; import { - AlphaTask, DelayTask, ParallelTask, ScaleTask, SerialTask -} from 'flashbang/tasks'; -import {Easing, TextureUtil} from 'flashbang/util'; -import {PlaySoundTask, Sounds} from 'eterna/resources'; -import {GameButton, GamePanel, GamePanelType} from 'eterna/ui'; -import {Fonts} from 'eterna/util'; -import {VibrateTask} from 'eterna/vfx'; + ContainerObject, TextureUtil, SerialTask, DelayTask, ParallelTask, AlphaTask, ScaleTask, Easing +} from 'flashbang'; +import GameButton from 'eterna/ui/GameButton'; +import GamePanel, {GamePanelType} from 'eterna/ui/GamePanel'; +import Fonts from 'eterna/util/Fonts'; +import PlaySoundTask from 'eterna/resources/PlaySoundTask'; +import Sounds from 'eterna/resources/Sounds'; +import VibrateTask from 'eterna/vfx/VibrateTask'; export default class AchievementBox extends ContainerObject { constructor(imageURL: string, text: string) { diff --git a/src/eterna/achievements/AchievementManager.ts b/src/eterna/achievements/AchievementManager.ts index b007603c7..ea8176a9c 100644 --- a/src/eterna/achievements/AchievementManager.ts +++ b/src/eterna/achievements/AchievementManager.ts @@ -1,9 +1,7 @@ import { - HAlign, VAlign, GameObject, GameObjectRef -} from 'flashbang/core'; -import {CallbackTask, FunctionTask, SerialTask} from 'flashbang/tasks'; -import {DisplayUtil} from 'flashbang/util'; -import {GameMode} from 'eterna/mode'; + GameObject, GameObjectRef, SerialTask, FunctionTask, CallbackTask, DisplayUtil, HAlign, VAlign +} from 'flashbang'; +import GameMode from 'eterna/mode/GameMode'; import AchievementBox from './AchievementBox'; export default class AchievementManager extends GameObject { diff --git a/src/eterna/achievements/index.ts b/src/eterna/achievements/index.ts deleted file mode 100644 index ffeb7d7aa..000000000 --- a/src/eterna/achievements/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export {default as AchievementBox} from './AchievementBox'; -export {default as AchievementManager} from './AchievementManager'; diff --git a/src/eterna/debug/TestMode.ts b/src/eterna/debug/TestMode.ts index 9aa6d010a..b2b8c5927 100644 --- a/src/eterna/debug/TestMode.ts +++ b/src/eterna/debug/TestMode.ts @@ -1,8 +1,9 @@ -import {GameMode} from '../mode'; -import {ViewSolutionDialog} from '../mode/DesignBrowser'; -import { - Puzzle, PuzzleManager, Solution, SolutionManager -} from '../puzzle'; +import GameMode from 'eterna/mode/GameMode'; +import PuzzleManager from 'eterna/puzzle/PuzzleManager'; +import Puzzle from 'eterna/puzzle/Puzzle'; +import SolutionManager from 'eterna/puzzle/SolutionManager'; +import Solution from 'eterna/puzzle/Solution'; +import ViewSolutionDialog from 'eterna/mode/DesignBrowser/ViewSolutionDialog'; export default class TestMode extends GameMode { protected setup(): void { diff --git a/src/eterna/debug/index.ts b/src/eterna/debug/index.ts deleted file mode 100644 index faa24a290..000000000 --- a/src/eterna/debug/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -/* eslint-disable import/prefer-default-export */ -export {default as TestMode} from './TestMode'; diff --git a/src/eterna/emscripten/index.ts b/src/eterna/emscripten/index.ts deleted file mode 100644 index 4fc976bea..000000000 --- a/src/eterna/emscripten/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -/* eslint-disable import/prefer-default-export */ -export {default as EmscriptenUtil} from './EmscriptenUtil'; diff --git a/src/eterna/folding/Folder.ts b/src/eterna/folding/Folder.ts index 626bc7ede..5eb01afc4 100644 --- a/src/eterna/folding/Folder.ts +++ b/src/eterna/folding/Folder.ts @@ -1,4 +1,4 @@ -import {PoseOp} from 'eterna/pose2D'; +import PoseOp from 'eterna/pose2D/PoseOp'; export default abstract class Folder { public abstract get name (): string; diff --git a/src/eterna/folding/LinearFoldBase.ts b/src/eterna/folding/LinearFoldBase.ts index 72190d340..10087e388 100644 --- a/src/eterna/folding/LinearFoldBase.ts +++ b/src/eterna/folding/LinearFoldBase.ts @@ -1,5 +1,5 @@ import * as log from 'loglevel'; -import {EmscriptenUtil} from 'eterna/emscripten'; +import EmscriptenUtil from 'eterna/emscripten/EmscriptenUtil'; import EPars from 'eterna/EPars'; /* eslint-disable import/no-duplicates, import/no-unresolved */ import * as LinearFoldLib from './engines/LinearFoldLib'; diff --git a/src/eterna/folding/LinearFoldC.ts b/src/eterna/folding/LinearFoldC.ts index c7a331801..764cd8a26 100644 --- a/src/eterna/folding/LinearFoldC.ts +++ b/src/eterna/folding/LinearFoldC.ts @@ -1,4 +1,4 @@ -import {EmscriptenUtil} from 'eterna/emscripten'; +import EmscriptenUtil from 'eterna/emscripten/EmscriptenUtil'; import LinearFoldBase from './LinearFoldBase'; export default class LinearFoldC extends LinearFoldBase { diff --git a/src/eterna/folding/LinearFoldV.ts b/src/eterna/folding/LinearFoldV.ts index a9f3ee67b..a92c7e0ea 100644 --- a/src/eterna/folding/LinearFoldV.ts +++ b/src/eterna/folding/LinearFoldV.ts @@ -1,4 +1,4 @@ -import {EmscriptenUtil} from 'eterna/emscripten'; +import EmscriptenUtil from 'eterna/emscripten/EmscriptenUtil'; import LinearFoldBase from './LinearFoldBase'; export default class LinearFoldV extends LinearFoldBase { diff --git a/src/eterna/folding/NuPACK.ts b/src/eterna/folding/NuPACK.ts index 111df942c..8eadfd890 100644 --- a/src/eterna/folding/NuPACK.ts +++ b/src/eterna/folding/NuPACK.ts @@ -1,9 +1,9 @@ import * as log from 'loglevel'; -import {EmscriptenUtil} from 'eterna/emscripten'; import EPars from 'eterna/EPars'; -import {PoseOp} from 'eterna/pose2D'; -import {int} from 'eterna/util'; /* eslint-disable import/no-duplicates, import/no-unresolved */ +import EmscriptenUtil from 'eterna/emscripten/EmscriptenUtil'; +import PoseOp from 'eterna/pose2D/PoseOp'; +import int from 'eterna/util/int'; import * as NupackLib from './engines/NupackLib'; import {DotPlotResult, FullEvalResult, FullFoldResult} from './engines/NupackLib'; /* eslint-enable import/no-duplicates, import/no-unresolved */ diff --git a/src/eterna/folding/Vienna.ts b/src/eterna/folding/Vienna.ts index f8aa55e76..a30c7f2a1 100644 --- a/src/eterna/folding/Vienna.ts +++ b/src/eterna/folding/Vienna.ts @@ -1,9 +1,9 @@ import * as log from 'loglevel'; -import {EmscriptenUtil} from 'eterna/emscripten'; import EPars from 'eterna/EPars'; -import {RNALayout} from 'eterna/pose2D'; -import {Utility} from 'eterna/util'; /* eslint-disable import/no-duplicates, import/no-unresolved */ +import EmscriptenUtil from 'eterna/emscripten/EmscriptenUtil'; +import Utility from 'eterna/util/Utility'; +import RNALayout from 'eterna/pose2D/RNALayout'; import * as ViennaLib from './engines/ViennaLib'; import {DotPlotResult, FullEvalResult, FullFoldResult} from './engines/ViennaLib'; /* eslint-enable import/no-duplicates, import/no-unresolved */ diff --git a/src/eterna/folding/Vienna2.ts b/src/eterna/folding/Vienna2.ts index b1cd5df9f..151dd7578 100644 --- a/src/eterna/folding/Vienna2.ts +++ b/src/eterna/folding/Vienna2.ts @@ -1,9 +1,9 @@ import * as log from 'loglevel'; -import {EmscriptenUtil} from 'eterna/emscripten'; import EPars from 'eterna/EPars'; -import {RNALayout} from 'eterna/pose2D'; -import {Utility} from 'eterna/util'; /* eslint-disable import/no-duplicates, import/no-unresolved */ +import EmscriptenUtil from 'eterna/emscripten/EmscriptenUtil'; +import Utility from 'eterna/util/Utility'; +import RNALayout from 'eterna/pose2D/RNALayout'; import * as Vienna2Lib from './engines/Viena2Lib'; import {DotPlotResult, FullEvalResult, FullFoldResult} from './engines/Viena2Lib'; /* eslint-enable import/no-duplicates, import/no-unresolved */ diff --git a/src/eterna/folding/__tests__/Folder.test.ts b/src/eterna/folding/__tests__/Folder.test.ts index 6c795870b..24d2b8407 100644 --- a/src/eterna/folding/__tests__/Folder.test.ts +++ b/src/eterna/folding/__tests__/Folder.test.ts @@ -1,6 +1,3 @@ -// Build order issues -import "eterna/EternaApp"; - import EPars from "eterna/EPars"; import Folder from "../Folder"; import NuPACK from "../NuPACK"; diff --git a/src/eterna/folding/index.ts b/src/eterna/folding/index.ts deleted file mode 100644 index 83fb4add5..000000000 --- a/src/eterna/folding/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -export {default as Folder} from './Folder'; -export {default as FolderManager} from './FolderManager'; -export {default as FoldUtil} from './FoldUtil'; -export {default as LinearFoldBase} from './LinearFoldBase'; -export {default as LinearFoldC} from './LinearFoldC'; -export {default as LinearFoldV} from './LinearFoldV'; -export {default as NuPACK} from './NuPACK'; -export {default as RNAFoldBasic} from './RNAFoldBasic'; -export {default as Vienna} from './Vienna'; -export {default as Vienna2} from './Vienna2'; diff --git a/src/eterna/mode/CopyTextDialogMode.ts b/src/eterna/mode/CopyTextDialogMode.ts index fb12e67d0..545ab7394 100644 --- a/src/eterna/mode/CopyTextDialogMode.ts +++ b/src/eterna/mode/CopyTextDialogMode.ts @@ -1,7 +1,6 @@ import {Graphics} from 'pixi.js'; -import {Flashbang, AppMode} from 'flashbang/core'; -import {KeyCode} from 'flashbang/input'; -import {TextInputPanel} from 'eterna/ui'; +import {AppMode, Flashbang, KeyCode} from 'flashbang'; +import TextInputPanel from 'eterna/ui/TextInputPanel'; /** Show a dialog with text that the user can copy */ export default class CopyTextDialogMode extends AppMode { diff --git a/src/eterna/mode/DesignBrowser/CustomizeColumnOrderDialog.ts b/src/eterna/mode/DesignBrowser/CustomizeColumnOrderDialog.ts index fd3276810..862862dfb 100644 --- a/src/eterna/mode/DesignBrowser/CustomizeColumnOrderDialog.ts +++ b/src/eterna/mode/DesignBrowser/CustomizeColumnOrderDialog.ts @@ -1,13 +1,15 @@ import {Container, Point, Text} from 'pixi.js'; -import {HAlign, VAlign} from 'flashbang/core'; -import {HLayoutContainer, VLayoutContainer} from 'flashbang/layout'; -import {Arrays, DisplayUtil} from 'flashbang/util'; import {Signal} from 'signals'; -import {Bitmaps} from 'eterna/resources'; +import Dialog from 'eterna/ui/Dialog'; +import GamePanel, {GamePanelType} from 'eterna/ui/GamePanel'; import { - Dialog, FixedWidthTextField, GameButton, GamePanel, GamePanelType -} from 'eterna/ui'; -import {Fonts, GraphicsUtil} from 'eterna/util'; + HAlign, VLayoutContainer, HLayoutContainer, Arrays, DisplayUtil, VAlign +} from 'flashbang'; +import GameButton from 'eterna/ui/GameButton'; +import GraphicsUtil from 'eterna/util/GraphicsUtil'; +import FixedWidthTextField from 'eterna/ui/FixedWidthTextField'; +import Fonts from 'eterna/util/Fonts'; +import Bitmaps from 'eterna/resources/Bitmaps'; import {DesignCategory} from './DesignBrowserMode'; export default class CustomizeColumnOrderDialog extends Dialog { diff --git a/src/eterna/mode/DesignBrowser/DataCol.ts b/src/eterna/mode/DesignBrowser/DataCol.ts index 1037fbb59..74ceda037 100644 --- a/src/eterna/mode/DesignBrowser/DataCol.ts +++ b/src/eterna/mode/DesignBrowser/DataCol.ts @@ -1,17 +1,18 @@ import { Container, Graphics, Point, Text } from 'pixi.js'; -import {Flashbang} from 'flashbang/core'; -import {ContainerObject} from 'flashbang/objects'; -import {TextBuilder} from 'flashbang/util'; import {Signal, UnitSignal} from 'signals'; +import {ContainerObject, TextBuilder, Flashbang} from 'flashbang'; import Feedback from 'eterna/Feedback'; -import {Solution} from 'eterna/puzzle'; -import {GameButton, TextInputObject} from 'eterna/ui'; -import {Fonts, int, Utility} from 'eterna/util'; -import {DesignBrowserDataType, DesignCategory} from './DesignBrowserMode'; -import SequenceStringListView from './SequenceStringListView'; +import GameButton from 'eterna/ui/GameButton'; +import TextInputObject from 'eterna/ui/TextInputObject'; +import Fonts from 'eterna/util/Fonts'; +import Solution from 'eterna/puzzle/Solution'; +import int from 'eterna/util/int'; +import Utility from 'eterna/util/Utility'; import {SortOrder} from './SortOptions'; +import SequenceStringListView from './SequenceStringListView'; +import {DesignBrowserDataType, DesignCategory} from './DesignBrowserMode'; export default class DataCol extends ContainerObject { public readonly sortOrderChanged = new Signal(); diff --git a/src/eterna/mode/DesignBrowser/DesignBrowserMode.ts b/src/eterna/mode/DesignBrowser/DesignBrowserMode.ts index 4c7eda17d..62d6b47d3 100644 --- a/src/eterna/mode/DesignBrowser/DesignBrowserMode.ts +++ b/src/eterna/mode/DesignBrowser/DesignBrowserMode.ts @@ -3,33 +3,36 @@ import MultiStyleText from 'pixi-multistyle-text'; import { Container, Graphics, Point, Sprite, Text } from 'pixi.js'; -import {Flashbang, HAlign, VAlign} from 'flashbang/core'; -import {HLayoutContainer} from 'flashbang/layout'; -import {ContainerObject, SceneObject} from 'flashbang/objects'; -import { - AlphaTask, CallbackTask, DelayTask, LocationTask, RepeatingTask, SerialTask -} from 'flashbang/tasks'; -import {DisplayUtil, Easing, MathUtil} from 'flashbang/util'; import EPars from 'eterna/EPars'; import Eterna from 'eterna/Eterna'; import Feedback from 'eterna/Feedback'; -import {Puzzle, Solution, SolutionManager} from 'eterna/puzzle'; -import {BitmapManager, Bitmaps} from 'eterna/resources'; +import GameMode from 'eterna/mode/GameMode'; +import Puzzle from 'eterna/puzzle/Puzzle'; +import GamePanel from 'eterna/ui/GamePanel'; +import Fonts from 'eterna/util/Fonts'; +import SliderBar from 'eterna/ui/SliderBar'; import { - GameButton, GamePanel, HTMLTextObject, SliderBar, URLButton -} from 'eterna/ui'; -import {Fonts, int} from 'eterna/util'; -import {GameMode} from 'eterna/mode'; -import CustomizeColumnOrderDialog from './CustomizeColumnOrderDialog'; -import DataCol from './DataCol'; -import DotLine from './DotLine'; -import GridLines from './GridLines'; -import MarkerBoxView from './MarkerBoxView'; -import SelectionBox from './SelectionBox'; -import SortOptions, {SortOrder} from './SortOptions'; -import SortOptionsDialog from './SortOptionsDialog'; -import ViewSolutionDialog from './ViewSolutionDialog'; + ContainerObject, DisplayUtil, HAlign, VAlign, RepeatingTask, SerialTask, DelayTask, CallbackTask, + MathUtil, Flashbang, SceneObject, AlphaTask, LocationTask, Easing, HLayoutContainer +} from 'flashbang'; +import GameButton from 'eterna/ui/GameButton'; +import Bitmaps from 'eterna/resources/Bitmaps'; +import BitmapManager from 'eterna/resources/BitmapManager'; +import HTMLTextObject from 'eterna/ui/HTMLTextObject'; +import Solution from 'eterna/puzzle/Solution'; +import SolutionManager from 'eterna/puzzle/SolutionManager'; +import URLButton from 'eterna/ui/URLButton'; +import int from 'eterna/util/int'; import VoteProcessor from './VoteProcessor'; +import ViewSolutionDialog from './ViewSolutionDialog'; +import SortOptionsDialog from './SortOptionsDialog'; +import SortOptions, {SortOrder} from './SortOptions'; +import SelectionBox from './SelectionBox'; +import MarkerBoxView from './MarkerBoxView'; +import GridLines from './GridLines'; +import DotLine from './DotLine'; +import DataCol from './DataCol'; +import CustomizeColumnOrderDialog from './CustomizeColumnOrderDialog'; export enum DesignBrowserDataType { INT = 0, diff --git a/src/eterna/mode/DesignBrowser/LabComments.ts b/src/eterna/mode/DesignBrowser/LabComments.ts index bca59f860..2665e8f10 100644 --- a/src/eterna/mode/DesignBrowser/LabComments.ts +++ b/src/eterna/mode/DesignBrowser/LabComments.ts @@ -1,5 +1,5 @@ import Eterna from 'eterna/Eterna'; -import {Utility} from 'eterna/util'; +import Utility from 'eterna/util/Utility'; export default class LabComments { constructor(nid: number) { diff --git a/src/eterna/mode/DesignBrowser/SequenceStringListView.ts b/src/eterna/mode/DesignBrowser/SequenceStringListView.ts index 8de60f3bb..24edcf742 100644 --- a/src/eterna/mode/DesignBrowser/SequenceStringListView.ts +++ b/src/eterna/mode/DesignBrowser/SequenceStringListView.ts @@ -1,12 +1,12 @@ import { Container, Graphics, Sprite, Texture } from 'pixi.js'; -import {TextBuilder, TextureUtil} from 'flashbang/util'; +import {TextBuilder, TextureUtil} from 'flashbang'; import EPars from 'eterna/EPars'; import Eterna from 'eterna/Eterna'; import ExpPainter from 'eterna/ExpPainter'; import Feedback from 'eterna/Feedback'; -import {EternaTextureUtil} from 'eterna/util'; +import EternaTextureUtil from 'eterna/util/EternaTextureUtil'; export default class SequenceStringListView extends Container { constructor(fontname: string, fontsize: number, fontbold: boolean, letterWidth: number, letterHeight: number) { diff --git a/src/eterna/mode/DesignBrowser/SolutionDescBox.ts b/src/eterna/mode/DesignBrowser/SolutionDescBox.ts index 6e2302274..69bb0f59e 100644 --- a/src/eterna/mode/DesignBrowser/SolutionDescBox.ts +++ b/src/eterna/mode/DesignBrowser/SolutionDescBox.ts @@ -1,20 +1,23 @@ import MultiStyleText from 'pixi-multistyle-text'; import {Point, Text} from 'pixi.js'; -import {HAlign} from 'flashbang/core'; -import {HLayoutContainer, VLayoutContainer} from 'flashbang/layout'; -import {SceneObject} from 'flashbang/objects'; -import {AlphaTask, RepeatingTask, SerialTask} from 'flashbang/tasks'; -import {Assert} from 'flashbang/util'; import Eterna from 'eterna/Eterna'; import Feedback from 'eterna/Feedback'; -import {EternaURL} from 'eterna/net'; -import {Puzzle, Solution} from 'eterna/puzzle'; +import GamePanel, {GamePanelType} from 'eterna/ui/GamePanel'; +import Puzzle from 'eterna/puzzle/Puzzle'; +import Solution from 'eterna/puzzle/Solution'; +import EternaURL from 'eterna/net/EternaURL'; +import Utility from 'eterna/util/Utility'; +import HTMLTextObject from 'eterna/ui/HTMLTextObject'; +import Fonts from 'eterna/util/Fonts'; +import GameButton from 'eterna/ui/GameButton'; +import TextInputObject from 'eterna/ui/TextInputObject'; +import VScrollBox from 'eterna/ui/VScrollBox'; import { - GameButton, GamePanel, GamePanelType, HTMLTextObject, TextInputObject, VScrollBox -} from 'eterna/ui'; -import {Fonts, Utility} from 'eterna/util'; -import {CopyTextDialogMode, GameMode} from 'eterna/mode'; + VLayoutContainer, HAlign, HLayoutContainer, SceneObject, RepeatingTask, SerialTask, AlphaTask +} from 'flashbang'; +import CopyTextDialogMode from '../CopyTextDialogMode'; import LabComments from './LabComments'; +import GameMode from '../GameMode'; export default class SolutionDescBox extends GamePanel { constructor(solution: Solution, puzzle: Puzzle) { diff --git a/src/eterna/mode/DesignBrowser/SortOptions.ts b/src/eterna/mode/DesignBrowser/SortOptions.ts index c0ee2c2e1..2ca5e36dd 100644 --- a/src/eterna/mode/DesignBrowser/SortOptions.ts +++ b/src/eterna/mode/DesignBrowser/SortOptions.ts @@ -1,6 +1,6 @@ -import {Arrays} from 'flashbang/util'; import {UnitSignal} from 'signals'; -import {Solution} from 'eterna/puzzle'; +import {Arrays} from 'flashbang'; +import Solution from 'eterna/puzzle/Solution'; import {DesignCategory} from './DesignBrowserMode'; export enum SortOrder { diff --git a/src/eterna/mode/DesignBrowser/SortOptionsDialog.ts b/src/eterna/mode/DesignBrowser/SortOptionsDialog.ts index edb5b1df1..fca12cb09 100644 --- a/src/eterna/mode/DesignBrowser/SortOptionsDialog.ts +++ b/src/eterna/mode/DesignBrowser/SortOptionsDialog.ts @@ -1,16 +1,18 @@ import { Container, Graphics, Point, Text } from 'pixi.js'; -import {HAlign, VAlign} from 'flashbang/core'; -import {HLayoutContainer, VLayoutContainer} from 'flashbang/layout'; -import {Arrays, DisplayUtil} from 'flashbang/util'; -import {Bitmaps} from 'eterna/resources'; +import GamePanel, {GamePanelType} from 'eterna/ui/GamePanel'; +import Dialog from 'eterna/ui/Dialog'; import { - Dialog, FixedWidthTextField, GameButton, GamePanel, GamePanelType -} from 'eterna/ui'; -import {Fonts, GraphicsUtil} from 'eterna/util'; -import {DesignCategory} from './DesignBrowserMode'; + VLayoutContainer, HAlign, HLayoutContainer, Arrays, VAlign, DisplayUtil +} from 'flashbang'; +import GraphicsUtil from 'eterna/util/GraphicsUtil'; +import GameButton from 'eterna/ui/GameButton'; +import FixedWidthTextField from 'eterna/ui/FixedWidthTextField'; +import Fonts from 'eterna/util/Fonts'; +import Bitmaps from 'eterna/resources/Bitmaps'; import SortOptions, {SortOrder} from './SortOptions'; +import {DesignCategory} from './DesignBrowserMode'; export default class SortOptionsDialog extends Dialog { public readonly options: SortOptions; diff --git a/src/eterna/mode/DesignBrowser/ViewSolutionDialog.ts b/src/eterna/mode/DesignBrowser/ViewSolutionDialog.ts index a39f5c60a..e23c3cefe 100644 --- a/src/eterna/mode/DesignBrowser/ViewSolutionDialog.ts +++ b/src/eterna/mode/DesignBrowser/ViewSolutionDialog.ts @@ -1,19 +1,21 @@ import { Container, Graphics, Point, Sprite, Text } from 'pixi.js'; -import {Flashbang, HAlign, VAlign} from 'flashbang/core'; -import {HLayoutContainer} from 'flashbang/layout'; -import {DisplayUtil, MathUtil} from 'flashbang/util'; import {UnitSignal} from 'signals'; import EPars from 'eterna/EPars'; import Eterna from 'eterna/Eterna'; import ExpPainter from 'eterna/ExpPainter'; -import {Puzzle, Solution} from 'eterna/puzzle'; -import {Bitmaps} from 'eterna/resources'; +import Dialog from 'eterna/ui/Dialog'; +import Solution from 'eterna/puzzle/Solution'; +import Puzzle from 'eterna/puzzle/Puzzle'; +import GamePanel from 'eterna/ui/GamePanel'; import { - Dialog, GameButton, GamePanel, PoseThumbnail, PoseThumbnailType -} from 'eterna/ui'; -import {Fonts} from 'eterna/util'; + HLayoutContainer, MathUtil, Flashbang, DisplayUtil, HAlign, VAlign +} from 'flashbang'; +import PoseThumbnail, {PoseThumbnailType} from 'eterna/ui/PoseThumbnail'; +import Bitmaps from 'eterna/resources/Bitmaps'; +import GameButton from 'eterna/ui/GameButton'; +import Fonts from 'eterna/util/Fonts'; import SolutionDescBox from './SolutionDescBox'; export default class ViewSolutionDialog extends Dialog { diff --git a/src/eterna/mode/DesignBrowser/VoteProcessor.ts b/src/eterna/mode/DesignBrowser/VoteProcessor.ts index 07a2894fa..a5ef919fc 100644 --- a/src/eterna/mode/DesignBrowser/VoteProcessor.ts +++ b/src/eterna/mode/DesignBrowser/VoteProcessor.ts @@ -1,6 +1,6 @@ import Eterna from 'eterna/Eterna'; -import {SolutionManager} from 'eterna/puzzle'; -import {int} from 'eterna/util'; +import int from 'eterna/util/int'; +import SolutionManager from 'eterna/puzzle/SolutionManager'; export default class VoteProcessor { public processData(data: any[]): void { diff --git a/src/eterna/mode/DesignBrowser/index.ts b/src/eterna/mode/DesignBrowser/index.ts deleted file mode 100644 index 7148d2de8..000000000 --- a/src/eterna/mode/DesignBrowser/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -export {default as CustomizeColumnOrderDialog} from './CustomizeColumnOrderDialog'; -export {default as DataCol} from './DataCol'; -export { - default as DesignBrowserMode, DesignBrowserDataType, DesignCategory, DesignBrowserFilter -} from './DesignBrowserMode'; -export {default as DotLine} from './DotLine'; -export {default as GridLines} from './GridLines'; -export {default as LabComments} from './LabComments'; -export {default as MarkerBoxView} from './MarkerBoxView'; -export {default as SelectionBox} from './SelectionBox'; -export {default as SequenceStringListView} from './SequenceStringListView'; -export {default as SolutionDescBox} from './SolutionDescBox'; -export {default as SortOptions, SortOrder, SortCriterion} from './SortOptions'; -export {default as SortOptionsDialog} from './SortOptionsDialog'; -export {default as ViewSolutionDialog} from './ViewSolutionDialog'; -export {default as VoteProcessor} from './VoteProcessor'; diff --git a/src/eterna/mode/ErrorDialogMode.ts b/src/eterna/mode/ErrorDialogMode.ts index cb167557d..400134996 100644 --- a/src/eterna/mode/ErrorDialogMode.ts +++ b/src/eterna/mode/ErrorDialogMode.ts @@ -1,9 +1,10 @@ import {Graphics, Point} from 'pixi.js'; -import {Flashbang, HAlign, AppMode} from 'flashbang/core'; -import {VLayoutContainer} from 'flashbang/layout'; -import {ErrorUtil} from 'flashbang/util'; -import {GameButton, GamePanel, GamePanelType} from 'eterna/ui'; -import {Fonts} from 'eterna/util'; +import GamePanel, {GamePanelType} from 'eterna/ui/GamePanel'; +import { + VLayoutContainer, HAlign, ErrorUtil, Flashbang, AppMode +} from 'flashbang'; +import Fonts from 'eterna/util/Fonts'; +import GameButton from 'eterna/ui/GameButton'; export default class ErrorDialogMode extends AppMode { public readonly error: any; diff --git a/src/eterna/mode/FeedbackViewMode.ts b/src/eterna/mode/FeedbackViewMode.ts index fb4316907..514a651ea 100644 --- a/src/eterna/mode/FeedbackViewMode.ts +++ b/src/eterna/mode/FeedbackViewMode.ts @@ -1,22 +1,27 @@ import * as log from 'loglevel'; import {DisplayObject, Point, Text} from 'pixi.js'; -import {HAlign, VAlign} from 'flashbang/core'; -import {KeyboardEventType, KeyCode} from 'flashbang/input'; -import {DisplayUtil} from 'flashbang/util'; import Constants from 'eterna/Constants'; import EPars from 'eterna/EPars'; import Eterna from 'eterna/Eterna'; import Feedback from 'eterna/Feedback'; import UndoBlock from 'eterna/UndoBlock'; -import {Folder, FolderManager, Vienna} from 'eterna/folding'; -import {GameMode} from 'eterna/mode'; -import {PoseField} from 'eterna/pose2D'; -import {Puzzle, Solution} from 'eterna/puzzle'; +import Solution from 'eterna/puzzle/Solution'; +import Puzzle from 'eterna/puzzle/Puzzle'; +import Background from 'eterna/vfx/Background'; +import Fonts from 'eterna/util/Fonts'; +import Toolbar, {ToolbarType} from 'eterna/ui/Toolbar'; +import PoseField from 'eterna/pose2D/PoseField'; +import FolderManager from 'eterna/folding/FolderManager'; +import Vienna from 'eterna/folding/Vienna'; import { - EternaViewOptionsDialog, EternaViewOptionsMode, SpecBoxDialog, URLButton, Toolbar, ToolbarType -} from 'eterna/ui'; -import {Fonts, Utility} from 'eterna/util'; -import {Background} from 'eterna/vfx'; + VAlign, HAlign, DisplayUtil, KeyboardEventType, KeyCode +} from 'flashbang'; +import EternaViewOptionsDialog, {EternaViewOptionsMode} from 'eterna/ui/EternaViewOptionsDialog'; +import Utility from 'eterna/util/Utility'; +import SpecBoxDialog from 'eterna/ui/SpecBoxDialog'; +import Folder from 'eterna/folding/Folder'; +import URLButton from 'eterna/ui/URLButton'; +import GameMode from './GameMode'; enum PoseFoldMode { ESTIMATE = 'ESTIMATE', diff --git a/src/eterna/mode/GameMode.ts b/src/eterna/mode/GameMode.ts index 9a2fa0e7a..da0279302 100644 --- a/src/eterna/mode/GameMode.ts +++ b/src/eterna/mode/GameMode.ts @@ -1,18 +1,24 @@ import * as log from 'loglevel'; import {Container, Point} from 'pixi.js'; -import {Flashbang, AppMode, GameObjectRef} from 'flashbang/core'; -import {SceneObject} from 'flashbang/objects'; -import {AchievementManager} from 'eterna/achievements'; import Eterna from 'eterna/Eterna'; -import {EternaURL} from 'eterna/net'; -import {Pose2D, PoseField} from 'eterna/pose2D'; -import { - ConfirmDialog, ContextMenu, Dialog, NotificationDialog, Tooltips, UILockDialog, URLButton -} from 'eterna/ui'; -import {ExternalInterface, ExternalInterfaceCtx} from 'eterna/util'; -import {Folder} from 'eterna/folding'; import UndoBlock from 'eterna/UndoBlock'; import EPars from 'eterna/EPars'; +import { + AppMode, SceneObject, Flashbang, GameObjectRef +} from 'flashbang'; +import AchievementManager from 'eterna/achievements/AchievementManager'; +import Tooltips from 'eterna/ui/Tooltips'; +import ExternalInterface, {ExternalInterfaceCtx} from 'eterna/util/ExternalInterface'; +import Pose2D from 'eterna/pose2D/Pose2D'; +import ConfirmDialog from 'eterna/ui/ConfirmDialog'; +import NotificationDialog from 'eterna/ui/NotificationDialog'; +import UILockDialog from 'eterna/ui/UILockDialog'; +import PoseField from 'eterna/pose2D/PoseField'; +import ContextMenu from 'eterna/ui/ContextMenu'; +import URLButton from 'eterna/ui/URLButton'; +import EternaURL from 'eterna/net/EternaURL'; +import Folder from 'eterna/folding/Folder'; +import Dialog from 'eterna/ui/Dialog'; export default abstract class GameMode extends AppMode { public readonly bgLayer = new Container(); diff --git a/src/eterna/mode/LoadingMode.ts b/src/eterna/mode/LoadingMode.ts index 06c95c412..b7a370988 100644 --- a/src/eterna/mode/LoadingMode.ts +++ b/src/eterna/mode/LoadingMode.ts @@ -1,13 +1,10 @@ import {Text} from 'pixi.js'; -import {Flashbang, AppMode, ObjectTask} from 'flashbang/core'; -import {ContainerObject} from 'flashbang/objects'; import { - DelayTask, RepeatingTask, ScaleTask, SerialTask -} from 'flashbang/tasks'; -import {Easing} from 'flashbang/util'; + AppMode, ContainerObject, SerialTask, DelayTask, RepeatingTask, ObjectTask, ScaleTask, Easing, Flashbang +} from 'flashbang'; +import Background from 'eterna/vfx/Background'; +import Fonts from 'eterna/util/Fonts'; import Eterna from 'eterna/Eterna'; -import {Fonts} from 'eterna/util'; -import {Background} from 'eterna/vfx'; /** Displays a simple animation while we're loading assets */ export default class LoadingMode extends AppMode { diff --git a/src/eterna/mode/PoseEdit/Booster.ts b/src/eterna/mode/PoseEdit/Booster.ts index d3b5b040b..d1588df2e 100644 --- a/src/eterna/mode/PoseEdit/Booster.ts +++ b/src/eterna/mode/PoseEdit/Booster.ts @@ -1,13 +1,12 @@ import * as log from 'loglevel'; import {Texture} from 'pixi.js'; -import {TextureUtil} from 'flashbang/util'; +import {TextureUtil, Flashbang} from 'flashbang'; import EPars from 'eterna/EPars'; -import Eterna from 'eterna/Eterna'; -import {Pose2D} from 'eterna/pose2D'; -import {Sounds} from 'eterna/resources'; -import {GameButton} from 'eterna/ui'; -import {ExternalInterface, ExternalInterfaceCtx} from 'eterna/util'; -import {GameMode} from 'eterna/mode'; +import Pose2D from 'eterna/pose2D/Pose2D'; +import GameButton from 'eterna/ui/GameButton'; +import Sounds from 'eterna/resources/Sounds'; +import ExternalInterface, {ExternalInterfaceCtx} from 'eterna/util/ExternalInterface'; +import GameMode from '../GameMode'; export enum BoosterType { PAINTER = 1, @@ -118,7 +117,7 @@ export default class Booster { } public onPaint(pose: Pose2D, baseNum: number): void { - Eterna.sound.playSound(Sounds.SoundPaint); + Flashbang.sound.playSound(Sounds.SoundPaint); this.executeScript(pose, 'MOUSE_DOWN', baseNum); } @@ -182,7 +181,7 @@ export default class Booster { .then((ret) => { if (useUILock) { this._view.popUILock(LOCK_NAME); - Eterna.sound.playSound( + Flashbang.sound.playSound( ret != null && ret['result'] ? Sounds.SoundScriptDone : Sounds.SoundScriptFail ); } @@ -190,7 +189,7 @@ export default class Booster { .catch(() => { if (useUILock) { this._view.popUILock(LOCK_NAME); - Eterna.sound.playSound(Sounds.SoundScriptFail); + Flashbang.sound.playSound(Sounds.SoundScriptFail); } }); } diff --git a/src/eterna/mode/PoseEdit/MissionClearedPanel.ts b/src/eterna/mode/PoseEdit/MissionClearedPanel.ts index dc251a21b..ef45753ad 100644 --- a/src/eterna/mode/PoseEdit/MissionClearedPanel.ts +++ b/src/eterna/mode/PoseEdit/MissionClearedPanel.ts @@ -1,17 +1,15 @@ import { Container, Graphics, Point, Text } from 'pixi.js'; -import {Flashbang, HAlign, VAlign} from 'flashbang/core'; -import {VLayoutContainer} from 'flashbang/layout'; -import {ContainerObject, DOMObject} from 'flashbang/objects'; -import {AlphaTask} from 'flashbang/tasks'; -import {DisplayUtil} from 'flashbang/util'; -import {RankScroll} from 'eterna/rank'; -import {Bitmaps} from 'eterna/resources'; import { - GameButton, GamePanel, GamePanelType, HTMLTextObject -} from 'eterna/ui'; -import {Fonts} from 'eterna/util'; + ContainerObject, VLayoutContainer, HAlign, DOMObject, AlphaTask, Flashbang, DisplayUtil, VAlign +} from 'flashbang'; +import GameButton from 'eterna/ui/GameButton'; +import Fonts from 'eterna/util/Fonts'; +import HTMLTextObject from 'eterna/ui/HTMLTextObject'; +import GamePanel, {GamePanelType} from 'eterna/ui/GamePanel'; +import Bitmaps from 'eterna/resources/Bitmaps'; +import RankScroll from 'eterna/rank/RankScroll'; export default class MissionClearedPanel extends ContainerObject { public nextButton: GameButton; diff --git a/src/eterna/mode/PoseEdit/MissionIntroMode.ts b/src/eterna/mode/PoseEdit/MissionIntroMode.ts index 3b746c106..319117608 100644 --- a/src/eterna/mode/PoseEdit/MissionIntroMode.ts +++ b/src/eterna/mode/PoseEdit/MissionIntroMode.ts @@ -1,16 +1,17 @@ import { Container, Graphics, Point, Sprite } from 'pixi.js'; -import {Flashbang, AppMode} from 'flashbang/core'; -import {DisplayObjectPointerTarget, InputUtil, KeyCode} from 'flashbang/input'; -import {DisplayUtil, StyledTextBuilder} from 'flashbang/util'; import EPars from 'eterna/EPars'; import Eterna from 'eterna/Eterna'; -import {Bitmaps} from 'eterna/resources'; import { - ConstraintBox, GameButton, HTMLTextObject, PoseThumbnail, PoseThumbnailType -} from 'eterna/ui'; -import {Fonts} from 'eterna/util'; + AppMode, DisplayObjectPointerTarget, InputUtil, StyledTextBuilder, Flashbang, DisplayUtil, KeyCode +} from 'flashbang'; +import ConstraintBox from 'eterna/ui/ConstraintBox'; +import Bitmaps from 'eterna/resources/Bitmaps'; +import Fonts from 'eterna/util/Fonts'; +import GameButton from 'eterna/ui/GameButton'; +import HTMLTextObject from 'eterna/ui/HTMLTextObject'; +import PoseThumbnail, {PoseThumbnailType} from 'eterna/ui/PoseThumbnail'; export default class MissionIntroMode extends AppMode { constructor( diff --git a/src/eterna/mode/PoseEdit/PoseEditMode.ts b/src/eterna/mode/PoseEdit/PoseEditMode.ts index d5138d21e..e91385fae 100644 --- a/src/eterna/mode/PoseEdit/PoseEditMode.ts +++ b/src/eterna/mode/PoseEdit/PoseEditMode.ts @@ -2,42 +2,56 @@ import * as log from 'loglevel'; import { Container, DisplayObject, Point, Sprite, Text } from 'pixi.js'; -import { - Flashbang, HAlign, VAlign, GameObjectRef -} from 'flashbang/core'; -import {KeyboardEventType, KeyCode} from 'flashbang/input'; -import {SpriteObject} from 'flashbang/objects'; -import {AlphaTask, SelfDestructTask, SerialTask} from 'flashbang/tasks'; -import {Assert, DisplayUtil, Easing} from 'flashbang/util'; import EPars from 'eterna/EPars'; import Eterna from 'eterna/Eterna'; -import {Folder, FolderManager, FoldUtil} from 'eterna/folding'; -import {CopyTextDialogMode, GameMode, PuzzleEditPoseData} from 'eterna/mode'; -import {EternaURL} from 'eterna/net'; -import { - Oligo, Pose2D, PoseField, PoseOp, PuzzleEditOp -} from 'eterna/pose2D'; -import { - Constraints, ConstraintType, BoostersData, PoseState, - Puzzle, PuzzleType, PuzzleManager, Solution, SolutionManager -} from 'eterna/puzzle'; -import {BitmapManager, Bitmaps, Sounds} from 'eterna/resources'; -import {RNAScript} from 'eterna/rscript'; -import { - ActionBar, ConstraintBox, ConstraintBoxType, ContextMenu, EternaViewOptionsDialog, EternaViewOptionsMode, - GameButton, GamePanel, HTMLTextObject, GetPaletteTargetBaseType, PaletteTargetType, - PasteSequenceDialog, SpecBox, SpecBoxDialog, URLButton, Toolbar, ToolbarType -} from 'eterna/ui'; import UndoBlock, {UndoBlockParam} from 'eterna/UndoBlock'; +import Solution from 'eterna/puzzle/Solution'; +import Puzzle, {PuzzleType, PoseState, BoostersData} from 'eterna/puzzle/Puzzle'; +import Background from 'eterna/vfx/Background'; +import Toolbar, {ToolbarType} from 'eterna/ui/Toolbar'; +import SpecBox from 'eterna/ui/SpecBox'; +import GameButton from 'eterna/ui/GameButton'; +import Bitmaps from 'eterna/resources/Bitmaps'; import { - ExternalInterface, ExternalInterfaceCtx, Fonts, int -} from 'eterna/util'; -import {Background, BubbleSweep} from 'eterna/vfx'; -import MissionClearedPanel from './MissionClearedPanel'; -import MissionIntroMode from './MissionIntroMode'; -import SubmitPoseDetails from './SubmitPoseDetails'; -import SubmitPoseDialog from './SubmitPoseDialog'; + KeyCode, SpriteObject, DisplayUtil, HAlign, VAlign, Flashbang, KeyboardEventType, Assert, + GameObjectRef, SerialTask, AlphaTask, Easing, SelfDestructTask +} from 'flashbang'; +import ActionBar from 'eterna/ui/ActionBar'; +import Fonts from 'eterna/util/Fonts'; +import PasteSequenceDialog from 'eterna/ui/PasteSequenceDialog'; +import EternaViewOptionsDialog, {EternaViewOptionsMode} from 'eterna/ui/EternaViewOptionsDialog'; +import FolderManager from 'eterna/folding/FolderManager'; +import Folder from 'eterna/folding/Folder'; +import {PaletteTargetType, GetPaletteTargetBaseType} from 'eterna/ui/NucleotidePalette'; +import GamePanel from 'eterna/ui/GamePanel'; +import HTMLTextObject from 'eterna/ui/HTMLTextObject'; +import PoseField from 'eterna/pose2D/PoseField'; +import Pose2D, {Oligo} from 'eterna/pose2D/Pose2D'; +import PuzzleEditOp from 'eterna/pose2D/PuzzleEditOp'; +import BitmapManager from 'eterna/resources/BitmapManager'; +import ConstraintBox, {ConstraintBoxType} from 'eterna/ui/ConstraintBox'; +import Constraints, {ConstraintType} from 'eterna/puzzle/Constraints'; +import int from 'eterna/util/int'; +import PoseOp from 'eterna/pose2D/PoseOp'; +import RNAScript from 'eterna/rscript/RNAScript'; +import SolutionManager from 'eterna/puzzle/SolutionManager'; +import ExternalInterface, {ExternalInterfaceCtx} from 'eterna/util/ExternalInterface'; +import ContextMenu from 'eterna/ui/ContextMenu'; +import SpecBoxDialog from 'eterna/ui/SpecBoxDialog'; +import BubbleSweep from 'eterna/vfx/BubbleSweep'; +import Sounds from 'eterna/resources/Sounds'; +import EternaURL from 'eterna/net/EternaURL'; +import PuzzleManager from 'eterna/puzzle/PuzzleManager'; +import URLButton from 'eterna/ui/URLButton'; +import FoldUtil from 'eterna/folding/FoldUtil'; +import {PuzzleEditPoseData} from '../PuzzleEdit/PuzzleEditMode'; +import CopyTextDialogMode from '../CopyTextDialogMode'; +import GameMode from '../GameMode'; import SubmittingDialog from './SubmittingDialog'; +import SubmitPoseDialog from './SubmitPoseDialog'; +import SubmitPoseDetails from './SubmitPoseDetails'; +import MissionIntroMode from './MissionIntroMode'; +import MissionClearedPanel from './MissionClearedPanel'; type InteractionEvent = PIXI.interaction.InteractionEvent; @@ -1713,7 +1727,7 @@ export default class PoseEditMode extends GameMode { this.disableTools(true); this.setPuzzleState(PuzzleState.CLEARED); - Eterna.sound.playSound(Sounds.SoundPuzzleClear); + Flashbang.sound.playSound(Sounds.SoundPuzzleClear); for (let pose of this._poses) { pose.setZoomLevel(0, true, true); let p = pose.startExplosion(); @@ -2855,14 +2869,14 @@ export default class PoseEditMode extends GameMode { if (allAreSatisfied && !allWereSatisfied && !hasPendingConstraints) { if (this._puzzle.puzzleType === PuzzleType.EXPERIMENTAL) { - Eterna.sound.playSound(Sounds.SoundAllConditions); + Flashbang.sound.playSound(Sounds.SoundAllConditions); } else if (this._puzState !== PuzzleState.GAME) { - Eterna.sound.playSound(Sounds.SoundCondition); + Flashbang.sound.playSound(Sounds.SoundCondition); } } else if (playConstraintSatisfiedSFX) { - Eterna.sound.playSound(Sounds.SoundCondition); + Flashbang.sound.playSound(Sounds.SoundCondition); } else if (playConstraintUnsatisfiedSFX) { - Eterna.sound.playSound(Sounds.SoundDecondition); + Flashbang.sound.playSound(Sounds.SoundDecondition); } return allAreSatisfied; @@ -3099,7 +3113,7 @@ export default class PoseEditMode extends GameMode { for (let jj = segments[2]; jj <= segments[3]; jj++) { this._targetPairs[xx][jj] = -1; } - Eterna.sound.playSound(Sounds.SoundRY); + Flashbang.sound.playSound(Sounds.SoundRY); this.flashConstraintForTarget(xx); this._poses[targetIndex].clearDesignStruct(); } else if (numUnpaired === segments[1] - segments[0] + segments[3] - segments[2] + 2) { @@ -3116,7 +3130,7 @@ export default class PoseEditMode extends GameMode { for (let jj = segments[2]; jj <= segments[3]; jj++) { this._targetPairs[xx][jj] = segments[1] - (jj - segments[2]); } - Eterna.sound.playSound(Sounds.SoundGB); + Flashbang.sound.playSound(Sounds.SoundGB); this.flashConstraintForTarget(xx); this._poses[targetIndex].clearDesignStruct(); // if the above fails, and we have multi-oligos, there may be a permutation where it works @@ -3152,7 +3166,7 @@ export default class PoseEditMode extends GameMode { for (let jj = segments[2]; jj <= segments[3]; jj++) { this._targetPairs[xx][jj] = segments[1] - (jj - segments[2]); } - Eterna.sound.playSound(Sounds.SoundGB); + Flashbang.sound.playSound(Sounds.SoundGB); this.flashConstraintForTarget(xx); this._poses[targetIndex].clearDesignStruct(); more = false; diff --git a/src/eterna/mode/PoseEdit/SubmitPoseDialog.ts b/src/eterna/mode/PoseEdit/SubmitPoseDialog.ts index e622f281e..cc5d7c13b 100644 --- a/src/eterna/mode/PoseEdit/SubmitPoseDialog.ts +++ b/src/eterna/mode/PoseEdit/SubmitPoseDialog.ts @@ -1,6 +1,6 @@ -import {Flashbang} from 'flashbang/core'; -import {KeyCode} from 'flashbang/input'; -import {Dialog, TextInputPanel} from 'eterna/ui'; +import {Flashbang, KeyCode} from 'flashbang'; +import Dialog from 'eterna/ui/Dialog'; +import TextInputPanel from 'eterna/ui/TextInputPanel'; import SubmitPoseDetails from './SubmitPoseDetails'; /** Prompts the player for a title and comment */ diff --git a/src/eterna/mode/PoseEdit/SubmittingDialog.ts b/src/eterna/mode/PoseEdit/SubmittingDialog.ts index 0037ed50a..26710abc5 100644 --- a/src/eterna/mode/PoseEdit/SubmittingDialog.ts +++ b/src/eterna/mode/PoseEdit/SubmittingDialog.ts @@ -1,9 +1,9 @@ import {Point} from 'pixi.js'; -import {Flashbang} from 'flashbang/core'; -import {AlphaTask, RepeatingTask, SerialTask} from 'flashbang/tasks'; -import {Easing} from 'flashbang/util'; -import {Dialog} from 'eterna/ui'; -import {Fonts} from 'eterna/util'; +import Dialog from 'eterna/ui/Dialog'; +import Fonts from 'eterna/util/Fonts'; +import { + RepeatingTask, SerialTask, AlphaTask, Easing, Flashbang +} from 'flashbang'; export default class SubmittingDialog extends Dialog { protected added(): void { diff --git a/src/eterna/mode/PoseEdit/index.ts b/src/eterna/mode/PoseEdit/index.ts deleted file mode 100644 index 483e2adcd..000000000 --- a/src/eterna/mode/PoseEdit/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -export {default as Booster, BoosterType} from './Booster'; -export {default as MissionClearedPanel} from './MissionClearedPanel'; -export {default as MissionIntroMode} from './MissionIntroMode'; -export {default as PoseEditMode, PuzzleState, PoseEditParams} from './PoseEditMode'; -export {default as SubmitPoseDetails} from './SubmitPoseDetails'; -export {default as SubmitPoseDialog} from './SubmitPoseDialog'; -export {default as SubmittingDialog} from './SubmittingDialog'; diff --git a/src/eterna/mode/PuzzleEdit/PuzzleEditMode.ts b/src/eterna/mode/PuzzleEdit/PuzzleEditMode.ts index 4dc2f4362..c8b03254e 100644 --- a/src/eterna/mode/PuzzleEdit/PuzzleEditMode.ts +++ b/src/eterna/mode/PuzzleEdit/PuzzleEditMode.ts @@ -1,28 +1,41 @@ import {DisplayObject, Point} from 'pixi.js'; -import {HAlign, VAlign} from 'flashbang/core'; -import {KeyCode} from 'flashbang/input'; -import {Base64, DisplayUtil} from 'flashbang/util'; import EPars from 'eterna/EPars'; import Eterna from 'eterna/Eterna'; -import { - Folder, FolderManager, LinearFoldC, LinearFoldV, NuPACK, Vienna, Vienna2 -} from 'eterna/folding'; -import { - Molecule, Pose2D, PoseField, PuzzleEditOp -} from 'eterna/pose2D'; -import {ConstraintType} from 'eterna/puzzle'; -import {Bitmaps} from 'eterna/resources'; -import { - AsyncProcessDialog, ConstraintBox, DialogCanceledError, EternaViewOptionsDialog, EternaViewOptionsMode, - GameButton, GetPaletteTargetBaseType, PaletteTargetType, PasteSequenceDialog, PoseThumbnail, PoseThumbnailType, - URLButton, Toolbar, ToolbarType -} from 'eterna/ui'; import UndoBlock, {UndoBlockParam} from 'eterna/UndoBlock'; -import {ExternalInterfaceCtx, Fonts} from 'eterna/util'; -import {Background, BaseGlow} from 'eterna/vfx'; -import {CopyTextDialogMode, GameMode} from 'eterna/mode'; -import StructureInput from './StructureInput'; +import Background from 'eterna/vfx/Background'; +import Molecule from 'eterna/pose2D/Molecule'; +import BaseGlow from 'eterna/vfx/BaseGlow'; +import FolderManager from 'eterna/folding/FolderManager'; +import Vienna from 'eterna/folding/Vienna'; +import GameButton from 'eterna/ui/GameButton'; +import Bitmaps from 'eterna/resources/Bitmaps'; +import Toolbar, {ToolbarType} from 'eterna/ui/Toolbar'; +import PasteSequenceDialog from 'eterna/ui/PasteSequenceDialog'; +import EternaViewOptionsDialog, {EternaViewOptionsMode} from 'eterna/ui/EternaViewOptionsDialog'; +import PoseField from 'eterna/pose2D/PoseField'; +import PuzzleEditOp from 'eterna/pose2D/PuzzleEditOp'; +import Pose2D from 'eterna/pose2D/Pose2D'; +import ConstraintBox from 'eterna/ui/ConstraintBox'; +import {PaletteTargetType, GetPaletteTargetBaseType} from 'eterna/ui/NucleotidePalette'; +import Folder from 'eterna/folding/Folder'; +import PoseThumbnail, {PoseThumbnailType} from 'eterna/ui/PoseThumbnail'; +import { + Base64, DisplayUtil, HAlign, VAlign, KeyCode +} from 'flashbang'; +import {DialogCanceledError} from 'eterna/ui/Dialog'; +import Vienna2 from 'eterna/folding/Vienna2'; +import NuPACK from 'eterna/folding/NuPACK'; +import AsyncProcessDialog from 'eterna/ui/AsyncProcessDialog'; +import {ConstraintType} from 'eterna/puzzle/Constraints'; +import {ExternalInterfaceCtx} from 'eterna/util/ExternalInterface'; +import URLButton from 'eterna/ui/URLButton'; +import Fonts from 'eterna/util/Fonts'; +import LinearFoldV from 'eterna/folding/LinearFoldV'; +import LinearFoldC from 'eterna/folding/LinearFoldC'; +import CopyTextDialogMode from '../CopyTextDialogMode'; +import GameMode from '../GameMode'; import SubmitPuzzleDialog, {SubmitPuzzleDetails} from './SubmitPuzzleDialog'; +import StructureInput from './StructureInput'; type InteractionEvent = PIXI.interaction.InteractionEvent; diff --git a/src/eterna/mode/PuzzleEdit/StructureInput.ts b/src/eterna/mode/PuzzleEdit/StructureInput.ts index 25b7bdec1..b26f4a915 100644 --- a/src/eterna/mode/PuzzleEdit/StructureInput.ts +++ b/src/eterna/mode/PuzzleEdit/StructureInput.ts @@ -1,12 +1,15 @@ import {Rectangle} from 'pixi.js'; -import {HAlign, VAlign, Updatable} from 'flashbang/core'; -import {KeyCode} from 'flashbang/input'; -import {DisplayUtil} from 'flashbang/util'; import EPars from 'eterna/EPars'; import Eterna from 'eterna/Eterna'; -import {Pose2D, PuzzleEditOp} from 'eterna/pose2D'; -import {GamePanel, TextInputObject, TextBalloon} from 'eterna/ui'; -import {Fonts} from 'eterna/util'; +import { + KeyCode, DisplayUtil, HAlign, VAlign, Updatable +} from 'flashbang'; +import GamePanel from 'eterna/ui/GamePanel'; +import Pose2D from 'eterna/pose2D/Pose2D'; +import TextInputObject from 'eterna/ui/TextInputObject'; +import TextBalloon from 'eterna/ui/TextBalloon'; +import PuzzleEditOp from 'eterna/pose2D/PuzzleEditOp'; +import Fonts from 'eterna/util/Fonts'; function IsArrowKey(keyCode: string): boolean { diff --git a/src/eterna/mode/PuzzleEdit/SubmitPuzzleDialog.ts b/src/eterna/mode/PuzzleEdit/SubmitPuzzleDialog.ts index 5f1645654..856289dd7 100644 --- a/src/eterna/mode/PuzzleEdit/SubmitPuzzleDialog.ts +++ b/src/eterna/mode/PuzzleEdit/SubmitPuzzleDialog.ts @@ -1,9 +1,9 @@ -import {Flashbang} from 'flashbang/core'; -import {KeyCode} from 'flashbang/input'; +import {KeyCode, Flashbang} from 'flashbang'; import EPars from 'eterna/EPars'; -import {Dialog, DialogCanceledError, TextInputPanel} from 'eterna/ui'; import UndoBlock, {UndoBlockParam} from 'eterna/UndoBlock'; -import {GameMode} from 'eterna/mode'; +import Dialog, {DialogCanceledError} from 'eterna/ui/Dialog'; +import TextInputPanel from 'eterna/ui/TextInputPanel'; +import GameMode from '../GameMode'; function GetNumber(dict: Map, name: string): number | undefined { if (!dict.has(name)) { diff --git a/src/eterna/mode/PuzzleEdit/index.ts b/src/eterna/mode/PuzzleEdit/index.ts deleted file mode 100644 index 7b11f3148..000000000 --- a/src/eterna/mode/PuzzleEdit/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export {default as PuzzleEditMode, PuzzleEditPoseData} from './PuzzleEditMode'; -export {default as StructureInput} from './StructureInput'; -export {default as SubmitPuzzleDialog, SubmitPuzzleDetails} from './SubmitPuzzleDialog'; diff --git a/src/eterna/mode/index.ts b/src/eterna/mode/index.ts deleted file mode 100644 index 041405d67..000000000 --- a/src/eterna/mode/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export {default as CopyTextDialogMode} from './CopyTextDialogMode'; -export {default as ErrorDialogMode} from './ErrorDialogMode'; -export {default as GameMode} from './GameMode'; -export {default as LoadingMode} from './LoadingMode'; -export {DesignBrowserMode, DesignBrowserFilter} from './DesignBrowser'; -export {default as FeedbackViewMode} from './FeedbackViewMode'; -export {PoseEditMode, PoseEditParams} from './PoseEdit'; -export {PuzzleEditMode, PuzzleEditPoseData} from './PuzzleEdit'; diff --git a/src/eterna/net/EternaURL.ts b/src/eterna/net/EternaURL.ts index 1561b48e6..b5cd42da7 100644 --- a/src/eterna/net/EternaURL.ts +++ b/src/eterna/net/EternaURL.ts @@ -1,5 +1,5 @@ import Eterna from 'eterna/Eterna'; -import {Utility} from 'eterna/util'; +import Utility from 'eterna/util/Utility'; export default class EternaURL { public static readonly BARCODE_HELP: string = '/web/lab/manual/#barcode'; diff --git a/src/eterna/net/GameClient.ts b/src/eterna/net/GameClient.ts index b8bdccd08..70674cd5b 100644 --- a/src/eterna/net/GameClient.ts +++ b/src/eterna/net/GameClient.ts @@ -1,5 +1,5 @@ import * as log from 'loglevel'; -import {Base64} from 'flashbang/util'; +import {Base64} from 'flashbang'; type JSONData = any; diff --git a/src/eterna/net/index.ts b/src/eterna/net/index.ts deleted file mode 100644 index e3ec118b7..000000000 --- a/src/eterna/net/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export {default as EternaURL} from './EternaURL'; -export {default as GameClient} from './GameClient'; diff --git a/src/eterna/pose2D/Base.ts b/src/eterna/pose2D/Base.ts index 8b1a78038..330ebf5e6 100644 --- a/src/eterna/pose2D/Base.ts +++ b/src/eterna/pose2D/Base.ts @@ -1,11 +1,10 @@ import * as log from 'loglevel'; import {Point, Sprite, Texture} from 'pixi.js'; -import {LateUpdatable} from 'flashbang/core'; -import {ContainerObject} from 'flashbang/objects'; +import {ContainerObject, LateUpdatable, Flashbang} from 'flashbang'; import Constants from 'eterna/Constants'; import EPars from 'eterna/EPars'; import Eterna from 'eterna/Eterna'; -import {ROPWait} from 'eterna/rscript'; +import ROPWait from 'eterna/rscript/ROPWait'; import BaseAssets from './BaseAssets'; import BaseDrawFlags from './BaseDrawFlags'; import Pose2D, {RNAHighlightState} from './Pose2D'; @@ -106,7 +105,7 @@ export default class Base extends ContainerObject implements LateUpdatable { if (playSound) { const soundName: string = BaseAssets.getBaseTypeSound(type); if (soundName != null) { - Eterna.sound.playSound(soundName); + Flashbang.sound.playSound(soundName); } } ROPWait.notifyNucleotideChange(this._baseIdx, type); diff --git a/src/eterna/pose2D/BaseAssets.ts b/src/eterna/pose2D/BaseAssets.ts index 392932a5c..14b8a4c31 100644 --- a/src/eterna/pose2D/BaseAssets.ts +++ b/src/eterna/pose2D/BaseAssets.ts @@ -1,14 +1,16 @@ import { Container, Graphics, Sprite, Texture } from 'pixi.js'; -import {ColorUtil, TextureUtil} from 'flashbang/util'; +import {ColorUtil, TextureUtil} from 'flashbang'; import EPars from 'eterna/EPars'; import ExpPainter from 'eterna/ExpPainter'; -import {BitmapManager, Bitmaps, Sounds} from 'eterna/resources'; -import {EternaTextureUtil} from 'eterna/util'; -import Base from './Base'; -import BaseDrawFlags from './BaseDrawFlags'; +import Sounds from 'eterna/resources/Sounds'; +import BitmapManager from 'eterna/resources/BitmapManager'; +import Bitmaps from 'eterna/resources/Bitmaps'; +import EternaTextureUtil from 'eterna/util/EternaTextureUtil'; import BaseTextures from './BaseTextures'; +import BaseDrawFlags from './BaseDrawFlags'; +import Base from './Base'; /** Handles initialization and management of Base-related assets */ export default class BaseAssets { @@ -246,10 +248,10 @@ export default class BaseAssets { // SOUNDS // log.debug("INIT SOUND"); - // Eterna.sound.add_sound_by_name(BaseAssets.GAMESOUND_R, "SoundR"); - // Eterna.sound.add_sound_by_name(BaseAssets.GAMESOUND_G, "SoundG"); - // Eterna.sound.add_sound_by_name(BaseAssets.GAMESOUND_Y, "SoundY"); - // Eterna.sound.add_sound_by_name(BaseAssets.GAMESOUND_B, "SoundB"); + // Flashbang.sound.add_sound_by_name(BaseAssets.GAMESOUND_R, "SoundR"); + // Flashbang.sound.add_sound_by_name(BaseAssets.GAMESOUND_G, "SoundG"); + // Flashbang.sound.add_sound_by_name(BaseAssets.GAMESOUND_Y, "SoundY"); + // Flashbang.sound.add_sound_by_name(BaseAssets.GAMESOUND_B, "SoundB"); } public static drawCircularBarcode(radius: number, lineThickness: number, lineAlpha: number): Texture { diff --git a/src/eterna/pose2D/BaseTextures.ts b/src/eterna/pose2D/BaseTextures.ts index 8c520a14a..394b8f0eb 100644 --- a/src/eterna/pose2D/BaseTextures.ts +++ b/src/eterna/pose2D/BaseTextures.ts @@ -1,10 +1,11 @@ import {Text, Texture} from 'pixi.js'; -import {TextureUtil} from 'flashbang/util'; +import {TextureUtil} from 'flashbang'; import EPars from 'eterna/EPars'; -import {BitmapManager} from 'eterna/resources'; -import {EternaTextureUtil, Fonts} from 'eterna/util'; -import Base from './Base'; +import BitmapManager from 'eterna/resources/BitmapManager'; +import EternaTextureUtil from 'eterna/util/EternaTextureUtil'; +import Fonts from 'eterna/util/Fonts'; import BaseDrawFlags from './BaseDrawFlags'; +import Base from './Base'; /** Encapsulates textures for a Base type */ export default class BaseTextures { diff --git a/src/eterna/pose2D/EnergyScoreDisplay.ts b/src/eterna/pose2D/EnergyScoreDisplay.ts index cc6857ce0..69e9307d2 100644 --- a/src/eterna/pose2D/EnergyScoreDisplay.ts +++ b/src/eterna/pose2D/EnergyScoreDisplay.ts @@ -1,8 +1,7 @@ import MultiStyleText from 'pixi-multistyle-text'; import {Container, Graphics, Point} from 'pixi.js'; -import {HAlign} from 'flashbang/core'; -import {VLayoutContainer} from 'flashbang/layout'; -import {Fonts} from 'eterna/util'; +import {VLayoutContainer, HAlign} from 'flashbang'; +import Fonts from 'eterna/util/Fonts'; export default class EnergyScoreDisplay extends Container { public static grey(text: string): string { diff --git a/src/eterna/pose2D/ExplosionFactorPanel.ts b/src/eterna/pose2D/ExplosionFactorPanel.ts index f746b5925..e89298630 100644 --- a/src/eterna/pose2D/ExplosionFactorPanel.ts +++ b/src/eterna/pose2D/ExplosionFactorPanel.ts @@ -1,8 +1,10 @@ import {Point, Text} from 'pixi.js'; import {Signal} from 'signals'; -import {KeyCode} from 'flashbang/input'; -import {GameButton, GamePanel, TextInputObject} from 'eterna/ui'; -import {Fonts} from 'eterna/util'; +import {KeyCode} from 'flashbang'; +import Fonts from 'eterna/util/Fonts'; +import TextInputObject from 'eterna/ui/TextInputObject'; +import GameButton from 'eterna/ui/GameButton'; +import GamePanel from 'eterna/ui/GamePanel'; export default class ExplosionFactorPanel extends GamePanel { public readonly factorUpdated: Signal = new Signal(); diff --git a/src/eterna/pose2D/HighlightBox.ts b/src/eterna/pose2D/HighlightBox.ts index 6ac99807f..02dd13755 100644 --- a/src/eterna/pose2D/HighlightBox.ts +++ b/src/eterna/pose2D/HighlightBox.ts @@ -1,8 +1,7 @@ import {DisplayObject, Graphics, Point} from 'pixi.js'; -import {GameObject, LateUpdatable, ObjectTask} from 'flashbang/core'; -import {Vector2} from 'flashbang/geom'; -import {AlphaTask, RepeatingTask, SerialTask} from 'flashbang/tasks'; -import {Assert} from 'flashbang/util'; +import { + GameObject, LateUpdatable, Assert, RepeatingTask, ObjectTask, SerialTask, AlphaTask, Vector2 +} from 'flashbang'; import Pose2D from './Pose2D'; export enum HighlightType { @@ -247,12 +246,12 @@ export default class HighlightBox extends GameObject implements LateUpdatable { for (let ii: number = loopStart; ii <= loopEnd; ii++) { let numGos = 0; - let axis: Vector2 = new Vector2(0, 0); + let axis = new Vector2(0, 0); baseLoc = this._pose.getBaseLoc(ii); if (ii > 0) { let prevBaseLoc: Point = this._pose.getBaseLoc(ii - 1); - let fromPrev: Vector2 = new Vector2((baseLoc.x - prevBaseLoc.x), (baseLoc.y - prevBaseLoc.y)); + let fromPrev = new Vector2((baseLoc.x - prevBaseLoc.x), (baseLoc.y - prevBaseLoc.y)); fromPrev.normalizeLocal(); axis.x += fromPrev.x; axis.y += fromPrev.y; diff --git a/src/eterna/pose2D/Molecule.ts b/src/eterna/pose2D/Molecule.ts index 382fa1c30..ccf8f9fb5 100644 --- a/src/eterna/pose2D/Molecule.ts +++ b/src/eterna/pose2D/Molecule.ts @@ -1,8 +1,10 @@ import { Container, Point, Sprite, Texture } from 'pixi.js'; -import {BitmapManager, Bitmaps} from 'eterna/resources'; -import {EternaTextureUtil, int} from 'eterna/util'; +import int from 'eterna/util/int'; +import BitmapManager from 'eterna/resources/BitmapManager'; +import Bitmaps from 'eterna/resources/Bitmaps'; +import EternaTextureUtil from 'eterna/util/EternaTextureUtil'; export default class Molecule extends Container { constructor() { diff --git a/src/eterna/pose2D/PaintCursor.ts b/src/eterna/pose2D/PaintCursor.ts index d4c606d27..6d112dd4f 100644 --- a/src/eterna/pose2D/PaintCursor.ts +++ b/src/eterna/pose2D/PaintCursor.ts @@ -1,5 +1,5 @@ import {Graphics, DisplayObject} from 'pixi.js'; -import {Flashbang, GameObject, Updatable} from 'flashbang/core'; +import {GameObject, Flashbang, Updatable} from 'flashbang'; import EPars from 'eterna/EPars'; export default class PaintCursor extends GameObject implements Updatable { diff --git a/src/eterna/pose2D/Pose2D.ts b/src/eterna/pose2D/Pose2D.ts index dbf286239..ab981a6a5 100644 --- a/src/eterna/pose2D/Pose2D.ts +++ b/src/eterna/pose2D/Pose2D.ts @@ -2,26 +2,25 @@ import * as log from 'loglevel'; import { Container, Graphics, Point, Sprite, Texture, Rectangle } from 'pixi.js'; -import {Flashbang, Updatable} from 'flashbang/core'; -import {Vector2} from 'flashbang/geom'; -import {InputUtil} from 'flashbang/input'; -import {ContainerObject, SceneObject, Dragger} from 'flashbang/objects'; -import { - AlphaTask, DelayTask, LocationTask, ParallelTask, RepeatingTask, SelfDestructTask, SerialTask -} from 'flashbang/tasks'; -import {Arrays, DisplayUtil, Easing} from 'flashbang/util'; import {Registration} from 'signals'; import EPars from 'eterna/EPars'; import Eterna from 'eterna/Eterna'; import ExpPainter from 'eterna/ExpPainter'; -import {Folder} from 'eterna/folding'; -import {GameMode} from 'eterna/mode'; -import {Booster} from 'eterna/mode/PoseEdit'; -import {BitmapManager, Sounds} from 'eterna/resources'; -import {ROPWait} from 'eterna/rscript'; -import {TextBalloon} from 'eterna/ui'; -import {Fonts, Utility} from 'eterna/util'; -import {BaseGlow, LightRay} from 'eterna/vfx'; +import { + ContainerObject, InputUtil, Flashbang, Dragger, DisplayUtil, SceneObject, SerialTask, Easing, + ParallelTask, AlphaTask, LocationTask, DelayTask, SelfDestructTask, Vector2, Arrays, RepeatingTask, Updatable +} from 'flashbang'; +import LightRay from 'eterna/vfx/LightRay'; +import TextBalloon from 'eterna/ui/TextBalloon'; +import ROPWait from 'eterna/rscript/ROPWait'; +import Fonts from 'eterna/util/Fonts'; +import Sounds from 'eterna/resources/Sounds'; +import BaseGlow from 'eterna/vfx/BaseGlow'; +import BitmapManager from 'eterna/resources/BitmapManager'; +import Booster from 'eterna/mode/PoseEdit/Booster'; +import GameMode from 'eterna/mode/GameMode'; +import Utility from 'eterna/util/Utility'; +import Folder from 'eterna/folding/Folder'; import Base from './Base'; import BaseDrawFlags from './BaseDrawFlags'; import EnergyScoreDisplay from './EnergyScoreDisplay'; @@ -1155,11 +1154,11 @@ export default class Pose2D extends ContainerObject implements Updatable { if (playSound) { if (playGC) { - Eterna.sound.playSound(Sounds.SoundRG); + Flashbang.sound.playSound(Sounds.SoundRG); } else if (playUA) { - Eterna.sound.playSound(Sounds.SoundYB); + Flashbang.sound.playSound(Sounds.SoundYB); } else if (playGU) { - Eterna.sound.playSound(Sounds.SoundRB); + Flashbang.sound.playSound(Sounds.SoundRB); } } } diff --git a/src/eterna/pose2D/PoseField.ts b/src/eterna/pose2D/PoseField.ts index 4056b299f..5eafa7322 100644 --- a/src/eterna/pose2D/PoseField.ts +++ b/src/eterna/pose2D/PoseField.ts @@ -1,10 +1,9 @@ import {Graphics, Point} from 'pixi.js'; -import {Flashbang, GameObjectRef} from 'flashbang/core'; import { - InputUtil, KeyboardEventType, KeyboardListener, KeyCode, MouseWheelListener -} from 'flashbang/input'; -import {ContainerObject, Dragger} from 'flashbang/objects'; -import {ROPWait} from 'eterna/rscript'; + ContainerObject, KeyboardListener, MouseWheelListener, InputUtil, Flashbang, + Dragger, KeyboardEventType, KeyCode, GameObjectRef +} from 'flashbang'; +import ROPWait from 'eterna/rscript/ROPWait'; import Pose2D from './Pose2D'; type InteractionEvent = PIXI.interaction.InteractionEvent; diff --git a/src/eterna/pose2D/RNAAnchorObject.ts b/src/eterna/pose2D/RNAAnchorObject.ts index ef00e82e3..581c29e6c 100644 --- a/src/eterna/pose2D/RNAAnchorObject.ts +++ b/src/eterna/pose2D/RNAAnchorObject.ts @@ -1,6 +1,5 @@ import {Point} from 'pixi.js'; -import {GameObjectRef} from 'flashbang/core'; -import {SceneObject} from 'flashbang/objects'; +import {GameObjectRef, SceneObject} from 'flashbang'; export default class RNAAnchorObject { public ref: GameObjectRef; diff --git a/src/eterna/pose2D/RNALayout.ts b/src/eterna/pose2D/RNALayout.ts index d7856ae16..b0453f6bf 100644 --- a/src/eterna/pose2D/RNALayout.ts +++ b/src/eterna/pose2D/RNALayout.ts @@ -1,5 +1,5 @@ import EPars from 'eterna/EPars'; -import {Folder} from 'eterna/folding'; +import Folder from 'eterna/folding/Folder'; export class RNATreeNode { public isPair: boolean = false; diff --git a/src/eterna/pose2D/ScoreDisplayNode.ts b/src/eterna/pose2D/ScoreDisplayNode.ts index 519e0f7cd..ba179a19e 100644 --- a/src/eterna/pose2D/ScoreDisplayNode.ts +++ b/src/eterna/pose2D/ScoreDisplayNode.ts @@ -1,4 +1,4 @@ -import {MathUtil, ColorUtil} from 'flashbang/util'; +import {ColorUtil, MathUtil} from 'flashbang'; export enum ScoreDisplayNodeType { STACK = 0, LOOP diff --git a/src/eterna/pose2D/index.ts b/src/eterna/pose2D/index.ts deleted file mode 100644 index c0f6482c4..000000000 --- a/src/eterna/pose2D/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -export {default as Base} from './Base'; -export {default as BaseAssets} from './BaseAssets'; -export {default as BaseDrawFlags} from './BaseDrawFlags'; -export {default as BaseTextures} from './BaseTextures'; -export {default as EnergyScoreDisplay} from './EnergyScoreDisplay'; -export {default as ExplosionFactorPanel} from './ExplosionFactorPanel'; -export {default as HighlightBox, HighlightType} from './HighlightBox'; -export {default as Molecule} from './Molecule'; -export {default as PaintCursor} from './PaintCursor'; -export { - default as Pose2D, PoseMouseDownCallback, Oligo, RNAHighlightState -} from './Pose2D'; -export {default as PoseField} from './PoseField'; -export {default as PoseOp} from './PoseOp'; -export {default as PoseUtil} from './PoseUtil'; -export {default as PuzzleEditOp} from './PuzzleEditOp'; -export {default as RNAAnchorObject} from './RNAAnchorObject'; -export {default as RNALayout, RNATreeNode} from './RNALayout'; -export {default as ScoreDisplayNode, ScoreDisplayNodeType} from './ScoreDisplayNode'; diff --git a/src/eterna/puzzle/Puzzle.ts b/src/eterna/puzzle/Puzzle.ts index a8523a296..4439eb9e9 100644 --- a/src/eterna/puzzle/Puzzle.ts +++ b/src/eterna/puzzle/Puzzle.ts @@ -1,8 +1,10 @@ import Constants from 'eterna/Constants'; import EPars from 'eterna/EPars'; -import {Folder, FolderManager, Vienna} from 'eterna/folding'; -import {EternaURL} from 'eterna/net'; -import {Pose2D} from 'eterna/pose2D'; +import FolderManager from 'eterna/folding/FolderManager'; +import Vienna from 'eterna/folding/Vienna'; +import Folder from 'eterna/folding/Folder'; +import EternaURL from 'eterna/net/EternaURL'; +import Pose2D from 'eterna/pose2D/Pose2D'; import {ConstraintType} from './Constraints'; export interface BoostersData { diff --git a/src/eterna/puzzle/PuzzleManager.ts b/src/eterna/puzzle/PuzzleManager.ts index 3d118c5e3..e835052cd 100644 --- a/src/eterna/puzzle/PuzzleManager.ts +++ b/src/eterna/puzzle/PuzzleManager.ts @@ -1,6 +1,7 @@ import * as log from 'loglevel'; import Eterna from 'eterna/Eterna'; -import {Folder, FolderManager} from '../folding'; +import FolderManager from 'eterna/folding/FolderManager'; +import Folder from 'eterna/folding/Folder'; import Puzzle from './Puzzle'; import SolutionManager from './SolutionManager'; diff --git a/src/eterna/puzzle/index.ts b/src/eterna/puzzle/index.ts deleted file mode 100644 index e93e91ad8..000000000 --- a/src/eterna/puzzle/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -export {default as Constraints, ConstraintType} from './Constraints'; -export { - default as Puzzle, BoostersData, PuzzleType, PoseState -} from './Puzzle'; -export {default as PuzzleManager} from './PuzzleManager'; -export {default as Solution} from './Solution'; -export {default as SolutionManager} from './SolutionManager'; diff --git a/src/eterna/rank/RankBoard.ts b/src/eterna/rank/RankBoard.ts index 1246a5808..dadc0632a 100644 --- a/src/eterna/rank/RankBoard.ts +++ b/src/eterna/rank/RankBoard.ts @@ -1,6 +1,5 @@ import {Point} from 'pixi.js'; -import {Updatable} from 'flashbang/core'; -import {ContainerObject} from 'flashbang/objects'; +import {ContainerObject, Updatable} from 'flashbang'; import PlayerRank from './PlayerRank'; import RankRowLayout from './RankRowLayout'; diff --git a/src/eterna/rank/RankRowLayout.ts b/src/eterna/rank/RankRowLayout.ts index 48db850f5..f3da2a491 100644 --- a/src/eterna/rank/RankRowLayout.ts +++ b/src/eterna/rank/RankRowLayout.ts @@ -1,7 +1,6 @@ import {Point, Text} from 'pixi.js'; -import {ContainerObject} from 'flashbang/objects'; -import {TextUtil} from 'flashbang/util'; -import {Fonts} from 'eterna/util'; +import {ContainerObject, TextUtil} from 'flashbang'; +import Fonts from 'eterna/util/Fonts'; import PlayerRank from './PlayerRank'; export default class RankRowLayout extends ContainerObject { diff --git a/src/eterna/rank/RankScroll.ts b/src/eterna/rank/RankScroll.ts index 5b18e9616..8f070b4a5 100644 --- a/src/eterna/rank/RankScroll.ts +++ b/src/eterna/rank/RankScroll.ts @@ -1,16 +1,15 @@ import {Graphics, Point, Text} from 'pixi.js'; -import {ContainerObject} from 'flashbang/objects'; import { - AlphaTask, DelayTask, InterpolatingTask, LocationTask, ParallelTask, SerialTask, VisibleTask -} from 'flashbang/tasks'; -import {Easing, EasingFunc} from 'flashbang/util'; + ContainerObject, LocationTask, Easing, SerialTask, VisibleTask, DelayTask, + ParallelTask, AlphaTask, InterpolatingTask, EasingFunc +} from 'flashbang'; import Eterna from 'eterna/Eterna'; -import {GamePanel} from 'eterna/ui'; -import {Fonts} from 'eterna/util'; -import {VibrateTask} from 'eterna/vfx'; -import PlayerRank from './PlayerRank'; -import RankBoard from './RankBoard'; +import GamePanel from 'eterna/ui/GamePanel'; +import Fonts from 'eterna/util/Fonts'; +import VibrateTask from 'eterna/vfx/VibrateTask'; import RankRowLayout from './RankRowLayout'; +import RankBoard from './RankBoard'; +import PlayerRank from './PlayerRank'; export default class RankScroll extends ContainerObject { public static hasRankScrollData(submissionRsp: any): boolean { @@ -215,7 +214,7 @@ export default class RankScroll extends ContainerObject { } } - let bg: GamePanel = new GamePanel(0, 0.9, 0x152843); + let bg = new GamePanel(0, 0.9, 0x152843); bg.setSize(310, 88); bg.display.position = new Point(-10, -10); this.addObject(bg, this.container); diff --git a/src/eterna/rank/index.ts b/src/eterna/rank/index.ts deleted file mode 100644 index 17ac8e556..000000000 --- a/src/eterna/rank/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export {default as PlayerRank} from './PlayerRank'; -export {default as RankBoard} from './RankBoard'; -export {default as RankRowLayout} from './RankRowLayout'; -export {default as RankScroll} from './RankScroll'; diff --git a/src/eterna/resources/BitmapManager.ts b/src/eterna/resources/BitmapManager.ts index 066af561e..a8c203a32 100644 --- a/src/eterna/resources/BitmapManager.ts +++ b/src/eterna/resources/BitmapManager.ts @@ -1,6 +1,6 @@ import {Texture} from 'pixi.js'; -import {Assert, TextBuilder, TextureUtil} from 'flashbang/util'; -import {Fonts} from 'eterna/util'; +import {TextureUtil, Assert, TextBuilder} from 'flashbang'; +import Fonts from 'eterna/util/Fonts'; import Bitmaps from './Bitmaps'; export default class BitmapManager { diff --git a/src/eterna/resources/PlaySoundTask.ts b/src/eterna/resources/PlaySoundTask.ts index 673a874f2..2a1862fcf 100644 --- a/src/eterna/resources/PlaySoundTask.ts +++ b/src/eterna/resources/PlaySoundTask.ts @@ -1,4 +1,4 @@ -import {ObjectTask} from 'flashbang/core'; +import {ObjectTask, Flashbang} from 'flashbang'; import Eterna from 'eterna/Eterna'; export default class PlaySoundTask extends ObjectTask { @@ -8,7 +8,7 @@ export default class PlaySoundTask extends ObjectTask { } protected added(): void { - Eterna.sound.playSound(this._soundName); + Flashbang.sound.playSound(this._soundName); this.destroySelf(); } diff --git a/src/eterna/resources/index.ts b/src/eterna/resources/index.ts deleted file mode 100644 index 70f0fab1e..000000000 --- a/src/eterna/resources/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export {default as BitmapManager} from './BitmapManager'; -export {default as Bitmaps} from './Bitmaps'; -export {default as PlaySoundTask} from './PlaySoundTask'; -export {default as SoundManager} from './SoundManager'; -export {default as Sounds} from './Sounds'; diff --git a/src/eterna/rscript/NovaPaintHint.ts b/src/eterna/rscript/NovaPaintHint.ts index 793c9e52b..35a0449ce 100644 --- a/src/eterna/rscript/NovaPaintHint.ts +++ b/src/eterna/rscript/NovaPaintHint.ts @@ -1,9 +1,8 @@ import {Point, Sprite, Texture} from 'pixi.js'; -import {Updatable} from 'flashbang/core'; -import {Vector2} from 'flashbang/geom'; -import {ContainerObject} from 'flashbang/objects'; -import {Pose2D} from 'eterna/pose2D'; -import {BitmapManager, Bitmaps} from 'eterna/resources'; +import {ContainerObject, Vector2, Updatable} from 'flashbang'; +import BitmapManager from 'eterna/resources/BitmapManager'; +import Bitmaps from 'eterna/resources/Bitmaps'; +import Pose2D from 'eterna/pose2D/Pose2D'; export default class NovaPaintHint extends ContainerObject implements Updatable { @@ -55,7 +54,7 @@ export default class NovaPaintHint extends ContainerObject implements Updatable } let stageTime: number = (currentTime - this._startAnimTime); - let dir: Vector2 = new Vector2(this._endPoint.x - this._startPoint.x, this._endPoint.y - this._startPoint.y); + let dir = new Vector2(this._endPoint.x - this._startPoint.x, this._endPoint.y - this._startPoint.y); if (stageTime < 1.5 && this._curStage === 0) { if (stageTime >= 1.4) { ++this._curStage; diff --git a/src/eterna/rscript/RNAScript.ts b/src/eterna/rscript/RNAScript.ts index b15726676..591dd2ed2 100644 --- a/src/eterna/rscript/RNAScript.ts +++ b/src/eterna/rscript/RNAScript.ts @@ -1,5 +1,5 @@ -import {PoseEditMode} from 'eterna/mode'; -import {Puzzle} from 'eterna/puzzle'; +import Puzzle from 'eterna/puzzle/Puzzle'; +import PoseEditMode from 'eterna/mode/PoseEdit/PoseEditMode'; import ROPHighlight, {ROPHighlightMode} from './ROPHighlight'; import ROPHint from './ROPHint'; import ROPPre from './ROPPre'; diff --git a/src/eterna/rscript/ROPHighlight.ts b/src/eterna/rscript/ROPHighlight.ts index 1798e8b27..ef06717ed 100644 --- a/src/eterna/rscript/ROPHighlight.ts +++ b/src/eterna/rscript/ROPHighlight.ts @@ -1,14 +1,14 @@ import * as log from 'loglevel'; import {Graphics, Point} from 'pixi.js'; -import {GameObject} from 'flashbang/core'; -import {SceneObject} from 'flashbang/objects'; -import {AlphaTask, RepeatingTask, SerialTask} from 'flashbang/tasks'; -import {ColorUtil, Easing, Assert} from 'flashbang/util'; -import {RNAHighlightState} from 'eterna/pose2D'; -import {ConstraintBox, EternaMenu} from 'eterna/ui'; -import RScriptEnv from './RScriptEnv'; -import RScriptOp from './RScriptOp'; +import { + GameObject, RepeatingTask, SceneObject, SerialTask, Easing, AlphaTask, ColorUtil +} from 'flashbang'; +import {RNAHighlightState} from 'eterna/pose2D/Pose2D'; +import ConstraintBox from 'eterna/ui/ConstraintBox'; +import EternaMenu from 'eterna/ui/EternaMenu'; import {RScriptUIElement, GetRScriptUIElementBounds, RScriptUIElementID} from './RScriptUIElement'; +import RScriptOp from './RScriptOp'; +import RScriptEnv from './RScriptEnv'; export enum ROPHighlightMode { RNA = 'RNA', diff --git a/src/eterna/rscript/ROPPre.ts b/src/eterna/rscript/ROPPre.ts index 0740a0cac..181dc8ff0 100644 --- a/src/eterna/rscript/ROPPre.ts +++ b/src/eterna/rscript/ROPPre.ts @@ -1,4 +1,4 @@ -import {PoseState} from 'eterna/puzzle'; +import {PoseState} from 'eterna/puzzle/Puzzle'; import RScriptEnv from './RScriptEnv'; import RScriptOp from './RScriptOp'; diff --git a/src/eterna/rscript/ROPRNA.ts b/src/eterna/rscript/ROPRNA.ts index ccb446a08..094799738 100644 --- a/src/eterna/rscript/ROPRNA.ts +++ b/src/eterna/rscript/ROPRNA.ts @@ -1,5 +1,5 @@ -import {MathUtil} from 'flashbang/util'; -import {StringToPaletteTargetType} from 'eterna/ui'; +import {MathUtil} from 'flashbang'; +import {StringToPaletteTargetType} from 'eterna/ui/NucleotidePalette'; import RScriptEnv from './RScriptEnv'; import RScriptOp from './RScriptOp'; diff --git a/src/eterna/rscript/ROPTextbox.ts b/src/eterna/rscript/ROPTextbox.ts index 052cbeff1..e592caa24 100644 --- a/src/eterna/rscript/ROPTextbox.ts +++ b/src/eterna/rscript/ROPTextbox.ts @@ -1,12 +1,12 @@ import * as log from 'loglevel'; import {ExtendedTextStyle} from 'pixi-multistyle-text'; import {Point} from 'pixi.js'; -import {Flashbang, GameObject} from 'flashbang/core'; -import {Vector2} from 'flashbang/geom'; -import {ColorUtil, StyledTextBuilder} from 'flashbang/util'; -import {RNAAnchorObject} from 'eterna/pose2D'; -import {FancyTextBalloon} from 'eterna/ui'; -import {Fonts} from 'eterna/util'; +import FancyTextBalloon from 'eterna/ui/FancyTextBalloon'; +import Fonts from 'eterna/util/Fonts'; +import { + StyledTextBuilder, Flashbang, Vector2, GameObject, ColorUtil +} from 'flashbang'; +import RNAAnchorObject from 'eterna/pose2D/RNAAnchorObject'; import ROPWait from './ROPWait'; import RScriptArrow from './RScriptArrow'; import RScriptEnv from './RScriptEnv'; diff --git a/src/eterna/rscript/RScriptArrow.ts b/src/eterna/rscript/RScriptArrow.ts index befba65c6..3accfae37 100644 --- a/src/eterna/rscript/RScriptArrow.ts +++ b/src/eterna/rscript/RScriptArrow.ts @@ -1,7 +1,6 @@ import {Graphics} from 'pixi.js'; -import {SceneObject} from 'flashbang/objects'; -import {MathUtil} from 'flashbang/util'; -import {GraphicsUtil} from 'eterna/util'; +import {SceneObject, MathUtil} from 'flashbang'; +import GraphicsUtil from 'eterna/util/GraphicsUtil'; export default class RScriptArrow extends SceneObject { constructor( diff --git a/src/eterna/rscript/RScriptEnv.ts b/src/eterna/rscript/RScriptEnv.ts index 7ff094e65..bdf9cf02e 100644 --- a/src/eterna/rscript/RScriptEnv.ts +++ b/src/eterna/rscript/RScriptEnv.ts @@ -1,12 +1,13 @@ import * as log from 'loglevel'; import {Container, DisplayObject} from 'pixi.js'; -import {GameObject} from 'flashbang/core'; -import {ContainerObject, Enableable} from 'flashbang/objects'; +import {ContainerObject, Enableable, GameObject} from 'flashbang'; import EPars from 'eterna/EPars'; -import {PoseEditMode} from 'eterna/mode'; -import {Pose2D, RNAHighlightState} from 'eterna/pose2D'; -import {Puzzle} from 'eterna/puzzle'; -import {PaletteTargetType, TextBalloon, ToggleBar} from 'eterna/ui'; +import PoseEditMode from 'eterna/mode/PoseEdit/PoseEditMode'; +import Puzzle from 'eterna/puzzle/Puzzle'; +import TextBalloon from 'eterna/ui/TextBalloon'; +import Pose2D, {RNAHighlightState} from 'eterna/pose2D/Pose2D'; +import {PaletteTargetType} from 'eterna/ui/NucleotidePalette'; +import ToggleBar from 'eterna/ui/ToggleBar'; import {RScriptUIElement, RScriptUIElementID} from './RScriptUIElement'; /** diff --git a/src/eterna/rscript/RScriptUIElement.ts b/src/eterna/rscript/RScriptUIElement.ts index 44152a208..8b0f8bd34 100644 --- a/src/eterna/rscript/RScriptUIElement.ts +++ b/src/eterna/rscript/RScriptUIElement.ts @@ -1,6 +1,5 @@ import {DisplayObject, Rectangle} from 'pixi.js'; -import {GameObject} from 'flashbang/core'; -import {DisplayUtil} from 'flashbang/util'; +import {GameObject, DisplayUtil} from 'flashbang'; export type RScriptUIElement = GameObject | DisplayObject | Rectangle; diff --git a/src/eterna/rscript/index.ts b/src/eterna/rscript/index.ts deleted file mode 100644 index 98ae22da5..000000000 --- a/src/eterna/rscript/index.ts +++ /dev/null @@ -1,14 +0,0 @@ -export {default as RScriptOp} from './RScriptOp'; -export {default as NovaPaintHint} from './NovaPaintHint'; -export {default as RNAScript} from './RNAScript'; -export {default as ROPHighlight, ROPHighlightMode} from './ROPHighlight'; -export {default as ROPHint} from './ROPHint'; -export {default as ROPPre} from './ROPPre'; -export {default as ROPRNA, ROPRNAType} from './ROPRNA'; -export {default as ROPTextbox, ROPTextboxMode} from './ROPTextbox'; -export {default as ROPUI} from './ROPUI'; -export {default as ROPWait, ROPWaitType} from './ROPWait'; -export {default as RScriptArrow} from './RScriptArrow'; -export {default as RScriptEnv, RScriptVarType} from './RScriptEnv'; -export {default as RScriptOpTree} from './RScriptOpTree'; -export {RScriptUIElement, GetRScriptUIElementBounds, RScriptUIElementID} from './RScriptUIElement'; diff --git a/src/eterna/settings/EternaSettings.ts b/src/eterna/settings/EternaSettings.ts index 5c66a863b..711b4ef34 100644 --- a/src/eterna/settings/EternaSettings.ts +++ b/src/eterna/settings/EternaSettings.ts @@ -1,6 +1,6 @@ -import {Setting, Settings} from 'flashbang/settings'; -import {DesignCategory} from 'eterna/mode/DesignBrowser'; +import {Settings, Setting} from 'flashbang'; import Eterna from 'eterna/Eterna'; +import {DesignCategory} from 'eterna/mode/DesignBrowser/DesignBrowserMode'; export default class EternaSettings extends Settings { public readonly showChat: Setting; diff --git a/src/eterna/settings/index.ts b/src/eterna/settings/index.ts deleted file mode 100644 index 0b05a7dc7..000000000 --- a/src/eterna/settings/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -/* eslint-disable import/prefer-default-export */ -export {default as EternaSettings} from './EternaSettings'; diff --git a/src/eterna/ui/ActionBar.ts b/src/eterna/ui/ActionBar.ts index 7e8e78780..c25ae95c3 100644 --- a/src/eterna/ui/ActionBar.ts +++ b/src/eterna/ui/ActionBar.ts @@ -1,6 +1,5 @@ import {Graphics, Point} from 'pixi.js'; -import {ContainerObject, SceneObject} from 'flashbang/objects'; -import {DisplayUtil} from 'flashbang/util'; +import {ContainerObject, SceneObject, DisplayUtil} from 'flashbang'; export default class ActionBar extends ContainerObject { constructor(height: number = 0) { diff --git a/src/eterna/ui/AsyncProcessDialog.ts b/src/eterna/ui/AsyncProcessDialog.ts index 6599e39a7..b30b098e8 100644 --- a/src/eterna/ui/AsyncProcessDialog.ts +++ b/src/eterna/ui/AsyncProcessDialog.ts @@ -1,8 +1,8 @@ import {Point} from 'pixi.js'; -import {Flashbang} from 'flashbang/core'; -import {AlphaTask, RepeatingTask, SerialTask} from 'flashbang/tasks'; -import {Easing} from 'flashbang/util'; -import {Fonts} from 'eterna/util'; +import Fonts from 'eterna/util/Fonts'; +import { + RepeatingTask, SerialTask, AlphaTask, Easing, Flashbang +} from 'flashbang'; import Dialog from './Dialog'; /** Dims the screen and shows a notification text that fades in and out */ diff --git a/src/eterna/ui/Band.ts b/src/eterna/ui/Band.ts index 0ce171676..ddb91568d 100644 --- a/src/eterna/ui/Band.ts +++ b/src/eterna/ui/Band.ts @@ -1,11 +1,12 @@ import { Graphics, Matrix, Point, Sprite, Text, Texture } from 'pixi.js'; -import {Updatable} from 'flashbang/core'; -import {ContainerObject} from 'flashbang/objects'; -import {ColorUtil, MathUtil, TextureUtil} from 'flashbang/util'; -import {BitmapManager, Bitmaps} from 'eterna/resources'; -import {Fonts} from 'eterna/util'; +import { + ContainerObject, MathUtil, TextureUtil, ColorUtil, Updatable +} from 'flashbang'; +import Fonts from 'eterna/util/Fonts'; +import BitmapManager from 'eterna/resources/BitmapManager'; +import Bitmaps from 'eterna/resources/Bitmaps'; type ColorMatrixFilter = PIXI.filters.ColorMatrixFilter; diff --git a/src/eterna/ui/BaseGamePanel.ts b/src/eterna/ui/BaseGamePanel.ts index acf87d825..fd842a3c4 100644 --- a/src/eterna/ui/BaseGamePanel.ts +++ b/src/eterna/ui/BaseGamePanel.ts @@ -1,4 +1,4 @@ -import {ContainerObject} from 'flashbang/objects'; +import {ContainerObject} from 'flashbang'; export default abstract class BaseGamePanel extends ContainerObject { public abstract setSize(width: number, height: number): void; diff --git a/src/eterna/ui/ConfirmDialog.ts b/src/eterna/ui/ConfirmDialog.ts index 5e8e688e2..2edf6c451 100644 --- a/src/eterna/ui/ConfirmDialog.ts +++ b/src/eterna/ui/ConfirmDialog.ts @@ -1,8 +1,8 @@ import {Point} from 'pixi.js'; -import {Flashbang, HAlign} from 'flashbang/core'; -import {HLayoutContainer, VLayoutContainer} from 'flashbang/layout'; -import {AlphaTask} from 'flashbang/tasks'; -import {Fonts} from 'eterna/util'; +import { + VLayoutContainer, HAlign, HLayoutContainer, AlphaTask, Flashbang +} from 'flashbang'; +import Fonts from 'eterna/util/Fonts'; import Dialog, {DialogCanceledError} from './Dialog'; import GameButton from './GameButton'; import GamePanel, {GamePanelType} from './GamePanel'; diff --git a/src/eterna/ui/ConstraintBox.ts b/src/eterna/ui/ConstraintBox.ts index 862b21f12..4634b6157 100644 --- a/src/eterna/ui/ConstraintBox.ts +++ b/src/eterna/ui/ConstraintBox.ts @@ -2,22 +2,19 @@ import MultiStyleText from 'pixi-multistyle-text'; import { Container, Graphics, Point, Sprite, Text, Texture } from 'pixi.js'; -import {HAlign, VAlign} from 'flashbang/core'; -import {ContainerObject, Enableable, SceneObject} from 'flashbang/objects'; -import { - AlphaTask, DelayTask, LocationTask, ParallelTask, ScaleTask, SerialTask, VisibleTask -} from 'flashbang/tasks'; -import { - DisplayUtil, Easing, StyledTextBuilder, TextureUtil -} from 'flashbang/util'; import {RegistrationGroup} from 'signals'; import EPars from 'eterna/EPars'; -import {ConstraintType} from 'eterna/puzzle'; -import {BitmapManager, Bitmaps} from 'eterna/resources'; -import {Fonts} from 'eterna/util'; -import Band from './Band'; -import PoseThumbnail, {PoseThumbnailType} from './PoseThumbnail'; +import { + ContainerObject, Enableable, Easing, LocationTask, AlphaTask, StyledTextBuilder, + DisplayUtil, TextureUtil, HAlign, VAlign, SerialTask, VisibleTask, ParallelTask, ScaleTask, SceneObject, DelayTask +} from 'flashbang'; +import Fonts from 'eterna/util/Fonts'; +import BitmapManager from 'eterna/resources/BitmapManager'; +import Bitmaps from 'eterna/resources/Bitmaps'; +import {ConstraintType} from 'eterna/puzzle/Constraints'; import TextBalloon from './TextBalloon'; +import PoseThumbnail, {PoseThumbnailType} from './PoseThumbnail'; +import Band from './Band'; export enum ConstraintBoxType { DEFAULT = 'DEFAULT', diff --git a/src/eterna/ui/ContextMenu.ts b/src/eterna/ui/ContextMenu.ts index 58b212b45..9badd5aa6 100644 --- a/src/eterna/ui/ContextMenu.ts +++ b/src/eterna/ui/ContextMenu.ts @@ -1,7 +1,5 @@ -import {HAlign} from 'flashbang/core'; -import {VLayoutContainer} from 'flashbang/layout'; -import {ContainerObject} from 'flashbang/objects'; import {UnitSignal} from 'signals'; +import {ContainerObject, VLayoutContainer, HAlign} from 'flashbang'; import GameButton from './GameButton'; import GamePanel, {GamePanelType} from './GamePanel'; diff --git a/src/eterna/ui/Dialog.ts b/src/eterna/ui/Dialog.ts index cafab8891..13bab0fea 100644 --- a/src/eterna/ui/Dialog.ts +++ b/src/eterna/ui/Dialog.ts @@ -1,9 +1,7 @@ import {Graphics} from 'pixi.js'; -import {Flashbang} from 'flashbang/core'; import { - InputUtil, KeyboardListener, MouseWheelListener, DisplayObjectPointerTarget -} from 'flashbang/input'; -import {ContainerObject} from 'flashbang/objects'; + ContainerObject, KeyboardListener, MouseWheelListener, DisplayObjectPointerTarget, InputUtil, Flashbang +} from 'flashbang'; /** Dialogs that expose a "confirmed" promise will reject with this error if the dialog is canceled */ export class DialogCanceledError extends Error {} diff --git a/src/eterna/ui/EternaMenu.ts b/src/eterna/ui/EternaMenu.ts index f1d6ec162..2f6919d3f 100644 --- a/src/eterna/ui/EternaMenu.ts +++ b/src/eterna/ui/EternaMenu.ts @@ -1,7 +1,5 @@ import {Point} from 'pixi.js'; -import {PointerCapture} from 'flashbang/input'; -import {Enableable} from 'flashbang/objects'; -import {DisplayUtil} from 'flashbang/util'; +import {Enableable, PointerCapture, DisplayUtil} from 'flashbang'; import GameButton from './GameButton'; import GamePanel, {GamePanelType} from './GamePanel'; diff --git a/src/eterna/ui/EternaViewOptionsDialog.ts b/src/eterna/ui/EternaViewOptionsDialog.ts index 3b6e19792..a34aaf9dd 100644 --- a/src/eterna/ui/EternaViewOptionsDialog.ts +++ b/src/eterna/ui/EternaViewOptionsDialog.ts @@ -1,10 +1,9 @@ import {Point} from 'pixi.js'; -import {HAlign, VAlign} from 'flashbang/core'; -import {HLayoutContainer, VLayoutContainer} from 'flashbang/layout'; -import {Setting} from 'flashbang/settings'; -import {DisplayUtil} from 'flashbang/util'; +import { + VLayoutContainer, HAlign, Setting, HLayoutContainer, VAlign, DisplayUtil, Flashbang +} from 'flashbang'; import Eterna from 'eterna/Eterna'; -import {Bitmaps} from 'eterna/resources'; +import Bitmaps from 'eterna/resources/Bitmaps'; import Dialog from './Dialog'; import GameButton from './GameButton'; import GameCheckbox from './GameCheckbox'; @@ -63,7 +62,7 @@ export default class EternaViewOptionsDialog extends Dialog { this._muteButton.clicked.connect(() => { this.setVolume(!Eterna.settings.soundMute.value, Eterna.settings.soundVolume.value); // Play the button-clicked sound after the volume has been adjusted. - Eterna.sound.playSound(GameButton.DEFAULT_DOWN_SOUND); + Flashbang.sound.playSound(GameButton.DEFAULT_DOWN_SOUND); }); this.addObject(this._muteButton, soundButtonLayout); @@ -73,7 +72,7 @@ export default class EternaViewOptionsDialog extends Dialog { volumeButton.downSound = null; volumeButton.clicked.connect(() => { this.setVolume(false, (ii + 1) / NUM_VOLUME_BUTTONS); - Eterna.sound.playSound(GameButton.DEFAULT_DOWN_SOUND); + Flashbang.sound.playSound(GameButton.DEFAULT_DOWN_SOUND); }); this._volumeButtons.push(volumeButton); this.addObject(volumeButton, soundButtonLayout); diff --git a/src/eterna/ui/FancyGamePanel.ts b/src/eterna/ui/FancyGamePanel.ts index 21a76e7a2..ac42d4681 100644 --- a/src/eterna/ui/FancyGamePanel.ts +++ b/src/eterna/ui/FancyGamePanel.ts @@ -1,5 +1,5 @@ import {Graphics, Point, Text} from 'pixi.js'; -import {Fonts} from 'eterna/util'; +import Fonts from 'eterna/util/Fonts'; import BaseGamePanel from './BaseGamePanel'; export enum FancyGamePanelType { diff --git a/src/eterna/ui/FancyTextBalloon.ts b/src/eterna/ui/FancyTextBalloon.ts index 0b4659c3a..cf3110ac5 100644 --- a/src/eterna/ui/FancyTextBalloon.ts +++ b/src/eterna/ui/FancyTextBalloon.ts @@ -1,12 +1,12 @@ import {Point} from 'pixi.js'; -import {HAlign, VAlign, Updatable} from 'flashbang/core'; -import {Vector2} from 'flashbang/geom'; -import {DisplayUtil} from 'flashbang/util'; -import {Bitmaps} from 'eterna/resources'; -import {RScriptArrow} from 'eterna/rscript'; -import FancyGamePanel from './FancyGamePanel'; -import GameButton from './GameButton'; +import { + Updatable, DisplayUtil, HAlign, VAlign, Vector2 +} from 'flashbang'; +import Bitmaps from 'eterna/resources/Bitmaps'; +import RScriptArrow from 'eterna/rscript/RScriptArrow'; import TextBalloon from './TextBalloon'; +import GameButton from './GameButton'; +import FancyGamePanel from './FancyGamePanel'; export default class FancyTextBalloon extends TextBalloon implements Updatable { constructor(balloonColor: number = 0xFFFFFF, balloonAlpha: number = 0.07, diff --git a/src/eterna/ui/FixedWidthTextField.ts b/src/eterna/ui/FixedWidthTextField.ts index 078c52293..7f122bd27 100644 --- a/src/eterna/ui/FixedWidthTextField.ts +++ b/src/eterna/ui/FixedWidthTextField.ts @@ -1,8 +1,7 @@ import { Container, Graphics, Text, TextStyle } from 'pixi.js'; -import {HAlign} from 'flashbang/core'; -import {Assert} from 'flashbang/util'; +import {HAlign, Assert} from 'flashbang'; export default class FixedWidthTextField extends Container { constructor(text: string, style: TextStyle, width: number, hAlign: HAlign = HAlign.LEFT) { diff --git a/src/eterna/ui/GameButton.ts b/src/eterna/ui/GameButton.ts index 70ce2ce67..41733717a 100644 --- a/src/eterna/ui/GameButton.ts +++ b/src/eterna/ui/GameButton.ts @@ -1,21 +1,25 @@ import { Container, DisplayObject, Graphics, Point, Rectangle, Sprite, Text, Texture } from 'pixi.js'; -import {HAlign, VAlign} from 'flashbang/core'; -import {KeyboardEventType, KeyboardListener} from 'flashbang/input'; -import {Button, ButtonState} from 'flashbang/objects'; -import {DisplayUtil, TextBuilder} from 'flashbang/util'; import {Registration, Registrations, Value} from 'signals'; -import {ROPWait, RScriptUIElementID} from 'eterna/rscript'; -import {Fonts} from 'eterna/util'; +import { + Button, KeyboardListener, ButtonState, TextBuilder, KeyboardEventType, DisplayUtil, HAlign, VAlign +} from 'flashbang'; +import {RScriptUIElementID} from 'eterna/rscript/RScriptUIElement'; +import ROPWait from 'eterna/rscript/ROPWait'; +import Fonts from 'eterna/util/Fonts'; +import Sounds from 'eterna/resources/Sounds'; import Tooltips from './Tooltips'; export default class GameButton extends Button implements KeyboardListener { public readonly toggled: Value = new Value(false); + public static readonly DEFAULT_DOWN_SOUND: string = Sounds.SoundButtonClick; constructor() { super(); + this.downSound = GameButton.DEFAULT_DOWN_SOUND; + this._content = new Container(); this.container.addChild(this._content); } diff --git a/src/eterna/ui/GameCheckbox.ts b/src/eterna/ui/GameCheckbox.ts index b651f61db..0050389b2 100644 --- a/src/eterna/ui/GameCheckbox.ts +++ b/src/eterna/ui/GameCheckbox.ts @@ -1,13 +1,16 @@ import {Graphics} from 'pixi.js'; -import {HAlign, VAlign} from 'flashbang/core'; -import {ButtonState, ToggleButton} from 'flashbang/objects'; -import {DisplayUtil} from 'flashbang/util'; -import {Fonts} from 'eterna/util'; +import { + ToggleButton, DisplayUtil, HAlign, VAlign, ButtonState +} from 'flashbang'; +import Fonts from 'eterna/util/Fonts'; +import GameButton from './GameButton'; export default class GameCheckbox extends ToggleButton { constructor(size: number, txt: string) { super(); + this.downSound = GameButton.DEFAULT_DOWN_SOUND; + // setting cacheAsBitmap on these Graphics objects // breaks interactivity :( (PIXI bug?) diff --git a/src/eterna/ui/GamePanel.ts b/src/eterna/ui/GamePanel.ts index 98558a807..22a8cf83b 100644 --- a/src/eterna/ui/GamePanel.ts +++ b/src/eterna/ui/GamePanel.ts @@ -1,7 +1,7 @@ import { Graphics, Point, Text, Rectangle } from 'pixi.js'; -import {Fonts} from 'eterna/util'; +import Fonts from 'eterna/util/Fonts'; import BaseGamePanel from './BaseGamePanel'; export enum GamePanelType { diff --git a/src/eterna/ui/HTMLTextObject.ts b/src/eterna/ui/HTMLTextObject.ts index a54ca0281..acab1036a 100644 --- a/src/eterna/ui/HTMLTextObject.ts +++ b/src/eterna/ui/HTMLTextObject.ts @@ -1,4 +1,4 @@ -import {DOMObject} from 'flashbang/objects'; +import {DOMObject} from 'flashbang'; import Eterna from 'eterna/Eterna'; /** A

object in the DOM that contains the given HTML. Floats on top of the PIXI canvas. */ diff --git a/src/eterna/ui/NotificationDialog.ts b/src/eterna/ui/NotificationDialog.ts index 8f1e41765..a365c4339 100644 --- a/src/eterna/ui/NotificationDialog.ts +++ b/src/eterna/ui/NotificationDialog.ts @@ -1,6 +1,5 @@ import {Point} from 'pixi.js'; -import {Flashbang} from 'flashbang/core'; -import {HLayoutContainer} from 'flashbang/layout'; +import {HLayoutContainer, Flashbang} from 'flashbang'; import Dialog from './Dialog'; import GameButton from './GameButton'; import TextBalloon from './TextBalloon'; diff --git a/src/eterna/ui/NucleotidePalette.ts b/src/eterna/ui/NucleotidePalette.ts index d5482d446..106be82d2 100644 --- a/src/eterna/ui/NucleotidePalette.ts +++ b/src/eterna/ui/NucleotidePalette.ts @@ -1,16 +1,16 @@ import { Point, Rectangle, Sprite, Text, Texture } from 'pixi.js'; -import { - InputUtil, KeyboardEventType, KeyboardListener, KeyCode -} from 'flashbang/input'; -import {ContainerObject, Enableable} from 'flashbang/objects'; -import {StyledTextBuilder, Assert} from 'flashbang/util'; import {Signal} from 'signals'; +import { + ContainerObject, KeyboardListener, Enableable, StyledTextBuilder, KeyCode, InputUtil, KeyboardEventType, Assert +} from 'flashbang'; import EPars from 'eterna/EPars'; -import {BitmapManager, Bitmaps} from 'eterna/resources'; -import {ROPWait, RScriptUIElementID} from 'eterna/rscript'; -import {Fonts} from 'eterna/util'; +import BitmapManager from 'eterna/resources/BitmapManager'; +import Bitmaps from 'eterna/resources/Bitmaps'; +import Fonts from 'eterna/util/Fonts'; +import {RScriptUIElementID} from 'eterna/rscript/RScriptUIElement'; +import ROPWait from 'eterna/rscript/ROPWait'; import Tooltips from './Tooltips'; type InteractionEvent = PIXI.interaction.InteractionEvent; diff --git a/src/eterna/ui/PasteSequenceDialog.ts b/src/eterna/ui/PasteSequenceDialog.ts index dd230f354..ee5ea74da 100644 --- a/src/eterna/ui/PasteSequenceDialog.ts +++ b/src/eterna/ui/PasteSequenceDialog.ts @@ -1,6 +1,5 @@ -import {Flashbang} from 'flashbang/core'; -import {KeyCode} from 'flashbang/input'; -import {GameMode} from 'eterna/mode'; +import {KeyCode, Flashbang} from 'flashbang'; +import GameMode from 'eterna/mode/GameMode'; import Dialog from './Dialog'; import TextInputPanel from './TextInputPanel'; diff --git a/src/eterna/ui/PoseThumbnail.ts b/src/eterna/ui/PoseThumbnail.ts index 22b775df5..a8b94e6d5 100644 --- a/src/eterna/ui/PoseThumbnail.ts +++ b/src/eterna/ui/PoseThumbnail.ts @@ -1,12 +1,12 @@ import { Container, DisplayObject, Graphics, Sprite, Texture } from 'pixi.js'; -import {DisplayUtil, TextureUtil} from 'flashbang/util'; +import {TextureUtil, DisplayUtil} from 'flashbang'; import Constants from 'eterna/Constants'; import EPars from 'eterna/EPars'; import ExpPainter from 'eterna/ExpPainter'; -import {RNALayout} from 'eterna/pose2D'; -import {Bitmaps} from 'eterna/resources'; +import Bitmaps from 'eterna/resources/Bitmaps'; +import RNALayout from 'eterna/pose2D/RNALayout'; export enum PoseThumbnailType { BASE_COLORED = 'BASE_COLORED', diff --git a/src/eterna/ui/ScrollContainer.ts b/src/eterna/ui/ScrollContainer.ts index b58f06c52..53e580f5e 100644 --- a/src/eterna/ui/ScrollContainer.ts +++ b/src/eterna/ui/ScrollContainer.ts @@ -1,5 +1,5 @@ import {Container, Graphics} from 'pixi.js'; -import {MathUtil} from 'flashbang/util'; +import {MathUtil} from 'flashbang'; export default class ScrollContainer extends Container { public readonly content = new Container(); diff --git a/src/eterna/ui/SliderBar.ts b/src/eterna/ui/SliderBar.ts index 006436654..bced8fcbc 100644 --- a/src/eterna/ui/SliderBar.ts +++ b/src/eterna/ui/SliderBar.ts @@ -1,8 +1,8 @@ import {Graphics, Point} from 'pixi.js'; -import {Flashbang, GameObjectRef} from 'flashbang/core'; -import {DisplayObjectPointerTarget} from 'flashbang/input'; -import {ContainerObject, Dragger} from 'flashbang/objects'; import {Signal} from 'signals'; +import { + ContainerObject, DisplayObjectPointerTarget, Dragger, Flashbang, GameObjectRef +} from 'flashbang'; export default class SliderBar extends ContainerObject { // The width (or height, for a horizontal SliderBar) of the thumb diff --git a/src/eterna/ui/SpecBox.ts b/src/eterna/ui/SpecBox.ts index e3e513a7e..9d8d7c05b 100644 --- a/src/eterna/ui/SpecBox.ts +++ b/src/eterna/ui/SpecBox.ts @@ -3,17 +3,16 @@ import MultiStyleText from 'pixi-multistyle-text'; import { Graphics, Point, Sprite, Text } from 'pixi.js'; -import {HAlign, VAlign} from 'flashbang/core'; -import {DisplayObjectPointerTarget, InputUtil, KeyCode} from 'flashbang/input'; -import {ContainerObject} from 'flashbang/objects'; -import {DisplayUtil, StyledTextBuilder} from 'flashbang/util'; import {UnitSignal} from 'signals'; import EPars from 'eterna/EPars'; import Plot from 'eterna/Plot'; -import {EternaURL} from 'eterna/net'; -import {Bitmaps} from 'eterna/resources'; import UndoBlock, {UndoBlockParam} from 'eterna/UndoBlock'; -import {Fonts} from 'eterna/util'; +import { + ContainerObject, KeyCode, DisplayObjectPointerTarget, InputUtil, StyledTextBuilder, DisplayUtil, HAlign, VAlign +} from 'flashbang'; +import Fonts from 'eterna/util/Fonts'; +import Bitmaps from 'eterna/resources/Bitmaps'; +import EternaURL from 'eterna/net/EternaURL'; import GameButton from './GameButton'; import GamePanel from './GamePanel'; import HTMLTextObject from './HTMLTextObject'; @@ -144,7 +143,7 @@ export default class SpecBox extends ContainerObject { this._meltplot = datablock.createMeltPlot(); if (this._stattext != null) { - let statString: StyledTextBuilder = new StyledTextBuilder({ + let statString = new StyledTextBuilder({ fontFamily: Fonts.ARIAL, fontSize: 14, fill: 0xffffff diff --git a/src/eterna/ui/SpecBoxDialog.ts b/src/eterna/ui/SpecBoxDialog.ts index 163396ba6..bf35cf67b 100644 --- a/src/eterna/ui/SpecBoxDialog.ts +++ b/src/eterna/ui/SpecBoxDialog.ts @@ -1,8 +1,8 @@ import {Point} from 'pixi.js'; -import {Flashbang, HAlign, VAlign} from 'flashbang/core'; -import {KeyCode} from 'flashbang/input'; -import {DisplayUtil} from 'flashbang/util'; import UndoBlock from 'eterna/UndoBlock'; +import { + KeyCode, Flashbang, DisplayUtil, HAlign, VAlign +} from 'flashbang'; import Dialog from './Dialog'; import GameButton from './GameButton'; import SpecBox from './SpecBox'; diff --git a/src/eterna/ui/TextBalloon.ts b/src/eterna/ui/TextBalloon.ts index 66ef79fbe..f53a75d0b 100644 --- a/src/eterna/ui/TextBalloon.ts +++ b/src/eterna/ui/TextBalloon.ts @@ -1,8 +1,7 @@ import MultiStyleText from 'pixi-multistyle-text'; import {Point, Text} from 'pixi.js'; -import {ContainerObject} from 'flashbang/objects'; -import {DisplayUtil, StyledTextBuilder} from 'flashbang/util'; -import {Fonts} from 'eterna/util'; +import {StyledTextBuilder, DisplayUtil, ContainerObject} from 'flashbang'; +import Fonts from 'eterna/util/Fonts'; import BaseGamePanel from './BaseGamePanel'; import GameButton from './GameButton'; import GamePanel, {GamePanelType} from './GamePanel'; diff --git a/src/eterna/ui/TextInputObject.ts b/src/eterna/ui/TextInputObject.ts index 3c9b58798..8018ba335 100644 --- a/src/eterna/ui/TextInputObject.ts +++ b/src/eterna/ui/TextInputObject.ts @@ -1,10 +1,8 @@ import {Graphics, Point, Sprite} from 'pixi.js'; -import {DisplayObjectPointerTarget} from 'flashbang/input'; -import {DOMObject} from 'flashbang/objects'; -import {TextBuilder} from 'flashbang/util'; import {Signal} from 'signals'; +import {DOMObject, DisplayObjectPointerTarget, TextBuilder} from 'flashbang'; import Eterna from 'eterna/Eterna'; -import {Fonts} from 'eterna/util'; +import Fonts from 'eterna/util/Fonts'; /** * A text input object in the DOM. Floats on top of the PIXI canvas. diff --git a/src/eterna/ui/TextInputPanel.ts b/src/eterna/ui/TextInputPanel.ts index 2472f89f7..c26d46aca 100644 --- a/src/eterna/ui/TextInputPanel.ts +++ b/src/eterna/ui/TextInputPanel.ts @@ -1,7 +1,6 @@ import {Point, Text} from 'pixi.js'; import {Signal, UnitSignal} from 'signals'; - -import {Fonts} from 'eterna/util'; +import Fonts from 'eterna/util/Fonts'; import GameButton from './GameButton'; import GamePanel from './GamePanel'; import TextInputObject from './TextInputObject'; diff --git a/src/eterna/ui/ToggleBar.ts b/src/eterna/ui/ToggleBar.ts index a348f9765..bca439fcb 100644 --- a/src/eterna/ui/ToggleBar.ts +++ b/src/eterna/ui/ToggleBar.ts @@ -1,13 +1,13 @@ import {Graphics, Point, Text} from 'pixi.js'; -import {KeyboardEventType, KeyboardListener, KeyCode} from 'flashbang/input'; -import {ContainerObject, Enableable} from 'flashbang/objects'; -import {LocationTask} from 'flashbang/tasks'; -import {Easing} from 'flashbang/util'; import {Signal} from 'signals'; import Eterna from 'eterna/Eterna'; -import {Sounds} from 'eterna/resources'; -import {ROPWait, RScriptUIElementID} from 'eterna/rscript'; -import {Fonts} from 'eterna/util'; +import { + ContainerObject, KeyboardListener, Enableable, LocationTask, Easing, KeyboardEventType, KeyCode, Flashbang +} from 'flashbang'; +import Fonts from 'eterna/util/Fonts'; +import Sounds from 'eterna/resources/Sounds'; +import {RScriptUIElementID} from 'eterna/rscript/RScriptUIElement'; +import ROPWait from 'eterna/rscript/ROPWait'; type InteractionEvent = PIXI.interaction.InteractionEvent; @@ -93,7 +93,7 @@ export default class ToggleBar extends ContainerObject implements KeyboardListen ); this._labels[this._selectedState].style.fill = ToggleBar.COLOR_HIGH; - Eterna.sound.playSound(Sounds.SoundSwitch); + Flashbang.sound.playSound(Sounds.SoundSwitch); this.stateChanged.emit(newState); } } diff --git a/src/eterna/ui/Toolbar.ts b/src/eterna/ui/Toolbar.ts index 761d2b5e1..18b13b90f 100644 --- a/src/eterna/ui/Toolbar.ts +++ b/src/eterna/ui/Toolbar.ts @@ -1,18 +1,15 @@ import {Graphics, Point} from 'pixi.js'; import {RegistrationGroup} from 'signals'; -import {Flashbang, HAlign, VAlign} from 'flashbang/core'; -import {KeyCode} from 'flashbang/input'; -import {HLayoutContainer, VLayoutContainer} from 'flashbang/layout'; -import {ContainerObject} from 'flashbang/objects'; -import {LocationTask} from 'flashbang/tasks'; -import {Easing, DisplayUtil} from 'flashbang/util'; import Eterna from 'eterna/Eterna'; -// Stupid cyclic dependancy - TODO: Fix later once this can get refactored import Booster from 'eterna/mode/PoseEdit/Booster'; import PoseEditMode from 'eterna/mode/PoseEdit/PoseEditMode'; -import {Bitmaps} from 'eterna/resources'; -import {RScriptUIElementID} from 'eterna/rscript'; -import {BoostersData} from 'eterna/puzzle'; +import { + ContainerObject, Flashbang, VLayoutContainer, HLayoutContainer, + KeyCode, VAlign, HAlign, DisplayUtil, LocationTask, Easing +} from 'flashbang'; +import {BoostersData} from 'eterna/puzzle/Puzzle'; +import Bitmaps from 'eterna/resources/Bitmaps'; +import {RScriptUIElementID} from 'eterna/rscript/RScriptUIElement'; import NucleotidePalette from './NucleotidePalette'; import GameButton from './GameButton'; import ToggleBar from './ToggleBar'; diff --git a/src/eterna/ui/Tooltips.ts b/src/eterna/ui/Tooltips.ts index 90c144c38..81646c945 100644 --- a/src/eterna/ui/Tooltips.ts +++ b/src/eterna/ui/Tooltips.ts @@ -2,12 +2,11 @@ import {ExtendedTextStyle} from 'pixi-multistyle-text'; import { Container, DisplayObject, Graphics, Point, Rectangle, Text } from 'pixi.js'; -import {Flashbang, GameObject, GameObjectRef} from 'flashbang/core'; -import {Button} from 'flashbang/objects'; -import {AlphaTask, DelayTask, SerialTask} from 'flashbang/tasks'; -import {Easing, StyledTextBuilder} from 'flashbang/util'; import {Registration, RegistrationGroup} from 'signals'; -import {Fonts} from 'eterna/util'; +import { + StyledTextBuilder, GameObject, Flashbang, SerialTask, Easing, AlphaTask, DelayTask, GameObjectRef, Button +} from 'flashbang'; +import Fonts from 'eterna/util/Fonts'; /** A tooltip can be a string, styled text, or a function that creates a DisplayObject */ export type Tooltip = (() => DisplayObject) | string | StyledTextBuilder; diff --git a/src/eterna/ui/UILockDialog.ts b/src/eterna/ui/UILockDialog.ts index 13d8015be..3a4f1fdbb 100644 --- a/src/eterna/ui/UILockDialog.ts +++ b/src/eterna/ui/UILockDialog.ts @@ -1,5 +1,5 @@ import * as log from 'loglevel'; -import {AlphaTask} from 'flashbang/tasks'; +import {AlphaTask} from 'flashbang'; import Dialog from './Dialog'; /** A "dialog" that simply dims the screen and eats UI events */ diff --git a/src/eterna/ui/VScrollBox.ts b/src/eterna/ui/VScrollBox.ts index 36851c88c..aa4780680 100644 --- a/src/eterna/ui/VScrollBox.ts +++ b/src/eterna/ui/VScrollBox.ts @@ -1,6 +1,5 @@ import {Container} from 'pixi.js'; -import {SceneObject} from 'flashbang/objects'; -import {MathUtil} from 'flashbang/util'; +import {SceneObject, MathUtil} from 'flashbang'; import ScrollContainer from './ScrollContainer'; import SliderBar from './SliderBar'; diff --git a/src/eterna/ui/index.ts b/src/eterna/ui/index.ts deleted file mode 100644 index a58634d1d..000000000 --- a/src/eterna/ui/index.ts +++ /dev/null @@ -1,36 +0,0 @@ -export {default as BaseGamePanel} from './BaseGamePanel'; -export {default as GamePanel, GamePanelType} from './GamePanel'; -export {default as ActionBar} from './ActionBar'; -export {default as Dialog, DialogCanceledError} from './Dialog'; -export {default as TextBalloon} from './TextBalloon'; -export {default as AsyncProcessDialog} from './AsyncProcessDialog'; -export {default as Band} from './Band'; -export {default as ConfirmDialog} from './ConfirmDialog'; -export {default as ConstraintBox, ConstraintBoxType} from './ConstraintBox'; -export {default as ContextMenu} from './ContextMenu'; -export {default as EternaMenu, EternaMenuStyle} from './EternaMenu'; -export {default as EternaViewOptionsDialog, EternaViewOptionsMode} from './EternaViewOptionsDialog'; -export {default as FancyGamePanel, FancyGamePanelType} from './FancyGamePanel'; -export {default as FancyTextBalloon} from './FancyTextBalloon'; -export {default as FixedWidthTextField} from './FixedWidthTextField'; -export {default as GameButton} from './GameButton'; -export {default as GameCheckbox} from './GameCheckbox'; -export {default as HTMLTextObject} from './HTMLTextObject'; -export {default as NotificationDialog} from './NotificationDialog'; -export { - default as NucleotidePalette, PaletteTargetType, GetPaletteTargetBaseType, StringToPaletteTargetType -} from './NucleotidePalette'; -export {default as PasteSequenceDialog} from './PasteSequenceDialog'; -export {default as PoseThumbnail, PoseThumbnailType} from './PoseThumbnail'; -export {default as ScrollContainer} from './ScrollContainer'; -export {default as SliderBar} from './SliderBar'; -export {default as SpecBox} from './SpecBox'; -export {default as SpecBoxDialog} from './SpecBoxDialog'; -export {default as TextInputObject} from './TextInputObject'; -export {default as TextInputPanel} from './TextInputPanel'; -export {default as ToggleBar} from './ToggleBar'; -export {default as Tooltips, Tooltip} from './Tooltips'; -export {default as UILockDialog} from './UILockDialog'; -export {default as URLButton} from './URLButton'; -export {default as VScrollBox} from './VScrollBox'; -export {default as Toolbar, ToolbarType} from './Toolbar'; diff --git a/src/eterna/util/EternaTextureUtil.ts b/src/eterna/util/EternaTextureUtil.ts index 75bde4181..533faf46d 100644 --- a/src/eterna/util/EternaTextureUtil.ts +++ b/src/eterna/util/EternaTextureUtil.ts @@ -1,5 +1,5 @@ import {Matrix, Sprite, Texture} from 'pixi.js'; -import {ColorUtil, MathUtil, TextureUtil} from 'flashbang/util'; +import {TextureUtil, ColorUtil, MathUtil} from 'flashbang'; export default class EternaTextureUtil { /** diff --git a/src/eterna/util/ExternalInterface.ts b/src/eterna/util/ExternalInterface.ts index f2234c23d..4c005a30e 100644 --- a/src/eterna/util/ExternalInterface.ts +++ b/src/eterna/util/ExternalInterface.ts @@ -1,6 +1,6 @@ import * as log from 'loglevel'; -import {Assert, Deferred} from 'flashbang/util'; import {Registration, UnitSignal} from 'signals'; +import {Deferred, Assert} from 'flashbang'; /** * A collection of externally registered callbacks. diff --git a/src/eterna/util/Fonts.ts b/src/eterna/util/Fonts.ts index 9789c52ec..529d15e4a 100644 --- a/src/eterna/util/Fonts.ts +++ b/src/eterna/util/Fonts.ts @@ -1,6 +1,5 @@ import * as log from 'loglevel'; -import {FontLoader} from 'flashbang/resources'; -import {TextBuilder} from 'flashbang/util'; +import {FontLoader, TextBuilder} from 'flashbang'; export default class Fonts { public static readonly ARIAL = 'Arial'; diff --git a/src/eterna/util/GraphicsUtil.ts b/src/eterna/util/GraphicsUtil.ts index 61ff0ca08..97a5862ec 100644 --- a/src/eterna/util/GraphicsUtil.ts +++ b/src/eterna/util/GraphicsUtil.ts @@ -1,5 +1,5 @@ import {Graphics, Point} from 'pixi.js'; -import {Vector2} from 'flashbang/geom'; +import {Vector2} from 'flashbang'; export default class GraphicsUtil { /** Draw a left-facing arrow, with its tip anchored at (0, 0) */ diff --git a/src/eterna/util/index.ts b/src/eterna/util/index.ts deleted file mode 100644 index e62d948d1..000000000 --- a/src/eterna/util/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export {default as EternaTextureUtil} from './EternaTextureUtil'; -export {default as ExternalInterface, ExternalInterfaceCtx, RunScriptOptions} from './ExternalInterface'; -export {default as Fonts} from './Fonts'; -export {default as GraphicsUtil} from './GraphicsUtil'; -export {default as int} from './int'; -export {default as Utility} from './Utility'; diff --git a/src/eterna/vfx/Background.ts b/src/eterna/vfx/Background.ts index 4d8e97fb2..e6a3a663f 100644 --- a/src/eterna/vfx/Background.ts +++ b/src/eterna/vfx/Background.ts @@ -1,4 +1,4 @@ -import {ContainerObject} from 'flashbang/objects'; +import {ContainerObject} from 'flashbang'; import Eterna from 'eterna/Eterna'; import Bubble from './Bubble'; diff --git a/src/eterna/vfx/BaseGlow.ts b/src/eterna/vfx/BaseGlow.ts index 418c5a6e7..3218370a8 100644 --- a/src/eterna/vfx/BaseGlow.ts +++ b/src/eterna/vfx/BaseGlow.ts @@ -1,6 +1,7 @@ import {Point, Sprite, Texture} from 'pixi.js'; -import {BitmapManager, Bitmaps} from 'eterna/resources'; -import {EternaTextureUtil} from 'eterna/util'; +import BitmapManager from 'eterna/resources/BitmapManager'; +import Bitmaps from 'eterna/resources/Bitmaps'; +import EternaTextureUtil from 'eterna/util/EternaTextureUtil'; export default class BaseGlow extends Sprite { constructor() { diff --git a/src/eterna/vfx/Bubble.ts b/src/eterna/vfx/Bubble.ts index 06d982c06..9915a2bab 100644 --- a/src/eterna/vfx/Bubble.ts +++ b/src/eterna/vfx/Bubble.ts @@ -1,9 +1,8 @@ import {Point, Texture} from 'pixi.js'; -import {Flashbang, Updatable} from 'flashbang/core'; -import {SpriteObject} from 'flashbang/objects'; -import {AlphaTask, ParallelTask, ScaleTask} from 'flashbang/tasks'; -import {Easing} from 'flashbang/util'; -import {Bitmaps} from 'eterna/resources'; +import { + SpriteObject, Flashbang, ParallelTask, Easing, AlphaTask, ScaleTask, Updatable +} from 'flashbang'; +import Bitmaps from 'eterna/resources/Bitmaps'; export default class Bubble extends SpriteObject implements Updatable { public isPaused: boolean = false; diff --git a/src/eterna/vfx/BubbleSweep.ts b/src/eterna/vfx/BubbleSweep.ts index a97613a2d..3ad3a6ff7 100644 --- a/src/eterna/vfx/BubbleSweep.ts +++ b/src/eterna/vfx/BubbleSweep.ts @@ -1,4 +1,4 @@ -import {ContainerObject} from 'flashbang/objects'; +import {ContainerObject} from 'flashbang'; import Bubble from './Bubble'; export default class BubbleSweep extends ContainerObject { diff --git a/src/eterna/vfx/LightRay.ts b/src/eterna/vfx/LightRay.ts index 81e6ddc8d..417244d97 100644 --- a/src/eterna/vfx/LightRay.ts +++ b/src/eterna/vfx/LightRay.ts @@ -1,8 +1,8 @@ import {Graphics} from 'pixi.js'; -import {Vector2} from 'flashbang/geom'; -import {SceneObject} from 'flashbang/objects'; -import {AlphaTask, SerialTask, VisibleTask} from 'flashbang/tasks'; import EPars from 'eterna/EPars'; +import { + SceneObject, SerialTask, AlphaTask, VisibleTask, Vector2 +} from 'flashbang'; export default class LightRay extends SceneObject { constructor() { diff --git a/src/eterna/vfx/VibrateTask.ts b/src/eterna/vfx/VibrateTask.ts index 4cd7c41bd..79b01c11f 100644 --- a/src/eterna/vfx/VibrateTask.ts +++ b/src/eterna/vfx/VibrateTask.ts @@ -1,6 +1,5 @@ import {DisplayObject, Point} from 'pixi.js'; -import {DisplayObjectTask} from 'flashbang/tasks'; -import {Easing} from 'flashbang/util'; +import {DisplayObjectTask, Easing} from 'flashbang'; export default class VibrateTask extends DisplayObjectTask { constructor(duration: number, target: DisplayObject = null) { diff --git a/src/eterna/vfx/index.ts b/src/eterna/vfx/index.ts deleted file mode 100644 index 6d6cc17e6..000000000 --- a/src/eterna/vfx/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export {default as Background} from './Background'; -export {default as BaseGlow} from './BaseGlow'; -export {default as Bubble} from './Bubble'; -export {default as BubbleSweep} from './BubbleSweep'; -export {default as LightRay} from './LightRay'; -export {default as VibrateTask} from './VibrateTask'; diff --git a/src/flashbang/core/AppMode.ts b/src/flashbang/core/AppMode.ts index c18abaa16..5f8c7e80e 100644 --- a/src/flashbang/core/AppMode.ts +++ b/src/flashbang/core/AppMode.ts @@ -2,8 +2,9 @@ import {Container} from 'pixi.js'; import { RegistrationGroup, Signal, SignalView, UnitSignal } from 'signals'; -import {KeyboardInput, MouseWheelInput} from '../input'; -import {Assert} from '../util'; +import KeyboardInput from 'flashbang/input/KeyboardInput'; +import MouseWheelInput from 'flashbang/input/MouseWheelInput'; +import Assert from 'flashbang/util/Assert'; import GameObject from './GameObject'; import GameObjectBase from './GameObjectBase'; import GameObjectRef from './GameObjectRef'; diff --git a/src/flashbang/core/Flashbang.ts b/src/flashbang/core/Flashbang.ts index 3774a7299..5296ba182 100644 --- a/src/flashbang/core/Flashbang.ts +++ b/src/flashbang/core/Flashbang.ts @@ -1,5 +1,6 @@ import * as PIXI from 'pixi.js'; -import {Assert} from '../util'; +import Assert from 'flashbang/util/Assert'; +import {SoundManager} from 'flashbang'; import FlashbangApp from './FlashbangApp'; import AppMode from './AppMode'; @@ -31,13 +32,19 @@ export default class Flashbang { return this._interaction.mouse.global; } + public static get sound(): SoundManager { + return this._sound; + } + /* internal */ public static registerApp(app: FlashbangApp): void { Assert.isTrue(Flashbang._app == null, 'A FlashbangApp has already been registered'); Flashbang._app = app; Flashbang._interaction = app.pixi.renderer.plugins.interaction; + Flashbang._sound = new SoundManager(); } private static _app: FlashbangApp; private static _interaction: InteractionManager; + private static _sound: SoundManager; } diff --git a/src/flashbang/core/FlashbangApp.ts b/src/flashbang/core/FlashbangApp.ts index bf05d5e28..3d7df56d9 100644 --- a/src/flashbang/core/FlashbangApp.ts +++ b/src/flashbang/core/FlashbangApp.ts @@ -1,6 +1,7 @@ import * as log from 'loglevel'; import {RegistrationGroup, Value} from 'signals'; -import {KeyboardEventType, KeyCode} from '../input'; +import KeyboardEventType from 'flashbang/input/KeyboardEventType'; +import KeyCode from 'flashbang/input/KeyCode'; import Flashbang from './Flashbang'; import ModeStack from './ModeStack'; import Updatable from './Updatable'; diff --git a/src/flashbang/core/GameObject.ts b/src/flashbang/core/GameObject.ts index 2444c8c19..760be7921 100644 --- a/src/flashbang/core/GameObject.ts +++ b/src/flashbang/core/GameObject.ts @@ -1,6 +1,6 @@ import * as log from 'loglevel'; import {Container, DisplayObject} from 'pixi.js'; -import Assert from '../util/Assert'; +import Assert from 'flashbang/util/Assert'; import GameObjectBase from './GameObjectBase'; import GameObjectRef from './GameObjectRef'; diff --git a/src/flashbang/core/ModeStack.ts b/src/flashbang/core/ModeStack.ts index 2c3a87157..2399e6cf3 100644 --- a/src/flashbang/core/ModeStack.ts +++ b/src/flashbang/core/ModeStack.ts @@ -1,6 +1,7 @@ import {Container} from 'pixi.js'; import {UnitSignal} from 'signals'; -import {Assert, MathUtil} from '../util'; +import MathUtil from 'flashbang/util/MathUtil'; +import Assert from 'flashbang/util/Assert'; import AppMode from './AppMode'; export enum ModeTransition { diff --git a/src/flashbang/core/index.ts b/src/flashbang/core/index.ts deleted file mode 100644 index 380e1ca76..000000000 --- a/src/flashbang/core/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -export {HAlign, VAlign} from './Align'; -export {default as GameObjectBase} from './GameObjectBase'; -export {default as GameObject} from './GameObject'; -export {default as AppMode} from './AppMode'; -export {default as Flashbang} from './Flashbang'; -export {default as FlashbangApp} from './FlashbangApp'; -export {default as GameObjectRef} from './GameObjectRef'; -export {default as LateUpdatable} from './LateUpdatable'; -export {default as ModeStack} from './ModeStack'; -export {default as ObjectTask} from './ObjectTask'; -export {default as Updatable} from './Updatable'; diff --git a/src/flashbang/geom/index.ts b/src/flashbang/geom/index.ts deleted file mode 100644 index 68a9951db..000000000 --- a/src/flashbang/geom/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -/* eslint-disable import/prefer-default-export */ -export {default as Vector2} from './Vector2'; diff --git a/src/flashbang/index.js b/src/flashbang/index.js new file mode 100644 index 000000000..8aa91fe65 --- /dev/null +++ b/src/flashbang/index.js @@ -0,0 +1,89 @@ +// Core +export {HAlign, VAlign} from './core/Align'; +export {default as AppMode} from './core/AppMode'; +export {default as Flashbang} from './core/Flashbang'; +export {default as FlashbangApp} from './core/FlashbangApp'; +export {default as GameObject} from './core/GameObject'; +export {default as GameObjectBase} from './core/GameObjectBase'; +export {default as GameObjectRef} from './core/GameObjectRef'; +export {default as LateUpdatable} from './core/LateUpdatable'; +export {default as ObjectTask} from './core/ObjectTask'; +export {default as Updatable} from './core/Updatable'; + +// Geom +export {default as Vector2} from './geom/Vector2'; + +// Input +export {default as DisplayObjectPointerTarget} from './input/DisplayObjectPointerTarget' +export {default as InputUtil} from './input/InputUtil'; +export {default as KeyboardEventType} from './input/KeyboardEventType'; +export {default as KeyboardInput, KeyboardListener} from './input/KeyboardInput'; +export {default as KeyCode} from './input/KeyCode'; +export {default as MouseWheelInput, MouseWheelListener} from './input/MouseWheelInput'; +export {default as PointerCapture} from './input/PointerCapture'; +export {default as PointerTarget} from './input/PointerTarget'; + +// Layout +export {default as HLayoutContainer} from './layout/HLayoutContainer'; +export {default as LayoutContainer} from './layout/LayoutContainer'; +export {default as VLayoutContainer} from './layout/VLayoutContainer' + +// Objects +export {default as Button, ButtonState} from './objects/Button'; +export {default as ContainerObject} from './objects/ContainerObject'; +export {default as DOMObject} from './objects/DOMObject'; +export {default as Dragger} from './objects/Dragger'; +export {default as Enableable} from './objects/Enableable'; +export {default as ImageButton} from './objects/ImageButton'; +export {default as SceneObject} from './objects/SceneObject'; +export {default as SimpleTextButton} from './objects/SimpleTextButton'; +export {default as SpriteObject} from './objects/SpriteObject'; +export {default as ToggleButton} from './objects/ToggleButton'; + +// Resources +export {default as FontLoader} from './resources/FontLoader'; +export {default as SoundManager} from './resources/SoundManager'; + +// Settings +export {default as SaveGameManager} from './settings/SaveGameManager'; +export {default as Setting} from './settings/setting'; +export {default as Settings} from './settings/settings'; + +// Tasks +export {default as AlphaTask} from "./tasks/AlphaTask"; +export {default as CallbackTask} from "./tasks/CallbackTask"; +export {default as DelayTask} from "./tasks/DelayTask"; +export {default as DisplayObjectTask} from "./tasks/DisplayObjectTask"; +export {default as FrameDelayTask} from "./tasks/FrameDelayTask"; +export {default as FunctionTask} from "./tasks/FunctionTask"; +export {default as InterpolatingTask} from "./tasks/InterpolatingTask"; +export {default as LocationTask} from "./tasks/LocationTask"; +export {default as ParallelTask} from "./tasks/ParallelTask"; +export {default as RepeatingTask} from "./tasks/RepeatingTask"; +export {default as RotationTask} from "./tasks/RotationTask"; +export {default as ScaleTask} from "./tasks/ScaleTask"; +export {default as SelfDestructTask} from "./tasks/SelfDestructTask"; +export {default as SerialTask} from "./tasks/SerialTask"; +export {default as VisibleTask} from "./tasks/VisibleTask"; + +// Util +export {default as Arrays} from "./util/Arrays"; +export {default as Assert} from "./util/Assert"; +export {default as Base64} from "./util/Base64"; +export {default as ColorUtil} from "./util/ColorUtil"; +export {default as Deferred} from "./util/Deferred"; +export {default as DisplayUtil} from "./util/DisplayUtil"; +export {default as Easing, EasingFunc} from "./util/Easing"; +export {default as ErrorUtil} from "./util/ErrorUtil"; +export {default as EventSignal} from "./util/EventSignal"; +export {default as JSONUtil} from "./util/JSONUtil"; +export {default as LinkedList, LinkedElement} from "./util/LinkedList"; +export {default as MathUtil} from "./util/MathUtil"; +export {default as MatrixUtil} from "./util/MatrixUtil"; +export {default as PowerEaser} from "./util/PowerEaser"; +export {default as RectangleUtil} from "./util/RectangleUtil"; +export {default as StringUtil} from "./util/StringUtil"; +export {default as StyledTextBuilder} from "./util/StyledTextBuilder"; +export {default as TextBuilder} from "./util/TextBuilder"; +export {default as TextureUtil} from "./util/TextureUtil"; +export {default as TextUtil} from "./util/TextUtil"; diff --git a/src/flashbang/input/DisplayObjectPointerTarget.ts b/src/flashbang/input/DisplayObjectPointerTarget.ts index 5bb9af2fb..e97553326 100644 --- a/src/flashbang/input/DisplayObjectPointerTarget.ts +++ b/src/flashbang/input/DisplayObjectPointerTarget.ts @@ -1,6 +1,6 @@ import {DisplayObject} from 'pixi.js'; import {SignalView} from 'signals'; -import {EventSignal} from '../util'; +import EventSignal from 'flashbang/util/EventSignal'; import PointerTarget from './PointerTarget'; type InteractionEvent = PIXI.interaction.InteractionEvent; diff --git a/src/flashbang/input/InputUtil.ts b/src/flashbang/input/InputUtil.ts index b34cc830d..d2a157426 100644 --- a/src/flashbang/input/InputUtil.ts +++ b/src/flashbang/input/InputUtil.ts @@ -1,4 +1,5 @@ type InteractionEvent = PIXI.interaction.InteractionEvent; + export default class InputUtil { public static IsLeftMouse = (e: InteractionEvent): boolean => e.data.isPrimary; } diff --git a/src/flashbang/input/KeyboardInput.ts b/src/flashbang/input/KeyboardInput.ts index 47f771b51..3ff2317af 100644 --- a/src/flashbang/input/KeyboardInput.ts +++ b/src/flashbang/input/KeyboardInput.ts @@ -1,5 +1,5 @@ import {Registration} from 'signals'; -import {LinkedElement, LinkedList} from '../util'; +import LinkedList, {LinkedElement} from 'flashbang/util/LinkedList'; export interface KeyboardListener { /** diff --git a/src/flashbang/input/MouseWheelInput.ts b/src/flashbang/input/MouseWheelInput.ts index 4f08834ee..4fbadc12f 100644 --- a/src/flashbang/input/MouseWheelInput.ts +++ b/src/flashbang/input/MouseWheelInput.ts @@ -1,5 +1,5 @@ import {Registration} from 'signals'; -import {LinkedElement, LinkedList} from '../util'; +import LinkedList, {LinkedElement} from 'flashbang/util/LinkedList'; export interface MouseWheelListener { /** diff --git a/src/flashbang/input/PointerCapture.ts b/src/flashbang/input/PointerCapture.ts index 859acb675..5f6345813 100644 --- a/src/flashbang/input/PointerCapture.ts +++ b/src/flashbang/input/PointerCapture.ts @@ -1,5 +1,5 @@ import {DisplayObject} from 'pixi.js'; -import {Flashbang} from '../core'; +import Flashbang from 'flashbang/core/Flashbang'; type InteractionPointerEvents = PIXI.interaction.InteractionPointerEvents; type InteractionEvent = PIXI.interaction.InteractionEvent; diff --git a/src/flashbang/input/index.ts b/src/flashbang/input/index.ts deleted file mode 100644 index 0a335f2e1..000000000 --- a/src/flashbang/input/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export {default as DisplayObjectPointerTarget} from './DisplayObjectPointerTarget'; -export {default as InputUtil} from './InputUtil'; -export {default as KeyboardEventType} from './KeyboardEventType'; -export {default as KeyboardInput, KeyboardListener} from './KeyboardInput'; -export {default as KeyCode} from './KeyCode'; -export {default as MouseWheelInput, MouseWheelListener} from './MouseWheelInput'; -export {default as PointerCapture} from './PointerCapture'; -export {default as PointerTarget} from './PointerTarget'; diff --git a/src/flashbang/layout/HLayoutContainer.ts b/src/flashbang/layout/HLayoutContainer.ts index bc4f8b7c1..caa9ddaf9 100644 --- a/src/flashbang/layout/HLayoutContainer.ts +++ b/src/flashbang/layout/HLayoutContainer.ts @@ -1,6 +1,6 @@ import {Rectangle} from 'pixi.js'; -import {VAlign} from '../core'; -import {DisplayUtil} from '../util'; +import {VAlign} from 'flashbang/core/Align'; +import DisplayUtil from 'flashbang/util/DisplayUtil'; import LayoutContainer from './LayoutContainer'; /** diff --git a/src/flashbang/layout/VLayoutContainer.ts b/src/flashbang/layout/VLayoutContainer.ts index fa8c2bb40..337f5a984 100644 --- a/src/flashbang/layout/VLayoutContainer.ts +++ b/src/flashbang/layout/VLayoutContainer.ts @@ -1,6 +1,6 @@ import {Rectangle} from 'pixi.js'; -import {HAlign} from '../core'; -import {DisplayUtil} from '../util'; +import {HAlign} from 'flashbang/core/Align'; +import DisplayUtil from 'flashbang/util/DisplayUtil'; import LayoutContainer from './LayoutContainer'; /** diff --git a/src/flashbang/layout/index.ts b/src/flashbang/layout/index.ts deleted file mode 100644 index a53bb1d74..000000000 --- a/src/flashbang/layout/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export {default as LayoutContainer} from './LayoutContainer'; -export {default as HLayoutContainer} from './HLayoutContainer'; -export {default as VLayoutContainer} from './VLayoutContainer'; diff --git a/src/flashbang/objects/Button.ts b/src/flashbang/objects/Button.ts index f147144a4..f3c883108 100644 --- a/src/flashbang/objects/Button.ts +++ b/src/flashbang/objects/Button.ts @@ -1,12 +1,14 @@ import {Point} from 'pixi.js'; -import Eterna from 'eterna/Eterna'; -import {Sounds} from 'eterna/resources'; import {UnitSignal} from 'signals'; -import {InputUtil, PointerCapture} from '../input'; -import {CallbackTask, DelayTask, SerialTask} from '../tasks'; -import {DisplayUtil} from '../util'; -import ContainerObject from './ContainerObject'; +import SerialTask from 'flashbang/tasks/SerialTask'; +import CallbackTask from 'flashbang/tasks/CallbackTask'; +import DelayTask from 'flashbang/tasks/DelayTask'; +import PointerCapture from 'flashbang/input/PointerCapture'; +import InputUtil from 'flashbang/input/InputUtil'; +import DisplayUtil from 'flashbang/util/DisplayUtil'; +import Flashbang from 'flashbang/core/Flashbang'; import Enableable from './Enableable'; +import ContainerObject from './ContainerObject'; type InteractionEvent = PIXI.interaction.InteractionEvent; @@ -16,8 +18,6 @@ export enum ButtonState { /** A button base class. */ export default abstract class Button extends ContainerObject implements Enableable { - public static readonly DEFAULT_DOWN_SOUND: string = Sounds.SoundButtonClick; - /** Fired when the button is clicked */ public readonly clicked: UnitSignal = new UnitSignal(); @@ -25,7 +25,7 @@ export default abstract class Button extends ContainerObject implements Enableab public readonly clickCanceled: UnitSignal = new UnitSignal(); /** Sound played when the button is pressed (null for no sound) */ - public downSound: string = Button.DEFAULT_DOWN_SOUND; + public downSound: string = null; /** Sound played when the button is pressed while disabled (null for no sound) */ public disabledSound: string = null; @@ -206,13 +206,13 @@ export default abstract class Button extends ContainerObject implements Enableab protected playStateTransitionSound(fromState: ButtonState, toState: ButtonState): void { // TODO: make SoundManager part of Flashbang if (toState === ButtonState.DOWN && this.downSound != null) { - Eterna.sound.playSound(this.downSound); + Flashbang.sound.playSound(this.downSound); } } protected playDisabledSound(): void { if (this.disabledSound != null) { - Eterna.sound.playSound(this.disabledSound); + Flashbang.sound.playSound(this.disabledSound); } } diff --git a/src/flashbang/objects/DOMObject.ts b/src/flashbang/objects/DOMObject.ts index 4deae5619..47b3b50f4 100644 --- a/src/flashbang/objects/DOMObject.ts +++ b/src/flashbang/objects/DOMObject.ts @@ -1,6 +1,7 @@ import {DisplayObject, Graphics, Matrix} from 'pixi.js'; -import {Flashbang, GameObject} from '../core'; -import {MatrixUtil} from '../util'; +import GameObject from 'flashbang/core/GameObject'; +import Flashbang from 'flashbang/core/Flashbang'; +import MatrixUtil from 'flashbang/util/MatrixUtil'; /** * Wraps an HTML element that lives in the DOM and is drawn on top of the PIXI canvas. diff --git a/src/flashbang/objects/Dragger.ts b/src/flashbang/objects/Dragger.ts index a3e556ece..8ec31bae2 100644 --- a/src/flashbang/objects/Dragger.ts +++ b/src/flashbang/objects/Dragger.ts @@ -1,7 +1,8 @@ import {Container, Graphics} from 'pixi.js'; import {UnitSignal} from 'signals'; -import {Flashbang, GameObject} from '../core'; -import {DisplayObjectPointerTarget} from '../input'; +import GameObject from 'flashbang/core/GameObject'; +import Flashbang from 'flashbang/core/Flashbang'; +import DisplayObjectPointerTarget from 'flashbang/input/DisplayObjectPointerTarget'; /** A utility object that captures mouse input and dispatches update events until a mouseUp occurs */ export default class Dragger extends GameObject { diff --git a/src/flashbang/objects/SceneObject.ts b/src/flashbang/objects/SceneObject.ts index 5ae3ea37d..4bd7acf43 100644 --- a/src/flashbang/objects/SceneObject.ts +++ b/src/flashbang/objects/SceneObject.ts @@ -1,7 +1,8 @@ import {DisplayObject} from 'pixi.js'; import {SignalView} from 'signals'; -import {GameObject} from '../core'; -import {PointerTarget, DisplayObjectPointerTarget} from '../input'; +import GameObject from 'flashbang/core/GameObject'; +import PointerTarget from 'flashbang/input/PointerTarget'; +import DisplayObjectPointerTarget from 'flashbang/input/DisplayObjectPointerTarget'; type InteractionEvent = PIXI.interaction.InteractionEvent; diff --git a/src/flashbang/objects/SimpleTextButton.ts b/src/flashbang/objects/SimpleTextButton.ts index 43246bb33..d3121517f 100644 --- a/src/flashbang/objects/SimpleTextButton.ts +++ b/src/flashbang/objects/SimpleTextButton.ts @@ -1,5 +1,5 @@ import {Graphics, Text} from 'pixi.js'; -import {TextBuilder} from '../util'; +import TextBuilder from 'flashbang/util/TextBuilder'; import Button, {ButtonState} from './Button'; /** A deliberately unstylish button that displays text on a rectangle. (For debugging.) */ diff --git a/src/flashbang/objects/index.ts b/src/flashbang/objects/index.ts deleted file mode 100644 index b5ee36b13..000000000 --- a/src/flashbang/objects/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -export {default as Enableable} from './Enableable'; -export {default as SceneObject} from './SceneObject'; -export {default as ContainerObject} from './ContainerObject'; -export {default as Button, ButtonState} from './Button'; -export {default as DOMObject} from './DOMObject'; -export {default as ImageButton} from './ImageButton'; -export {default as SimpleTextButton} from './SimpleTextButton'; -export {default as SpriteObject} from './SpriteObject'; -export {default as ToggleButton} from './ToggleButton'; -export {default as Dragger} from './Dragger'; diff --git a/src/eterna/resources/SoundManager.ts b/src/flashbang/resources/SoundManager.ts similarity index 52% rename from src/eterna/resources/SoundManager.ts rename to src/flashbang/resources/SoundManager.ts index 4337c61b5..621c63845 100644 --- a/src/eterna/resources/SoundManager.ts +++ b/src/flashbang/resources/SoundManager.ts @@ -1,47 +1,47 @@ import * as log from 'loglevel'; import 'pixi-sound'; -import {RegistrationGroup} from 'signals'; -import Eterna from 'eterna/Eterna'; -import {EternaSettings} from 'eterna/settings'; export default class SoundManager { - constructor(settings: EternaSettings) { - this._settings = settings; + public set muted(mute: boolean) { + if (mute) { + PIXI.sound.muteAll(); + } else { + PIXI.sound.unmuteAll(); + } - this._regs.add(settings.soundMute.connectNotify((mute) => { - if (mute) { - PIXI.sound.muteAll(); - } else { - PIXI.sound.unmuteAll(); - } - })); + this._muted = mute; } + public get muted(): boolean { + return this._muted; + } + + public volume: number = 0.6; + public playSound(name: string, startTime: number = 0): void { - if (this._settings.soundMute.value) { + if (this._muted) { return; } try { let sound = this.getSound(name); - sound.play({volume: this._settings.soundVolume.value, start: startTime}); + sound.play({volume: this.volume, start: startTime}); } catch (e) { log.error(`Failed to play sound ${name}`, e); } } - private getSound(name: string): EternaSound { - let sound = this._sounds.get(name); + private getSound(url: string): Sound { + let sound = this._sounds.get(url); if (sound === undefined) { - sound = new EternaSound(name); - this._sounds.set(name, sound); + sound = new Sound(url, this); + this._sounds.set(url, sound); } return sound; } - private readonly _settings: EternaSettings; - private readonly _sounds: Map = new Map(); - private readonly _regs: RegistrationGroup = new RegistrationGroup(); + private _muted: boolean; + private readonly _sounds: Map = new Map(); } /** @@ -49,9 +49,10 @@ export default class SoundManager { * For sounds that are loading, we store the last play request, and play the sound with those settings * when it has completed loading. */ -class EternaSound { - constructor(url: string) { +class Sound { + constructor(url: string, manager: SoundManager) { this._sound = PIXI.sound.Sound.from({url, preload: true, loaded: () => this.onLoaded()}); + this._manager = manager; } public play(options: PIXI.sound.PlayOptions) { @@ -63,13 +64,14 @@ class EternaSound { } private onLoaded(): void { - if (this._pendingPlayOptions != null && !Eterna.settings.soundMute.value) { - this._pendingPlayOptions.volume = Eterna.settings.soundVolume.value; + if (this._pendingPlayOptions != null && !this._manager.muted) { + this._pendingPlayOptions.volume = this._manager.volume; this._sound.play(this._pendingPlayOptions); } this._pendingPlayOptions = null; } private readonly _sound: PIXI.sound.Sound; + private readonly _manager: SoundManager; private _pendingPlayOptions: PIXI.sound.PlayOptions; } diff --git a/src/flashbang/resources/index.ts b/src/flashbang/resources/index.ts deleted file mode 100644 index 93fec9b46..000000000 --- a/src/flashbang/resources/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -/* eslint-disable import/prefer-default-export */ -export {default as FontLoader} from './FontLoader'; diff --git a/src/flashbang/settings/index.ts b/src/flashbang/settings/index.ts deleted file mode 100644 index c81ba310c..000000000 --- a/src/flashbang/settings/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export {default as SaveGameManager} from './SaveGameManager'; -export {default as Setting} from './Setting'; -export {default as Settings} from './Settings'; diff --git a/src/flashbang/tasks/AlphaTask.ts b/src/flashbang/tasks/AlphaTask.ts index 5d41abc63..09a93079d 100644 --- a/src/flashbang/tasks/AlphaTask.ts +++ b/src/flashbang/tasks/AlphaTask.ts @@ -1,5 +1,5 @@ import {DisplayObject} from 'pixi.js'; -import {EasingFunc} from '../util'; +import {EasingFunc} from 'flashbang/util/Easing'; import DisplayObjectTask from './DisplayObjectTask'; export default class AlphaTask extends DisplayObjectTask { diff --git a/src/flashbang/tasks/CallbackTask.ts b/src/flashbang/tasks/CallbackTask.ts index 84a41966f..29e9d024f 100644 --- a/src/flashbang/tasks/CallbackTask.ts +++ b/src/flashbang/tasks/CallbackTask.ts @@ -1,4 +1,4 @@ -import {ObjectTask} from '../core'; +import ObjectTask from 'flashbang/core/ObjectTask'; /** A Task that calls a function once and then completes. */ export default class CallbackTask extends ObjectTask { diff --git a/src/flashbang/tasks/DelayTask.ts b/src/flashbang/tasks/DelayTask.ts index e4cf35861..b6e0f1e20 100644 --- a/src/flashbang/tasks/DelayTask.ts +++ b/src/flashbang/tasks/DelayTask.ts @@ -1,4 +1,5 @@ -import {ObjectTask, Updatable} from '../core'; +import ObjectTask from 'flashbang/core/ObjectTask'; +import Updatable from 'flashbang/core/Updatable'; export default class DelayTask extends ObjectTask implements Updatable { constructor(time: number) { diff --git a/src/flashbang/tasks/DisplayObjectTask.ts b/src/flashbang/tasks/DisplayObjectTask.ts index 0e7994531..9307840b8 100644 --- a/src/flashbang/tasks/DisplayObjectTask.ts +++ b/src/flashbang/tasks/DisplayObjectTask.ts @@ -1,5 +1,6 @@ import {DisplayObject} from 'pixi.js'; -import {Assert, EasingFunc} from '../util'; +import {EasingFunc} from 'flashbang/util/Easing'; +import Assert from 'flashbang/util/Assert'; import InterpolatingTask from './InterpolatingTask'; export default class DisplayObjectTask extends InterpolatingTask { diff --git a/src/flashbang/tasks/FrameDelayTask.ts b/src/flashbang/tasks/FrameDelayTask.ts index fd8c6d895..9bc8c1068 100644 --- a/src/flashbang/tasks/FrameDelayTask.ts +++ b/src/flashbang/tasks/FrameDelayTask.ts @@ -1,4 +1,5 @@ -import {ObjectTask, Updatable} from '../core'; +import ObjectTask from 'flashbang/core/ObjectTask'; +import Updatable from 'flashbang/core/Updatable'; /** Delays for the given number of frames. (Unlike DelayTask, which delays for a specific amount of time.) */ export default class FrameDelayTask extends ObjectTask implements Updatable { diff --git a/src/flashbang/tasks/FunctionTask.ts b/src/flashbang/tasks/FunctionTask.ts index 8f71349ff..c91815481 100644 --- a/src/flashbang/tasks/FunctionTask.ts +++ b/src/flashbang/tasks/FunctionTask.ts @@ -1,4 +1,5 @@ -import {ObjectTask, Updatable} from '../core'; +import ObjectTask from 'flashbang/core/ObjectTask'; +import Updatable from 'flashbang/core/Updatable'; /** A Task that calls a function continuously until the function returns true */ export default class FunctionTask extends ObjectTask implements Updatable { diff --git a/src/flashbang/tasks/InterpolatingTask.ts b/src/flashbang/tasks/InterpolatingTask.ts index a7c961318..36fbf2e0f 100644 --- a/src/flashbang/tasks/InterpolatingTask.ts +++ b/src/flashbang/tasks/InterpolatingTask.ts @@ -1,5 +1,6 @@ -import {ObjectTask, Updatable} from '../core'; -import {Easing, EasingFunc} from '../util'; +import ObjectTask from 'flashbang/core/ObjectTask'; +import Updatable from 'flashbang/core/Updatable'; +import Easing, {EasingFunc} from 'flashbang/util/Easing'; export default class InterpolatingTask extends ObjectTask implements Updatable { constructor(time: number = 0, easingFn: EasingFunc = null) { diff --git a/src/flashbang/tasks/LocationTask.ts b/src/flashbang/tasks/LocationTask.ts index e1451fdba..9bba14a03 100644 --- a/src/flashbang/tasks/LocationTask.ts +++ b/src/flashbang/tasks/LocationTask.ts @@ -1,5 +1,5 @@ import {DisplayObject} from 'pixi.js'; -import {EasingFunc} from '../util'; +import {EasingFunc} from 'flashbang/util/Easing'; import DisplayObjectTask from './DisplayObjectTask'; export default class LocationTask extends DisplayObjectTask { diff --git a/src/flashbang/tasks/ParallelTask.ts b/src/flashbang/tasks/ParallelTask.ts index fa2e72a8f..c4feea2b4 100644 --- a/src/flashbang/tasks/ParallelTask.ts +++ b/src/flashbang/tasks/ParallelTask.ts @@ -1,5 +1,5 @@ -import {ObjectTask} from '../core'; -import {Assert} from '../util'; +import ObjectTask from 'flashbang/core/ObjectTask'; +import Assert from 'flashbang/util/Assert'; export default class ParallelTask extends ObjectTask { constructor(...tasks: ObjectTask[]) { diff --git a/src/flashbang/tasks/RepeatingTask.ts b/src/flashbang/tasks/RepeatingTask.ts index a476bf0f0..bbfdc6892 100644 --- a/src/flashbang/tasks/RepeatingTask.ts +++ b/src/flashbang/tasks/RepeatingTask.ts @@ -1,4 +1,4 @@ -import {ObjectTask} from '../core'; +import ObjectTask from 'flashbang/core/ObjectTask'; type TaskCreator = () => ObjectTask; diff --git a/src/flashbang/tasks/RotationTask.ts b/src/flashbang/tasks/RotationTask.ts index df7303d5a..9c2887f11 100644 --- a/src/flashbang/tasks/RotationTask.ts +++ b/src/flashbang/tasks/RotationTask.ts @@ -1,5 +1,5 @@ import {DisplayObject} from 'pixi.js'; -import {EasingFunc} from '../util'; +import {EasingFunc} from 'flashbang/util/Easing'; import DisplayObjectTask from './DisplayObjectTask'; export default class RotationTask extends DisplayObjectTask { diff --git a/src/flashbang/tasks/ScaleTask.ts b/src/flashbang/tasks/ScaleTask.ts index 11b086b94..cb392d80e 100644 --- a/src/flashbang/tasks/ScaleTask.ts +++ b/src/flashbang/tasks/ScaleTask.ts @@ -1,5 +1,5 @@ import {DisplayObject} from 'pixi.js'; -import {EasingFunc} from '../util'; +import {EasingFunc} from 'flashbang/util/Easing'; import DisplayObjectTask from './DisplayObjectTask'; export default class ScaleTask extends DisplayObjectTask { diff --git a/src/flashbang/tasks/SelfDestructTask.ts b/src/flashbang/tasks/SelfDestructTask.ts index f60541801..d30eadb7e 100644 --- a/src/flashbang/tasks/SelfDestructTask.ts +++ b/src/flashbang/tasks/SelfDestructTask.ts @@ -1,4 +1,4 @@ -import {ObjectTask} from '../core'; +import ObjectTask from 'flashbang/core/ObjectTask'; /** * A Task that destroys its parent. diff --git a/src/flashbang/tasks/SerialTask.ts b/src/flashbang/tasks/SerialTask.ts index 5376908eb..bb26b70be 100644 --- a/src/flashbang/tasks/SerialTask.ts +++ b/src/flashbang/tasks/SerialTask.ts @@ -1,5 +1,5 @@ -import {ObjectTask} from '../core'; -import {Assert} from '../util'; +import ObjectTask from 'flashbang/core/ObjectTask'; +import Assert from 'flashbang/util/Assert'; export default class SerialTask extends ObjectTask { constructor(...tasks: ObjectTask[]) { diff --git a/src/flashbang/tasks/VisibleTask.ts b/src/flashbang/tasks/VisibleTask.ts index 5cbd793e2..9e0272198 100644 --- a/src/flashbang/tasks/VisibleTask.ts +++ b/src/flashbang/tasks/VisibleTask.ts @@ -1,6 +1,6 @@ import {DisplayObject} from 'pixi.js'; -import {ObjectTask} from '../core'; -import {Assert} from '../util'; +import ObjectTask from 'flashbang/core/ObjectTask'; +import Assert from 'flashbang/util/Assert'; export default class VisibleTask extends ObjectTask { constructor(visible: boolean, target: DisplayObject = null) { diff --git a/src/flashbang/tasks/index.ts b/src/flashbang/tasks/index.ts deleted file mode 100644 index 44d0ee6fb..000000000 --- a/src/flashbang/tasks/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -export {default as InterpolatingTask} from './InterpolatingTask'; -export {default as DisplayObjectTask} from './DisplayObjectTask'; -export {default as AlphaTask} from './AlphaTask'; -export {default as CallbackTask} from './CallbackTask'; -export {default as DelayTask} from './DelayTask'; -export {default as FrameDelayTask} from './FrameDelayTask'; -export {default as FunctionTask} from './FunctionTask'; -export {default as LocationTask} from './LocationTask'; -export {default as ParallelTask} from './ParallelTask'; -export {default as RepeatingTask, Repeat} from './RepeatingTask'; -export {default as RotationTask} from './RotationTask'; -export {default as ScaleTask} from './ScaleTask'; -export {default as SelfDestructTask} from './SelfDestructTask'; -export {default as SerialTask} from './SerialTask'; -export {default as VisibleTask} from './VisibleTask'; diff --git a/src/flashbang/util/DisplayUtil.ts b/src/flashbang/util/DisplayUtil.ts index b2d7fca22..ec3a7ca54 100644 --- a/src/flashbang/util/DisplayUtil.ts +++ b/src/flashbang/util/DisplayUtil.ts @@ -2,9 +2,10 @@ import { DisplayObject, Graphics, Matrix, Point, Rectangle } from 'pixi.js'; import * as UPNG from 'upng-js'; -import {Flashbang, HAlign, VAlign} from '../core'; +import Flashbang from 'flashbang/core/Flashbang'; +import {HAlign, VAlign} from 'flashbang/core/Align'; import RectangleUtil from './RectangleUtil'; -import {Assert} from '.'; +import Assert from './Assert'; export default class DisplayUtil { public static renderToPNG(target: DisplayObject): ArrayBuffer { diff --git a/src/flashbang/util/TextureUtil.ts b/src/flashbang/util/TextureUtil.ts index 670de7bcf..3c4810929 100644 --- a/src/flashbang/util/TextureUtil.ts +++ b/src/flashbang/util/TextureUtil.ts @@ -1,7 +1,7 @@ import { BaseRenderTexture, BaseTexture, Container, DisplayObject, Rectangle, RenderTexture, Texture } from 'pixi.js'; -import {Flashbang} from '../core'; +import Flashbang from 'flashbang/core/Flashbang'; import Assert from './Assert'; export default class TextureUtil { diff --git a/src/flashbang/util/index.ts b/src/flashbang/util/index.ts deleted file mode 100644 index b5d481631..000000000 --- a/src/flashbang/util/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -export {default as Assert} from './Assert'; -export {default as Arrays} from './Arrays'; -export {default as Base64} from './Base64'; -export {default as ColorUtil} from './ColorUtil'; -export {default as Deferred} from './Deferred'; -export {default as DisplayUtil} from './DisplayUtil'; -export {default as PowerEaser} from './PowerEaser'; -export {default as Easing, EasingFunc} from './Easing'; -export {default as ErrorUtil} from './ErrorUtil'; -export {default as EventSignal} from './EventSignal'; -export {default as JSONUtil} from './JSONUtil'; -export {default as LinkedList, LinkedElement} from './LinkedList'; -export {default as MathUtil} from './MathUtil'; -export {default as MatrixUtil} from './MatrixUtil'; -export {default as RectangleUtil} from './RectangleUtil'; -export {default as StringUtil} from './StringUtil'; -export {default as StyledTextBuilder} from './StyledTextBuilder'; -export {default as TextBuilder} from './TextBuilder'; -export {default as TextureUtil} from './TextureUtil'; -export {default as TextUtil} from './TextUtil'; From 9c546f6b183d4743040842621f9686440d849f94 Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Sat, 13 Jul 2019 00:29:03 -0400 Subject: [PATCH 20/39] Add underscore prefix to internal fields --- src/eterna/pose2D/Base.ts | 2 +- src/eterna/pose2D/BaseAssets.ts | 2 +- src/flashbang/core/AppMode.ts | 14 +++++++------- src/flashbang/core/Flashbang.ts | 2 +- src/flashbang/core/FlashbangApp.ts | 6 +++--- src/flashbang/core/GameObject.ts | 2 +- src/flashbang/core/ModeStack.ts | 28 ++++++++++++++-------------- src/flashbang/util/LinkedList.ts | 4 ++-- src/signals/Cons.ts | 14 +++++++------- src/signals/Reactor.ts | 12 ++++++------ 10 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/eterna/pose2D/Base.ts b/src/eterna/pose2D/Base.ts index 330ebf5e6..892863c52 100644 --- a/src/eterna/pose2D/Base.ts +++ b/src/eterna/pose2D/Base.ts @@ -17,7 +17,7 @@ export default class Base extends ContainerObject implements LateUpdatable { constructor(pose: Pose2D, type: number) { super(); - BaseAssets.init(); + BaseAssets._init(); this._pose = pose; this.setType(type); diff --git a/src/eterna/pose2D/BaseAssets.ts b/src/eterna/pose2D/BaseAssets.ts index 14b8a4c31..cf7778822 100644 --- a/src/eterna/pose2D/BaseAssets.ts +++ b/src/eterna/pose2D/BaseAssets.ts @@ -154,7 +154,7 @@ export default class BaseAssets { } /* internal */ - public static init(): void { + public static _init(): void { if (BaseAssets._inited) { return; } diff --git a/src/flashbang/core/AppMode.ts b/src/flashbang/core/AppMode.ts index 5f8c7e80e..b8c2dcf1d 100644 --- a/src/flashbang/core/AppMode.ts +++ b/src/flashbang/core/AppMode.ts @@ -213,13 +213,13 @@ export default class AppMode { } /* internal */ - public setupInternal(modeStack: ModeStack): void { + public _setupInternal(modeStack: ModeStack): void { this._modeStack = modeStack; this.setup(); } /* internal */ - public disposeInternal(): void { + public _disposeInternal(): void { Assert.isTrue(!this._isDiposed, 'already disposed'); this._isDiposed = true; @@ -245,7 +245,7 @@ export default class AppMode { } /* internal */ - public enterInternal(): void { + public _enterInternal(): void { this._isActive = true; this.container.interactiveChildren = true; this.enter(); @@ -258,7 +258,7 @@ export default class AppMode { } /* internal */ - public exitInternal(): void { + public _exitInternal(): void { this._exited.emit(); this._isActive = false; this.container.interactiveChildren = false; @@ -266,13 +266,13 @@ export default class AppMode { } /* internal */ - public updateInternal(dt: number): void { + public _updateInternal(dt: number): void { this.update(dt); this._updateComplete.emit(); } /* internal */ - public registerObjectInternal(obj: GameObjectBase): void { + public _registerObjectInternal(obj: GameObjectBase): void { obj._mode = this; // Handle IDs @@ -305,7 +305,7 @@ export default class AppMode { } /* internal */ - public resizeInternal(): void { + public _resizeInternal(): void { if (this._isActive) { this.onResized(); } else { diff --git a/src/flashbang/core/Flashbang.ts b/src/flashbang/core/Flashbang.ts index 5296ba182..fecf21bec 100644 --- a/src/flashbang/core/Flashbang.ts +++ b/src/flashbang/core/Flashbang.ts @@ -37,7 +37,7 @@ export default class Flashbang { } /* internal */ - public static registerApp(app: FlashbangApp): void { + public static _registerApp(app: FlashbangApp): void { Assert.isTrue(Flashbang._app == null, 'A FlashbangApp has already been registered'); Flashbang._app = app; Flashbang._interaction = app.pixi.renderer.plugins.interaction; diff --git a/src/flashbang/core/FlashbangApp.ts b/src/flashbang/core/FlashbangApp.ts index 3d7df56d9..42f87592f 100644 --- a/src/flashbang/core/FlashbangApp.ts +++ b/src/flashbang/core/FlashbangApp.ts @@ -29,10 +29,10 @@ export default class FlashbangApp { this._modeStack = new ModeStack(this._pixi.stage); - Flashbang.registerApp(this); + Flashbang._registerApp(this); this.setup(); - this._modeStack.handleModeTransitions(); + this._modeStack._handleModeTransitions(); this._pixi.ticker.add(delta => this.update(delta)); @@ -138,7 +138,7 @@ export default class FlashbangApp { } protected disposeNow(): void { - this._modeStack.dispose(); + this._modeStack._dispose(); this._updatables = null; diff --git a/src/flashbang/core/GameObject.ts b/src/flashbang/core/GameObject.ts index 760be7921..a034aeb9a 100644 --- a/src/flashbang/core/GameObject.ts +++ b/src/flashbang/core/GameObject.ts @@ -157,7 +157,7 @@ export default class GameObject extends GameObjectBase { /* internal */ public _registerObject(obj: GameObjectBase): void { - this._mode.registerObjectInternal(obj); + this._mode._registerObjectInternal(obj); obj._addedInternal(); } diff --git a/src/flashbang/core/ModeStack.ts b/src/flashbang/core/ModeStack.ts index 2399e6cf3..18d0a1e26 100644 --- a/src/flashbang/core/ModeStack.ts +++ b/src/flashbang/core/ModeStack.ts @@ -145,7 +145,7 @@ export default class ModeStack { /** Called when the app is resized */ public onResized(): void { for (let mode of this._modeStack) { - mode.resizeInternal(); + mode._resizeInternal(); } } @@ -153,17 +153,17 @@ export default class ModeStack { if (this._pendingModeTransitionQueue.length > 0) { // handleModeTransition generates a lot of garbage in memory, avoid calling it on // updates where it will NOOP anyway. - this.handleModeTransitions(); + this._handleModeTransitions(); } // update the top mode if (this._modeStack.length > 0) { - this._modeStack[this._modeStack.length - 1].updateInternal(dt); + this._modeStack[this._modeStack.length - 1]._updateInternal(dt); } } /* internal */ - public handleModeTransitions(): void { + public _handleModeTransitions(): void { if (this._pendingModeTransitionQueue.length <= 0) { return; } @@ -178,7 +178,7 @@ export default class ModeStack { this._modeStack.push(newMode); this._container.addChild(newMode.container); - newMode.setupInternal(this); + newMode._setupInternal(this); }; const doInsertMode = (newMode: AppMode, index: number) => { @@ -194,7 +194,7 @@ export default class ModeStack { this._modeStack.splice(index, 0, newMode); this._container.addChildAt(newMode.container, index); - newMode.setupInternal(this); + newMode._setupInternal(this); }; const doRemoveMode = (modeOrIndex: AppMode | number) => { @@ -220,11 +220,11 @@ export default class ModeStack { // if the top mode is removed, make sure it's exited first let mode: AppMode = this._modeStack[index]; if (mode === initialTopMode) { - initialTopMode.exitInternal(); + initialTopMode._exitInternal(); initialTopMode = null; } - mode.disposeInternal(); + mode._disposeInternal(); this._modeStack.splice(index, 1); }; @@ -316,28 +316,28 @@ export default class ModeStack { let newTopMode = this.topMode; if (newTopMode !== initialTopMode) { if (initialTopMode != null) { - initialTopMode.exitInternal(); + initialTopMode._exitInternal(); } if (newTopMode != null) { - newTopMode.enterInternal(); + newTopMode._enterInternal(); } this.topModeChanged.emit(); } } /* internal */ - public clearModeStackNow(): void { + public _clearModeStackNow(): void { this._pendingModeTransitionQueue.length = 0; if (this._modeStack.length > 0) { this.popAllModes(); - this.handleModeTransitions(); + this._handleModeTransitions(); } } /* internal */ - public dispose(): void { - this.clearModeStackNow(); + public _dispose(): void { + this._clearModeStackNow(); this._modeStack = null; this._pendingModeTransitionQueue = null; this._container.destroy(); diff --git a/src/flashbang/util/LinkedList.ts b/src/flashbang/util/LinkedList.ts index c796fcbb8..b6481029f 100644 --- a/src/flashbang/util/LinkedList.ts +++ b/src/flashbang/util/LinkedList.ts @@ -93,7 +93,7 @@ export default class LinkedList { } /* internal */ - public removeCons(cons: Cons): void { + public _removeCons(cons: Cons): void { if (this.isIterating) { this._pendingRuns = LinkedList.pend(this._pendingRuns, new Runs(() => { this._head = Cons.remove(this._head, cons); @@ -146,7 +146,7 @@ class Cons implements Registration, LinkedElement { public close(): void { // multiple disconnects are OK, we just NOOP after the first one if (this.owner != null) { - this.owner.removeCons(this); + this.owner._removeCons(this); this.owner = null; this.data = null; } diff --git a/src/signals/Cons.ts b/src/signals/Cons.ts index b49e63639..21a68ba5e 100644 --- a/src/signals/Cons.ts +++ b/src/signals/Cons.ts @@ -50,38 +50,38 @@ export default class Cons implements Connection { } /* internal */ - public static insert(head: Cons, cons: Cons): Cons { + public static _insert(head: Cons, cons: Cons): Cons { if (head == null) { return cons; } else if (cons._priority > head._priority) { cons.next = head; return cons; } else { - head.next = Cons.insert(head.next, cons); + head.next = Cons._insert(head.next, cons); return head; } } /* internal */ - public static remove(head: Cons, cons: Cons): Cons { + public static _remove(head: Cons, cons: Cons): Cons { if (head == null) { return head; } else if (head === cons) { return head.next; } else { - head.next = Cons.remove(head.next, cons); + head.next = Cons._remove(head.next, cons); return head; } } /* internal */ - public static removeAll(head: Cons, listener: RListener): Cons { + public static _removeAll(head: Cons, listener: RListener): Cons { if (head == null) { return null; } else if (head.listener === listener) { - return Cons.removeAll(head.next, listener); + return Cons._removeAll(head.next, listener); } else { - head.next = Cons.removeAll(head.next, listener); + head.next = Cons._removeAll(head.next, listener); return head; } } diff --git a/src/signals/Reactor.ts b/src/signals/Reactor.ts index ad3f31c44..099dc3daa 100644 --- a/src/signals/Reactor.ts +++ b/src/signals/Reactor.ts @@ -22,11 +22,11 @@ export default abstract class Reactor { protected removeConnection(listener: RListener): void { if (this.isDispatching) { this._pendingRuns = Reactor.insert(this._pendingRuns, new Runs((): void => { - this._listeners = Cons.removeAll(this._listeners, listener); + this._listeners = Cons._removeAll(this._listeners, listener); this.connectionRemoved(); })); } else { - this._listeners = Cons.removeAll(this._listeners, listener); + this._listeners = Cons._removeAll(this._listeners, listener); this.connectionRemoved(); } } @@ -104,11 +104,11 @@ export default abstract class Reactor { public _addCons(cons: Cons): Cons { if (this.isDispatching) { this._pendingRuns = Reactor.insert(this._pendingRuns, new Runs(() => { - this._listeners = Cons.insert(this._listeners, cons); + this._listeners = Cons._insert(this._listeners, cons); this.connectionAdded(); })); } else { - this._listeners = Cons.insert(this._listeners, cons); + this._listeners = Cons._insert(this._listeners, cons); this.connectionAdded(); } return cons; @@ -118,11 +118,11 @@ export default abstract class Reactor { public _removeCons(cons: Cons): void { if (this.isDispatching) { this._pendingRuns = Reactor.insert(this._pendingRuns, new Runs(() => { - this._listeners = Cons.remove(this._listeners, cons); + this._listeners = Cons._remove(this._listeners, cons); this.connectionRemoved(); })); } else { - this._listeners = Cons.remove(this._listeners, cons); + this._listeners = Cons._remove(this._listeners, cons); this.connectionRemoved(); } } From b3cc7648e0aa96dd325d37782741549cf4c89f10 Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Sat, 13 Jul 2019 00:34:29 -0400 Subject: [PATCH 21/39] Directly access Flashbang.sound singleton in Sound --- src/flashbang/resources/SoundManager.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/flashbang/resources/SoundManager.ts b/src/flashbang/resources/SoundManager.ts index 621c63845..15f2081b7 100644 --- a/src/flashbang/resources/SoundManager.ts +++ b/src/flashbang/resources/SoundManager.ts @@ -1,5 +1,6 @@ import * as log from 'loglevel'; import 'pixi-sound'; +import {Flashbang} from 'flashbang'; export default class SoundManager { public set muted(mute: boolean) { @@ -34,7 +35,7 @@ export default class SoundManager { private getSound(url: string): Sound { let sound = this._sounds.get(url); if (sound === undefined) { - sound = new Sound(url, this); + sound = new Sound(url); this._sounds.set(url, sound); } return sound; @@ -50,9 +51,8 @@ export default class SoundManager { * when it has completed loading. */ class Sound { - constructor(url: string, manager: SoundManager) { + constructor(url: string) { this._sound = PIXI.sound.Sound.from({url, preload: true, loaded: () => this.onLoaded()}); - this._manager = manager; } public play(options: PIXI.sound.PlayOptions) { @@ -64,14 +64,13 @@ class Sound { } private onLoaded(): void { - if (this._pendingPlayOptions != null && !this._manager.muted) { - this._pendingPlayOptions.volume = this._manager.volume; + if (this._pendingPlayOptions != null && !Flashbang.sound.muted) { + this._pendingPlayOptions.volume = Flashbang.sound.volume; this._sound.play(this._pendingPlayOptions); } this._pendingPlayOptions = null; } private readonly _sound: PIXI.sound.Sound; - private readonly _manager: SoundManager; private _pendingPlayOptions: PIXI.sound.PlayOptions; } From a339bf689376bf40965371f2e998387e13b27b47 Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Mon, 29 Jul 2019 21:02:56 -0400 Subject: [PATCH 22/39] Class-based constraints (minus SCRIPT) --- src/eterna/EPars.ts | 12 + src/eterna/constraints/BarcodeConstraint.ts | 55 +++ src/eterna/constraints/BindingConstraint.ts | 241 +++++++++++++ src/eterna/constraints/BoostConstraint.ts | 60 ++++ .../constraints/ConsecutiveBaseConstraint.ts | 107 ++++++ src/eterna/constraints/Constraint.ts | 42 +++ src/eterna/constraints/ConstraintBox.ts | 339 ++++++++++++++++++ .../constraints/MaximumBaseConstraint.ts | 97 +++++ .../constraints/MaximumMutationConstraint.ts | 79 ++++ .../constraints/MaximumPairConstraint.ts | 133 +++++++ .../constraints/MinimumBaseConstraint.ts | 95 +++++ .../constraints/MinimumPairConstraint.ts | 184 ++++++++++ .../MinimumStackLengthConstraint.ts | 77 ++++ src/eterna/constraints/ShapeConstraint.ts | 252 +++++++++++++ src/eterna/constraints/SynthesisConstraint.ts | 126 +++++++ src/eterna/mode/PoseEdit/PoseEditMode.ts | 2 +- src/eterna/ui/PoseThumbnail.ts | 1 + 17 files changed, 1901 insertions(+), 1 deletion(-) create mode 100644 src/eterna/constraints/BarcodeConstraint.ts create mode 100644 src/eterna/constraints/BindingConstraint.ts create mode 100644 src/eterna/constraints/BoostConstraint.ts create mode 100644 src/eterna/constraints/ConsecutiveBaseConstraint.ts create mode 100644 src/eterna/constraints/Constraint.ts create mode 100644 src/eterna/constraints/ConstraintBox.ts create mode 100644 src/eterna/constraints/MaximumBaseConstraint.ts create mode 100644 src/eterna/constraints/MaximumMutationConstraint.ts create mode 100644 src/eterna/constraints/MaximumPairConstraint.ts create mode 100644 src/eterna/constraints/MinimumBaseConstraint.ts create mode 100644 src/eterna/constraints/MinimumPairConstraint.ts create mode 100644 src/eterna/constraints/MinimumStackLengthConstraint.ts create mode 100644 src/eterna/constraints/ShapeConstraint.ts create mode 100644 src/eterna/constraints/SynthesisConstraint.ts diff --git a/src/eterna/EPars.ts b/src/eterna/EPars.ts index 5efce1c11..b11510be1 100644 --- a/src/eterna/EPars.ts +++ b/src/eterna/EPars.ts @@ -360,6 +360,18 @@ export default class EPars { } } + public static nucleotidePairToString(value: number): 'AU'|'GU'|'GC' { + if (value === EPars.RNABASE_AU_PAIR) { + return 'AU'; + } else if (value === EPars.RNABASE_GU_PAIR) { + return 'GU'; + } else if (value === EPars.RNABASE_GC_PAIR) { + return 'GC'; + } else { + throw new Error(`Bad nucleotide '${value}`); + } + } + public static stringToSequence(seq: string, allowCut: boolean = true, allowUnknown: boolean = true): number[] { let seqarray: number[] = []; for (let ii = 0; ii < seq.length; ii++) { diff --git a/src/eterna/constraints/BarcodeConstraint.ts b/src/eterna/constraints/BarcodeConstraint.ts new file mode 100644 index 000000000..dc5931030 --- /dev/null +++ b/src/eterna/constraints/BarcodeConstraint.ts @@ -0,0 +1,55 @@ +import UndoBlock from 'eterna/UndoBlock'; +import SolutionManager from 'eterna/puzzle/SolutionManager'; +import EPars from 'eterna/EPars'; +import BitmapManager from 'eterna/resources/BitmapManager'; +import Bitmaps from 'eterna/resources/Bitmaps'; +import ConstraintBox, {ConstraintBoxConfig} from './ConstraintBox'; +import Constraint, {BaseConstraintStatus} from './Constraint'; + +export default class BarcodeConstraint extends Constraint { + public static readonly NAME = 'BARCODE'; + + public evaluate(undoBlocks: UndoBlock[]): BaseConstraintStatus { + return { + satisfied: !SolutionManager.instance.checkRedundancyByHairpin( + EPars.sequenceToString(undoBlocks[0].sequence) + ) + }; + } + + public getConstraintBoxConfig( + status: BaseConstraintStatus, + undoBlocks: UndoBlock[], + targetConditions: any[], + forMissionScreen: boolean + ): ConstraintBoxConfig { + let tooltip = ConstraintBox.createTextStyle(); + + if (forMissionScreen) { + tooltip.pushStyle('altTextMain'); + } + + tooltip.append('You must have a '); + + if (forMissionScreen) { + tooltip.append('unique ', 'altText'); + } else { + tooltip.append('unique '); + } + + tooltip.append('barcode.'); + + if (forMissionScreen) { + tooltip.popStyle(); + } + + return { + satisfied: status.satisfied, + fullTexture: forMissionScreen + ? BitmapManager.getBitmap(Bitmaps.NovaBarcodeMissionReq) + : BitmapManager.getBitmap(Bitmaps.NovaBarcodeReq), + clarificationText: 'MUST BE UNIQUE', + tooltip + }; + } +} diff --git a/src/eterna/constraints/BindingConstraint.ts b/src/eterna/constraints/BindingConstraint.ts new file mode 100644 index 000000000..07dc5555f --- /dev/null +++ b/src/eterna/constraints/BindingConstraint.ts @@ -0,0 +1,241 @@ +import UndoBlock, {UndoBlockParam} from 'eterna/UndoBlock'; +import {OligoDef} from 'eterna/mode/PoseEdit/PoseEditMode'; +import {StyledTextBuilder} from 'flashbang'; +import {Graphics} from 'pixi.js'; +import EPars from 'eterna/EPars'; +import {HighlightType} from 'eterna/pose2D/HighlightBox'; +import Utility from 'eterna/util/Utility'; +import ConstraintBox, {ConstraintBoxConfig} from './ConstraintBox'; +import Constraint, {BaseConstraintStatus, HighlightInfo} from './Constraint'; + +interface OligoInfo { + bind: boolean; + label: string; + name: string; +} + +abstract class BindingsConstraint extends Constraint { + public stateIndex: number; + + constructor(stateIndex: number) { + super(); + this.stateIndex = stateIndex; + } + + protected _getOligoInfo(targetConditions: any[]): OligoInfo[] { + return [{ + name: targetConditions[this.stateIndex]['oligo_name'] || 'Oligo 1', + label: targetConditions[this.stateIndex]['oligo_label'] || 'A', + bind: true + }]; + } + + public getConstraintBoxConfig( + status: BaseConstraintStatus, + undoBlocks: UndoBlock[], + targetConditions: any[], + forMissionScreen: boolean + ): ConstraintBoxConfig { + let oligos = this._getOligoInfo(targetConditions); + + let tooltip = ConstraintBox.createTextStyle(); + if (forMissionScreen) { + tooltip.pushStyle('altTextMain'); + } + + tooltip.append(`In state ${this.stateIndex + 1}, your RNA must:\n`); + + for (let oligo of oligos) { + tooltip.append('- '); + if (forMissionScreen) { + tooltip.pushStyle('altText'); + } + tooltip.append(oligo.bind ? 'bind' : 'NOT bind'); + if (forMissionScreen) { + tooltip.popStyle(); + } + tooltip.append(` with ${oligo.name}\n`); + } + + if (forMissionScreen) { + tooltip.popStyle(); + } + + let clarifyTextBuilder = new StyledTextBuilder(); + for (let ii = 0; ii < oligos.length; ii++) { + if (ii > 0) { + clarifyTextBuilder.append('\u2003'); + } + + clarifyTextBuilder.append( + ` ${oligos[ii].label}`, + {fill: oligos[ii].bind ? 0xffffff : 0x808080} + ); + } + + let tw: number = Math.min(101, 15 * (2 * oligos.length - 1)); + let step: number = tw / (2 * oligos.length - 1); + if (oligos.length === 1) tw = 45; + + let iconGraphics = new Graphics(); + iconGraphics.lineStyle(2.5, 0xFFFFFF, 0.9); + iconGraphics.moveTo(0, 25); + iconGraphics.lineTo(tw, 25); + + for (let ii = 0; ii < oligos.length; ii++) { + let ctrlY: number = (oligos[ii].bind ? 22 : 14); + iconGraphics.moveTo((ii * 2) * step, ctrlY); + iconGraphics.lineTo((ii * 2 + 1) * step, ctrlY); + } + + return { + satisfied: status.satisfied, + tooltip, + clarificationText: clarifyTextBuilder, + showOutline: true, + stateNumber: this.stateIndex + 1, + drawBG: true + }; + } + + public getHighlight( + status: BaseConstraintStatus, + undoBlocks: UndoBlock[], + targetConditions: any[] + ): HighlightInfo { + let undoBlock = undoBlocks[this.stateIndex]; + let stateCondition = targetConditions[this.stateIndex]; + + return { + ranges: status.satisfied + ? Utility.range( + undoBlock.sequence.length + 1, + undoBlock.sequence.length + 1 + stateCondition['oligo_sequence'].length - 1 + ) : null, + color: HighlightType.RESTRICTED + }; + } +} + +interface MultistrandConstraintStatus extends BaseConstraintStatus { + unsatisfiedOligoIndexes: number[]; +} + +export class MultistrandBindingsConstraint extends BindingsConstraint { + public static readonly NAME = 'BINDINGS'; + + public evaluate(undoBlocks: UndoBlock[], targetConditions: any[]): MultistrandConstraintStatus { + let undoBlock = undoBlocks[this.stateIndex]; + if (targetConditions == null) { + throw new Error('Target object not available for BINDINGS constraint'); + } + + let stateCondition = targetConditions[this.stateIndex]; + + if (stateCondition == null) { + throw new Error('Target condition not available for BINDINGS constraint'); + } + + const oligos: OligoDef[] = stateCondition['oligos']; + if (oligos == null) { + throw new Error('Target condition not available for BINDINGS constraint'); + } + + let oligoOrder = undoBlock.oligoOrder; + // Unbound oligos are always at the end of the natural mode oligo order, so to know if it's bound according to + // target mode ordering, check if its index in natural mode is less than the number bound + let bindMap = Utility.range(oligoOrder.length).map( + targetIdx => oligoOrder.indexOf(targetIdx) < undoBlock.oligosPaired + ); + + let unsatisfiedOligoIndexes = oligos.map( + (oligoDef, index) => ( + (oligoDef['bind'] != null && oligoDef['bind'] !== bindMap[index]) ? index : -1) + ).filter(val => val !== -1); + + return { + satisfied: unsatisfiedOligoIndexes.length > 0, + unsatisfiedOligoIndexes + }; + } + + protected _getOligoInfo(targetConditions: any[]): OligoInfo[] { + const oligos: OligoDef[] = targetConditions[this.stateIndex]['oligos']; + + return oligos.map( + (def, idx) => (def['bind'] != null ? { + name: def['name'] || `Oligo ${(idx + 1).toString()}`, + bind: Boolean(def['bind']), + label: def['label'] || String.fromCharCode(65 + idx) + } : null) + ); + } + + public getHighlight( + status: MultistrandConstraintStatus, + undoBlocks: UndoBlock[], + targetConditions: any[] + ): HighlightInfo { + let undoBlock = undoBlocks[this.stateIndex]; + const oligos: OligoDef[] = targetConditions[this.stateIndex]['oligos']; + + let highlightedIndices: number[] = []; + // The + 1 is used to account for the "cut" base denoting split points between strands + let oligoFirstBaseIndex = undoBlock.sequence.length + 1; + for (let [idx, oligo] of oligos.entries()) { + if (status.unsatisfiedOligoIndexes.includes(idx)) { + highlightedIndices.push(oligoFirstBaseIndex, oligoFirstBaseIndex + oligo.sequence.length - 1); + } + oligoFirstBaseIndex += oligo.sequence.length + 1; + } + + return { + ranges: highlightedIndices, + color: HighlightType.RESTRICTED + }; + } +} + +export class OligoBoundConstraint extends BindingsConstraint { + public static readonly NAME = 'OLIGO_BOUND'; + + public evaluate(undoBlocks: UndoBlock[], targetConditions: any[]): BaseConstraintStatus { + let nnfe: number[] = undoBlocks[this.stateIndex] + .getParam(UndoBlockParam.NNFE_ARRAY, EPars.DEFAULT_TEMPERATURE); + + if (targetConditions == null) { + throw new Error('Target object not available for BINDINGS constraint'); + } + + let stateCondition = targetConditions[this.stateIndex]; + if (stateCondition == null) { + throw new Error('Target condition not available for BINDINGS constraint'); + } + + return { + satisfied: nnfe != null && nnfe[0] === -2 + }; + } +} + +export class OligoUnboundConstraint extends BindingsConstraint { + public static readonly NAME = 'OLIGO_UNBOUND'; + + public evaluate(undoBlocks: UndoBlock[], targetConditions: any[]): BaseConstraintStatus { + let nnfe: number[] = undoBlocks[this.stateIndex] + .getParam(UndoBlockParam.NNFE_ARRAY, EPars.DEFAULT_TEMPERATURE); + + if (targetConditions == null) { + throw new Error('Target object not available for BINDINGS constraint'); + } + + let stateCondition = targetConditions[this.stateIndex]; + if (stateCondition == null) { + throw new Error('Target condition not available for BINDINGS constraint'); + } + + return { + satisfied: nnfe != null && nnfe[0] !== -2 + }; + } +} diff --git a/src/eterna/constraints/BoostConstraint.ts b/src/eterna/constraints/BoostConstraint.ts new file mode 100644 index 000000000..d804f49da --- /dev/null +++ b/src/eterna/constraints/BoostConstraint.ts @@ -0,0 +1,60 @@ +import UndoBlock from 'eterna/UndoBlock'; +import BitmapManager from 'eterna/resources/BitmapManager'; +import Bitmaps from 'eterna/resources/Bitmaps'; +import ConstraintBox, {ConstraintBoxConfig} from './ConstraintBox'; +import Constraint, {BaseConstraintStatus} from './Constraint'; + +interface BoostConstraintStatus extends BaseConstraintStatus { + boostCount: number; +} + +class BoostConstraint extends Constraint { + public static readonly NAME = 'BOOST'; + public minBoosts: number; + + constructor(minBoosts: number) { + super(); + this.minBoosts = minBoosts; + throw new Error('BOOST constraint is unimplemented'); + } + + public evaluate(undoBlocks: UndoBlock[]): BoostConstraintStatus { + throw new Error('BOOST constraint is unimplemented'); + } + + public getConstraintBoxConfig( + status: BoostConstraintStatus, + undoBlocks: UndoBlock[], + targetConditions: any[], + forMissionScreen: boolean + ): ConstraintBoxConfig { + let tooltip = ConstraintBox.createTextStyle(); + if (forMissionScreen) { + tooltip.pushStyle('altTextMain'); + } + tooltip.append(`You must have ${this.minBoosts.toString()} or `); + + if (forMissionScreen) { + tooltip.append('more', 'altText'); + } else { + tooltip.append('more'); + } + + tooltip.append('boosted loops.'); + + if (forMissionScreen) { + tooltip.popStyle(); + } + + return { + tooltip, + satisfied: status.satisfied, + clarificationText: `${this.minBoosts} OR MORE`, + statText: status.boostCount.toString(), + fullTexture: forMissionScreen + ? BitmapManager.getBitmap(Bitmaps.NovaBoostMissionReq) + : BitmapManager.getBitmap(Bitmaps.NovaBoostReq), + showOutline: true + }; + } +} diff --git a/src/eterna/constraints/ConsecutiveBaseConstraint.ts b/src/eterna/constraints/ConsecutiveBaseConstraint.ts new file mode 100644 index 000000000..40f4ff75d --- /dev/null +++ b/src/eterna/constraints/ConsecutiveBaseConstraint.ts @@ -0,0 +1,107 @@ +import UndoBlock from 'eterna/UndoBlock'; +import EPars from 'eterna/EPars'; +import BitmapManager from 'eterna/resources/BitmapManager'; +import {HighlightType} from 'eterna/pose2D/HighlightBox'; +import ConstraintBox, {ConstraintBoxConfig} from './ConstraintBox'; +import Constraint, {BaseConstraintStatus, HighlightInfo} from './Constraint'; + +interface ConsecutiveConstraintStatus extends BaseConstraintStatus { + currentConsecutive: number; +} + +abstract class ConsecutiveBaseConstraint extends Constraint { + public baseType: number; + public maxConsecutive: number; + + constructor(baseType: number, count: number) { + super(); + this.baseType = baseType; + this.maxConsecutive = count; + } + + public evaluate(undoBlocks: UndoBlock[]): ConsecutiveConstraintStatus { + let count = EPars.countConsecutive( + undoBlocks[0].sequence, + this.baseType + ); + + return { + satisfied: count < this.maxConsecutive, + currentConsecutive: count + }; + } + + public getConstraintBoxConfig( + status: ConsecutiveConstraintStatus, + undoBlocks: UndoBlock[], + targetConditions: any[], + forMissionScreen: boolean + ): ConstraintBoxConfig { + let tooltip = ConstraintBox.createTextStyle(); + if (forMissionScreen) { + tooltip.pushStyle('altTextMain'); + } + tooltip.append('You must have ') + .append('at most', 'altText') + .append(` ${this.maxConsecutive - 1} ${EPars.getColoredLetter(EPars.nucleotideToString(this.baseType, false, false))}s in a row.`); + + if (forMissionScreen) { + tooltip.popStyle(); + } + + return { + satisfied: status.satisfied, + tooltip, + clarificationText: `AT MOST ${this.maxConsecutive - 1} IN A ROW`, + statText: status.currentConsecutive.toString(), + fullTexture: forMissionScreen + ? BitmapManager.getBitmapNamed(`Nova${EPars.nucleotideToString(this.baseType, false, false)}RowMissionReq`) + : BitmapManager.getBitmapNamed(`Nova${EPars.nucleotideToString(this.baseType, false, false)}RowReq`), + showOutline: true + }; + } + + public getHighlight(status: ConsecutiveConstraintStatus, undoBlocks: UndoBlock[]): HighlightInfo { + return { + ranges: EPars.getRestrictedConsecutive( + undoBlocks[0].sequence, + this.baseType, + this.maxConsecutive, + undoBlocks[0].puzzleLocks + ), + color: HighlightType.RESTRICTED + }; + } +} + +export class ConsecutiveAConstraint extends ConsecutiveBaseConstraint { + public static readonly NAME: 'CONSECUTIVE_A'; + + constructor(count: number) { + super(EPars.RNABASE_ADENINE, count); + } +} + +export class ConsecutiveUConstraint extends ConsecutiveBaseConstraint { + public static readonly NAME: 'CONSECUTIVE_U'; + + constructor(count: number) { + super(EPars.RNABASE_URACIL, count); + } +} + +export class ConsecutiveGConstraint extends ConsecutiveBaseConstraint { + public static readonly NAME: 'CONSECUTIVE_G'; + + constructor(count: number) { + super(EPars.RNABASE_GUANINE, count); + } +} + +export class ConsecutiveCConstraint extends ConsecutiveBaseConstraint { + public static readonly NAME: 'CONSECUTIVE_C'; + + constructor(count: number) { + super(EPars.RNABASE_CYTOSINE, count); + } +} diff --git a/src/eterna/constraints/Constraint.ts b/src/eterna/constraints/Constraint.ts new file mode 100644 index 000000000..fca22363a --- /dev/null +++ b/src/eterna/constraints/Constraint.ts @@ -0,0 +1,42 @@ +import UndoBlock from 'eterna/UndoBlock'; +import Puzzle from 'eterna/puzzle/Puzzle'; +import {HighlightType} from 'eterna/pose2D/HighlightBox'; +import {ConstraintBoxConfig} from './ConstraintBox'; + +export interface BaseConstraintStatus { + satisfied: boolean; +} + +export interface HighlightInfo { + // E.g., [1,4,10,12] highlights base indexes 1, 2, 3, 4, 10, 11, and 12 + ranges: number[]; + color: HighlightType; + // Set if only a specific state should have the highlight + stateIndex?: number; +} + +export default abstract class Constraint { + public static readonly NAME: string; + /** + * @param undoBlocks Current undo block for each state of the puzzle + * @param targetConditions + * @param puzzle This is not available in the puzzle maker, so any constraints which require it will not be + * usable within PuzzleMaker for now + */ + public abstract evaluate(undoBlocks: UndoBlock[], targetConditions: any[], puzzle?: Puzzle): ConstraintStatus; + + public abstract getConstraintBoxConfig( + status: ConstraintStatus, + undoBlocks: UndoBlock[], + targetConditions: any[], + forMissionScreen: boolean + ): ConstraintBoxConfig; + + public getHighlight( + status: ConstraintStatus, + undoBlocks: UndoBlock[], + targetConditions: any[] + ): HighlightInfo { + return null; + } +} diff --git a/src/eterna/constraints/ConstraintBox.ts b/src/eterna/constraints/ConstraintBox.ts new file mode 100644 index 000000000..aa2d4e68a --- /dev/null +++ b/src/eterna/constraints/ConstraintBox.ts @@ -0,0 +1,339 @@ +import { + ContainerObject, Enableable, SceneObject, StyledTextBuilder, DisplayUtil, HAlign, VAlign, + SerialTask, DelayTask, AlphaTask, TextureUtil +} from 'flashbang'; +import { + Graphics, Sprite, Text, Point, Texture +} from 'pixi.js'; +import MultiStyleText from 'pixi-multistyle-text'; +import Fonts from 'eterna/util/Fonts'; +import BitmapManager from 'eterna/resources/BitmapManager'; +import Bitmaps from 'eterna/resources/Bitmaps'; +import EPars from 'eterna/EPars'; +import TextBalloon from 'eterna/ui/TextBalloon'; +import {RegistrationGroup} from 'signals'; + +export interface ConstraintBoxConfig { + // Toggle checkmark, green vs red outline + satisfied: boolean; + // Tooltip on hover + tooltip: string | StyledTextBuilder; + // Show the green/red outline + showOutline?: boolean; + // Used when the constraint image includes a background + fullTexture?: Texture; + // Whether to draw the transparent background + drawBG?: boolean; + // Used with drawBG, constraint image without background. If a string, it will be parsed as a base64 encoded image + iconTexture?: Texture | string; + // Alternative to drawBG, used for SHAPE constraints + thumbnailBG?: boolean; + // Alternative to iconTexture, used for SHAPE constraints + thumbnail?: Texture; + // Text used to augment the constraint graphic to describe the constraint + clarificationText?: string | StyledTextBuilder; + // Text describing the current state of the constraint/the value it's "monitoring" + statText?: string | StyledTextBuilder; + // Displays large number in a corner of the constraint box + stateNumber?: number; + // Displays large "NO" in a corner of the constraint box + noText?: boolean; +} + +export default class ConstraintBox extends ContainerObject implements Enableable { + constructor(forMissionScreen: boolean) { + super(); + this._forMissionScreen = forMissionScreen; + } + + public setup(): void { + this._bgGraphics = new Graphics(); + this._bgGraphics.interactiveChildren = false; + this.container.addChild(this._bgGraphics); + + // this._backlight = new Graphics(); + // this._backlight.visible = false; + // this.container.addChild(this._backlight); + + this._req = new Sprite(); + this._req.visible = false; + this.container.addChild(this._req); + + this._bg = new Sprite(); + this._bg.visible = false; + this.container.addChild(this._bg); + + this._icon = new Sprite(null); + this._icon.visible = false; + this.container.addChild(this._icon); + + this._noText = Fonts.arial('NO', 16).color(0xffffff).bold().letterSpacing(-0.5) + .build(); + this._noText.position = new Point(35, 0); + this._noText.visible = false; + this.container.addChild(this._noText); + + this._stateText = Fonts.arial('', 18).color(0xffffff).bold().letterSpacing(-0.5) + .build(); + this._stateText.position = new Point(3, 45); + this._stateText.visible = false; + this.container.addChild(this._stateText); + + this._reqClarifyText = new MultiStyleText('', { + default: { + fontFamily: Fonts.ARIAL, + fontSize: 11, + fill: 0xC0DCE7, + letterSpacing: -0.5 + } + }); + this._reqClarifyText.position = new Point(50, 30); + this._reqClarifyText.visible = false; + this.container.addChild(this._reqClarifyText); + + this._reqStatText = new MultiStyleText('', { + default: { + fontFamily: Fonts.ARIAL, + fontSize: 11, + fill: 0xC0DCE7, + letterSpacing: -0.5 + } + }); + this._reqStatText.position = new Point(50, 50); + this._reqStatText.visible = false; + this.container.addChild(this._reqStatText); + + this._smallThumbnail = new Sprite(); + this._smallThumbnail.position = new Point(6, 6); + this.container.addChild(this._smallThumbnail); + + // this._flag = new Graphics(); + // this._flag.clear(); + // this._flag.beginFill(0xBEDCE7, 1.0); + // this._flag.drawRect(0, 0, 5, 5); + // this._flag.endFill(); + // this._flag.position = new Point(4, 4); + // this.container.addChild(this._flag); + + // if (this._type === ConstraintBoxType.MISSION_SCREEN) { + // this._sideText = new MultiStyleText("", { + // default: { + // fontFamily: Fonts.STDFONT_REGULAR, + // fontSize: 16, + // fill: 0xffffff, + // letterSpacing: -0.5, + // wordWrap: true, + // wordWrapWidth: 250 + // } + // }); + // this.container.addChild(this._sideText); + // } + + this._check = new Sprite(BitmapManager.getBitmap(Bitmaps.NovaGreenCheck)); + this._check.position = new Point(80, 50); + this._check.visible = false; + this.container.addChild(this._check); + + this._outline = new Sprite(); + this._outline.visible = false; + this.container.addChild(this._outline); + + // this._fglow = new Graphics(); + // this._fglow.visible = false; + // this.container.addChild(this._fglow); + } + + public setContent(details: ConstraintBoxConfig): void { + this._check.visible = details.satisfied && this._forMissionScreen; + + this._req.visible = details.fullTexture != null; + if (this._req.visible) { + this._req.texture = details.fullTexture; + } + + this._outline.visible = details.showOutline || false; + if (this._outline.visible) { + this._outline.texture = details.satisfied + ? BitmapManager.getBitmap(Bitmaps.NovaPassOutline) + : BitmapManager.getBitmap(Bitmaps.NovaFailOutline); + } + + this._reqClarifyText.visible = details.clarificationText != null; + if (this._reqClarifyText.visible) { + this.setPossiblyStyledText(details.clarificationText, this._reqClarifyText); + DisplayUtil.positionRelative( + this._reqClarifyText, HAlign.CENTER, VAlign.TOP, + this._outline, HAlign.CENTER, VAlign.TOP, 2, 32 + ); + } + + this._reqStatText.visible = details.statText != null && !this._forMissionScreen; + if (this._reqStatText.visible) { + this.setPossiblyStyledText(details.statText, this._reqStatText); + DisplayUtil.positionRelative( + this._reqStatText, HAlign.CENTER, VAlign.TOP, + this._outline, HAlign.CENTER, VAlign.TOP, 0, 50 + ); + } + + let tooltipText = details.tooltip instanceof StyledTextBuilder + ? details.tooltip : ConstraintBox.createTextStyle().append(details.tooltip); + + if (!details.satisfied) { + tooltipText = tooltipText.clone().append('\n').append('Unsatisfied', {fill: 0xff0000}); + } + + let balloon = new TextBalloon('', 0x0, 0.8); + balloon.styledText = tooltipText; + this.setMouseOverObject(balloon); + + this._bgGraphics.visible = details.drawBG || false; + if (this._bgGraphics.visible) { + this._bgGraphics.clear(); + this._bgGraphics.beginFill(0x1E314B, 0.5); + this._bgGraphics.drawRoundedRect(0, 0, 111, this._forMissionScreen ? 55 : 75, 15); + this._bgGraphics.endFill(); + } + + this._bg.visible = details.thumbnailBG || false; + if (this._bg.visible) { + if (details.satisfied) { + this._bg.texture = BitmapManager.getBitmap(Bitmaps.NovaPuzThumbSmallMet); + } else { + this._bg.texture = BitmapManager.getBitmap(Bitmaps.NovaPuzThumbSmallFail); + } + + this._check.position = new Point(55, 55); + this._noText.position = new Point(35, 1); + this._stateText.position = new Point(3, 45); + } + + if (details.stateNumber) { + this._stateText.visible = true; + this._stateText.text = details.stateNumber.toString(); + } + + if (details.thumbnail) { + this._smallThumbnail.visible = true; + this._smallThumbnail.texture = details.thumbnail; + DisplayUtil.center(this._smallThumbnail, this._bg); + } + + if (details.iconTexture) { + if (details.iconTexture instanceof Texture) { + this._icon.texture = details.iconTexture; + this._icon.position = new Point((111 - this._icon.width) * 0.5, 2); + } else { + TextureUtil.fromBase64PNG(details.iconTexture).then((tex) => { + this._icon.texture = tex; + this._icon.position = new Point((111 - this._icon.width) * 0.5, 2); + }); + } + } + } + + public get enabled(): boolean { + return this.display.visible; + } + + public set enabled(value: boolean) { + this.display.visible = value; + } + + /** Creates a StyledTextBuilder with the ConstraintBox's default settings */ + public static createTextStyle(): StyledTextBuilder { + let style: StyledTextBuilder = new StyledTextBuilder({ + fontFamily: Fonts.STDFONT_REGULAR, + fontSize: 16, + fill: 0xffffff, + letterSpacing: -0.5, + wordWrap: true, + wordWrapWidth: 250 + }).addStyle('altText', { + fontFamily: Fonts.STDFONT_MEDIUM, + leading: 10 + }).addStyle('altTextMain', { + fontFamily: Fonts.STDFONT_REGULAR, + leading: 5 + }); + + EPars.addLetterStyles(style); + + return style; + } + + private setPossiblyStyledText(str: string | StyledTextBuilder, text: MultiStyleText): void { + if (str instanceof StyledTextBuilder) { + str.defaultStyle(text.style); + str.apply(text); + } else { + text.text = str; + } + } + + private setMouseOverObject(obj: SceneObject): void { + const FADE_IN_DELAY = 1.0; + + if (this._mouseOverObject != null) { + this._mouseOverObject.destroySelf(); + this._mouseOverObject = null; + this._mouseOverRegs.close(); + this._mouseOverRegs = null; + } + + if (obj != null) { + obj.display.x = 0; + obj.display.y = 78; + obj.display.visible = false; + obj.display.interactive = false; + this.addObject(obj, this.container); + + this._mouseOverObject = obj; + + const MOUSE_OVER_ANIM = 'MouseOverAnim'; + + let isMouseOver = false; + this._mouseOverRegs = new RegistrationGroup(); + this._mouseOverRegs.add(this.pointerOver.connect(() => { + if (!isMouseOver) { + isMouseOver = true; + obj.display.visible = true; + obj.display.alpha = 0; + obj.replaceNamedObject(MOUSE_OVER_ANIM, new SerialTask( + new DelayTask(FADE_IN_DELAY), + new AlphaTask(1, 0.1) + )); + } + })); + + this._mouseOverRegs.add(this.pointerOut.connect(() => { + if (isMouseOver) { + isMouseOver = false; + obj.removeNamedObjects(MOUSE_OVER_ANIM); + obj.display.visible = false; + } + })); + } + } + + private _forMissionScreen: boolean; + + private _bgGraphics: Graphics; + // private _backlight: Graphics; + private _req: Sprite; + private _bg: Sprite; + private _icon: Sprite; + private _noText: Text; + private _stateText: Text; + private _reqClarifyText: MultiStyleText; + private _reqStatText: MultiStyleText; + private _smallThumbnail: Sprite; + // private _flag: Graphics; + // private _sideText: MultiStyleText; + private _check: Sprite; + private _outline: Sprite; + // private _fglow: Graphics; + + private _mouseOverRegs: RegistrationGroup; + private _mouseOverObject: SceneObject; +} diff --git a/src/eterna/constraints/MaximumBaseConstraint.ts b/src/eterna/constraints/MaximumBaseConstraint.ts new file mode 100644 index 000000000..daa96f3a3 --- /dev/null +++ b/src/eterna/constraints/MaximumBaseConstraint.ts @@ -0,0 +1,97 @@ +import UndoBlock from 'eterna/UndoBlock'; +import EPars from 'eterna/EPars'; +import BitmapManager from 'eterna/resources/BitmapManager'; +import ConstraintBox, {ConstraintBoxConfig} from './ConstraintBox'; +import Constraint, {BaseConstraintStatus} from './Constraint'; + +interface MaxBaseConstraintStatus extends BaseConstraintStatus { + currentCount: number; +} + +abstract class MaximumBaseConstraint extends Constraint { + public baseType: number; + public maxCount: number; + + constructor(baseType: number, maxCount: number) { + super(); + this.baseType = baseType; + this.maxCount = maxCount; + } + + public evaluate(undoBlocks: UndoBlock[]): MaxBaseConstraintStatus { + // TODO: Multistate? + const count = undoBlocks[0].sequence.reduce( + (acc, curr) => acc + (curr === this.baseType ? 1 : 0), 0 + ); + + return { + satisfied: count <= this.maxCount, + currentCount: count + }; + } + + public getConstraintBoxConfig( + status: MaxBaseConstraintStatus, + undoBlocks: UndoBlock[], + targetConditions: any[], + forMissionScreen: boolean + ): ConstraintBoxConfig { + let tooltip = ConstraintBox.createTextStyle(); + + if (forMissionScreen) { + tooltip.pushStyle('altTextMain'); + } + + tooltip.append('You must have ') + .append('at most', 'altText') + .append(` ${this.maxCount}`) + .append(` ${EPars.getColoredLetter(EPars.nucleotideToString(this.baseType, false, false))}s.`); + + if (forMissionScreen) { + tooltip.popStyle(); + } + + return { + satisfied: status.satisfied, + tooltip, + clarificationText: `${this.maxCount} OR FEWER`, + statText: status.currentCount.toString(), + showOutline: true, + fullTexture: forMissionScreen + ? BitmapManager.getBitmapNamed(`Nova${EPars.nucleotideToString(this.baseType, false, false)}MissionReq`) + : BitmapManager.getBitmapNamed(`Nova${EPars.nucleotideToString(this.baseType, false, false)}Req`) + }; + } +} + +export class MaximumAConstraint extends MaximumBaseConstraint { + public static readonly NAME: 'AMAX'; + + constructor(count: number) { + super(EPars.RNABASE_ADENINE, count); + } +} + +export class MaximumUConstraint extends MaximumBaseConstraint { + public static readonly NAME: 'UMAX'; + + constructor(count: number) { + super(EPars.RNABASE_URACIL, count); + } +} + +export class MaximumGConstraint extends MaximumBaseConstraint { + public static readonly NAME: 'GMAX'; + + constructor(count: number) { + super(EPars.RNABASE_GUANINE, count); + } +} + +export class MaximumCConstraint extends MaximumBaseConstraint { + public static readonly NAME: 'CMAX'; + + constructor(count: number) { + super(EPars.RNABASE_CYTOSINE, count); + } +} diff --git a/src/eterna/constraints/MaximumMutationConstraint.ts b/src/eterna/constraints/MaximumMutationConstraint.ts new file mode 100644 index 000000000..621635696 --- /dev/null +++ b/src/eterna/constraints/MaximumMutationConstraint.ts @@ -0,0 +1,79 @@ +import { + Sprite, Texture, Container, Point +} from 'pixi.js'; +import {TextureUtil} from 'flashbang'; +import UndoBlock from 'eterna/UndoBlock'; +import Puzzle from 'eterna/puzzle/Puzzle'; +import EPars from 'eterna/EPars'; +import BitmapManager from 'eterna/resources/BitmapManager'; +import Bitmaps from 'eterna/resources/Bitmaps'; +import ConstraintBox, {ConstraintBoxConfig} from './ConstraintBox'; +import Constraint, {BaseConstraintStatus} from './Constraint'; + +interface MaxMutationConstraintStatus extends BaseConstraintStatus { + mutations: number; +} + +export default class MaximumMutationConstraint extends Constraint { + public static readonly NAME = 'MUTATION'; + public maxMutations: number; + + constructor(maxMutations: number) { + super(); + this.maxMutations = maxMutations; + } + + public evaluate(undoBlocks: UndoBlock[], targetConditions: any, puzzle: Puzzle): MaxMutationConstraintStatus { + if (!puzzle) throw new Error('Mutaiton constraint requires beginning sequence, which is unavailable'); + + const mutations: number = EPars.sequenceDiff( + puzzle.getSubsequenceWithoutBarcode(undoBlocks[0].sequence), + puzzle.getSubsequenceWithoutBarcode(puzzle.getBeginningSequence()) + ); + + return { + satisfied: mutations <= this.maxMutations, + mutations + }; + } + + public getConstraintBoxConfig(status: MaxMutationConstraintStatus): ConstraintBoxConfig { + let statText = ConstraintBox.createTextStyle() + .append(status.mutations.toString(), {fill: (status.satisfied ? 0x00aa00 : 0xaa0000)}) + .append(`/${this.maxMutations}`); + + let tooltip = ConstraintBox.createTextStyle().append(`You can only mutate up to ${this.maxMutations} bases`); + + return { + satisfied: status.satisfied, + tooltip, + drawBG: true, + iconTexture: MaximumMutationConstraint._icon, + showOutline: true, + statText, + clarificationText: `AT MOST ${this.maxMutations} CHANGES` + }; + } + + private static get _icon(): Texture { + let icon = new Container(); + + let base1 = new Sprite(BitmapManager.getBitmap(Bitmaps.BaseAMid)); + base1.position = new Point(28, 8); + icon.addChild(base1); + + let base2 = new Sprite(BitmapManager.getBitmap(Bitmaps.BaseGMid)); + base2.position = new Point(36, 8); + icon.addChild(base2); + + let base3 = new Sprite(BitmapManager.getBitmap(Bitmaps.BaseUMid)); + base3.position = new Point(44, 8); + icon.addChild(base3); + + let base4 = new Sprite(BitmapManager.getBitmap(Bitmaps.BaseCMid)); + base4.position = new Point(52, 8); + icon.addChild(base4); + + return TextureUtil.renderToTexture(icon); + } +} diff --git a/src/eterna/constraints/MaximumPairConstraint.ts b/src/eterna/constraints/MaximumPairConstraint.ts new file mode 100644 index 000000000..4ec1ed004 --- /dev/null +++ b/src/eterna/constraints/MaximumPairConstraint.ts @@ -0,0 +1,133 @@ +import UndoBlock, {UndoBlockParam} from 'eterna/UndoBlock'; +import EPars from 'eterna/EPars'; +import BitmapManager from 'eterna/resources/BitmapManager'; +import Bitmaps from 'eterna/resources/Bitmaps'; +import ConstraintBox, {ConstraintBoxConfig} from './ConstraintBox'; +import Constraint, {BaseConstraintStatus} from './Constraint'; + +interface MaxPairConstraintStatus extends BaseConstraintStatus { + currentPairs: number; +} + +abstract class MaximumPairConstraint extends Constraint { + public pairType: number; + public maxPairs: number; + + constructor(pairType: number, maxPairs: number) { + super(); + this.pairType = pairType; + this.maxPairs = maxPairs; + } + + public evaluate(undoBlocks: UndoBlock[]): MaxPairConstraintStatus { + // TODO: Multistate? + const currentPairs: number = undoBlocks[0].getParam( + UndoBlockParam[EPars.nucleotidePairToString(this.pairType)] + ); + return { + satisfied: ( + currentPairs <= this.maxPairs + ), + currentPairs + }; + } + + public getConstraintBoxConfig( + status: MaxPairConstraintStatus, + undoBlocks: UndoBlock[], + targetConditions: any[], + forMissionScreen: boolean + ): ConstraintBoxConfig { + let tooltip = ConstraintBox.createTextStyle(); + + if (forMissionScreen) { + tooltip.pushStyle('altTextMain'); + } + + tooltip.append('You must have ') + .append('at most', 'altText') + .append(` ${this.maxPairs} `) + .append(`${EPars.getColoredLetter(EPars.nucleotidePairToString(this.pairType).charAt(0))}-`) + .append(`${EPars.getColoredLetter(EPars.nucleotidePairToString(this.pairType).charAt(1))} pairs.`); + + if (forMissionScreen) { + tooltip.popStyle(); + } + + return { + satisfied: status.satisfied, + clarificationText: `${this.maxPairs} OR FEWER`, + statText: status.currentPairs.toString(), + tooltip + }; + } +} + +export class MaximumGCConstraint extends MaximumPairConstraint { + public static readonly NAME = 'GC'; + + constructor(count: number) { + super(EPars.RNABASE_GC_PAIR, count); + } + + /** @override */ + public getConstraintBoxConfig( + status: MaxPairConstraintStatus, + undoBlocks: UndoBlock[], + targetConditions: any[], + forMissionScreen: boolean + ): ConstraintBoxConfig { + return { + ...super.getConstraintBoxConfig(status, undoBlocks, targetConditions, forMissionScreen), + fullTexture: forMissionScreen + ? BitmapManager.getBitmap(Bitmaps.NovaGCMissionReq) + : BitmapManager.getBitmap(Bitmaps.NovaGCReq) + }; + } +} + +export class MaximumAUConstraint extends MaximumPairConstraint { + public static readonly NAME = 'AUMAX'; + + constructor(count: number) { + super(EPars.RNABASE_AU_PAIR, count); + } + + /** @override */ + public getConstraintBoxConfig( + status: MaxPairConstraintStatus, + undoBlocks: UndoBlock[], + targetConditions: any[], + forMissionScreen: boolean + ): ConstraintBoxConfig { + return { + ...super.getConstraintBoxConfig(status, undoBlocks, targetConditions, forMissionScreen), + fullTexture: forMissionScreen + ? BitmapManager.getBitmap(Bitmaps.NovaAUMissionReq) + : BitmapManager.getBitmap(Bitmaps.NovaAUReq) + }; + } +} + +export class MaximumGUConstraint extends MaximumPairConstraint { + public static readonly NAME = 'GUMAX'; + + constructor(count: number) { + super(EPars.RNABASE_GU_PAIR, count); + } + + /** @override */ + public getConstraintBoxConfig( + status: MaxPairConstraintStatus, + undoBlocks: UndoBlock[], + targetConditions: any[], + forMissionScreen: boolean + ): ConstraintBoxConfig { + return { + ...super.getConstraintBoxConfig(status, undoBlocks, targetConditions, forMissionScreen), + fullTexture: forMissionScreen + ? BitmapManager.getBitmap(Bitmaps.NovaAUMissionReq) + : BitmapManager.getBitmap(Bitmaps.NovaAUReq) + }; + } +} diff --git a/src/eterna/constraints/MinimumBaseConstraint.ts b/src/eterna/constraints/MinimumBaseConstraint.ts new file mode 100644 index 000000000..80543677b --- /dev/null +++ b/src/eterna/constraints/MinimumBaseConstraint.ts @@ -0,0 +1,95 @@ +import UndoBlock from 'eterna/UndoBlock'; +import EPars from 'eterna/EPars'; +import BitmapManager from 'eterna/resources/BitmapManager'; +import ConstraintBox, {ConstraintBoxConfig} from './ConstraintBox'; +import Constraint, {BaseConstraintStatus} from './Constraint'; + +interface MinBaseConstraintStatus extends BaseConstraintStatus{ + currentCount: number; +} + +abstract class MinimumBaseConstraint extends Constraint { + public baseType: number; + public minCount: number; + + constructor(baseType: number, minCount: number) { + super(); + this.baseType = baseType; + this.minCount = minCount; + } + + public evaluate(undoBlocks: UndoBlock[]): MinBaseConstraintStatus { + // TODO: Multistate? + const count = undoBlocks[0].sequence.reduce( + (acc, curr) => acc + (curr === this.baseType ? 1 : 0), 0 + ); + + return { + satisfied: count >= this.minCount, + currentCount: count + }; + } + + public getConstraintBoxConfig( + status: MinBaseConstraintStatus, + undoBlocks: UndoBlock[], + targetConditions: any[], + forMissionScreen: boolean + ): ConstraintBoxConfig { + let tooltip = ConstraintBox.createTextStyle(); + + if (forMissionScreen) { + tooltip.pushStyle('altTextMain'); + } + + tooltip.append(`You must have ${this.minCount} or more`) + .append(` ${EPars.getColoredLetter(EPars.nucleotideToString(this.baseType, false, false))}s.`); + + if (forMissionScreen) { + tooltip.popStyle(); + } + + return { + satisfied: status.satisfied, + tooltip, + clarificationText: `${this.minCount} OR MORE`, + statText: status.currentCount.toString(), + showOutline: true, + fullTexture: forMissionScreen + ? BitmapManager.getBitmapNamed(`Nova${EPars.nucleotideToString(this.baseType, false, false)}MissionReq`) + : BitmapManager.getBitmapNamed(`Nova${EPars.nucleotideToString(this.baseType, false, false)}Req`) + }; + } +} + +export class MinimumAConstraint extends MinimumBaseConstraint { + public static readonly NAME: 'A'; + + constructor(count: number) { + super(EPars.RNABASE_ADENINE, count); + } +} + +export class MinimumUConstraint extends MinimumBaseConstraint { + public static readonly NAME: 'U'; + + constructor(count: number) { + super(EPars.RNABASE_URACIL, count); + } +} + +export class MinimumGConstraint extends MinimumBaseConstraint { + public static readonly NAME: 'G'; + + constructor(count: number) { + super(EPars.RNABASE_GUANINE, count); + } +} + +export class MinimumCConstraint extends MinimumBaseConstraint { + public static readonly NAME: 'C'; + + constructor(count: number) { + super(EPars.RNABASE_CYTOSINE, count); + } +} diff --git a/src/eterna/constraints/MinimumPairConstraint.ts b/src/eterna/constraints/MinimumPairConstraint.ts new file mode 100644 index 000000000..547f2d629 --- /dev/null +++ b/src/eterna/constraints/MinimumPairConstraint.ts @@ -0,0 +1,184 @@ +import UndoBlock, {UndoBlockParam} from 'eterna/UndoBlock'; +import EPars from 'eterna/EPars'; +import BitmapManager from 'eterna/resources/BitmapManager'; +import Bitmaps from 'eterna/resources/Bitmaps'; +import ConstraintBox, {ConstraintBoxConfig} from './ConstraintBox'; +import Constraint, {BaseConstraintStatus} from './Constraint'; + +interface MinPairConstraintStatus extends BaseConstraintStatus { + currentPairs: number; +} + +abstract class MinimumPairConstraint extends Constraint { + public pairType: number; + public minPairs: number; + + constructor(pairType: number, minPairs: number) { + super(); + this.pairType = pairType; + this.minPairs = minPairs; + } + + public evaluate(undoBlocks: UndoBlock[]): MinPairConstraintStatus { + // TODO: Multistate? + const currentPairs: number = undoBlocks[0].getParam( + UndoBlockParam[EPars.nucleotidePairToString(this.pairType)] + ); + return { + satisfied: ( + currentPairs >= this.minPairs + ), + currentPairs + }; + } + + public getConstraintBoxConfig( + status: MinPairConstraintStatus, + undoBlocks: UndoBlock[], + targetConditions: any[], + forMissionScreen: boolean + ): ConstraintBoxConfig { + let tooltip = ConstraintBox.createTextStyle(); + + if (forMissionScreen) { + tooltip.pushStyle('altTextMain'); + } + + tooltip.append('You must have ') + .append(`${this.minPairs} or more`) + .append(`${EPars.getColoredLetter(EPars.nucleotidePairToString(this.pairType).charAt(0))}-`) + .append(`${EPars.getColoredLetter(EPars.nucleotidePairToString(this.pairType).charAt(1))} pairs.`); + + if (forMissionScreen) { + tooltip.popStyle(); + } + + return { + satisfied: status.satisfied, + clarificationText: `${this.minPairs} OR MORE`, + statText: status.currentPairs.toString(), + tooltip + }; + } +} + +export class MinimumGCConstraint extends MinimumPairConstraint { + public static readonly NAME = 'GCMIN'; + + constructor(count: number) { + super(EPars.RNABASE_GC_PAIR, count); + } + + /** @override */ + public getConstraintBoxConfig( + status: MinPairConstraintStatus, + undoBlocks: UndoBlock[], + targetConditions: any[], + forMissionScreen: boolean + ): ConstraintBoxConfig { + return { + ...super.getConstraintBoxConfig(status, undoBlocks, targetConditions, forMissionScreen), + fullTexture: forMissionScreen + ? BitmapManager.getBitmap(Bitmaps.NovaGCMissionReq) + : BitmapManager.getBitmap(Bitmaps.NovaGCReq) + }; + } +} + +export class MinimumAUConstraint extends MinimumPairConstraint { + public static readonly NAME = 'AU'; + + constructor(count: number) { + super(EPars.RNABASE_AU_PAIR, count); + } + + /** @override */ + public getConstraintBoxConfig( + status: MinPairConstraintStatus, + undoBlocks: UndoBlock[], + targetConditions: any[], + forMissionScreen: boolean + ): ConstraintBoxConfig { + return { + ...super.getConstraintBoxConfig(status, undoBlocks, targetConditions, forMissionScreen), + fullTexture: forMissionScreen + ? BitmapManager.getBitmap(Bitmaps.NovaAUMissionReq) + : BitmapManager.getBitmap(Bitmaps.NovaAUReq) + }; + } +} + +export class MinimumGUConstraint extends MinimumPairConstraint { + public static readonly NAME = 'GU'; + + constructor(count: number) { + super(EPars.RNABASE_GU_PAIR, count); + } + + /** @override */ + public getConstraintBoxConfig( + status: MinPairConstraintStatus, + undoBlocks: UndoBlock[], + targetConditions: any[], + forMissionScreen: boolean + ): ConstraintBoxConfig { + return { + ...super.getConstraintBoxConfig(status, undoBlocks, targetConditions, forMissionScreen), + fullTexture: forMissionScreen + ? BitmapManager.getBitmap(Bitmaps.NovaAUMissionReq) + : BitmapManager.getBitmap(Bitmaps.NovaAUReq) + }; + } +} + +export class MinimumAnyPairConstraint extends MinimumPairConstraint { + public static readonly NAME = 'PAIRS'; + + constructor(count: number) { + super(null, count); + } + + /** @override */ + public evaluate(undoBlocks: UndoBlock[]): MinPairConstraintStatus { + // TODO: Multistate? + const currentPairs: number = ( + undoBlocks[0].getParam(UndoBlockParam['GC']) + + undoBlocks[0].getParam(UndoBlockParam['AU']) + + undoBlocks[0].getParam(UndoBlockParam['GU']) + ); + return { + satisfied: ( + currentPairs >= this.minPairs + ), + currentPairs + }; + } + + /** @override */ + public getConstraintBoxConfig( + status: MinPairConstraintStatus, + undoBlocks: UndoBlock[], + targetConditions: any[], + forMissionScreen: boolean + ): ConstraintBoxConfig { + let tooltip = ConstraintBox.createTextStyle(); + + if (forMissionScreen) { + tooltip.pushStyle('altTextMain'); + } + + tooltip.append(`You must have ${this.minPairs} or more pairs`); + + if (forMissionScreen) { + tooltip.popStyle(); + } + + return { + ...super.getConstraintBoxConfig(status, undoBlocks, targetConditions, forMissionScreen), + tooltip, + fullTexture: forMissionScreen + ? BitmapManager.getBitmap(Bitmaps.NovaPairsMissionReq) + : BitmapManager.getBitmap(Bitmaps.NovaPairsReq) + }; + } +} diff --git a/src/eterna/constraints/MinimumStackLengthConstraint.ts b/src/eterna/constraints/MinimumStackLengthConstraint.ts new file mode 100644 index 000000000..a66876272 --- /dev/null +++ b/src/eterna/constraints/MinimumStackLengthConstraint.ts @@ -0,0 +1,77 @@ +import UndoBlock, {UndoBlockParam} from 'eterna/UndoBlock'; +import { + Container, Sprite, Point, Texture +} from 'pixi.js'; +import BitmapManager from 'eterna/resources/BitmapManager'; +import Bitmaps from 'eterna/resources/Bitmaps'; +import {TextureUtil} from 'flashbang'; +import Band from 'eterna/ui/Band'; +import ConstraintBox, {ConstraintBoxConfig} from './ConstraintBox'; +import Constraint, {BaseConstraintStatus} from './Constraint'; + +interface MinStackConstraintStatus extends BaseConstraintStatus{ + currentLength: number; +} + +export default class MinimumStackLengthConstraint extends Constraint { + public static readonly NAME = 'STACK'; + public minLength: number; + + constructor(minLength: number) { + super(); + this.minLength = minLength; + } + + public evaluate(undoBlocks: UndoBlock[]): MinStackConstraintStatus { + // TODO: Multistate? + const stackLen = undoBlocks[0].getParam(UndoBlockParam.STACK); + return { + satisfied: stackLen >= this.minLength, + currentLength: stackLen + }; + } + + public getConstraintBoxConfig(status: MinStackConstraintStatus): ConstraintBoxConfig { + let statText = ConstraintBox.createTextStyle() + .append(status.currentLength.toString(), {fill: status.satisfied ? 0x00aa00 : 0xaa0000}) + .append(`/${this.minLength}`); + + return { + satisfied: status.satisfied, + tooltip: `You must have a stack with ${this.minLength} or more pairs.`, + statText, + iconTexture: MinimumStackLengthConstraint._icon + }; + } + + private static get _icon(): Texture { + let icon = new Container(); + let tex = BitmapManager.getBitmap(Bitmaps.BaseWMidPattern); + + let base1 = new Sprite(tex); + base1.position = new Point(8, 1); + icon.addChild(base1); + + let base2 = new Sprite(tex); + base2.position = new Point(33, 1); + icon.addChild(base2); + + let base3 = new Sprite(tex); + base3.position = new Point(8, 15); + icon.addChild(base3); + + let base4 = new Sprite(tex); + base4.position = new Point(33, 15); + icon.addChild(base4); + + let bond1 = new Band(3, 3, 1); + bond1.display.position = new Point(22, 3); + icon.addChild(bond1.container); + + let bond2 = new Band(3, 3, 1); + bond2.display.position = new Point(22, 17); + icon.addChild(bond2.container); + + return TextureUtil.renderToTexture(icon); + } +} diff --git a/src/eterna/constraints/ShapeConstraint.ts b/src/eterna/constraints/ShapeConstraint.ts new file mode 100644 index 000000000..f3728d20f --- /dev/null +++ b/src/eterna/constraints/ShapeConstraint.ts @@ -0,0 +1,252 @@ +import UndoBlock from 'eterna/UndoBlock'; +import EPars from 'eterna/EPars'; +import PoseThumbnail, {PoseThumbnailType} from 'eterna/ui/PoseThumbnail'; +import {HighlightType} from 'eterna/pose2D/HighlightBox'; +import Constraint, {BaseConstraintStatus, HighlightInfo} from './Constraint'; +import ConstraintBox, {ConstraintBoxConfig} from './ConstraintBox'; + +interface ShapeConstraintStatus extends BaseConstraintStatus { + wrongPairs: number[]; +} + +abstract class BaseShapeConstraint extends Constraint { + protected readonly stateIndex: number; + + constructor(stateIndex: number) { + super(); + this.stateIndex = stateIndex; + } + + /** + * Given the constraints for the "raw" indices of bases (oligo order defined by targetOligos) + * get the constraints for each base with the "target structure" indices of bases + * (oligo order defined by the target structure, user-modifiable with magic glue) + * + * @param constraints + * @param ublk + */ + protected _targetAlignedConstraints(constraints: boolean[], ublk: UndoBlock): boolean[] { + let targetMap = ublk.reorderedOligosIndexMap(ublk.targetOligoOrder); + + let targetAlignedConstraints: boolean[] = []; + for (let [rawIndex, targetIndex] of Object.entries(targetMap)) { + targetAlignedConstraints[targetIndex] = constraints[Number(rawIndex)]; + } + return targetAlignedConstraints; + } + + /** + * Given the pair map for the "natural mode" indices of bases (oligo order defined by the natural mode folding) + * get the pair map for using the "target structure" indices of bases + * (oligo order defined by the target structure, user-modifiable with magic glue) + * so that the pair map for natural mode can be compared to the pair map for target mode + * + * @param constraints + * @param ublk + */ + protected _targetAlignedNaturalPairs(ublk: UndoBlock): number[] { + // rawIndex => targetAlignedIndex + let targetMap = ublk.reorderedOligosIndexMap(ublk.targetOligoOrder); + // rawIndex => naturalAlignedIndex + let naturalMap = ublk.reorderedOligosIndexMap(ublk.oligoOrder); + let naturalPairs = ublk.getPairs(); + + let targetAlignedNaturalPairs: number[] = []; + for (let [rawIndex, targetIndex] of Object.entries(targetMap)) { + let naturalIndex = naturalMap[Number(rawIndex)]; + let naturalPairedIndex = naturalPairs[naturalIndex]; + let rawPairedIndex = naturalMap.indexOf(naturalPairedIndex); + + // If unpaired, it's unpaired, otherwise we need to get the index of the paired base + // according to target mode + targetAlignedNaturalPairs[targetIndex] = naturalPairedIndex < 0 + ? naturalPairedIndex : targetMap[rawPairedIndex]; + } + + return targetAlignedNaturalPairs; + } + + public getConstraintBoxConfig( + status: ShapeConstraintStatus, + undoBlocks: UndoBlock[], + targetConditions: any[] + ): ConstraintBoxConfig { + let undoBlock = undoBlocks[this.stateIndex]; + let naturalPairs = this._targetAlignedNaturalPairs(undoBlock); + + return { + satisfied: status.satisfied, + tooltip: '', + thumbnailBG: true, + stateNumber: targetConditions.length > 1 ? this.stateIndex + 1 : null, + thumbnail: PoseThumbnail.createFramedBitmap( + new Array(naturalPairs.length).fill(EPars.RNABASE_ADENINE), + undoBlock.targetPairs, 3, PoseThumbnailType.WRONG_COLORED, 0, status.wrongPairs, false, 0 + ) + }; + } + + public getHighlight(status: ShapeConstraintStatus): HighlightInfo { + let unstable: number[] = []; + if (status.wrongPairs) { + let curr = 0; + let jj: number; + for (jj = 0; jj < status.wrongPairs.length; jj++) { + let stat: number = (status.wrongPairs[jj] === 1 ? 1 : 0); + if ((curr ^ stat) !== 0) { + unstable.push(jj - curr); + curr = stat; + } + } + if ((unstable.length % 2) === 1) { + unstable.push(jj - 1); + } + } + + return { + ranges: unstable, + color: HighlightType.UNSTABLE + }; + } +} + +export default class ShapeConstraint extends BaseShapeConstraint { + public static readonly NAME = 'SHAPE'; + + public evaluate(undoBlocks: UndoBlock[], targetConditions: any[]): ShapeConstraintStatus { + let undoBlock = undoBlocks[this.stateIndex]; + + // TODO: These checks should probably be in Puzzle + if (targetConditions == null) { + throw new Error('Target object not available for SHAPE constraint'); + } + + if (targetConditions[this.stateIndex] == null) { + throw new Error('Target condition not available for SHAPE constraint'); + } + + let structureConstraints: any = targetConditions[this.stateIndex]['structure_constraints']; + + let naturalPairs = this._targetAlignedNaturalPairs(undoBlock); + let targetAlignedConstraints = this._targetAlignedConstraints(structureConstraints, undoBlock); + + return { + satisfied: EPars.arePairsSame(naturalPairs, undoBlock.targetPairs, targetAlignedConstraints), + wrongPairs: this._getWrongPairs(naturalPairs, undoBlock.targetPairs, targetAlignedConstraints) + }; + } + + public getConstraintBoxConfig( + status: ShapeConstraintStatus, + undoBlocks: UndoBlock[], + targetConditions: any[] + ): ConstraintBoxConfig { + let details = super.getConstraintBoxConfig(status, undoBlocks, targetConditions); + return { + ...details, + tooltip: ConstraintBox.createTextStyle().append( + details.stateNumber + ? `In state ${details.stateNumber}, your RNA must fold into the outlined structure.` + : 'Your RNA must fold into the outlined structure.' + ) + }; + } + + private _getWrongPairs( + naturalPairs: number[], targetPairs: number[], structureConstraints: any[] + ): number[] { + let wrongPairs: number[] = new Array(naturalPairs.length); + + for (let ii = 0; ii < wrongPairs.length; ii++) { + wrongPairs[ii] = -1; + } + for (let ii = 0; ii < wrongPairs.length; ii++) { + if (naturalPairs[ii] !== targetPairs[ii]) { + if (structureConstraints == null || structureConstraints[ii]) { + wrongPairs[ii] = 1; + } else { + wrongPairs[ii] = 0; + } + } else if (structureConstraints == null || structureConstraints[ii]) { + wrongPairs[ii] = -1; + } else { + wrongPairs[ii] = 0; + } + } + return wrongPairs; + } +} + +export class AntiShapeConstraint extends BaseShapeConstraint { + public static readonly NAME = 'ANTISHAPE'; + + public evaluate(undoBlocks: UndoBlock[], targetConditions: any[]): ShapeConstraintStatus { + let undoBlock = undoBlocks[this.stateIndex]; + + // TODO: These checks should probably be in Puzzle + if (targetConditions == null) { + throw new Error('Target object not available for SHAPE constraint'); + } + + if (targetConditions[this.stateIndex] == null) { + throw new Error('Target condition not available for SHAPE constraint'); + } + + let antiStructureConstraints: any[] = targetConditions[this.stateIndex]['anti_structure_constraints']; + + let naturalPairs = this._targetAlignedNaturalPairs(undoBlock); + let targetAlignedConstraints = this._targetAlignedConstraints(antiStructureConstraints, undoBlock); + + let antiStructureString: string = targetConditions[this.stateIndex]['anti_secstruct']; + if (antiStructureString == null) { + throw new Error('Target structure not available for ANTISHAPE constraint'); + } + let antiPairs: number[] = EPars.parenthesisToPairs(antiStructureString); + + return { + satisfied: !EPars.arePairsSame(naturalPairs, antiPairs, targetAlignedConstraints), + wrongPairs: this._getWrongPairs( + naturalPairs, + targetAlignedConstraints, + EPars.arePairsSame(naturalPairs, antiPairs, targetAlignedConstraints) + ) + }; + } + + public getConstraintBoxConfig( + status: ShapeConstraintStatus, + undoBlocks: UndoBlock[], + targetConditions: any[] + ): ConstraintBoxConfig { + let details = super.getConstraintBoxConfig(status, undoBlocks, targetConditions); + return { + ...details, + tooltip: ConstraintBox.createTextStyle().append( + details.stateNumber + ? `In state ${details.stateNumber}, your RNA must fold into the outlined structure.` + : 'Your RNA must fold into the outlined structure.' + ), + noText: true + }; + } + + private _getWrongPairs( + naturalPairs: number[], structureConstraints: any[], satisfied: boolean + ): number[] { + let wrongPairs: number[] = new Array(naturalPairs.length); + + for (let ii = 0; ii < wrongPairs.length; ii++) { + wrongPairs[ii] = 0; + } + for (let ii = 0; ii < wrongPairs.length; ii++) { + if (structureConstraints == null || structureConstraints[ii]) { + if (satisfied) { + wrongPairs[ii] = -1; + } else { + wrongPairs[ii] = 1; + } + } + } + return wrongPairs; + } +} diff --git a/src/eterna/constraints/SynthesisConstraint.ts b/src/eterna/constraints/SynthesisConstraint.ts new file mode 100644 index 000000000..0af7a50f0 --- /dev/null +++ b/src/eterna/constraints/SynthesisConstraint.ts @@ -0,0 +1,126 @@ +import UndoBlock from 'eterna/UndoBlock'; +import BitmapManager from 'eterna/resources/BitmapManager'; +import Bitmaps from 'eterna/resources/Bitmaps'; +import {StyledTextBuilder} from 'flashbang'; +import Fonts from 'eterna/util/Fonts'; +import EPars from 'eterna/EPars'; +import {HighlightType} from 'eterna/pose2D/HighlightBox'; +import ConstraintBox, {ConstraintBoxConfig} from './ConstraintBox'; +import {ConsecutiveAConstraint, ConsecutiveGConstraint, ConsecutiveCConstraint} from './ConsecutiveBaseConstraint'; +import Constraint, {BaseConstraintStatus, HighlightInfo} from './Constraint'; + +interface SynthConstraintStatus extends BaseConstraintStatus { + currentA: number; + currentG: number; + currentC: number; +} + +export default class SynthesisConstraint extends Constraint { + public static readonly NAME = 'LAB_REQUIREMENTS'; + + public static readonly AMAX = 5; + public static readonly GMAX = 4; + public static readonly CMAX = 5; + + public evaluate(undoBlocks: UndoBlock[]): SynthConstraintStatus { + let aRet = this._consecutiveAConstraint.evaluate(undoBlocks); + let gRet = this._consecutiveGConstraint.evaluate(undoBlocks); + let cRet = this._consecutiveCConstraint.evaluate(undoBlocks); + + return { + satisfied: [aRet, gRet, cRet].every(ret => ret.satisfied), + currentA: aRet.currentConsecutive, + currentG: aRet.currentConsecutive, + currentC: cRet.currentConsecutive + }; + } + + public getConstraintBoxConfig( + status: SynthConstraintStatus, + undoBlocks: UndoBlock[], + targetConditions: any[], + forMissionScreen: boolean + ): ConstraintBoxConfig { + let statText: StyledTextBuilder | string; + + if (forMissionScreen) { + statText = ''; + } else if (status.satisfied) { + statText = 'ok'; + } else { + statText = new StyledTextBuilder({ + fontFamily: Fonts.ARIAL, + fontSize: 11, + fill: 0xC0DCE7, + letterSpacing: -0.5 + }); + statText.addStyle('redText', {fill: 0xff0000}); + + if (!(status.currentG < SynthesisConstraint.GMAX)) { + statText.append((status.currentG).toString(), 'redText').append('G'); + } + + if (!(status.currentC < SynthesisConstraint.CMAX)) { + statText.append((status.currentC).toString(), 'redText').append('C'); + } + + if (!(status.currentA < SynthesisConstraint.AMAX)) { + statText.append((status.currentA).toString(), 'redText').append('A'); + } + } + + let tooltip = ConstraintBox.createTextStyle(); + if (forMissionScreen) { + tooltip.pushStyle('altTextMain'); + } + + tooltip.append('You must have:\n') + .append('- ').append('at most', 'altText').append(` ${SynthesisConstraint.GMAX - 1} `) + .append(`${EPars.getColoredLetter('G')}s in a row\n`) + .append('- ') + .append('at most', 'altText') + .append(` ${SynthesisConstraint.CMAX - 1} `) + .append(`${EPars.getColoredLetter('C')}s in a row\n`) + .append('- ') + .append('at most', 'altText') + .append(` ${SynthesisConstraint.AMAX - 1} `) + .append(`${EPars.getColoredLetter('A')}s in a row\n`); + + if (forMissionScreen) { + tooltip.popStyle(); + } + + return { + satisfied: status.satisfied, + iconTexture: BitmapManager.getBitmap(Bitmaps.ImgLabReq), + drawBG: true, + showOutline: true, + statText, + tooltip + }; + } + + public getHighlight(status: SynthConstraintStatus, undoBlocks: UndoBlock[]): HighlightInfo { + return { + ranges: [ + ...this._consecutiveAConstraint.getHighlight( + this._consecutiveAConstraint.evaluate(undoBlocks), + undoBlocks + ).ranges, + ...this._consecutiveGConstraint.getHighlight( + this._consecutiveGConstraint.evaluate(undoBlocks), + undoBlocks + ).ranges, + ...this._consecutiveCConstraint.getHighlight( + this._consecutiveCConstraint.evaluate(undoBlocks), + undoBlocks + ).ranges + ], + color: HighlightType.RESTRICTED + }; + } + + private readonly _consecutiveAConstraint = new ConsecutiveAConstraint(SynthesisConstraint.AMAX); + private readonly _consecutiveGConstraint = new ConsecutiveGConstraint(SynthesisConstraint.GMAX); + private readonly _consecutiveCConstraint = new ConsecutiveCConstraint(SynthesisConstraint.CMAX); +} diff --git a/src/eterna/mode/PoseEdit/PoseEditMode.ts b/src/eterna/mode/PoseEdit/PoseEditMode.ts index e91385fae..c1ac157fa 100644 --- a/src/eterna/mode/PoseEdit/PoseEditMode.ts +++ b/src/eterna/mode/PoseEdit/PoseEditMode.ts @@ -84,7 +84,7 @@ interface ConstraintInfo { maxAllowedAdenine: number; } -interface OligoDef { +export interface OligoDef { sequence: string; malus: number; name: string; diff --git a/src/eterna/ui/PoseThumbnail.ts b/src/eterna/ui/PoseThumbnail.ts index a8b94e6d5..ac51067fd 100644 --- a/src/eterna/ui/PoseThumbnail.ts +++ b/src/eterna/ui/PoseThumbnail.ts @@ -33,6 +33,7 @@ export default class PoseThumbnail { return TextureUtil.renderToTexture(disp); } + // TODO: Remove public static drawToSprite( sprite: Sprite, sequence: number[], From f37a01cb6489d7fbd158fd90d4fba28b2e7e7c12 Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Mon, 29 Jul 2019 21:04:13 -0400 Subject: [PATCH 23/39] Class-based SCRIPT constraint (plus truly-synchronous ExternalInterface) --- src/eterna/constraints/ScriptConstraint.ts | 83 ++++++++++++++++++++++ src/eterna/util/ExternalInterface.ts | 77 +++++++++++++++++++- 2 files changed, 158 insertions(+), 2 deletions(-) create mode 100644 src/eterna/constraints/ScriptConstraint.ts diff --git a/src/eterna/constraints/ScriptConstraint.ts b/src/eterna/constraints/ScriptConstraint.ts new file mode 100644 index 000000000..7f36c2090 --- /dev/null +++ b/src/eterna/constraints/ScriptConstraint.ts @@ -0,0 +1,83 @@ +import UndoBlock from 'eterna/UndoBlock'; +import Puzzle from 'eterna/puzzle/Puzzle'; +import ExternalInterface from 'eterna/util/ExternalInterface'; +import {HighlightType} from 'eterna/pose2D/HighlightBox'; +import Constraint, {BaseConstraintStatus, HighlightInfo} from './Constraint'; +import ConstraintBox, {ConstraintBoxConfig} from './ConstraintBox'; + +interface ScriptConstraintStatus extends BaseConstraintStatus { + goal: string; + resultValue: string; + stateIndex: number; + dataPNG: string; +} + +export default class ScriptConstraint extends Constraint { + public static readonly NAME = 'SCRIPT'; + public scriptID: number; + + constructor(scriptID: number) { + super(); + this.scriptID = scriptID; + } + + public evaluate(_1: UndoBlock[], _2: any[], puzzle?: Puzzle): ScriptConstraintStatus { + let satisfied = false; + + const scriptID = this.scriptID; + const scriptResult = ExternalInterface.runScriptSync( + scriptID, + {params: {puzzleInfo: puzzle.toJSON() || null}} + ).result; + + let goal = ''; + let resultValue = ''; + let index = null; + let dataPNG = ''; + if (scriptResult && scriptResult.cause) { + if (scriptResult.cause.satisfied) satisfied = scriptResult.cause.satisfied; + if (scriptResult.cause.goal != null) goal = scriptResult.cause.goal; + if (scriptResult.cause.value != null) resultValue = scriptResult.cause.value; + if (scriptResult.cause.index != null) { + index = scriptResult.cause.index; + } + + if (scriptResult.cause.icon_b64) { + dataPNG = scriptResult.cause.icon_b64; + } + } + + return { + goal, + resultValue, + stateIndex: index, + dataPNG, + satisfied + }; + } + + public getConstraintBoxConfig( + status: ScriptConstraintStatus, + undoBlocks: UndoBlock[], + targetConditions: any[], + forMissionScreen: boolean + ): ConstraintBoxConfig { + return { + satisfied: status.satisfied, + drawBG: true, + showOutline: true, + iconTexture: status.dataPNG, + stateNumber: status.stateIndex + 1, + statText: !forMissionScreen ? status.resultValue : null, + tooltip: ConstraintBox.createTextStyle().append(status.goal || `Your puzzle must satisfy script ${this.scriptID}`) + }; + } + + public getHighlight(status: ScriptConstraintStatus): HighlightInfo { + return { + ranges: [], + color: HighlightType.USER_DEFINED, + stateIndex: status.stateIndex + }; + } +} diff --git a/src/eterna/util/ExternalInterface.ts b/src/eterna/util/ExternalInterface.ts index 4c005a30e..4bfd6bea2 100644 --- a/src/eterna/util/ExternalInterface.ts +++ b/src/eterna/util/ExternalInterface.ts @@ -97,6 +97,25 @@ export default class ExternalInterface { } } + /** + * Request a script over the network and cache it. + * The script interface lazily loads scripts and caches them. By requesting it ahead of time, + * we can ensure that a script can be executed synchronously (as long as the script itself runs + * synchronously) + */ + public static preloadScript(scriptID: string | number): Promise { + return new Promise((resolve, reject) => { + this.call( + 'Script.get_script', + scriptID, + () => { + Promise.resolve(); + ExternalInterface._preloadedScripts.push(`${scriptID}`); + } + ); + }); + } + /** * Requests execution of an external script. * runScript requests are processed in order, and only one script can run at a time, except for @@ -118,6 +137,54 @@ export default class ExternalInterface { }); } + /** + * Requests execution of an external script, and attempts to get its return value synchronously. + * Promises are always resolved asynchronously, so this runScript flavor eschews Promises. + * + * preloadScript **MUST** be used in order to ensure sychronous execution. Note that nothing is stopping script + * authors from using code such as setTimeout, setInterval, async net requests, or so forth. There are a couple + * basic checks to detect that happening (specifically, if the author does not know this and tries indicating + * the script as async, an error will be thrown). Naturally if nothing is synchronously returned, then the script + * will be useless to whatever functionality calls this function. Beyond that, any asynchronous code in a script + * run by this function may lead to undefined behavior. + * + * The primary reason for the existance of this function is for SCRIPT constraints, which are designed to be + * executed synchronously. If at all possible, use the async version of this function. + */ + public static runScriptSync( + scriptID: string | number, options: RunScriptOptions + ): {result: any; error: any} { + if (!this._preloadedScripts.includes(`${scriptID}`)) { + // If we try to do this it's almost certainly going to break (scripts have to be asynchronously loaded once, + // so this can't be synchronous), so just... don't. + throw new Error('runScriptSync attempted to run a script which has not been preloaded'); + } + + let completed = false; + let scriptReturn = null; + const complete = (result: any, error: any) => { + if (completed) { + return; + } + completed = true; + scriptReturn = {result, error}; + }; + + ExternalInterface.runPendingScript({ + scriptID: `${scriptID}`, + options, + resolve: result => complete(result, undefined), + reject: err => complete(undefined, err), + synchronous: true + }, true); + + if (!completed) { + throw new Error(`Script did not complete synchronously, but it was supposed to! [scriptID=${scriptID}]`); + } + + return scriptReturn; + } + /** * Requests execution of an external script, and attempts to get its return value synchronously. * Promises are always resolved asynchronously, so this runScript flavor eschews Promises and takes a @@ -192,7 +259,7 @@ export default class ExternalInterface { } } - private static runPendingScript(script: PendingScript): void { + private static runPendingScript(script: PendingScript, sync: boolean = false): void { let {ctx} = script.options; if (ctx == null) { ctx = new ExternalInterfaceCtx(); @@ -221,7 +288,9 @@ export default class ExternalInterface { script.resolve(successValue); } - this.maybeRunNextScript(); + if (!sync) { + this.maybeRunNextScript(); + } }; // Create a new "end_" callback @@ -229,6 +298,9 @@ export default class ExternalInterface { if (!this.isAsync(returnValue)) { complete(returnValue, undefined); } else if (!isAsync) { + if (sync) { + throw new Error(`Script requested to run asynchronously, which is not supported for this script type [scriptID=${script.scriptID}]`); + } // Scripts can indicate that they run asynchronously by calling their end_ // function with { "cause": { "async": "true" } }. (They must later // call the end_ function normally, when they've actually completed.) @@ -295,6 +367,7 @@ export default class ExternalInterface { private static _scriptRoot: any; private static _curSyncScript: PendingScript; private static _noPendingScripts: Deferred; + private static _preloadedScripts: string[]; } interface PendingScript { From 8f261262f8cfdb444305c3620325ad60c35a2407 Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Tue, 30 Jul 2019 11:20:48 -0400 Subject: [PATCH 24/39] ExternalInterface.preloadScript: Don't do things after resolving the promise --- src/eterna/util/ExternalInterface.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/eterna/util/ExternalInterface.ts b/src/eterna/util/ExternalInterface.ts index 4bfd6bea2..b8bb8b118 100644 --- a/src/eterna/util/ExternalInterface.ts +++ b/src/eterna/util/ExternalInterface.ts @@ -109,8 +109,8 @@ export default class ExternalInterface { 'Script.get_script', scriptID, () => { - Promise.resolve(); ExternalInterface._preloadedScripts.push(`${scriptID}`); + Promise.resolve(); } ); }); From ba6e496bd5478444fdae0d9ba8a0cd3f87f41251 Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Tue, 30 Jul 2019 11:24:58 -0400 Subject: [PATCH 25/39] Correct comments - one things shouldn't be removed, a different thing thing should --- src/eterna/ui/PoseThumbnail.ts | 1 - src/eterna/util/ExternalInterface.ts | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/eterna/ui/PoseThumbnail.ts b/src/eterna/ui/PoseThumbnail.ts index ac51067fd..a8b94e6d5 100644 --- a/src/eterna/ui/PoseThumbnail.ts +++ b/src/eterna/ui/PoseThumbnail.ts @@ -33,7 +33,6 @@ export default class PoseThumbnail { return TextureUtil.renderToTexture(disp); } - // TODO: Remove public static drawToSprite( sprite: Sprite, sequence: number[], diff --git a/src/eterna/util/ExternalInterface.ts b/src/eterna/util/ExternalInterface.ts index b8bb8b118..36cc7e3b8 100644 --- a/src/eterna/util/ExternalInterface.ts +++ b/src/eterna/util/ExternalInterface.ts @@ -185,6 +185,7 @@ export default class ExternalInterface { return scriptReturn; } + // TODO: Remove once class-based constraints (using preloadScript/runScriptSync) are used /** * Requests execution of an external script, and attempts to get its return value synchronously. * Promises are always resolved asynchronously, so this runScript flavor eschews Promises and takes a From cdada0b08067b590470605fccd23d8969aab2efd Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Tue, 30 Jul 2019 18:18:23 -0400 Subject: [PATCH 26/39] Move constraint implementations into subfolder --- src/eterna/constraints/{ => constraints}/BarcodeConstraint.ts | 4 ++-- src/eterna/constraints/{ => constraints}/BindingConstraint.ts | 4 ++-- src/eterna/constraints/{ => constraints}/BoostConstraint.ts | 4 ++-- .../{ => constraints}/ConsecutiveBaseConstraint.ts | 4 ++-- .../constraints/{ => constraints}/MaximumBaseConstraint.ts | 4 ++-- .../{ => constraints}/MaximumMutationConstraint.ts | 4 ++-- .../constraints/{ => constraints}/MaximumPairConstraint.ts | 4 ++-- .../constraints/{ => constraints}/MinimumBaseConstraint.ts | 4 ++-- .../constraints/{ => constraints}/MinimumPairConstraint.ts | 4 ++-- .../{ => constraints}/MinimumStackLengthConstraint.ts | 4 ++-- src/eterna/constraints/{ => constraints}/ScriptConstraint.ts | 4 ++-- src/eterna/constraints/{ => constraints}/ShapeConstraint.ts | 4 ++-- .../constraints/{ => constraints}/SynthesisConstraint.ts | 4 ++-- 13 files changed, 26 insertions(+), 26 deletions(-) rename src/eterna/constraints/{ => constraints}/BarcodeConstraint.ts (92%) rename src/eterna/constraints/{ => constraints}/BindingConstraint.ts (99%) rename src/eterna/constraints/{ => constraints}/BoostConstraint.ts (93%) rename src/eterna/constraints/{ => constraints}/ConsecutiveBaseConstraint.ts (97%) rename src/eterna/constraints/{ => constraints}/MaximumBaseConstraint.ts (95%) rename src/eterna/constraints/{ => constraints}/MaximumMutationConstraint.ts (95%) rename src/eterna/constraints/{ => constraints}/MaximumPairConstraint.ts (96%) rename src/eterna/constraints/{ => constraints}/MinimumBaseConstraint.ts (95%) rename src/eterna/constraints/{ => constraints}/MinimumPairConstraint.ts (97%) rename src/eterna/constraints/{ => constraints}/MinimumStackLengthConstraint.ts (94%) rename src/eterna/constraints/{ => constraints}/ScriptConstraint.ts (96%) rename src/eterna/constraints/{ => constraints}/ShapeConstraint.ts (99%) rename src/eterna/constraints/{ => constraints}/SynthesisConstraint.ts (98%) diff --git a/src/eterna/constraints/BarcodeConstraint.ts b/src/eterna/constraints/constraints/BarcodeConstraint.ts similarity index 92% rename from src/eterna/constraints/BarcodeConstraint.ts rename to src/eterna/constraints/constraints/BarcodeConstraint.ts index dc5931030..34997436f 100644 --- a/src/eterna/constraints/BarcodeConstraint.ts +++ b/src/eterna/constraints/constraints/BarcodeConstraint.ts @@ -3,8 +3,8 @@ import SolutionManager from 'eterna/puzzle/SolutionManager'; import EPars from 'eterna/EPars'; import BitmapManager from 'eterna/resources/BitmapManager'; import Bitmaps from 'eterna/resources/Bitmaps'; -import ConstraintBox, {ConstraintBoxConfig} from './ConstraintBox'; -import Constraint, {BaseConstraintStatus} from './Constraint'; +import ConstraintBox, {ConstraintBoxConfig} from '../ConstraintBox'; +import Constraint, {BaseConstraintStatus} from '../Constraint'; export default class BarcodeConstraint extends Constraint { public static readonly NAME = 'BARCODE'; diff --git a/src/eterna/constraints/BindingConstraint.ts b/src/eterna/constraints/constraints/BindingConstraint.ts similarity index 99% rename from src/eterna/constraints/BindingConstraint.ts rename to src/eterna/constraints/constraints/BindingConstraint.ts index 07dc5555f..0aa5c35a6 100644 --- a/src/eterna/constraints/BindingConstraint.ts +++ b/src/eterna/constraints/constraints/BindingConstraint.ts @@ -5,8 +5,8 @@ import {Graphics} from 'pixi.js'; import EPars from 'eterna/EPars'; import {HighlightType} from 'eterna/pose2D/HighlightBox'; import Utility from 'eterna/util/Utility'; -import ConstraintBox, {ConstraintBoxConfig} from './ConstraintBox'; -import Constraint, {BaseConstraintStatus, HighlightInfo} from './Constraint'; +import ConstraintBox, {ConstraintBoxConfig} from '../ConstraintBox'; +import Constraint, {BaseConstraintStatus, HighlightInfo} from '../Constraint'; interface OligoInfo { bind: boolean; diff --git a/src/eterna/constraints/BoostConstraint.ts b/src/eterna/constraints/constraints/BoostConstraint.ts similarity index 93% rename from src/eterna/constraints/BoostConstraint.ts rename to src/eterna/constraints/constraints/BoostConstraint.ts index d804f49da..7033e7e9c 100644 --- a/src/eterna/constraints/BoostConstraint.ts +++ b/src/eterna/constraints/constraints/BoostConstraint.ts @@ -1,8 +1,8 @@ import UndoBlock from 'eterna/UndoBlock'; import BitmapManager from 'eterna/resources/BitmapManager'; import Bitmaps from 'eterna/resources/Bitmaps'; -import ConstraintBox, {ConstraintBoxConfig} from './ConstraintBox'; -import Constraint, {BaseConstraintStatus} from './Constraint'; +import ConstraintBox, {ConstraintBoxConfig} from '../ConstraintBox'; +import Constraint, {BaseConstraintStatus} from '../Constraint'; interface BoostConstraintStatus extends BaseConstraintStatus { boostCount: number; diff --git a/src/eterna/constraints/ConsecutiveBaseConstraint.ts b/src/eterna/constraints/constraints/ConsecutiveBaseConstraint.ts similarity index 97% rename from src/eterna/constraints/ConsecutiveBaseConstraint.ts rename to src/eterna/constraints/constraints/ConsecutiveBaseConstraint.ts index 40f4ff75d..c5970b993 100644 --- a/src/eterna/constraints/ConsecutiveBaseConstraint.ts +++ b/src/eterna/constraints/constraints/ConsecutiveBaseConstraint.ts @@ -2,8 +2,8 @@ import UndoBlock from 'eterna/UndoBlock'; import EPars from 'eterna/EPars'; import BitmapManager from 'eterna/resources/BitmapManager'; import {HighlightType} from 'eterna/pose2D/HighlightBox'; -import ConstraintBox, {ConstraintBoxConfig} from './ConstraintBox'; -import Constraint, {BaseConstraintStatus, HighlightInfo} from './Constraint'; +import ConstraintBox, {ConstraintBoxConfig} from '../ConstraintBox'; +import Constraint, {BaseConstraintStatus, HighlightInfo} from '../Constraint'; interface ConsecutiveConstraintStatus extends BaseConstraintStatus { currentConsecutive: number; diff --git a/src/eterna/constraints/MaximumBaseConstraint.ts b/src/eterna/constraints/constraints/MaximumBaseConstraint.ts similarity index 95% rename from src/eterna/constraints/MaximumBaseConstraint.ts rename to src/eterna/constraints/constraints/MaximumBaseConstraint.ts index daa96f3a3..08ac82499 100644 --- a/src/eterna/constraints/MaximumBaseConstraint.ts +++ b/src/eterna/constraints/constraints/MaximumBaseConstraint.ts @@ -1,8 +1,8 @@ import UndoBlock from 'eterna/UndoBlock'; import EPars from 'eterna/EPars'; import BitmapManager from 'eterna/resources/BitmapManager'; -import ConstraintBox, {ConstraintBoxConfig} from './ConstraintBox'; -import Constraint, {BaseConstraintStatus} from './Constraint'; +import ConstraintBox, {ConstraintBoxConfig} from '../ConstraintBox'; +import Constraint, {BaseConstraintStatus} from '../Constraint'; interface MaxBaseConstraintStatus extends BaseConstraintStatus { currentCount: number; diff --git a/src/eterna/constraints/MaximumMutationConstraint.ts b/src/eterna/constraints/constraints/MaximumMutationConstraint.ts similarity index 95% rename from src/eterna/constraints/MaximumMutationConstraint.ts rename to src/eterna/constraints/constraints/MaximumMutationConstraint.ts index 621635696..dff505782 100644 --- a/src/eterna/constraints/MaximumMutationConstraint.ts +++ b/src/eterna/constraints/constraints/MaximumMutationConstraint.ts @@ -7,8 +7,8 @@ import Puzzle from 'eterna/puzzle/Puzzle'; import EPars from 'eterna/EPars'; import BitmapManager from 'eterna/resources/BitmapManager'; import Bitmaps from 'eterna/resources/Bitmaps'; -import ConstraintBox, {ConstraintBoxConfig} from './ConstraintBox'; -import Constraint, {BaseConstraintStatus} from './Constraint'; +import ConstraintBox, {ConstraintBoxConfig} from '../ConstraintBox'; +import Constraint, {BaseConstraintStatus} from '../Constraint'; interface MaxMutationConstraintStatus extends BaseConstraintStatus { mutations: number; diff --git a/src/eterna/constraints/MaximumPairConstraint.ts b/src/eterna/constraints/constraints/MaximumPairConstraint.ts similarity index 96% rename from src/eterna/constraints/MaximumPairConstraint.ts rename to src/eterna/constraints/constraints/MaximumPairConstraint.ts index 4ec1ed004..20aab8588 100644 --- a/src/eterna/constraints/MaximumPairConstraint.ts +++ b/src/eterna/constraints/constraints/MaximumPairConstraint.ts @@ -2,8 +2,8 @@ import UndoBlock, {UndoBlockParam} from 'eterna/UndoBlock'; import EPars from 'eterna/EPars'; import BitmapManager from 'eterna/resources/BitmapManager'; import Bitmaps from 'eterna/resources/Bitmaps'; -import ConstraintBox, {ConstraintBoxConfig} from './ConstraintBox'; -import Constraint, {BaseConstraintStatus} from './Constraint'; +import ConstraintBox, {ConstraintBoxConfig} from '../ConstraintBox'; +import Constraint, {BaseConstraintStatus} from '../Constraint'; interface MaxPairConstraintStatus extends BaseConstraintStatus { currentPairs: number; diff --git a/src/eterna/constraints/MinimumBaseConstraint.ts b/src/eterna/constraints/constraints/MinimumBaseConstraint.ts similarity index 95% rename from src/eterna/constraints/MinimumBaseConstraint.ts rename to src/eterna/constraints/constraints/MinimumBaseConstraint.ts index 80543677b..c1614149c 100644 --- a/src/eterna/constraints/MinimumBaseConstraint.ts +++ b/src/eterna/constraints/constraints/MinimumBaseConstraint.ts @@ -1,8 +1,8 @@ import UndoBlock from 'eterna/UndoBlock'; import EPars from 'eterna/EPars'; import BitmapManager from 'eterna/resources/BitmapManager'; -import ConstraintBox, {ConstraintBoxConfig} from './ConstraintBox'; -import Constraint, {BaseConstraintStatus} from './Constraint'; +import ConstraintBox, {ConstraintBoxConfig} from '../ConstraintBox'; +import Constraint, {BaseConstraintStatus} from '../Constraint'; interface MinBaseConstraintStatus extends BaseConstraintStatus{ currentCount: number; diff --git a/src/eterna/constraints/MinimumPairConstraint.ts b/src/eterna/constraints/constraints/MinimumPairConstraint.ts similarity index 97% rename from src/eterna/constraints/MinimumPairConstraint.ts rename to src/eterna/constraints/constraints/MinimumPairConstraint.ts index 547f2d629..be7c7571d 100644 --- a/src/eterna/constraints/MinimumPairConstraint.ts +++ b/src/eterna/constraints/constraints/MinimumPairConstraint.ts @@ -2,8 +2,8 @@ import UndoBlock, {UndoBlockParam} from 'eterna/UndoBlock'; import EPars from 'eterna/EPars'; import BitmapManager from 'eterna/resources/BitmapManager'; import Bitmaps from 'eterna/resources/Bitmaps'; -import ConstraintBox, {ConstraintBoxConfig} from './ConstraintBox'; -import Constraint, {BaseConstraintStatus} from './Constraint'; +import ConstraintBox, {ConstraintBoxConfig} from '../ConstraintBox'; +import Constraint, {BaseConstraintStatus} from '../Constraint'; interface MinPairConstraintStatus extends BaseConstraintStatus { currentPairs: number; diff --git a/src/eterna/constraints/MinimumStackLengthConstraint.ts b/src/eterna/constraints/constraints/MinimumStackLengthConstraint.ts similarity index 94% rename from src/eterna/constraints/MinimumStackLengthConstraint.ts rename to src/eterna/constraints/constraints/MinimumStackLengthConstraint.ts index a66876272..24d7ae773 100644 --- a/src/eterna/constraints/MinimumStackLengthConstraint.ts +++ b/src/eterna/constraints/constraints/MinimumStackLengthConstraint.ts @@ -6,8 +6,8 @@ import BitmapManager from 'eterna/resources/BitmapManager'; import Bitmaps from 'eterna/resources/Bitmaps'; import {TextureUtil} from 'flashbang'; import Band from 'eterna/ui/Band'; -import ConstraintBox, {ConstraintBoxConfig} from './ConstraintBox'; -import Constraint, {BaseConstraintStatus} from './Constraint'; +import ConstraintBox, {ConstraintBoxConfig} from '../ConstraintBox'; +import Constraint, {BaseConstraintStatus} from '../Constraint'; interface MinStackConstraintStatus extends BaseConstraintStatus{ currentLength: number; diff --git a/src/eterna/constraints/ScriptConstraint.ts b/src/eterna/constraints/constraints/ScriptConstraint.ts similarity index 96% rename from src/eterna/constraints/ScriptConstraint.ts rename to src/eterna/constraints/constraints/ScriptConstraint.ts index 7f36c2090..7618088f5 100644 --- a/src/eterna/constraints/ScriptConstraint.ts +++ b/src/eterna/constraints/constraints/ScriptConstraint.ts @@ -2,8 +2,8 @@ import UndoBlock from 'eterna/UndoBlock'; import Puzzle from 'eterna/puzzle/Puzzle'; import ExternalInterface from 'eterna/util/ExternalInterface'; import {HighlightType} from 'eterna/pose2D/HighlightBox'; -import Constraint, {BaseConstraintStatus, HighlightInfo} from './Constraint'; -import ConstraintBox, {ConstraintBoxConfig} from './ConstraintBox'; +import Constraint, {BaseConstraintStatus, HighlightInfo} from '../Constraint'; +import ConstraintBox, {ConstraintBoxConfig} from '../ConstraintBox'; interface ScriptConstraintStatus extends BaseConstraintStatus { goal: string; diff --git a/src/eterna/constraints/ShapeConstraint.ts b/src/eterna/constraints/constraints/ShapeConstraint.ts similarity index 99% rename from src/eterna/constraints/ShapeConstraint.ts rename to src/eterna/constraints/constraints/ShapeConstraint.ts index f3728d20f..3c220203e 100644 --- a/src/eterna/constraints/ShapeConstraint.ts +++ b/src/eterna/constraints/constraints/ShapeConstraint.ts @@ -2,8 +2,8 @@ import UndoBlock from 'eterna/UndoBlock'; import EPars from 'eterna/EPars'; import PoseThumbnail, {PoseThumbnailType} from 'eterna/ui/PoseThumbnail'; import {HighlightType} from 'eterna/pose2D/HighlightBox'; -import Constraint, {BaseConstraintStatus, HighlightInfo} from './Constraint'; -import ConstraintBox, {ConstraintBoxConfig} from './ConstraintBox'; +import Constraint, {BaseConstraintStatus, HighlightInfo} from '../Constraint'; +import ConstraintBox, {ConstraintBoxConfig} from '../ConstraintBox'; interface ShapeConstraintStatus extends BaseConstraintStatus { wrongPairs: number[]; diff --git a/src/eterna/constraints/SynthesisConstraint.ts b/src/eterna/constraints/constraints/SynthesisConstraint.ts similarity index 98% rename from src/eterna/constraints/SynthesisConstraint.ts rename to src/eterna/constraints/constraints/SynthesisConstraint.ts index 0af7a50f0..f3337dcd6 100644 --- a/src/eterna/constraints/SynthesisConstraint.ts +++ b/src/eterna/constraints/constraints/SynthesisConstraint.ts @@ -5,9 +5,9 @@ import {StyledTextBuilder} from 'flashbang'; import Fonts from 'eterna/util/Fonts'; import EPars from 'eterna/EPars'; import {HighlightType} from 'eterna/pose2D/HighlightBox'; -import ConstraintBox, {ConstraintBoxConfig} from './ConstraintBox'; +import ConstraintBox, {ConstraintBoxConfig} from '../ConstraintBox'; import {ConsecutiveAConstraint, ConsecutiveGConstraint, ConsecutiveCConstraint} from './ConsecutiveBaseConstraint'; -import Constraint, {BaseConstraintStatus, HighlightInfo} from './Constraint'; +import Constraint, {BaseConstraintStatus, HighlightInfo} from '../Constraint'; interface SynthConstraintStatus extends BaseConstraintStatus { currentA: number; From 0f5e7e4fff91ed5fb6108c08e4963956e2f8b061 Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Tue, 30 Jul 2019 18:22:45 -0400 Subject: [PATCH 27/39] Temporary constraints aren't actually used for anything, remove them --- src/eterna/mode/PoseEdit/PoseEditMode.ts | 21 +++++---------------- src/eterna/puzzle/Puzzle.ts | 20 -------------------- 2 files changed, 5 insertions(+), 36 deletions(-) diff --git a/src/eterna/mode/PoseEdit/PoseEditMode.ts b/src/eterna/mode/PoseEdit/PoseEditMode.ts index c1ac157fa..1ff466511 100644 --- a/src/eterna/mode/PoseEdit/PoseEditMode.ts +++ b/src/eterna/mode/PoseEdit/PoseEditMode.ts @@ -1285,7 +1285,6 @@ export default class PoseEditMode extends GameMode { this.showConfirmDialog(PROMPT).closed.then((confirmed) => { if (confirmed) { this.resetAutosaveData(); - this._puzzle.temporaryConstraints = null; this.modeStack.changeMode(new PoseEditMode(this._puzzle, {isReset: true})); } }); @@ -1934,10 +1933,6 @@ export default class PoseEditMode extends GameMode { let numConstraints = 0; let constraints: string[] = this._puzzle.constraints; - if (this._puzzle.temporaryConstraints != null) { - constraints = this._puzzle.temporaryConstraints; - } - if (constraints != null) { numConstraints = constraints.length; } @@ -2001,7 +1996,7 @@ export default class PoseEditMode extends GameMode { private startCountdown(): void { this._isPlaying = false; - const constraints: string[] = this._puzzle.curConstraints; + const constraints: string[] = this._puzzle.constraints; if (constraints == null || constraints.length === 0 || !this._showMissionScreen) { this.startPlaying(); } else { @@ -2764,7 +2759,7 @@ export default class PoseEditMode extends GameMode { } private checkConstraints(render: boolean = true): boolean { - const constraints: string[] = this._puzzle.curConstraints; + const constraints: string[] = this._puzzle.constraints; if (constraints == null || constraints.length === 0) { return false; } @@ -3023,9 +3018,7 @@ export default class PoseEditMode extends GameMode { // / Update spec thumbnail if it is open this.updateDockedSpecBox(); - let isThereTempConstraints: boolean = (this._puzzle.temporaryConstraints != null); - - if (constraintsSatisfied && !isThereTempConstraints) { + if (constraintsSatisfied) { if (this._puzzle.puzzleType !== PuzzleType.EXPERIMENTAL && this._puzState === PuzzleState.GAME) { this.submitCurrentPose(); } @@ -3502,10 +3495,6 @@ export default class PoseEditMode extends GameMode { let isShapeConstrained = false; let constraints: string[] = this._puzzle.constraints; - if (this._puzzle.temporaryConstraints != null) { - constraints = this._puzzle.temporaryConstraints; - } - if (constraints != null) { for (let ii = 0; ii < constraints.length; ii += 2) { if (constraints[ii] === ConstraintType.SHAPE) { @@ -3685,8 +3674,8 @@ export default class PoseEditMode extends GameMode { */ private onConstraintBoxClicked(idx: number): void { if ( - this._puzzle.curConstraints[idx] === ConstraintType.SHAPE - || this._puzzle.curConstraints[idx] === ConstraintType.ANTISHAPE + this._puzzle.constraints[idx] === ConstraintType.SHAPE + || this._puzzle.constraints[idx] === ConstraintType.ANTISHAPE ) { this._unstableShapeConstraintIdx = (this._unstableShapeConstraintIdx === idx ? -1 : idx); this.checkConstraints(); diff --git a/src/eterna/puzzle/Puzzle.ts b/src/eterna/puzzle/Puzzle.ts index 4439eb9e9..fb3f044c1 100644 --- a/src/eterna/puzzle/Puzzle.ts +++ b/src/eterna/puzzle/Puzzle.ts @@ -189,23 +189,6 @@ export default class Puzzle { } } - public get temporaryConstraints(): string[] { - return this._tempConstraints; - } - - public set temporaryConstraints(constraints: string[]) { - if (constraints != null) { - this._tempConstraints = constraints.slice(); - } else { - this._tempConstraints = null; - } - } - - /** Returns temporaryConstraints, if they're set, else constraints */ - public get curConstraints(): string[] { - return this.temporaryConstraints || this.constraints; - } - public get puzzleLocks(): boolean[] { let puzlocks: boolean[]; let ii: number; @@ -616,8 +599,6 @@ export default class Puzzle { folderName: this.folderName, targetConditions: this.targetConditions, constraints: this.constraints, - temporaryConstraints: this.temporaryConstraints, - curConstraints: this.curConstraints, puzzleLocks: this.puzzleLocks, shiftLimit: this.shiftLimit, secstructs: this.getSecstructs(), @@ -647,7 +628,6 @@ export default class Puzzle { private _useBarcode: boolean = false; private _targetConditions: any[] = null; private _constraints: string[] = null; - private _tempConstraints: string[]; private _round: number = -1; private _numSubmissions: number = 3; private _folder: string; From 6cd86fc3ca96a5f94055ea3fe494b4abe962141c Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Fri, 2 Aug 2019 21:39:56 -0400 Subject: [PATCH 28/39] ConstraintBar, integrate new constraint architecture with PoseEdit, constraint bugfixes + completed pairity --- src/eterna/EternaApp.ts | 12 +- src/eterna/constraints/ConstraintBar.ts | 180 ++++ src/eterna/constraints/ConstraintBox.ts | 246 +++-- .../constraints/BarcodeConstraint.ts | 3 +- .../constraints/BindingConstraint.ts | 9 +- .../constraints/ConsecutiveBaseConstraint.ts | 8 +- .../constraints/MaximumMutationConstraint.ts | 2 +- .../constraints/MaximumPairConstraint.ts | 7 +- .../constraints/MinimumPairConstraint.ts | 7 +- .../MinimumStackLengthConstraint.ts | 2 +- .../constraints/ScriptConstraint.ts | 39 +- .../constraints/ShapeConstraint.ts | 94 +- .../constraints/SynthesisConstraint.ts | 2 +- src/eterna/mode/PoseEdit/MissionIntroMode.ts | 3 +- src/eterna/mode/PoseEdit/PoseEditMode.ts | 961 ++---------------- src/eterna/puzzle/Puzzle.ts | 54 +- src/eterna/puzzle/PuzzleManager.ts | 178 +++- src/eterna/rscript/ROPHighlight.ts | 10 +- src/eterna/rscript/RScriptEnv.ts | 2 +- src/eterna/ui/PoseThumbnail.ts | 21 + src/eterna/util/ExternalInterface.ts | 52 +- 21 files changed, 738 insertions(+), 1154 deletions(-) create mode 100644 src/eterna/constraints/ConstraintBar.ts diff --git a/src/eterna/EternaApp.ts b/src/eterna/EternaApp.ts index f6b6a269d..9f4f414ae 100644 --- a/src/eterna/EternaApp.ts +++ b/src/eterna/EternaApp.ts @@ -312,16 +312,14 @@ export default class EternaApp extends FlashbangApp { }); } - private loadPuzzle(puzzleOrID: number | Puzzle): Promise { + private async loadPuzzle(puzzleOrID: number | Puzzle): Promise { if (puzzleOrID instanceof Puzzle) { - return Promise.resolve(puzzleOrID); + return puzzleOrID; } else { this.setLoadingText(`Loading puzzle ${puzzleOrID}...`); - return PuzzleManager.instance.getPuzzleByID(puzzleOrID) - .then((puzzle) => { - this.popLoadingMode(); - return puzzle; - }); + let puzzle = await PuzzleManager.instance.getPuzzleByID(puzzleOrID); + this.popLoadingMode(); + return puzzle; } } diff --git a/src/eterna/constraints/ConstraintBar.ts b/src/eterna/constraints/ConstraintBar.ts new file mode 100644 index 000000000..dd4a72fb6 --- /dev/null +++ b/src/eterna/constraints/ConstraintBar.ts @@ -0,0 +1,180 @@ +import {ContainerObject, Flashbang} from 'flashbang'; +import UndoBlock from 'eterna/UndoBlock'; +import Puzzle from 'eterna/puzzle/Puzzle'; +import {Point} from 'pixi.js'; +import {Value} from 'signals'; +import Eterna from 'eterna/Eterna'; +import {HighlightType} from 'eterna/pose2D/HighlightBox'; +import ShapeConstraint, {AntiShapeConstraint} from './constraints/ShapeConstraint'; +import ConstraintBox from './ConstraintBox'; +import Constraint, {BaseConstraintStatus, HighlightInfo} from './Constraint'; + +interface ConstraintWrapper { + constraint: Constraint; + constraintBox: ConstraintBox; + highlightCache?: HighlightInfo; +} + +interface StateSpecificConstraintWrapper extends ConstraintWrapper { + constraint: ShapeConstraint | AntiShapeConstraint; +} + +function isSSCW( + constraint: ConstraintWrapper | StateSpecificConstraintWrapper +): constraint is StateSpecificConstraintWrapper { + return constraint.constraint instanceof ShapeConstraint || constraint.constraint instanceof AntiShapeConstraint; +} + +export default class ConstraintBar extends ContainerObject { + public sequenceHighlights: Value = new Value(null); + + constructor(constraints: Constraint[]) { + super(); + this._constraints = constraints.map( + constraint => ({constraint, constraintBox: new ConstraintBox(false)}) + ); + + Eterna.settings.highlightRestricted.connect(() => { + this.updateHighlights(); + }); + } + + protected added() { + for (let constraint of this._constraints) { + this.addObject(constraint.constraintBox, this.container); + constraint.constraintBox.pointerDown.connect(() => { + this.onConstraintBoxClicked(constraint); + }); + } + } + + /** + * @param animate "Fly in" constraints from the middle of the screen + * @param pipStates If > 1, lay out structure-related constraints such that they align (as best as possible) + * to the states they're intended for in PiP mode + */ + public layout(animate: boolean, pipStates: number) { + let nonStateConstraints = this._constraints.filter(constraint => !isSSCW(constraint)); + + if (animate) { + for (let [idx, constraint] of this._constraints.entries()) { + constraint.constraintBox.setLocation(new Point( + (Flashbang.stageWidth * 0.3), + (Flashbang.stageHeight * 0.4) + (idx * 77) + )); + } + } + + let xWalker = 17; + let yPos = 35; + + for (let constraint of nonStateConstraints) { + let box = constraint.constraintBox; + box.setLocation(new Point(xWalker, yPos), animate); + xWalker += 119; + } + + if (nonStateConstraints.length > 0) { + xWalker += 25; + } + + let stateConstraints = this._constraints.filter(isSSCW).sort( + (a, b) => (( + (a.constraint instanceof ShapeConstraint && b.constraint instanceof AntiShapeConstraint) + || a.constraint.stateIndex < b.constraint.stateIndex + ) ? -1 : 1) + ); + + for (let constraint of stateConstraints) { + xWalker = pipStates > 1 + ? Math.max(xWalker, (constraint.constraint.stateIndex / pipStates) * Flashbang.stageWidth + 17) + : xWalker; + + let box = constraint.constraintBox; + box.setLocation(new Point(xWalker, yPos), animate); + xWalker += 77; + } + } + + public updateHighlights(): void { + let highlights: HighlightInfo[] = []; + for (let constraint of this._constraints) { + if (constraint.highlightCache != null && ( + ( + constraint.highlightCache.color === HighlightType.UNSTABLE + && constraint === this._flaggedConstraint + ) || ( + constraint.highlightCache.color === HighlightType.RESTRICTED + && Eterna.settings.highlightRestricted.value + ) || ( + constraint.highlightCache.color === HighlightType.USER_DEFINED + ) + )) { + highlights.push(constraint.highlightCache); + } + } + this.sequenceHighlights.value = highlights; + } + + public onConstraintBoxClicked(constraint: ConstraintWrapper): void { + if (isSSCW(constraint)) { + if (this._flaggedConstraint === constraint) { + this._flaggedConstraint.constraintBox.flagged = false; + this._flaggedConstraint = null; + this.updateHighlights(); + } else { + if (this._flaggedConstraint) this._flaggedConstraint.constraintBox.flagged = false; + this._flaggedConstraint = constraint; + constraint.constraintBox.flagged = true; + this.updateHighlights(); + } + } + } + + public updateConstraints(undoBlocks: UndoBlock[], targetConditions: any[], puzzle?: Puzzle): boolean { + let satisfied = true; + + for (let constraint of this._constraints) { + let status = constraint.constraint.evaluate(undoBlocks, targetConditions, puzzle); + constraint.constraintBox.setContent( + constraint.constraint.getConstraintBoxConfig(status, undoBlocks, targetConditions, false) + ); + constraint.highlightCache = status.satisfied + ? null : constraint.constraint.getHighlight(status, undoBlocks, targetConditions); + satisfied = satisfied && status.satisfied; + } + + this.updateHighlights(); + + return satisfied; + } + + /** + * Fade the constraints for states that aren't being shown on screen + * @param stateIndex pass -1 to return all boxes to normal + */ + public highlightState(stateIndex: number): void { + let stateConstraints = this._constraints.filter(isSSCW); + for (let constraint of stateConstraints) { + constraint.constraintBox.display.alpha = ( + constraint.constraint.stateIndex === stateIndex || stateIndex === -1 + ) ? 1.0 : 0.3; + } + } + + public getConstraintBox(index: number): ConstraintBox { + return this._constraints[index].constraintBox; + } + + public getShapeBox(index: number): ConstraintBox { + return this._constraints.filter( + constraint => ( + constraint.constraint instanceof ShapeConstraint + && constraint.constraint.stateIndex === index + ) + )[0].constraintBox; + } + + private _constraints: ConstraintWrapper[]; + private _flaggedConstraint: ConstraintWrapper; +} diff --git a/src/eterna/constraints/ConstraintBox.ts b/src/eterna/constraints/ConstraintBox.ts index aa2d4e68a..5828d3b7c 100644 --- a/src/eterna/constraints/ConstraintBox.ts +++ b/src/eterna/constraints/ConstraintBox.ts @@ -1,6 +1,6 @@ import { ContainerObject, Enableable, SceneObject, StyledTextBuilder, DisplayUtil, HAlign, VAlign, - SerialTask, DelayTask, AlphaTask, TextureUtil + SerialTask, DelayTask, AlphaTask, TextureUtil, LocationTask, Easing, ParallelTask, ScaleTask, VisibleTask, Flashbang } from 'flashbang'; import { Graphics, Sprite, Text, Point, Texture @@ -12,6 +12,7 @@ import Bitmaps from 'eterna/resources/Bitmaps'; import EPars from 'eterna/EPars'; import TextBalloon from 'eterna/ui/TextBalloon'; import {RegistrationGroup} from 'signals'; +import Sounds from 'eterna/resources/Sounds'; export interface ConstraintBoxConfig { // Toggle checkmark, green vs red outline @@ -25,11 +26,11 @@ export interface ConstraintBoxConfig { // Whether to draw the transparent background drawBG?: boolean; // Used with drawBG, constraint image without background. If a string, it will be parsed as a base64 encoded image - iconTexture?: Texture | string; + icon?: Texture | Graphics | string; // Alternative to drawBG, used for SHAPE constraints thumbnailBG?: boolean; // Alternative to iconTexture, used for SHAPE constraints - thumbnail?: Texture; + thumbnail?: Graphics; // Text used to augment the constraint graphic to describe the constraint clarificationText?: string | StyledTextBuilder; // Text describing the current state of the constraint/the value it's "monitoring" @@ -44,16 +45,14 @@ export default class ConstraintBox extends ContainerObject implements Enableable constructor(forMissionScreen: boolean) { super(); this._forMissionScreen = forMissionScreen; - } - public setup(): void { this._bgGraphics = new Graphics(); this._bgGraphics.interactiveChildren = false; this.container.addChild(this._bgGraphics); - // this._backlight = new Graphics(); - // this._backlight.visible = false; - // this.container.addChild(this._backlight); + this._backlight = new Graphics(); + this._backlight.visible = false; + this.container.addChild(this._backlight); this._req = new Sprite(); this._req.visible = false; @@ -63,7 +62,7 @@ export default class ConstraintBox extends ContainerObject implements Enableable this._bg.visible = false; this.container.addChild(this._bg); - this._icon = new Sprite(null); + this._icon = new Sprite(); this._icon.visible = false; this.container.addChild(this._icon); @@ -107,27 +106,28 @@ export default class ConstraintBox extends ContainerObject implements Enableable this._smallThumbnail.position = new Point(6, 6); this.container.addChild(this._smallThumbnail); - // this._flag = new Graphics(); - // this._flag.clear(); - // this._flag.beginFill(0xBEDCE7, 1.0); - // this._flag.drawRect(0, 0, 5, 5); - // this._flag.endFill(); - // this._flag.position = new Point(4, 4); - // this.container.addChild(this._flag); - - // if (this._type === ConstraintBoxType.MISSION_SCREEN) { - // this._sideText = new MultiStyleText("", { - // default: { - // fontFamily: Fonts.STDFONT_REGULAR, - // fontSize: 16, - // fill: 0xffffff, - // letterSpacing: -0.5, - // wordWrap: true, - // wordWrapWidth: 250 - // } - // }); - // this.container.addChild(this._sideText); - // } + this._flag = new Graphics(); + this._flag.clear(); + this._flag.beginFill(0xBEDCE7, 1.0); + this._flag.drawRect(0, 0, 5, 5); + this._flag.endFill(); + this._flag.position = new Point(4, 4); + this.container.addChild(this._flag); + this._flag.visible = false; + + if (this._forMissionScreen) { + this._sideText = new MultiStyleText('', { + default: { + fontFamily: Fonts.STDFONT_REGULAR, + fontSize: 16, + fill: 0xffffff, + letterSpacing: -0.5, + wordWrap: true, + wordWrapWidth: 250 + } + }); + this.container.addChild(this._sideText); + } this._check = new Sprite(BitmapManager.getBitmap(Bitmaps.NovaGreenCheck)); this._check.position = new Point(80, 50); @@ -138,48 +138,48 @@ export default class ConstraintBox extends ContainerObject implements Enableable this._outline.visible = false; this.container.addChild(this._outline); - // this._fglow = new Graphics(); - // this._fglow.visible = false; - // this.container.addChild(this._fglow); + this._fglow = new Graphics(); + this._fglow.visible = false; + this.container.addChild(this._fglow); } - public setContent(details: ConstraintBoxConfig): void { - this._check.visible = details.satisfied && this._forMissionScreen; + public setContent(config: ConstraintBoxConfig): void { + this._check.visible = config.satisfied && !this._forMissionScreen; - this._req.visible = details.fullTexture != null; + this._req.visible = config.fullTexture != null; if (this._req.visible) { - this._req.texture = details.fullTexture; + this._req.texture = config.fullTexture; } - this._outline.visible = details.showOutline || false; + this._outline.visible = config.showOutline || false; if (this._outline.visible) { - this._outline.texture = details.satisfied + this._outline.texture = config.satisfied ? BitmapManager.getBitmap(Bitmaps.NovaPassOutline) : BitmapManager.getBitmap(Bitmaps.NovaFailOutline); } - this._reqClarifyText.visible = details.clarificationText != null; + this._reqClarifyText.visible = config.clarificationText != null; if (this._reqClarifyText.visible) { - this.setPossiblyStyledText(details.clarificationText, this._reqClarifyText); + this.setPossiblyStyledText(config.clarificationText, this._reqClarifyText); DisplayUtil.positionRelative( this._reqClarifyText, HAlign.CENTER, VAlign.TOP, this._outline, HAlign.CENTER, VAlign.TOP, 2, 32 ); } - this._reqStatText.visible = details.statText != null && !this._forMissionScreen; + this._reqStatText.visible = config.statText != null && !this._forMissionScreen; if (this._reqStatText.visible) { - this.setPossiblyStyledText(details.statText, this._reqStatText); + this.setPossiblyStyledText(config.statText, this._reqStatText); DisplayUtil.positionRelative( this._reqStatText, HAlign.CENTER, VAlign.TOP, this._outline, HAlign.CENTER, VAlign.TOP, 0, 50 ); } - let tooltipText = details.tooltip instanceof StyledTextBuilder - ? details.tooltip : ConstraintBox.createTextStyle().append(details.tooltip); + let tooltipText = config.tooltip instanceof StyledTextBuilder + ? config.tooltip : ConstraintBox.createTextStyle().append(config.tooltip); - if (!details.satisfied) { + if (!config.satisfied && !this._forMissionScreen) { tooltipText = tooltipText.clone().append('\n').append('Unsatisfied', {fill: 0xff0000}); } @@ -187,7 +187,19 @@ export default class ConstraintBox extends ContainerObject implements Enableable balloon.styledText = tooltipText; this.setMouseOverObject(balloon); - this._bgGraphics.visible = details.drawBG || false; + if (this._forMissionScreen) { + this._outline.visible = false; + tooltipText.apply(this._sideText); + if (this._req.visible) { + this._sideText.position = new Point( + this._req.width + 18, this._req.height / 2 - this._sideText.height / 2 + ); + } else { + this._sideText.position = new Point(111 + 18, 55 / 2 - this._sideText.height / 2); + } + } + + this._bgGraphics.visible = config.drawBG || false; if (this._bgGraphics.visible) { this._bgGraphics.clear(); this._bgGraphics.beginFill(0x1E314B, 0.5); @@ -195,9 +207,9 @@ export default class ConstraintBox extends ContainerObject implements Enableable this._bgGraphics.endFill(); } - this._bg.visible = details.thumbnailBG || false; + this._bg.visible = config.thumbnailBG || false; if (this._bg.visible) { - if (details.satisfied) { + if (config.satisfied) { this._bg.texture = BitmapManager.getBitmap(Bitmaps.NovaPuzThumbSmallMet); } else { this._bg.texture = BitmapManager.getBitmap(Bitmaps.NovaPuzThumbSmallFail); @@ -208,28 +220,54 @@ export default class ConstraintBox extends ContainerObject implements Enableable this._stateText.position = new Point(3, 45); } - if (details.stateNumber) { + if (config.stateNumber && !this._forMissionScreen) { this._stateText.visible = true; - this._stateText.text = details.stateNumber.toString(); + this._stateText.text = config.stateNumber.toString(); } - if (details.thumbnail) { + if (config.thumbnail) { this._smallThumbnail.visible = true; - this._smallThumbnail.texture = details.thumbnail; + this._smallThumbnail.removeChildren(); + this._smallThumbnail.addChild(config.thumbnail); DisplayUtil.center(this._smallThumbnail, this._bg); } - if (details.iconTexture) { - if (details.iconTexture instanceof Texture) { - this._icon.texture = details.iconTexture; + if (config.icon) { + this._icon.visible = true; + this._icon.removeChildren(); + this._icon.texture = null; + if (config.icon instanceof Texture) { + this._icon.texture = config.icon; this._icon.position = new Point((111 - this._icon.width) * 0.5, 2); + } else if (config.icon instanceof Graphics) { + this._icon.addChild(config.icon); } else { - TextureUtil.fromBase64PNG(details.iconTexture).then((tex) => { + TextureUtil.fromBase64PNG(config.icon).then((tex) => { this._icon.texture = tex; this._icon.position = new Point((111 - this._icon.width) * 0.5, 2); }); } } + + this._noText.visible = config.noText || false; + + if (config.satisfied && !this._satisfied) { + Flashbang.sound.playSound(Sounds.SoundCondition); + this.flare(true); + } else if (!config.satisfied && this._satisfied) { + Flashbang.sound.playSound(Sounds.SoundDecondition); + this.flare(false); + } + + this._satisfied = config.satisfied; + } + + public set flagged(vis: boolean) { + this._flag.visible = vis; + } + + public get flagged(): boolean { + return this._flag.visible; } public get enabled(): boolean { @@ -316,10 +354,92 @@ export default class ConstraintBox extends ContainerObject implements Enableable } } + public setLocation(p: Point, animate: boolean = false, animTime: number = 0.5): void { + if (animate) { + this.replaceNamedObject( + ConstraintBox.LOCATION_ANIM, + new LocationTask(p.x, p.y, animTime, Easing.easeIn) + ); + } else { + this.removeNamedObjects(ConstraintBox.LOCATION_ANIM); + this.display.position = p; + } + } + + public flare(satisfied: boolean): void { + if (this._forMissionScreen) { + this.removeNamedObjects(ConstraintBox.BACKLIGHT_ANIM); + this.removeNamedObjects(ConstraintBox.FGLOW_ANIM); + this._backlight.visible = false; + this._fglow.visible = false; + + return; + } + + let lineWidth = 6; + + this._fglow.clear(); + this._fglow.lineStyle(lineWidth, satisfied ? 0x00FF00 : 0xFF0000, 1.0); + this._fglow.drawRoundedRect( + lineWidth / 2, + lineWidth / 2, + this.display.width - lineWidth, + this.display.height - lineWidth, + 10 + ); + this._fglow.scale.x = 1; + this._fglow.scale.y = 1; + this._fglow.alpha = 0; + this._fglow.visible = true; + this._fglow.position = new Point(0, 0); + this.replaceNamedObject(ConstraintBox.FGLOW_ANIM, new ParallelTask( + new LocationTask(0, -lineWidth, 1.6, Easing.easeIn, this._fglow), + new ScaleTask(1.0, 1.0 + 2 * (lineWidth + 1) / this.display.width, 1.6, Easing.easeIn, this._fglow), + new SerialTask( + new AlphaTask(1, 0.8, Easing.linear, this._fglow), + new AlphaTask(0, 0.8, Easing.linear, this._fglow), + new VisibleTask(false, this._fglow) + ), + )); + + this._backlight.clear(); + this._backlight.beginFill(satisfied ? 0x00FF00 : 0xFF0000, 0.7); + this._backlight.drawRoundedRect(0, 0, this.display.width, this.display.height, 10); + this._backlight.endFill(); + this._backlight.alpha = 0; + this._backlight.visible = true; + this._backlight.position = new Point(0, 0); + this.replaceNamedObject(ConstraintBox.BACKLIGHT_ANIM, new SerialTask( + new AlphaTask(1, 0.8, Easing.easeInOut, this._backlight), + new AlphaTask(0, 0.8, Easing.easeInOut, this._backlight), + new VisibleTask(false, this._backlight), + )); + } + + public flash(color: number): void { + this._backlight.clear(); + this._backlight.beginFill(color, 0.9); + this._backlight.drawRoundedRect(0, 0, this.display.width, this.display.height, 10); + this._backlight.endFill(); + this._backlight.alpha = 0; + this._backlight.visible = true; + this._backlight.position = new Point(0, 0); + + this.replaceNamedObject(ConstraintBox.BACKLIGHT_ANIM, new SerialTask( + new AlphaTask(1, 0.15, Easing.easeInOut, this._backlight), + new AlphaTask(0, 0.15, Easing.easeInOut, this._backlight), + new AlphaTask(1, 0.3, Easing.easeInOut, this._backlight), + new AlphaTask(0, 0.4, Easing.easeInOut, this._backlight), + new VisibleTask(false, this._backlight), + )); + } + private _forMissionScreen: boolean; + private _satisfied: boolean; + private _bgGraphics: Graphics; - // private _backlight: Graphics; + private _backlight: Graphics; private _req: Sprite; private _bg: Sprite; private _icon: Sprite; @@ -328,12 +448,16 @@ export default class ConstraintBox extends ContainerObject implements Enableable private _reqClarifyText: MultiStyleText; private _reqStatText: MultiStyleText; private _smallThumbnail: Sprite; - // private _flag: Graphics; - // private _sideText: MultiStyleText; + private _flag: Graphics; + private _sideText: MultiStyleText; private _check: Sprite; private _outline: Sprite; - // private _fglow: Graphics; + private _fglow: Graphics; private _mouseOverRegs: RegistrationGroup; private _mouseOverObject: SceneObject; + + private static readonly LOCATION_ANIM = 'AnimateLocation'; + private static readonly BACKLIGHT_ANIM = 'BacklightAnim'; + private static readonly FGLOW_ANIM = 'FGlowAnim'; } diff --git a/src/eterna/constraints/constraints/BarcodeConstraint.ts b/src/eterna/constraints/constraints/BarcodeConstraint.ts index 34997436f..d4e45c141 100644 --- a/src/eterna/constraints/constraints/BarcodeConstraint.ts +++ b/src/eterna/constraints/constraints/BarcodeConstraint.ts @@ -49,7 +49,8 @@ export default class BarcodeConstraint extends Constraint ? BitmapManager.getBitmap(Bitmaps.NovaBarcodeMissionReq) : BitmapManager.getBitmap(Bitmaps.NovaBarcodeReq), clarificationText: 'MUST BE UNIQUE', - tooltip + tooltip, + showOutline: true }; } } diff --git a/src/eterna/constraints/constraints/BindingConstraint.ts b/src/eterna/constraints/constraints/BindingConstraint.ts index 0aa5c35a6..62af9b44a 100644 --- a/src/eterna/constraints/constraints/BindingConstraint.ts +++ b/src/eterna/constraints/constraints/BindingConstraint.ts @@ -107,11 +107,10 @@ abstract class BindingsConstraint let stateCondition = targetConditions[this.stateIndex]; return { - ranges: status.satisfied - ? Utility.range( - undoBlock.sequence.length + 1, - undoBlock.sequence.length + 1 + stateCondition['oligo_sequence'].length - 1 - ) : null, + ranges: Utility.range( + undoBlock.sequence.length + 1, + undoBlock.sequence.length + 1 + stateCondition['oligo_sequence'].length - 1 + ), color: HighlightType.RESTRICTED }; } diff --git a/src/eterna/constraints/constraints/ConsecutiveBaseConstraint.ts b/src/eterna/constraints/constraints/ConsecutiveBaseConstraint.ts index c5970b993..fd8737d6f 100644 --- a/src/eterna/constraints/constraints/ConsecutiveBaseConstraint.ts +++ b/src/eterna/constraints/constraints/ConsecutiveBaseConstraint.ts @@ -75,7 +75,7 @@ abstract class ConsecutiveBaseConstraint extends Constraint satisfied: status.satisfied, clarificationText: `${this.maxPairs} OR FEWER`, statText: status.currentPairs.toString(), - tooltip + tooltip, + showOutline: true }; } } @@ -126,8 +127,8 @@ export class MaximumGUConstraint extends MaximumPairConstraint { return { ...super.getConstraintBoxConfig(status, undoBlocks, targetConditions, forMissionScreen), fullTexture: forMissionScreen - ? BitmapManager.getBitmap(Bitmaps.NovaAUMissionReq) - : BitmapManager.getBitmap(Bitmaps.NovaAUReq) + ? BitmapManager.getBitmap(Bitmaps.NovaGUMissionReq) + : BitmapManager.getBitmap(Bitmaps.NovaGUReq) }; } } diff --git a/src/eterna/constraints/constraints/MinimumPairConstraint.ts b/src/eterna/constraints/constraints/MinimumPairConstraint.ts index be7c7571d..75a3121e6 100644 --- a/src/eterna/constraints/constraints/MinimumPairConstraint.ts +++ b/src/eterna/constraints/constraints/MinimumPairConstraint.ts @@ -57,7 +57,8 @@ abstract class MinimumPairConstraint extends Constraint satisfied: status.satisfied, clarificationText: `${this.minPairs} OR MORE`, statText: status.currentPairs.toString(), - tooltip + tooltip, + showOutline: true }; } } @@ -125,8 +126,8 @@ export class MinimumGUConstraint extends MinimumPairConstraint { return { ...super.getConstraintBoxConfig(status, undoBlocks, targetConditions, forMissionScreen), fullTexture: forMissionScreen - ? BitmapManager.getBitmap(Bitmaps.NovaAUMissionReq) - : BitmapManager.getBitmap(Bitmaps.NovaAUReq) + ? BitmapManager.getBitmap(Bitmaps.NovaGUMissionReq) + : BitmapManager.getBitmap(Bitmaps.NovaGUReq) }; } } diff --git a/src/eterna/constraints/constraints/MinimumStackLengthConstraint.ts b/src/eterna/constraints/constraints/MinimumStackLengthConstraint.ts index 24d7ae773..faf8b7101 100644 --- a/src/eterna/constraints/constraints/MinimumStackLengthConstraint.ts +++ b/src/eterna/constraints/constraints/MinimumStackLengthConstraint.ts @@ -40,7 +40,7 @@ export default class MinimumStackLengthConstraint extends Constraint { @@ -22,37 +23,19 @@ export default class ScriptConstraint extends Constraint } public evaluate(_1: UndoBlock[], _2: any[], puzzle?: Puzzle): ScriptConstraintStatus { - let satisfied = false; - - const scriptID = this.scriptID; const scriptResult = ExternalInterface.runScriptSync( - scriptID, + this.scriptID, {params: {puzzleInfo: puzzle.toJSON() || null}} ).result; - let goal = ''; - let resultValue = ''; - let index = null; - let dataPNG = ''; - if (scriptResult && scriptResult.cause) { - if (scriptResult.cause.satisfied) satisfied = scriptResult.cause.satisfied; - if (scriptResult.cause.goal != null) goal = scriptResult.cause.goal; - if (scriptResult.cause.value != null) resultValue = scriptResult.cause.value; - if (scriptResult.cause.index != null) { - index = scriptResult.cause.index; - } - - if (scriptResult.cause.icon_b64) { - dataPNG = scriptResult.cause.icon_b64; - } - } - return { - goal, - resultValue, - stateIndex: index, - dataPNG, - satisfied + goal: scriptResult.cause.goal != null ? scriptResult.cause.goal : '', + resultValue: scriptResult.cause.value != null ? scriptResult.cause.value : '', + stateIndex: scriptResult.cause.index != null && scriptResult.cause.index >= 0 + ? scriptResult.cause.index : null, + highlightRanges: scriptResult.cause.highlight ? scriptResult.cause.highlight : [], + dataPNG: scriptResult.cause.icon_b64 != null ? scriptResult.cause.icon_b64 : '', + satisfied: !!scriptResult.cause.satisfied }; } @@ -66,7 +49,7 @@ export default class ScriptConstraint extends Constraint satisfied: status.satisfied, drawBG: true, showOutline: true, - iconTexture: status.dataPNG, + icon: status.dataPNG, stateNumber: status.stateIndex + 1, statText: !forMissionScreen ? status.resultValue : null, tooltip: ConstraintBox.createTextStyle().append(status.goal || `Your puzzle must satisfy script ${this.scriptID}`) @@ -75,7 +58,7 @@ export default class ScriptConstraint extends Constraint public getHighlight(status: ScriptConstraintStatus): HighlightInfo { return { - ranges: [], + ranges: status.highlightRanges, color: HighlightType.USER_DEFINED, stateIndex: status.stateIndex }; diff --git a/src/eterna/constraints/constraints/ShapeConstraint.ts b/src/eterna/constraints/constraints/ShapeConstraint.ts index 3c220203e..155786dd8 100644 --- a/src/eterna/constraints/constraints/ShapeConstraint.ts +++ b/src/eterna/constraints/constraints/ShapeConstraint.ts @@ -2,15 +2,18 @@ import UndoBlock from 'eterna/UndoBlock'; import EPars from 'eterna/EPars'; import PoseThumbnail, {PoseThumbnailType} from 'eterna/ui/PoseThumbnail'; import {HighlightType} from 'eterna/pose2D/HighlightBox'; -import Constraint, {BaseConstraintStatus, HighlightInfo} from '../Constraint'; +import Eterna from 'eterna/Eterna'; +import {Sprite} from 'pixi.js'; +import {TextureUtil} from 'flashbang'; import ConstraintBox, {ConstraintBoxConfig} from '../ConstraintBox'; +import Constraint, {BaseConstraintStatus, HighlightInfo} from '../Constraint'; interface ShapeConstraintStatus extends BaseConstraintStatus { wrongPairs: number[]; } abstract class BaseShapeConstraint extends Constraint { - protected readonly stateIndex: number; + public stateIndex: number; constructor(stateIndex: number) { super(); @@ -28,11 +31,15 @@ abstract class BaseShapeConstraint extends Constraint { protected _targetAlignedConstraints(constraints: boolean[], ublk: UndoBlock): boolean[] { let targetMap = ublk.reorderedOligosIndexMap(ublk.targetOligoOrder); - let targetAlignedConstraints: boolean[] = []; - for (let [rawIndex, targetIndex] of Object.entries(targetMap)) { - targetAlignedConstraints[targetIndex] = constraints[Number(rawIndex)]; + if (targetMap != null) { + let targetAlignedConstraints: boolean[] = []; + for (let [rawIndex, targetIndex] of Object.entries(targetMap)) { + targetAlignedConstraints[targetIndex] = constraints[Number(rawIndex)]; + } + return targetAlignedConstraints; + } else { + return constraints; } - return targetAlignedConstraints; } /** @@ -45,25 +52,30 @@ abstract class BaseShapeConstraint extends Constraint { * @param ublk */ protected _targetAlignedNaturalPairs(ublk: UndoBlock): number[] { - // rawIndex => targetAlignedIndex - let targetMap = ublk.reorderedOligosIndexMap(ublk.targetOligoOrder); - // rawIndex => naturalAlignedIndex - let naturalMap = ublk.reorderedOligosIndexMap(ublk.oligoOrder); let naturalPairs = ublk.getPairs(); - let targetAlignedNaturalPairs: number[] = []; - for (let [rawIndex, targetIndex] of Object.entries(targetMap)) { - let naturalIndex = naturalMap[Number(rawIndex)]; - let naturalPairedIndex = naturalPairs[naturalIndex]; - let rawPairedIndex = naturalMap.indexOf(naturalPairedIndex); + // rawIndex => targetAlignedIndex + let targetMap = ublk.reorderedOligosIndexMap(ublk.targetOligoOrder); + if (targetMap != null) { + // rawIndex => naturalAlignedIndex + let naturalMap = ublk.reorderedOligosIndexMap(ublk.oligoOrder); + + let targetAlignedNaturalPairs: number[] = []; + for (let [rawIndex, targetIndex] of Object.entries(targetMap)) { + let naturalIndex = naturalMap[Number(rawIndex)]; + let naturalPairedIndex = naturalPairs[naturalIndex]; + let rawPairedIndex = naturalMap.indexOf(naturalPairedIndex); + + // If unpaired, it's unpaired, otherwise we need to get the index of the paired base + // according to target mode + targetAlignedNaturalPairs[targetIndex] = naturalPairedIndex < 0 + ? naturalPairedIndex : targetMap[rawPairedIndex]; + } - // If unpaired, it's unpaired, otherwise we need to get the index of the paired base - // according to target mode - targetAlignedNaturalPairs[targetIndex] = naturalPairedIndex < 0 - ? naturalPairedIndex : targetMap[rawPairedIndex]; + return targetAlignedNaturalPairs; + } else { + return naturalPairs; } - - return targetAlignedNaturalPairs; } public getConstraintBoxConfig( @@ -71,18 +83,11 @@ abstract class BaseShapeConstraint extends Constraint { undoBlocks: UndoBlock[], targetConditions: any[] ): ConstraintBoxConfig { - let undoBlock = undoBlocks[this.stateIndex]; - let naturalPairs = this._targetAlignedNaturalPairs(undoBlock); - return { satisfied: status.satisfied, tooltip: '', thumbnailBG: true, - stateNumber: targetConditions.length > 1 ? this.stateIndex + 1 : null, - thumbnail: PoseThumbnail.createFramedBitmap( - new Array(naturalPairs.length).fill(EPars.RNABASE_ADENINE), - undoBlock.targetPairs, 3, PoseThumbnailType.WRONG_COLORED, 0, status.wrongPairs, false, 0 - ) + stateNumber: targetConditions.length > 1 ? this.stateIndex + 1 : null }; } @@ -116,19 +121,13 @@ export default class ShapeConstraint extends BaseShapeConstraint { public evaluate(undoBlocks: UndoBlock[], targetConditions: any[]): ShapeConstraintStatus { let undoBlock = undoBlocks[this.stateIndex]; - // TODO: These checks should probably be in Puzzle - if (targetConditions == null) { - throw new Error('Target object not available for SHAPE constraint'); - } - - if (targetConditions[this.stateIndex] == null) { - throw new Error('Target condition not available for SHAPE constraint'); + let targetAlignedConstraints: boolean[] = null; + if (targetConditions !== null && targetConditions[this.stateIndex] != null) { + let structureConstraints: any = targetConditions[this.stateIndex]['structure_constraints']; + targetAlignedConstraints = this._targetAlignedConstraints(structureConstraints, undoBlock); } - let structureConstraints: any = targetConditions[this.stateIndex]['structure_constraints']; - let naturalPairs = this._targetAlignedNaturalPairs(undoBlock); - let targetAlignedConstraints = this._targetAlignedConstraints(structureConstraints, undoBlock); return { satisfied: EPars.arePairsSame(naturalPairs, undoBlock.targetPairs, targetAlignedConstraints), @@ -142,12 +141,18 @@ export default class ShapeConstraint extends BaseShapeConstraint { targetConditions: any[] ): ConstraintBoxConfig { let details = super.getConstraintBoxConfig(status, undoBlocks, targetConditions); + let undoBlock = undoBlocks[this.stateIndex]; + let naturalPairs = this._targetAlignedNaturalPairs(undoBlock); return { ...details, tooltip: ConstraintBox.createTextStyle().append( details.stateNumber ? `In state ${details.stateNumber}, your RNA must fold into the outlined structure.` : 'Your RNA must fold into the outlined structure.' + ), + thumbnail: PoseThumbnail.drawToGraphics( + new Array(naturalPairs.length).fill(EPars.RNABASE_ADENINE), + undoBlock.targetPairs, 3, PoseThumbnailType.WRONG_COLORED, 0, status.wrongPairs, false, 0 ) }; } @@ -208,7 +213,7 @@ export class AntiShapeConstraint extends BaseShapeConstraint { wrongPairs: this._getWrongPairs( naturalPairs, targetAlignedConstraints, - EPars.arePairsSame(naturalPairs, antiPairs, targetAlignedConstraints) + !EPars.arePairsSame(naturalPairs, antiPairs, targetAlignedConstraints) ) }; } @@ -219,6 +224,8 @@ export class AntiShapeConstraint extends BaseShapeConstraint { targetConditions: any[] ): ConstraintBoxConfig { let details = super.getConstraintBoxConfig(status, undoBlocks, targetConditions); + let undoBlock = undoBlocks[this.stateIndex]; + let naturalPairs = this._targetAlignedNaturalPairs(undoBlock); return { ...details, tooltip: ConstraintBox.createTextStyle().append( @@ -226,7 +233,12 @@ export class AntiShapeConstraint extends BaseShapeConstraint { ? `In state ${details.stateNumber}, your RNA must fold into the outlined structure.` : 'Your RNA must fold into the outlined structure.' ), - noText: true + noText: true, + thumbnail: PoseThumbnail.drawToGraphics( + new Array(naturalPairs.length).fill(EPars.RNABASE_ADENINE), + EPars.parenthesisToPairs(targetConditions[this.stateIndex]['anti_secstruct']), + 3, PoseThumbnailType.WRONG_COLORED, 0, status.wrongPairs, false, 0 + ) }; } diff --git a/src/eterna/constraints/constraints/SynthesisConstraint.ts b/src/eterna/constraints/constraints/SynthesisConstraint.ts index f3337dcd6..f039917a2 100644 --- a/src/eterna/constraints/constraints/SynthesisConstraint.ts +++ b/src/eterna/constraints/constraints/SynthesisConstraint.ts @@ -92,7 +92,7 @@ export default class SynthesisConstraint extends Constraint 0) { - if (numConstraints % 2 !== 0) { - throw new Error('Wrong constraints length'); - } - - for (let constraintIdx = 0; constraintIdx < numConstraints; constraintIdx += 2) { - let newbox = new ConstraintBox(ConstraintBoxType.DEFAULT); - this._constraintBoxes.push(newbox); - this.addObject(newbox, this._constraintsLayer); - - newbox.pointerDown.connect(() => { - this.onConstraintBoxClicked(constraintIdx); - }); - } - - this._constraintShapeBoxes = []; - this._constraintShapeBoxes.push(null); - - this._constraintAntishapeBoxes = []; - this._constraintAntishapeBoxes.push(null); - if (this._targetPairs.length > 1) { - for (let pairsIdx = 1; pairsIdx < this._targetPairs.length; pairsIdx++) { - this._constraintShapeBoxes[pairsIdx] = null; - this._constraintAntishapeBoxes[pairsIdx] = null; - for (let constraintIdx = 0; constraintIdx < numConstraints; constraintIdx += 2) { - if (constraints[constraintIdx] === ConstraintType.SHAPE) { - if (int(constraints[constraintIdx + 1]) === pairsIdx) { - let newbox = new ConstraintBox(ConstraintBoxType.DEFAULT); - this._constraintShapeBoxes[pairsIdx] = newbox; - this.addObject(newbox, this._constraintsLayer); - - newbox.pointerDown.connect(() => { - this.onConstraintBoxClicked(constraintIdx); - }); - } - } else if (constraints[constraintIdx] === ConstraintType.ANTISHAPE) { - if (int(constraints[constraintIdx + 1]) === pairsIdx) { - let newbox = new ConstraintBox(ConstraintBoxType.DEFAULT); - this._constraintAntishapeBoxes[pairsIdx] = newbox; - this.addObject(newbox, this._constraintsLayer); - - newbox.pointerDown.connect(() => { - this.onConstraintBoxClicked(constraintIdx); - }); - } + this._constraintBar = new ConstraintBar(this._puzzle.constraints); + this.addObject(this._constraintBar, this._constraintsLayer); + this._constraintBar.sequenceHighlights.connect((highlightInfos) => { + for (let pose of this._poses) { + pose.clearRestrictedHighlight(); + pose.clearUnstableHighlight(); + pose.clearUserDefinedHighlight(); + for (let highlightInfo of highlightInfos) { + if (highlightInfo) { + switch (highlightInfo.color) { + case HighlightType.RESTRICTED: + pose.highlightRestrictedSequence(highlightInfo.ranges); + break; + case HighlightType.UNSTABLE: + pose.highlightUnstableSequence(highlightInfo.ranges); + break; + case HighlightType.USER_DEFINED: + pose.highlightUserDefinedSequence(highlightInfo.ranges); + break; + default: + log.error(`Invalid highlight type: ${highlightInfo.color}`); } } } } - } - - for (let box of this._constraintBoxes) { - box.display.visible = false; - } + }); let pairs: number[] = EPars.parenthesisToPairs(this._puzzle.getSecstruct()); @@ -860,17 +823,14 @@ export default class PoseEditMode extends GameMode { return this.getCurrentUndoBlock(indx).getParam(UndoBlockParam.FE); }); - this._scriptInterface.addCallback( - 'get_constraints', (): any[] => JSON.parse(JSON.stringify(this._puzzle.constraints)) - ); - - this._scriptInterface.addCallback('check_constraints', (): boolean => this.checkConstraints(false)); + this._scriptInterface.addCallback('check_constraints', (): boolean => this.checkConstraints()); this._scriptInterface.addCallback('constraint_satisfied', (idx: number): boolean => { - this.checkConstraints(true); + this.checkConstraints(); if (idx >= 0 && idx < this.constraintCount) { - let o: ConstraintBox = this.getConstraint(idx); - return o.isSatisfied; + return this._puzzle.constraints[idx].evaluate( + this._seqStacks[this._stackLevel], this._targetConditions, this._puzzle + ).satisfied; } else { return false; } @@ -1030,26 +990,6 @@ export default class PoseEditMode extends GameMode { .catch(() => this.popUILock(LOCK_NAME)); } - public layoutConstraints(): void { - let minX: number = this._constraintsOffset + 17; - let relX: number; - if (this._targetPairs == null) return; - let n: number = this._targetPairs.length; - if (n < 2) return; - for (let ii = 1; ii < n; ii++) { - relX = (ii / n) * Flashbang.stageWidth + 17; - if (relX < minX) relX = minX; - if (this._constraintShapeBoxes[ii]) { - this._constraintShapeBoxes[ii].display.position = new Point(relX, 35); - minX = relX + 77; - } - if (this._constraintAntishapeBoxes[ii]) { - this._constraintAntishapeBoxes[ii].display.position = new Point(relX + 77, 35); - minX = relX + 2 * 77; - } - } - } - public onKeyboardEvent(e: KeyboardEvent): void { let handled: boolean = this.keyboardInput.handleKeyboardEvent(e); @@ -1139,15 +1079,15 @@ export default class PoseEditMode extends GameMode { } public get constraintCount(): number { - return this._constraintBoxes.length; + return this._puzzle.constraints.length; } - public getConstraint(i: number): ConstraintBox { - return this._constraintBoxes[this._constraintBoxes.length - i - 1]; + public getConstraintBox(i: number): ConstraintBox { + return this._constraintBar.getConstraintBox(i); } public getShapeBox(i: number): ConstraintBox { - return this._constraintBoxes[i]; + return this._constraintBar.getShapeBox(i); } public setAncestorId(id: number): void { @@ -1162,12 +1102,13 @@ export default class PoseEditMode extends GameMode { this._toolbar.stateToggle.display.visible = false; this._targetName.visible = false; + this._constraintBar.highlightState(-1); + this._constraintBar.layout(false, this._targetPairs.length); + for (let ii = 0; ii < this._poses.length; ii++) { this.setPoseTarget(ii, ii); } - this.displayConstraintBoxes(false, true); - if (this._poseState === PoseState.NATIVE) { this.setToNativeMode(); } else if (this._poseState === PoseState.TARGET) { @@ -1188,6 +1129,9 @@ export default class PoseEditMode extends GameMode { this._toolbar.stateToggle.display.visible = true; this._targetName.visible = true; + this._constraintBar.highlightState(this._curTargetIndex); + this._constraintBar.layout(false, 1); + this.changeTarget(this._curTargetIndex); this._poses[0].setZoomLevel(this._poses[0].computeDefaultZoomLevel(), true, true); } @@ -1293,6 +1237,8 @@ export default class PoseEditMode extends GameMode { private changeTarget(targetIndex: number): void { this._curTargetIndex = targetIndex; + this._constraintBar.highlightState(targetIndex); + if (this._targetConditions && this._targetConditions[this._curTargetIndex]) { if (this._targetConditions[this._curTargetIndex]['state_name'] != null) { this._targetName.text = this._targetConditions[this._curTargetIndex]['state_name']; @@ -1585,7 +1531,7 @@ export default class PoseEditMode extends GameMode { + 'You can still submit the sequence, but please note that there is a risk of not getting\n' + 'synthesized properly'; - if (!this.checkConstraints(false)) { + if (!this.checkConstraints()) { if (this._puzzle.isSoftConstraint || Eterna.DEV_MODE) { this.showConfirmDialog(NOT_SATISFIED_PROMPT).closed .then((confirmed) => { @@ -1929,93 +1875,15 @@ export default class PoseEditMode extends GameMode { // if (this._beam_cmi) this._beam_cmi.enabled = !disable; } - private displayConstraintBoxes(animate: boolean, display: boolean): void { - let numConstraints = 0; - let constraints: string[] = this._puzzle.constraints; - - if (constraints != null) { - numConstraints = constraints.length; - } - - let wWalker = 17; - - for (let xx = 0; xx < this._targetPairs.length; xx++) { - if (xx === 0) { - // scan for non-(ANTI)SHAPE - for (let ii = 0; ii < numConstraints / 2; ii++) { - const box = this._constraintBoxes[ii]; - if ( - box.constraintType === ConstraintType.SHAPE || box.constraintType === ConstraintType.ANTISHAPE - ) { - continue; - } - let cpos = new Point(wWalker, 35); - wWalker += 119; - box.setLocation(cpos, animate); - box.showBigText = false; - box.display.visible = display; - } - if (wWalker > 17) { - wWalker += 25; - } - } else if (xx === 1) { - // save the offset for later use (avoid overlaps in PIP mode) - this._constraintsOffset = wWalker; - } - - // scan for SHAPE - for (let ii = 0; ii < numConstraints / 2; ii++) { - const box = this._constraintBoxes[ii]; - if (box.constraintType !== ConstraintType.SHAPE || int(constraints[2 * ii + 1]) !== xx) { - continue; - } - let cpos = new Point(wWalker, 35); - wWalker += 77; - box.setLocation(cpos, animate); - box.showBigText = false; - box.display.visible = (xx === 0 || !this._isPipMode) ? display : false; - } - - // scan for ANTISHAPE - for (let ii = 0; ii < numConstraints / 2; ii++) { - const box = this._constraintBoxes[ii]; - if (box.constraintType !== ConstraintType.ANTISHAPE || int(constraints[2 * ii + 1]) !== xx) { - continue; - } - let cpos = new Point(wWalker, 35); - wWalker += 77; - box.setLocation(cpos, animate); - box.showBigText = false; - box.display.visible = (xx === 0 || !this._isPipMode) ? display : false; - } - } - - this.layoutConstraints(); - } - private startCountdown(): void { this._isPlaying = false; - const constraints: string[] = this._puzzle.constraints; + const constraints = this._puzzle.constraints; if (constraints == null || constraints.length === 0 || !this._showMissionScreen) { this.startPlaying(); } else { this.setPuzzleState(PuzzleState.COUNTDOWN); - this._constraintsHead = this._constraintsTop; - this._constraintsFoot = this._constraintsBottom; - - for (let ii = 0; ii < constraints.length / 2; ii++) { - let box: ConstraintBox = this._constraintBoxes[ii]; - box.display.visible = true; - box.showBigText = true; - - box.setLocation(new Point( - (Flashbang.stageWidth * 0.3), - (Flashbang.stageHeight * 0.4) + (ii * 77) - )); - } - this._startSolvingTime = new Date().getTime(); this.startPlaying(); this.showIntroScreen(); @@ -2031,41 +1899,34 @@ export default class PoseEditMode extends GameMode { missionText = boosters.mission['text']; } - // Create constraint boxes and pass them to the MissionIntroMode. - // The ConstraintBox creation logic is so tied to PoseEditMode that it's just much easier - - // though uglier - to do things this way. - - let dummyInfo: ConstraintInfo = { - wrongPairs: null, - restrictedLocal: null, - maxAllowedAdenine: -1, - maxAllowedCytosine: -1, - maxAllowedGuanine: -1 - }; - let introConstraintBoxes: ConstraintBox[] = []; - let constraints = this._puzzle.constraints; - for (let ii = 0; ii < constraints.length; ii += 2) { - const type: ConstraintType = constraints[ii] as ConstraintType; - if (type === ConstraintType.SHAPE || type === ConstraintType.ANTISHAPE) { - continue; + let introConstraintBoxes: ConstraintBox[] = this._puzzle.constraints.filter( + constraint => !(constraint instanceof ShapeConstraint || constraint instanceof AntiShapeConstraint) + ).map( + (constraint) => { + let box = new ConstraintBox(true); + box.setContent(constraint.getConstraintBoxConfig( + constraint.evaluate(this._seqStacks[this._stackLevel], this._targetConditions, this._puzzle), + this._seqStacks[this._stackLevel], + this._targetConditions, + true + )); + return box; } + ); - const value = constraints[ii + 1]; - const box = new ConstraintBox(ConstraintBoxType.MISSION_SCREEN); - this.updateConstraint(type, value, ii, box, true, dummyInfo); + this._constraintBar.display.visible = false; - introConstraintBoxes.push(box); - } + this.modeStack.pushMode(new MissionIntroMode( + this._puzzle.getName(true), + missionText, + this._targetPairs, + introConstraintBoxes + )); - // Don't show our intro screen till scripts have completed running, - // so that our introConstraintBoxes are properly populated - ExternalInterface.waitForScriptCompletion().then(() => { - this.modeStack.pushMode(new MissionIntroMode( - this._puzzle.getName(true), - missionText, - this._targetPairs, - introConstraintBoxes - )); + let conn = this.entered.connect(() => { + this._constraintBar.display.visible = true; + this._constraintBar.layout(true, this._isPipMode ? this._targetPairs.length : 1); + conn.close(); }); } @@ -2074,7 +1935,6 @@ export default class PoseEditMode extends GameMode { this.disableTools(false); this.setPuzzleState(PuzzleState.GAME); - this.displayConstraintBoxes(true, true); } private resetAutosaveData(): void { @@ -2216,16 +2076,6 @@ export default class PoseEditMode extends GameMode { this._moves = []; } - private setDefaultVisibilities(): void { - this._exitButton.display.visible = false; - - this._showMissionScreen = true; - this.showConstraints(true); - - this._toolbar.palette.resetOverrides(); - this._toolbar.palette.changeDefaultMode(); - } - private moveHistoryAddMutations(before: number[], after: number[]): void { let muts: any[] = []; for (let ii = 0; ii < after.length; ii++) { @@ -2272,609 +2122,12 @@ export default class PoseEditMode extends GameMode { this.ropPresets(); } - private updateConstraint( - type: ConstraintType, value: string, constraintIdx: number, - box: ConstraintBox, render: boolean, outInfo: ConstraintInfo - ): ConstraintStatus { - let isSatisfied = true; - let isPending = false; - - const undoBlock: UndoBlock = this.getCurrentUndoBlock(); - const sequence = undoBlock.sequence; - - if (type === ConstraintType.GU) { - const count: number = undoBlock.getParam(UndoBlockParam.GU); - isSatisfied = (count >= Number(value)); - if (render) { - box.setContent(ConstraintType.GU, value, isSatisfied, count); - } - } else if (type === ConstraintType.AU) { - const count: number = undoBlock.getParam(UndoBlockParam.AU); - isSatisfied = (count >= Number(value)); - if (render) { - box.setContent(ConstraintType.AU, value, isSatisfied, count); - } - } else if (type === ConstraintType.GC) { - const count: number = undoBlock.getParam(UndoBlockParam.GC); - isSatisfied = (count <= Number(value)); - if (render) { - box.setContent(ConstraintType.GC, value, isSatisfied, count); - } - } else if (type === ConstraintType.MUTATION) { - const sequenceDiff: number = EPars.sequenceDiff( - this._puzzle.getSubsequenceWithoutBarcode(sequence), - this._puzzle.getSubsequenceWithoutBarcode(this._puzzle.getBeginningSequence()) - ); - isSatisfied = sequenceDiff <= Number(value); - if (render) { - box.setContent(ConstraintType.MUTATION, value, isSatisfied, sequenceDiff); - } - } else if (type === ConstraintType.SHAPE) { - const targetIndex = Number(value); - const ublk: UndoBlock = this.getCurrentUndoBlock(targetIndex); - let nativePairs = ublk.getPairs(); - let structureConstraints: any[] = null; - if (this._targetConditions != null && this._targetConditions[targetIndex] != null) { - structureConstraints = this._targetConditions[targetIndex]['structure_constraints']; - - if (ublk.oligoOrder != null) { - let npMap: number[] = ublk.reorderedOligosIndexMap(ublk.oligoOrder); - let tpMap: number[] = ublk.reorderedOligosIndexMap(ublk.targetOligoOrder); - if (npMap != null) { - let newPairs: number[] = []; - let newSC: number[] = []; - for (let jj = 0; jj < nativePairs.length; jj++) { - let kk: number = tpMap.indexOf(jj); - newSC[jj] = structureConstraints[kk]; - let pp: number = nativePairs[npMap[kk]]; - newPairs[jj] = pp < 0 ? pp : tpMap[npMap.indexOf(pp)]; - } - nativePairs = newPairs; - structureConstraints = newSC; - } - } - } - - isSatisfied = EPars.arePairsSame(nativePairs, this._targetPairs[targetIndex], structureConstraints); - - let inputIndex: number; - if (this._targetPairs.length > 1) { - inputIndex = targetIndex; - } - - if (render) { - box.setContent(ConstraintType.SHAPE, { - target: this._targetPairs[targetIndex], - index: inputIndex, - native: nativePairs, - structureConstraints - }, isSatisfied, 0); - box.flagged = this._unstableShapeConstraintIdx === constraintIdx; - if (this._unstableShapeConstraintIdx === constraintIdx) { - outInfo.wrongPairs = box.getWrongPairs( - nativePairs, this._targetPairs[targetIndex], structureConstraints, isSatisfied - ); - } - } - - if (targetIndex > 0) { - if (this._constraintShapeBoxes != null) { - if (this._constraintShapeBoxes[targetIndex] != null) { - this._constraintShapeBoxes[targetIndex].setContent(ConstraintType.SHAPE, { - target: this._targetPairs[targetIndex], - index: inputIndex, - native: nativePairs, - structureConstraints - }, isSatisfied, 0); - - let flag = this._unstableShapeConstraintIdx === constraintIdx; - this._constraintShapeBoxes[targetIndex].flagged = flag; - this._constraintShapeBoxes[targetIndex].display.visible = this._isPipMode; - } - } - } - } else if (type === ConstraintType.ANTISHAPE) { - let targetIndex = Number(value); - let nativePairs = this.getCurrentUndoBlock(targetIndex).getPairs(); - if (this._targetConditions == null) { - throw new Error('Target object not available for ANTISHAPE constraint'); - } - - if (this._targetConditions[targetIndex] == null) { - throw new Error('Target condition not available for ANTISHAPE constraint'); - } - - let antiStructureString: string = this._targetConditions[targetIndex]['anti_secstruct']; - - if (antiStructureString == null) { - throw new Error('Target structure not available for ANTISHAPE constraint'); - } - - let antiStructureConstraints: any[] = this._targetConditions[targetIndex]['anti_structure_constraints']; - let antiPairs: number[] = EPars.parenthesisToPairs(antiStructureString); - isSatisfied = !EPars.arePairsSame(nativePairs, antiPairs, antiStructureConstraints); - - let inputIndex: number; - if (this._targetPairs.length > 1) { - inputIndex = targetIndex; - } - - if (render) { - box.setContent(ConstraintType.ANTISHAPE, { - target: antiPairs, - native: nativePairs, - index: inputIndex, - structureConstraints: antiStructureConstraints - }, isSatisfied, 0); - box.flagged = this._unstableShapeConstraintIdx === constraintIdx; - - if (this._unstableShapeConstraintIdx === constraintIdx) { - outInfo.wrongPairs = box.getWrongPairs( - nativePairs, antiPairs, antiStructureConstraints, isSatisfied - ); - } - } - - if (targetIndex > 0) { - if (this._constraintAntishapeBoxes != null) { - if (this._constraintAntishapeBoxes[targetIndex] != null) { - this._constraintAntishapeBoxes[targetIndex].setContent(ConstraintType.ANTISHAPE, { - target: antiPairs, - native: nativePairs, - index: inputIndex, - structureConstraints: antiStructureConstraints - }, isSatisfied, 0); - - let flag = this._unstableShapeConstraintIdx === constraintIdx; - this._constraintAntishapeBoxes[targetIndex].flagged = flag; - - this._constraintAntishapeBoxes[targetIndex].display.visible = this._isPipMode; - } - } - } - } else if (type === ConstraintType.BINDINGS) { - const targetIndex = Number(value); - const undoblk: UndoBlock = this.getCurrentUndoBlock(targetIndex); - - if (this._targetConditions == null) { - throw new Error('Target object not available for BINDINGS constraint'); - } - - if (this._targetConditions[targetIndex] == null) { - throw new Error('Target condition not available for BINDINGS constraint'); - } - - const oligos: OligoDef[] = this._targetConditions[targetIndex]['oligos']; - if (oligos == null) { - throw new Error('Target condition not available for BINDINGS constraint'); - } - - let oNames: string[] = []; - let bind: boolean[] = []; - let label: string[] = []; - let bmap: boolean[] = []; - let offsets: number[] = []; - let ofs: number = sequence.length; - let o: number[] = undoblk.oligoOrder; - let count: number = undoblk.oligosPaired; - for (let jj = 0; jj < o.length; jj++) { - bmap[o[jj]] = (jj < count); - offsets[o[jj]] = ofs + 1; - ofs += oligos[o[jj]]['sequence'].length + 1; - } - - isSatisfied = true; - for (let jj = 0; jj < oligos.length; jj++) { - if (oligos[jj]['bind'] == null) continue; - let oName: string = oligos[jj]['name']; - if (oName == null) oName = `Oligo ${(jj + 1).toString()}`; - oNames.push(oName); - let expected = Boolean(oligos[jj]['bind']); - bind.push(expected); - let lbl: string = oligos[jj]['label'] != null - ? String(oligos[jj]['label']) : String.fromCharCode(65 + jj); - label.push(lbl); - - if (bmap[jj] !== expected) { - isSatisfied = false; - if (outInfo.restrictedLocal == null) { - outInfo.restrictedLocal = []; - } - if (outInfo.restrictedLocal[targetIndex] == null) { - outInfo.restrictedLocal[targetIndex] = []; - } - outInfo.restrictedLocal[targetIndex].push(offsets[jj]); - outInfo.restrictedLocal[targetIndex].push(offsets[jj] + oligos[jj]['sequence'].length - 1); - } - } - - if (render) { - box.setContent(ConstraintType.BINDINGS, { - index: targetIndex, - bind, - label, - oligoNames: oNames - }, isSatisfied, 0); - } - } else if (type === ConstraintType.G) { - const count: number = Constraints.count(sequence, EPars.RNABASE_GUANINE); - isSatisfied = (count >= Number(value)); - if (render) { - box.setContent(ConstraintType.G, value, isSatisfied, count); - } - } else if (type === ConstraintType.GMAX) { - const count = Constraints.count(sequence, EPars.RNABASE_GUANINE); - isSatisfied = (count <= Number(value)); - if (render) { - box.setContent(ConstraintType.GMAX, value, isSatisfied, count); - } - } else if (type === ConstraintType.A) { - const count: number = Constraints.count(sequence, EPars.RNABASE_ADENINE); - isSatisfied = (count >= Number(value)); - if (render) { - box.setContent(ConstraintType.A, value, isSatisfied, count); - } - } else if (type === ConstraintType.AMAX) { - const count = Constraints.count(sequence, EPars.RNABASE_ADENINE); - isSatisfied = (count <= Number(value)); - if (render) { - box.setContent(ConstraintType.AMAX, value, isSatisfied, count); - } - } else if (type === ConstraintType.U) { - const count: number = Constraints.count(sequence, EPars.RNABASE_URACIL); - isSatisfied = (count >= Number(value)); - if (render) { - box.setContent(ConstraintType.U, value, isSatisfied, count); - } - } else if (type === ConstraintType.UMAX) { - const count = Constraints.count(sequence, EPars.RNABASE_URACIL); - isSatisfied = (count <= Number(value)); - if (render) { - box.setContent(ConstraintType.UMAX, value, isSatisfied, count); - } - } else if (type === ConstraintType.C) { - const count: number = Constraints.count(sequence, EPars.RNABASE_CYTOSINE); - isSatisfied = (count >= Number(value)); - if (render) { - box.setContent(ConstraintType.C, value, isSatisfied, count); - } - } else if (type === ConstraintType.CMAX) { - const count = Constraints.count(sequence, EPars.RNABASE_CYTOSINE); - isSatisfied = (count <= Number(value)); - if (render) { - box.setContent(ConstraintType.CMAX, value, isSatisfied, count); - } - } else if (type === ConstraintType.PAIRS) { - let numGU: number = undoBlock.getParam(UndoBlockParam.GU); - let numGC: number = undoBlock.getParam(UndoBlockParam.GC); - let numUA: number = undoBlock.getParam(UndoBlockParam.AU); - isSatisfied = (numGC + numGU + numUA >= Number(value)); - - if (render) { - box.setContent(ConstraintType.PAIRS, value, isSatisfied, numGC + numGU + numUA); - } - } else if (type === ConstraintType.STACK) { - const stackLen: number = undoBlock.getParam(UndoBlockParam.STACK); - isSatisfied = (stackLen >= Number(value)); - - if (render) { - box.setContent(ConstraintType.STACK, value, isSatisfied, stackLen); - } - } else if (type === ConstraintType.CONSECUTIVE_G) { - let consecutiveGCount: number = EPars.countConsecutive(sequence, EPars.RNABASE_GUANINE); - isSatisfied = (consecutiveGCount < Number(value)); - - if (render) { - box.setContent(ConstraintType.CONSECUTIVE_G, value, isSatisfied, consecutiveGCount); - } - - outInfo.maxAllowedGuanine = Number(value); - } else if (type === ConstraintType.CONSECUTIVE_C) { - let consecutiveCCount: number = EPars.countConsecutive(sequence, EPars.RNABASE_CYTOSINE); - isSatisfied = (consecutiveCCount < Number(value)); - - if (render) { - box.setContent(ConstraintType.CONSECUTIVE_C, value, isSatisfied, consecutiveCCount); - } - - outInfo.maxAllowedCytosine = Number(value); - } else if (type === ConstraintType.CONSECUTIVE_A) { - let consecutiveACount: number = EPars.countConsecutive(sequence, EPars.RNABASE_ADENINE); - isSatisfied = (consecutiveACount < Number(value)); - - if (render) { - box.setContent(ConstraintType.CONSECUTIVE_A, value, isSatisfied, consecutiveACount); - } - - outInfo.maxAllowedAdenine = Number(value); - } else if (type === ConstraintType.LAB_REQUIREMENTS) { - let locks: boolean[] = undoBlock.puzzleLocks; - let consecutiveGCount: number = EPars.countConsecutive(sequence, EPars.RNABASE_GUANINE, locks); - let consecutiveCCount: number = EPars.countConsecutive(sequence, EPars.RNABASE_CYTOSINE, locks); - let consecutiveACount: number = EPars.countConsecutive(sequence, EPars.RNABASE_ADENINE, locks); - outInfo.maxAllowedGuanine = 4; - outInfo.maxAllowedCytosine = 4; - outInfo.maxAllowedAdenine = 5; - isSatisfied = (consecutiveGCount < outInfo.maxAllowedGuanine); - isSatisfied = isSatisfied && (consecutiveCCount < outInfo.maxAllowedCytosine); - isSatisfied = isSatisfied && (consecutiveACount < outInfo.maxAllowedAdenine); - - if (render) { - box.setContent(ConstraintType.LAB_REQUIREMENTS, { - gCount: consecutiveGCount, - gMax: outInfo.maxAllowedGuanine, - cCount: consecutiveCCount, - cMax: outInfo.maxAllowedCytosine, - aCount: consecutiveACount, - aMax: outInfo.maxAllowedAdenine - }, isSatisfied, 0); - } - } else if (type === ConstraintType.BARCODE) { - isSatisfied = !SolutionManager.instance.checkRedundancyByHairpin(EPars.sequenceToString(sequence)); - if (render) { - box.setContent(ConstraintType.BARCODE, 0, isSatisfied, 0); - } - } else if (type === ConstraintType.OLIGO_BOUND) { - let targetIndex = Number(value); - let nnfe: number[] = this.getCurrentUndoBlock(targetIndex) - .getParam(UndoBlockParam.NNFE_ARRAY, EPars.DEFAULT_TEMPERATURE); - isSatisfied = (nnfe != null && nnfe[0] === -2); - - if (this._targetConditions == null) { - throw new Error('Target object not available for BINDINGS constraint'); - } - - if (this._targetConditions[targetIndex] == null) { - throw new Error('Target condition not available for BINDINGS constraint'); - } - - let oNames: string[] = []; - let oName: string = this._targetConditions[targetIndex]['oligo_name']; - - // TSC: not sure what this value should be. It's not guaranteed to be initialized in the original Flash code - let jj = 0; - if (oName == null) oName = `Oligo ${(jj + 1).toString()}`; - oNames.push(oName); - - let bind: boolean[] = []; - bind.push(true); - - let label: string[] = []; - let lbl: string = this._targetConditions[targetIndex]['oligo_label']; - if (lbl == null) lbl = String.fromCharCode(65 + jj); - label.push(lbl); - - if (render) { - box.setContent(ConstraintType.BINDINGS, { - index: targetIndex, - bind, - label, - oligoNames: oNames - }, isSatisfied, 0); - } - } else if (type === ConstraintType.OLIGO_UNBOUND) { - let targetIndex = Number(value); - let nnfe: number[] = this.getCurrentUndoBlock(targetIndex) - .getParam(UndoBlockParam.NNFE_ARRAY, EPars.DEFAULT_TEMPERATURE); - isSatisfied = (nnfe == null || nnfe[0] !== -2); - - if (this._targetConditions == null) { - throw new Error('Target object not available for BINDINGS constraint'); - } - - if (this._targetConditions[targetIndex] == null) { - throw new Error('Target condition not available for BINDINGS constraint'); - } - - // TSC: not sure what this value should be. It's not guaranteed to be initialized in the original Flash code - let jj = 0; - - let oNames: string[] = []; - let oName: string = this._targetConditions[targetIndex]['oligo_name']; - if (oName == null) oName = `Oligo ${(jj + 1).toString()}`; - oNames.push(oName); - - let bind: boolean[] = []; - bind.push(false); - - let label: string[] = []; - let lbl: string = this._targetConditions[targetIndex]['oligo_label']; - if (lbl == null) lbl = String.fromCharCode(65 + jj); - label.push(lbl); - - if (render) { - box.setContent(ConstraintType.BINDINGS, { - index: targetIndex, - bind, - label, - oligoNames: oNames - }, isSatisfied, 0); - } - } else if (type === ConstraintType.SCRIPT) { - isSatisfied = false; - - const scriptID = value; - const scriptCompleted = ExternalInterface.runScriptMaybeSynchronously(scriptID, - {params: {puzzleInfo: this._puzzle.toJSON()}}, - (scriptResult) => { - let goal = ''; - let name = '...'; - let resultValue = ''; - let index = null; - let dataPNG = ''; - if (scriptResult && scriptResult.cause) { - if (scriptResult.cause.satisfied) isSatisfied = scriptResult.cause.satisfied; - if (scriptResult.cause.goal != null) goal = scriptResult.cause.goal; - if (scriptResult.cause.name != null) name = scriptResult.cause.name; - if (scriptResult.cause.value != null) resultValue = scriptResult.cause.value; - if (scriptResult.cause.index != null) { - index = (scriptResult.cause.index + 1).toString(); - let ll: number; - if (this._isPipMode) { - ll = scriptResult.cause.index; - } else { - ll = (scriptResult.cause.index === this._curTargetIndex ? 0 : -1); - } - - if (ll >= 0) { - if (scriptResult.cause.highlight != null) { - this._poses[ll].highlightUserDefinedSequence(scriptResult.cause.highlight); - } else { - this._poses[ll].clearUserDefinedHighlight(); - } - } - } - - if (scriptResult.cause.icon_b64) { - dataPNG = scriptResult.cause.icon_b64; - } - } - - if (render) { - box.setContent(ConstraintType.SCRIPT, { - nid: scriptID, - goal, - name, - value: resultValue, - index, - dataPNG - }, isSatisfied, 0); - } - }); - - if (!scriptCompleted) { - log.warn(`Constraint script wasn't able to run synchronously [scriptID=${scriptID}]`); - isSatisfied = false; - isPending = true; - } - } - - if (isPending) { - return ConstraintStatus.PENDING; - } else if (isSatisfied) { - return ConstraintStatus.SATISFIED; - } else { - return ConstraintStatus.UNSATISFIED; - } - } - - private checkConstraints(render: boolean = true): boolean { - const constraints: string[] = this._puzzle.constraints; - if (constraints == null || constraints.length === 0) { - return false; - } - - let constraintsInfo: ConstraintInfo = { - wrongPairs: null, - restrictedLocal: null, - maxAllowedAdenine: -1, - maxAllowedCytosine: -1, - maxAllowedGuanine: -1 - }; - - let allAreSatisfied = true; - let allWereSatisfied = true; - let hasPendingConstraints = false; - - let playConstraintSatisfiedSFX = false; - let playConstraintUnsatisfiedSFX = false; - - for (let ii = 0; ii < constraints.length; ii += 2) { - const type: ConstraintType = constraints[ii] as ConstraintType; - const value = constraints[ii + 1]; - const box: ConstraintBox = this._constraintBoxes[ii / 2]; - - const wasSatisfied: boolean = box.isSatisfied; - const status = this.updateConstraint(type, value, ii, box, render, constraintsInfo); - - allAreSatisfied = allAreSatisfied && status === ConstraintStatus.SATISFIED; - allWereSatisfied = allWereSatisfied && wasSatisfied; - hasPendingConstraints = hasPendingConstraints || status === ConstraintStatus.PENDING; - - if (type === ConstraintType.SHAPE || type === ConstraintType.ANTISHAPE) { - const targetIndex = Number(value); - if (!this._isPipMode) { - box.display.alpha = (targetIndex === this._curTargetIndex) ? 1.0 : 0.3; - } else { - box.display.alpha = 1.0; - } - - if (this._isPipMode && targetIndex > 0) { - box.display.visible = false; - } else if (this._puzState === PuzzleState.GAME || this._puzState === PuzzleState.CLEARED) { - box.display.visible = true; - } - } - - if (render) { - if (status === ConstraintStatus.SATISFIED && !wasSatisfied) { - playConstraintSatisfiedSFX = true; - box.flare(true); - } else if (status === ConstraintStatus.UNSATISFIED && wasSatisfied) { - playConstraintUnsatisfiedSFX = true; - box.flare(false); - } - } - } - - let unstable: number[] = []; - if (constraintsInfo.wrongPairs) { - let curr = 0; - let jj: number; - for (jj = 0; jj < constraintsInfo.wrongPairs.length; jj++) { - let stat: number = (constraintsInfo.wrongPairs[jj] === 1 ? 1 : 0); - if ((curr ^ stat) !== 0) { - unstable.push(jj - curr); - curr = stat; - } - } - if ((unstable.length % 2) === 1) { - unstable.push(jj - 1); - } - } - - const undoBlock: UndoBlock = this.getCurrentUndoBlock(); - const sequence: number[] = undoBlock.sequence; - const locks: boolean[] = undoBlock.puzzleLocks; - - const restrictedGuanine = EPars.getRestrictedConsecutive( - sequence, EPars.RNABASE_GUANINE, constraintsInfo.maxAllowedGuanine - 1, locks + private checkConstraints(): boolean { + return this._constraintBar.updateConstraints( + this._seqStacks[this._stackLevel], + this._targetConditions, + this._puzzle ); - const restrictedCytosine = EPars.getRestrictedConsecutive( - sequence, EPars.RNABASE_CYTOSINE, constraintsInfo.maxAllowedCytosine - 1, locks - ); - const restrictedAdenine = EPars.getRestrictedConsecutive( - sequence, EPars.RNABASE_ADENINE, constraintsInfo.maxAllowedAdenine - 1, locks - ); - - const restrictedGlobal: number[] = restrictedGuanine.concat(restrictedCytosine).concat(restrictedAdenine); - - for (let ii = 0; ii < this._poses.length; ii++) { - let jj = (this._isPipMode || ii !== 0) ? ii : this._curTargetIndex; - - let restricted: number[]; - if (constraintsInfo.restrictedLocal && constraintsInfo.restrictedLocal[jj]) { - restricted = restrictedGlobal.concat(constraintsInfo.restrictedLocal[jj]); - } else { - restricted = restrictedGlobal; - } - this._poses[ii].highlightRestrictedSequence(restricted); - this._poses[ii].highlightUnstableSequence(unstable); - } - - if (allAreSatisfied && !allWereSatisfied && !hasPendingConstraints) { - if (this._puzzle.puzzleType === PuzzleType.EXPERIMENTAL) { - Flashbang.sound.playSound(Sounds.SoundAllConditions); - } else if (this._puzState !== PuzzleState.GAME) { - Flashbang.sound.playSound(Sounds.SoundCondition); - } - } else if (playConstraintSatisfiedSFX) { - Flashbang.sound.playSound(Sounds.SoundCondition); - } else if (playConstraintUnsatisfiedSFX) { - Flashbang.sound.playSound(Sounds.SoundDecondition); - } - - return allAreSatisfied; } private updateScore(): void { @@ -2883,8 +2136,6 @@ export default class PoseEditMode extends GameMode { // if (dn != null) dn.visible = (this._stack_level === 0); let undoBlock: UndoBlock = this.getCurrentUndoBlock(); - let sequence: number[] = undoBlock.sequence; - let bestPairs: number[] = undoBlock.getPairs(EPars.DEFAULT_TEMPERATURE); let nnfe: number[]; if (!this._paused) { @@ -3005,11 +2256,6 @@ export default class PoseEditMode extends GameMode { } } - let wasSatisfied = true; - for (let ii = 0; ii < this._puzzle.constraints.length; ii += 2) { - wasSatisfied = wasSatisfied && this._constraintBoxes[ii / 2].isSatisfied; - } - let constraintsSatisfied: boolean = this.checkConstraints(); for (let ii = 0; ii < this._poses.length; ii++) { this.getCurrentUndoBlock(ii).stable = constraintsSatisfied; @@ -3026,22 +2272,7 @@ export default class PoseEditMode extends GameMode { } private flashConstraintForTarget(targetIndex: number): void { - let box: ConstraintBox = null; - if (targetIndex === 0 || !this._isPipMode) { - let constraints: string[] = this._puzzle.constraints; - for (let ii = 0; ii < constraints.length; ii += 2) { - if (constraints[ii] === ConstraintType.SHAPE && Number(constraints[ii + 1]) === targetIndex) { - box = this._constraintBoxes[ii / 2]; - break; - } - } - } else { - box = this._constraintShapeBoxes[targetIndex]; - } - - if (box != null) { - box.flash(0x00FFFF); - } + this._constraintBar.getShapeBox(targetIndex).flash(0x00FFFF); } private poseEditByTarget(targetIndex: number): void { @@ -3492,16 +2723,7 @@ export default class PoseEditMode extends GameMode { } if (lastBestPairs != null) { - let isShapeConstrained = false; - let constraints: string[] = this._puzzle.constraints; - - if (constraints != null) { - for (let ii = 0; ii < constraints.length; ii += 2) { - if (constraints[ii] === ConstraintType.SHAPE) { - isShapeConstrained = true; - } - } - } + let isShapeConstrained = this._puzzle.constraints.some(constraint => constraint instanceof ShapeConstraint); let pairsDiff: number[] = []; @@ -3668,20 +2890,6 @@ export default class PoseEditMode extends GameMode { this._seqStacks = []; } - /** - * When a structure constraint box is clicked, we hilite the bases that are misfolding. - * The _unstableShapeConstraintIdx indicates which constraint's misfolded bases should be hilited. - */ - private onConstraintBoxClicked(idx: number): void { - if ( - this._puzzle.constraints[idx] === ConstraintType.SHAPE - || this._puzzle.constraints[idx] === ConstraintType.ANTISHAPE - ) { - this._unstableShapeConstraintIdx = (this._unstableShapeConstraintIdx === idx ? -1 : idx); - this.checkConstraints(); - } - } - private readonly _puzzle: Puzzle; private readonly _params: PoseEditParams; private readonly _scriptInterface = new ExternalInterfaceCtx(); @@ -3728,19 +2936,16 @@ export default class PoseEditMode extends GameMode { private _hintBoxRef: GameObjectRef = GameObjectRef.NULL; // / constraints && scoring display - private _constraintBoxes: ConstraintBox[]; - private _constraintShapeBoxes: ConstraintBox[]; - private _constraintAntishapeBoxes: ConstraintBox[]; - private _unstableShapeConstraintIdx: number; - private _constraintsOffset: number; + private _constraintBar: ConstraintBar; + // private _constraintBoxes: ConstraintBox[]; + // private _constraintShapeBoxes: ConstraintBox[]; + // private _constraintAntishapeBoxes: ConstraintBox[]; + // private _unstableShapeConstraintIdx: number; + // private _constraintsOffset: number; private _dockedSpecBox: SpecBox; private _exitButton: GameButton; - private _constraintsHead: number = 0; - private _constraintsFoot: number = 0; - private _constraintsTop: number = 0; - private _constraintsBottom: number = 0; private _uiHighlight: SpriteObject; private _homeButton: URLButton; diff --git a/src/eterna/puzzle/Puzzle.ts b/src/eterna/puzzle/Puzzle.ts index fb3f044c1..db9ec7931 100644 --- a/src/eterna/puzzle/Puzzle.ts +++ b/src/eterna/puzzle/Puzzle.ts @@ -5,6 +5,8 @@ import Vienna from 'eterna/folding/Vienna'; import Folder from 'eterna/folding/Folder'; import EternaURL from 'eterna/net/EternaURL'; import Pose2D from 'eterna/pose2D/Pose2D'; +import Constraint, {BaseConstraintStatus} from 'eterna/constraints/Constraint'; +import ShapeConstraint from 'eterna/constraints/constraints/ShapeConstraint'; import {ConstraintType} from './Constraints'; export interface BoostersData { @@ -148,45 +150,12 @@ export default class Puzzle { } } - public get constraints(): string[] { + public get constraints(): Constraint[] { return this._constraints; } - public set constraints(constraints: string[]) { - this._constraints = []; - let shapes: boolean[] = []; - let antishapes: boolean[] = []; - - for (let ii = 0; ii < constraints.length; ii += 2) { - if (constraints[ii] === ConstraintType.SHAPE) { - shapes[Number(constraints[ii + 1])] = true; - } else if (constraints[ii] === ConstraintType.ANTISHAPE) { - antishapes[Number(constraints[ii + 1])] = true; - } - } - - for (let ii = shapes.length - 1; ii >= 0; ii--) { - if (antishapes[ii]) { - this._constraints.push(ConstraintType.ANTISHAPE); - this._constraints.push(`${ii}`); - } - - if (shapes[ii]) { - this._constraints.push(ConstraintType.SHAPE); - this._constraints.push(`${ii}`); - } - } - - for (let ii = 0; ii < constraints.length; ii += 2) { - if (constraints[ii] !== ConstraintType.SHAPE - && constraints[ii] !== ConstraintType.SOFT - && constraints[ii] !== ConstraintType.ANTISHAPE) { - this._constraints.push(constraints[ii]); - this._constraints.push(constraints[ii + 1]); - } else if (constraints[ii] === ConstraintType.SOFT) { - this._isSoftConstraint = true; - } - } + public set constraints(constraints: Constraint[]) { + this._constraints = constraints; } public get puzzleLocks(): boolean[] { @@ -375,6 +344,10 @@ export default class Puzzle { return this._isSoftConstraint; } + public set isSoftConstraint(isSoftConstraint: boolean) { + this._isSoftConstraint = isSoftConstraint; + } + public get round(): number { return this._round; } @@ -409,12 +382,7 @@ export default class Puzzle { public get isPairBrushAllowed(): boolean { let isBasic: boolean = (this._puzzleType !== PuzzleType.BASIC); - let hasTarget = false; - for (let ii = 0; ii < this._constraints.length; ii++) { - if (this._constraints[ii] === ConstraintType.SHAPE) { - hasTarget = true; - } - } + let hasTarget = this._constraints.some(constraint => constraint instanceof ShapeConstraint); return isBasic || hasTarget; } @@ -627,7 +595,7 @@ export default class Puzzle { private _useShortTails: boolean = false; private _useBarcode: boolean = false; private _targetConditions: any[] = null; - private _constraints: string[] = null; + private _constraints: Constraint[] = null; private _round: number = -1; private _numSubmissions: number = 3; private _folder: string; diff --git a/src/eterna/puzzle/PuzzleManager.ts b/src/eterna/puzzle/PuzzleManager.ts index e835052cd..789fd6bcf 100644 --- a/src/eterna/puzzle/PuzzleManager.ts +++ b/src/eterna/puzzle/PuzzleManager.ts @@ -2,8 +2,38 @@ import * as log from 'loglevel'; import Eterna from 'eterna/Eterna'; import FolderManager from 'eterna/folding/FolderManager'; import Folder from 'eterna/folding/Folder'; -import Puzzle from './Puzzle'; +import ShapeConstraint, {AntiShapeConstraint} from 'eterna/constraints/constraints/ShapeConstraint'; +import { + MultistrandBindingsConstraint, + OligoBoundConstraint, + OligoUnboundConstraint +} from 'eterna/constraints/constraints/BindingConstraint'; +import Constraint, {BaseConstraintStatus} from 'eterna/constraints/Constraint'; +import { + ConsecutiveAConstraint, ConsecutiveCConstraint, ConsecutiveUConstraint, ConsecutiveGConstraint +} from 'eterna/constraints/constraints/ConsecutiveBaseConstraint'; +import { + MaximumAConstraint, MaximumCConstraint, MaximumGConstraint, MaximumUConstraint +} from 'eterna/constraints/constraints/MaximumBaseConstraint'; +import MaximumMutationConstraint from 'eterna/constraints/constraints/MaximumMutationConstraint'; +import { + MaximumAUConstraint, + MaximumGCConstraint, + MaximumGUConstraint +} from 'eterna/constraints/constraints/MaximumPairConstraint'; +import { + MinimumAConstraint, MinimumCConstraint, MinimumGConstraint, MinimumUConstraint +} from 'eterna/constraints/constraints/MinimumBaseConstraint'; +import { + MinimumAUConstraint, MinimumGCConstraint, MinimumGUConstraint, MinimumAnyPairConstraint +} from 'eterna/constraints/constraints/MinimumPairConstraint'; +import MinimumStackLengthConstraint from 'eterna/constraints/constraints/MinimumStackLengthConstraint'; +import ScriptConstraint from 'eterna/constraints/constraints/ScriptConstraint'; +import SynthesisConstraint from 'eterna/constraints/constraints/SynthesisConstraint'; +import BarcodeConstraint from 'eterna/constraints/constraints/BarcodeConstraint'; +import ExternalInterface from 'eterna/util/ExternalInterface'; import SolutionManager from './SolutionManager'; +import Puzzle from './Puzzle'; export default class PuzzleManager { public static get instance(): PuzzleManager { @@ -168,17 +198,115 @@ export default class PuzzleManager { } } + let constraints: Constraint[] = []; if (json['constraints'] && json['constraints'].length > 0) { - let constraints: string[] = json['constraints'].split(','); - if (json['check_hairpin'] && Number(json['check_hairpin'])) { - constraints.push('BARCODE'); - constraints.push('0'); + let constraintDefs: string[] = json['constraints'].split(','); + if (constraintDefs.length % 2 === 1) { + throw new Error('Invalid constraint definition - uneven number of constraints and parameters'); + } + + for (let i = 0; i < constraintDefs.length; i += 2) { + let [name, parameter] = constraintDefs.slice(i, i + 2); + switch (name) { + case 'SOFT': + newpuz.isSoftConstraint = true; + break; + case AntiShapeConstraint.NAME: + constraints.push(new AntiShapeConstraint(Number(parameter))); + break; + case MultistrandBindingsConstraint.NAME: + constraints.push(new MultistrandBindingsConstraint(Number(parameter))); + break; + case OligoBoundConstraint.NAME: + constraints.push(new OligoBoundConstraint(Number(parameter))); + break; + case OligoUnboundConstraint.NAME: + constraints.push(new OligoUnboundConstraint(Number(parameter))); + break; + case ConsecutiveAConstraint.NAME: + constraints.push(new ConsecutiveAConstraint(Number(parameter))); + break; + case ConsecutiveCConstraint.NAME: + constraints.push(new ConsecutiveCConstraint(Number(parameter))); + break; + case ConsecutiveGConstraint.NAME: + constraints.push(new ConsecutiveGConstraint(Number(parameter))); + break; + case ConsecutiveUConstraint.NAME: + constraints.push(new ConsecutiveUConstraint(Number(parameter))); + break; + case MaximumAConstraint.NAME: + constraints.push(new MaximumAConstraint(Number(parameter))); + break; + case MaximumCConstraint.NAME: + constraints.push(new MaximumCConstraint(Number(parameter))); + break; + case MaximumGConstraint.NAME: + constraints.push(new MaximumGConstraint(Number(parameter))); + break; + case MaximumUConstraint.NAME: + constraints.push(new MaximumUConstraint(Number(parameter))); + break; + case MaximumMutationConstraint.NAME: + constraints.push(new MaximumMutationConstraint(Number(parameter))); + break; + case MaximumAUConstraint.NAME: + constraints.push(new MaximumAUConstraint(Number(parameter))); + break; + case MaximumGCConstraint.NAME: + constraints.push(new MaximumGCConstraint(Number(parameter))); + break; + case MaximumGUConstraint.NAME: + constraints.push(new MaximumGUConstraint(Number(parameter))); + break; + case MinimumAConstraint.NAME: + constraints.push(new MinimumAConstraint(Number(parameter))); + break; + case MinimumCConstraint.NAME: + constraints.push(new MinimumCConstraint(Number(parameter))); + break; + case MinimumGConstraint.NAME: + constraints.push(new MinimumGConstraint(Number(parameter))); + break; + case MinimumUConstraint.NAME: + constraints.push(new MinimumUConstraint(Number(parameter))); + break; + case MinimumAUConstraint.NAME: + constraints.push(new MinimumAUConstraint(Number(parameter))); + break; + case MinimumGCConstraint.NAME: + constraints.push(new MinimumGCConstraint(Number(parameter))); + break; + case MinimumGUConstraint.NAME: + constraints.push(new MinimumGUConstraint(Number(parameter))); + break; + case MinimumAnyPairConstraint.NAME: + constraints.push(new MinimumAnyPairConstraint(Number(parameter))); + break; + case MinimumStackLengthConstraint.NAME: + constraints.push(new MinimumStackLengthConstraint(Number(parameter))); + break; + case ScriptConstraint.NAME: + constraints.push(new ScriptConstraint(Number(parameter))); + break; + case ShapeConstraint.NAME: + constraints.push(new ShapeConstraint(Number(parameter))); + break; + case SynthesisConstraint.NAME: + constraints.push(new SynthesisConstraint()); + break; + default: + log.warn(`Unknown constraint ${name} - skipping`); + } } - newpuz.constraints = constraints; - } else if (json['check_hairpin'] && Number(json['check_hairpin'])) { - newpuz.constraints = ['BARCODE', '0']; } + if (json['check_hairpin'] && Number(json['check_hairpin'])) { + constraints.push(new BarcodeConstraint()); + } + + newpuz.constraints = constraints; + if (!newpuz.canUseFolder(FolderManager.instance.getFolder(newpuz.folderName))) { newpuz.folderName = FolderManager.instance.getNextFolder( newpuz.folderName, (folder: Folder) => !newpuz.canUseFolder(folder) @@ -202,7 +330,7 @@ export default class PuzzleManager { return newpuz; } - public getPuzzleByID(puznid: number, scriptid: number = -1): Promise { + public async getPuzzleByID(puznid: number, scriptid: number = -1): Promise { for (let puzzle of this._puzzles) { if (puzzle.nodeID === puznid) { return Promise.resolve(puzzle); @@ -210,17 +338,25 @@ export default class PuzzleManager { } log.info(`Loading puzzle [nid=${puznid}, scriptid=${scriptid}...]`); - return Eterna.client.getPuzzle(puznid, scriptid) - .then((json: any) => { - let data = json['data']; - if (data['hairpins']) { - SolutionManager.instance.addHairpins(data['hairpins']); - } + let json = await Eterna.client.getPuzzle(puznid, scriptid); + let data = json['data']; + if (data['hairpins']) { + SolutionManager.instance.addHairpins(data['hairpins']); + } + + let puzzle = this.parsePuzzle(data['puzzle']); + let scriptConstraints = puzzle.constraints.filter(constraint => constraint instanceof ScriptConstraint); - let puzzle = this.parsePuzzle(data['puzzle']); - log.info(`Loaded puzzle [name=${puzzle.getName()}]`); - return puzzle; - }); + let isScriptConstraint = ( + constraint: Constraint | ScriptConstraint + ): constraint is ScriptConstraint => constraint instanceof ScriptConstraint; + + await Promise.all( + puzzle.constraints.filter(isScriptConstraint) + .map(scriptConstraint => ExternalInterface.preloadScript(scriptConstraint.scriptID)) + ); + log.info(`Loaded puzzle [name=${puzzle.getName()}]`); + return puzzle; } private _puzzles: Puzzle[] = []; @@ -235,3 +371,7 @@ export default class PuzzleManager { private static readonly RE_MISSION_TEXT = /(.*?)<\/span>/s; } + +interface Array { + filter(pred: (a: T) => a is U): U[]; +} diff --git a/src/eterna/rscript/ROPHighlight.ts b/src/eterna/rscript/ROPHighlight.ts index ef06717ed..ecd9467bc 100644 --- a/src/eterna/rscript/ROPHighlight.ts +++ b/src/eterna/rscript/ROPHighlight.ts @@ -4,7 +4,7 @@ import { GameObject, RepeatingTask, SceneObject, SerialTask, Easing, AlphaTask, ColorUtil } from 'flashbang'; import {RNAHighlightState} from 'eterna/pose2D/Pose2D'; -import ConstraintBox from 'eterna/ui/ConstraintBox'; +import ConstraintBox from 'eterna/constraints/ConstraintBox'; import EternaMenu from 'eterna/ui/EternaMenu'; import {RScriptUIElement, GetRScriptUIElementBounds, RScriptUIElementID} from './RScriptUIElement'; import RScriptOp from './RScriptOp'; @@ -127,9 +127,9 @@ export default class ROPHighlight extends RScriptOp { switch (key) { case RScriptUIElementID.OBJECTIVES: { let n: number = this._env.ui.constraintCount; - let firstObj: ConstraintBox = this._env.ui.getConstraint(0); - let lastObj: ConstraintBox = this._env.ui.getConstraint(n - 1); - size.x = lastObj.display.x - firstObj.display.x + lastObj.width + 2 * padding.x; + let firstObj: ConstraintBox = this._env.ui.getConstraintBox(0); + let lastObj: ConstraintBox = this._env.ui.getConstraintBox(n - 1); + size.x = lastObj.display.x - firstObj.display.x + lastObj.display.width + 2 * padding.x; size.y = 84; break; } @@ -138,7 +138,7 @@ export default class ROPHighlight extends RScriptOp { size.y = 84; break; case RScriptUIElementID.OBJECTIVE: - size.x = 10 + (uiObj as ConstraintBox).width; + size.x = 10 + (uiObj as ConstraintBox).display.width; size.y = 84; break; case RScriptUIElementID.SWAP: diff --git a/src/eterna/rscript/RScriptEnv.ts b/src/eterna/rscript/RScriptEnv.ts index bdf9cf02e..dc87ba293 100644 --- a/src/eterna/rscript/RScriptEnv.ts +++ b/src/eterna/rscript/RScriptEnv.ts @@ -175,7 +175,7 @@ export default class RScriptEnv extends ContainerObject { case RScriptUIElementID.SHAPEOBJECTIVE: return this.ui.getShapeBox(0); case RScriptUIElementID.OBJECTIVE: - return this.ui.getConstraint(i); + return this.ui.getConstraintBox(i); case RScriptUIElementID.SWITCH: return this.ui.toolbar.stateToggle; case RScriptUIElementID.TOTALENERGY: diff --git a/src/eterna/ui/PoseThumbnail.ts b/src/eterna/ui/PoseThumbnail.ts index a8b94e6d5..390d1f7e6 100644 --- a/src/eterna/ui/PoseThumbnail.ts +++ b/src/eterna/ui/PoseThumbnail.ts @@ -33,6 +33,27 @@ export default class PoseThumbnail { return TextureUtil.renderToTexture(disp); } + public static drawToGraphics( + sequence: number[], + pairs: number[], + size: number = 1, + type: PoseThumbnailType = PoseThumbnailType.BASE_COLORED, + expStartIndex: number = 0, + wrongPairs: number[] = null, + expUseThreshold: boolean = false, + expThreshold: number = 0 + ) { + const graphics = new Graphics(); + PoseThumbnail.create( + sequence, pairs, size, type, expStartIndex, wrongPairs, expUseThreshold, expThreshold, graphics + ); + const newGraphics = graphics.clone(); + let bounds = newGraphics.getLocalBounds(); + newGraphics.x = -bounds.left; + newGraphics.y = -bounds.top; + return newGraphics; + } + public static drawToSprite( sprite: Sprite, sequence: number[], diff --git a/src/eterna/util/ExternalInterface.ts b/src/eterna/util/ExternalInterface.ts index 36cc7e3b8..cc1466c7b 100644 --- a/src/eterna/util/ExternalInterface.ts +++ b/src/eterna/util/ExternalInterface.ts @@ -110,7 +110,7 @@ export default class ExternalInterface { scriptID, () => { ExternalInterface._preloadedScripts.push(`${scriptID}`); - Promise.resolve(); + resolve(); } ); }); @@ -185,54 +185,6 @@ export default class ExternalInterface { return scriptReturn; } - // TODO: Remove once class-based constraints (using preloadScript/runScriptSync) are used - /** - * Requests execution of an external script, and attempts to get its return value synchronously. - * Promises are always resolved asynchronously, so this runScript flavor eschews Promises and takes a - * callback that will be called immediately *if possible*. - * - * This doesn't guarantee synchronous execution - another script may already be running, or the script itself - * may be asynchronous, or the script may need to be fetched from the network if it hasn't already been - * cached. In fact, the entire premise is folly, ScriptInterface cannot make the guarantee that it claims - * to, and this function is only here because PoseEditMode.checkConstraint was designed to resolve its - * constraints synchronously. Use the async version of this function if possible! - * - * @return true if the script ran to completion, and false if it couldn't run synchronously and is instead - * queued to be executed asynchronously. - */ - public static runScriptMaybeSynchronously( - scriptID: string | number, options: RunScriptOptions, callback: (result: any, error: any) => void - ): boolean { - let completed = false; - const complete = (result: any, error: any) => { - if (completed) { - return; - } - completed = true; - callback(result, error); - }; - - this._pendingScripts.push({ - scriptID: `${scriptID}`, - options, - resolve: result => complete(result, undefined), - reject: err => complete(undefined, err), - synchronous: true - }); - - this.maybeRunNextScript(); - - // Omit this warning because it'll be fired whenever a puzzle with script constraints is loaded. - // This is some seriously busted functionality, and script-interface and/or constraint evaluation - // should be refactored to either always assume async results, or guarantee synchronous return. - - // if (!completed) { - // log.warn(`Script did not complete synchronously, but it was supposed to! [scriptID=${scriptID}]`); - // } - - return completed; - } - public static call(name: string, ...args: any[]): any { try { let [thisVal, f] = getDeepProperty(window as any, name); @@ -368,7 +320,7 @@ export default class ExternalInterface { private static _scriptRoot: any; private static _curSyncScript: PendingScript; private static _noPendingScripts: Deferred; - private static _preloadedScripts: string[]; + private static _preloadedScripts: string[] = []; } interface PendingScript { From 343f88f4b72d65048508889aaa3f1cda836579b9 Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Mon, 5 Aug 2019 15:43:29 -0400 Subject: [PATCH 29/39] Constraint config should be readonly --- src/eterna/constraints/constraints/BindingConstraint.ts | 2 +- src/eterna/constraints/constraints/BoostConstraint.ts | 5 +++-- .../constraints/constraints/ConsecutiveBaseConstraint.ts | 4 ++-- src/eterna/constraints/constraints/MaximumBaseConstraint.ts | 4 ++-- .../constraints/constraints/MaximumMutationConstraint.ts | 2 +- src/eterna/constraints/constraints/MaximumPairConstraint.ts | 4 ++-- src/eterna/constraints/constraints/MinimumBaseConstraint.ts | 4 ++-- src/eterna/constraints/constraints/MinimumPairConstraint.ts | 4 ++-- .../constraints/constraints/MinimumStackLengthConstraint.ts | 2 +- src/eterna/constraints/constraints/ScriptConstraint.ts | 2 +- src/eterna/constraints/constraints/ShapeConstraint.ts | 2 +- 11 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/eterna/constraints/constraints/BindingConstraint.ts b/src/eterna/constraints/constraints/BindingConstraint.ts index 62af9b44a..8d84da7d4 100644 --- a/src/eterna/constraints/constraints/BindingConstraint.ts +++ b/src/eterna/constraints/constraints/BindingConstraint.ts @@ -15,7 +15,7 @@ interface OligoInfo { } abstract class BindingsConstraint extends Constraint { - public stateIndex: number; + public readonly stateIndex: number; constructor(stateIndex: number) { super(); diff --git a/src/eterna/constraints/constraints/BoostConstraint.ts b/src/eterna/constraints/constraints/BoostConstraint.ts index 7033e7e9c..3381b13c2 100644 --- a/src/eterna/constraints/constraints/BoostConstraint.ts +++ b/src/eterna/constraints/constraints/BoostConstraint.ts @@ -1,6 +1,7 @@ import UndoBlock from 'eterna/UndoBlock'; import BitmapManager from 'eterna/resources/BitmapManager'; import Bitmaps from 'eterna/resources/Bitmaps'; +import {Value, UnitSignal, ValueView} from 'signals'; import ConstraintBox, {ConstraintBoxConfig} from '../ConstraintBox'; import Constraint, {BaseConstraintStatus} from '../Constraint'; @@ -10,11 +11,11 @@ interface BoostConstraintStatus extends BaseConstraintStatus { class BoostConstraint extends Constraint { public static readonly NAME = 'BOOST'; - public minBoosts: number; + public readonly minBoosts: number; constructor(minBoosts: number) { super(); - this.minBoosts = minBoosts; + throw new Error('BOOST constraint is unimplemented'); } diff --git a/src/eterna/constraints/constraints/ConsecutiveBaseConstraint.ts b/src/eterna/constraints/constraints/ConsecutiveBaseConstraint.ts index fd8737d6f..d645bb0ca 100644 --- a/src/eterna/constraints/constraints/ConsecutiveBaseConstraint.ts +++ b/src/eterna/constraints/constraints/ConsecutiveBaseConstraint.ts @@ -10,8 +10,8 @@ interface ConsecutiveConstraintStatus extends BaseConstraintStatus { } abstract class ConsecutiveBaseConstraint extends Constraint { - public baseType: number; - public maxConsecutive: number; + public readonly baseType: number; + public readonly maxConsecutive: number; constructor(baseType: number, count: number) { super(); diff --git a/src/eterna/constraints/constraints/MaximumBaseConstraint.ts b/src/eterna/constraints/constraints/MaximumBaseConstraint.ts index 08ac82499..9390a3d3a 100644 --- a/src/eterna/constraints/constraints/MaximumBaseConstraint.ts +++ b/src/eterna/constraints/constraints/MaximumBaseConstraint.ts @@ -9,8 +9,8 @@ interface MaxBaseConstraintStatus extends BaseConstraintStatus { } abstract class MaximumBaseConstraint extends Constraint { - public baseType: number; - public maxCount: number; + public readonly baseType: number; + public readonly maxCount: number; constructor(baseType: number, maxCount: number) { super(); diff --git a/src/eterna/constraints/constraints/MaximumMutationConstraint.ts b/src/eterna/constraints/constraints/MaximumMutationConstraint.ts index 9d6738e38..46d1e30a5 100644 --- a/src/eterna/constraints/constraints/MaximumMutationConstraint.ts +++ b/src/eterna/constraints/constraints/MaximumMutationConstraint.ts @@ -16,7 +16,7 @@ interface MaxMutationConstraintStatus extends BaseConstraintStatus { export default class MaximumMutationConstraint extends Constraint { public static readonly NAME = 'MUTATION'; - public maxMutations: number; + public readonly maxMutations: number; constructor(maxMutations: number) { super(); diff --git a/src/eterna/constraints/constraints/MaximumPairConstraint.ts b/src/eterna/constraints/constraints/MaximumPairConstraint.ts index 5a0fa17e8..2b0481e81 100644 --- a/src/eterna/constraints/constraints/MaximumPairConstraint.ts +++ b/src/eterna/constraints/constraints/MaximumPairConstraint.ts @@ -10,8 +10,8 @@ interface MaxPairConstraintStatus extends BaseConstraintStatus { } abstract class MaximumPairConstraint extends Constraint { - public pairType: number; - public maxPairs: number; + public readonly pairType: number; + public readonly maxPairs: number; constructor(pairType: number, maxPairs: number) { super(); diff --git a/src/eterna/constraints/constraints/MinimumBaseConstraint.ts b/src/eterna/constraints/constraints/MinimumBaseConstraint.ts index c1614149c..8aeeddd8d 100644 --- a/src/eterna/constraints/constraints/MinimumBaseConstraint.ts +++ b/src/eterna/constraints/constraints/MinimumBaseConstraint.ts @@ -9,8 +9,8 @@ interface MinBaseConstraintStatus extends BaseConstraintStatus{ } abstract class MinimumBaseConstraint extends Constraint { - public baseType: number; - public minCount: number; + public readonly baseType: number; + public readonly minCount: number; constructor(baseType: number, minCount: number) { super(); diff --git a/src/eterna/constraints/constraints/MinimumPairConstraint.ts b/src/eterna/constraints/constraints/MinimumPairConstraint.ts index 75a3121e6..98b2b7b77 100644 --- a/src/eterna/constraints/constraints/MinimumPairConstraint.ts +++ b/src/eterna/constraints/constraints/MinimumPairConstraint.ts @@ -10,8 +10,8 @@ interface MinPairConstraintStatus extends BaseConstraintStatus { } abstract class MinimumPairConstraint extends Constraint { - public pairType: number; - public minPairs: number; + public readonly pairType: number; + public readonly minPairs: number; constructor(pairType: number, minPairs: number) { super(); diff --git a/src/eterna/constraints/constraints/MinimumStackLengthConstraint.ts b/src/eterna/constraints/constraints/MinimumStackLengthConstraint.ts index faf8b7101..8754aca6d 100644 --- a/src/eterna/constraints/constraints/MinimumStackLengthConstraint.ts +++ b/src/eterna/constraints/constraints/MinimumStackLengthConstraint.ts @@ -15,7 +15,7 @@ interface MinStackConstraintStatus extends BaseConstraintStatus{ export default class MinimumStackLengthConstraint extends Constraint { public static readonly NAME = 'STACK'; - public minLength: number; + public readonly minLength: number; constructor(minLength: number) { super(); diff --git a/src/eterna/constraints/constraints/ScriptConstraint.ts b/src/eterna/constraints/constraints/ScriptConstraint.ts index 39abd6970..a08feebe3 100644 --- a/src/eterna/constraints/constraints/ScriptConstraint.ts +++ b/src/eterna/constraints/constraints/ScriptConstraint.ts @@ -15,7 +15,7 @@ interface ScriptConstraintStatus extends BaseConstraintStatus { export default class ScriptConstraint extends Constraint { public static readonly NAME = 'SCRIPT'; - public scriptID: number; + public readonly scriptID: number; constructor(scriptID: number) { super(); diff --git a/src/eterna/constraints/constraints/ShapeConstraint.ts b/src/eterna/constraints/constraints/ShapeConstraint.ts index 155786dd8..9b7aad133 100644 --- a/src/eterna/constraints/constraints/ShapeConstraint.ts +++ b/src/eterna/constraints/constraints/ShapeConstraint.ts @@ -13,7 +13,7 @@ interface ShapeConstraintStatus extends BaseConstraintStatus { } abstract class BaseShapeConstraint extends Constraint { - public stateIndex: number; + public readonly stateIndex: number; constructor(stateIndex: number) { super(); From dbb48cba4b2c06dfc3f5ce1d1e848f5d569062ba Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Mon, 5 Aug 2019 15:58:58 -0400 Subject: [PATCH 30/39] Accidentally removed parameter set on boost constraint --- src/eterna/constraints/constraints/BoostConstraint.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/eterna/constraints/constraints/BoostConstraint.ts b/src/eterna/constraints/constraints/BoostConstraint.ts index 3381b13c2..0085c3fe7 100644 --- a/src/eterna/constraints/constraints/BoostConstraint.ts +++ b/src/eterna/constraints/constraints/BoostConstraint.ts @@ -16,6 +16,8 @@ class BoostConstraint extends Constraint { constructor(minBoosts: number) { super(); + this.minBoosts = minBoosts; + throw new Error('BOOST constraint is unimplemented'); } From 3ef35d32ca471ec3ecc620711f13f7178cbf6669 Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Mon, 5 Aug 2019 16:11:47 -0400 Subject: [PATCH 31/39] Target conditions aren't in puzzlemaker either --- src/eterna/constraints/Constraint.ts | 17 +++++++++-------- src/eterna/constraints/ConstraintBar.ts | 4 ++-- .../constraints/BarcodeConstraint.ts | 2 -- .../constraints/BindingConstraint.ts | 4 ++-- .../constraints/BoostConstraint.ts | 6 ++---- .../constraints/ConsecutiveBaseConstraint.ts | 2 -- .../constraints/MaximumBaseConstraint.ts | 2 -- .../constraints/MaximumPairConstraint.ts | 14 +++----------- .../constraints/MinimumBaseConstraint.ts | 2 -- .../constraints/MinimumPairConstraint.ts | 18 ++++-------------- .../constraints/ScriptConstraint.ts | 4 +--- .../constraints/ShapeConstraint.ts | 19 +++++++++---------- .../constraints/SynthesisConstraint.ts | 2 -- src/eterna/mode/PoseEdit/PoseEditMode.ts | 4 ++-- 14 files changed, 34 insertions(+), 66 deletions(-) diff --git a/src/eterna/constraints/Constraint.ts b/src/eterna/constraints/Constraint.ts index fca22363a..9af361b2c 100644 --- a/src/eterna/constraints/Constraint.ts +++ b/src/eterna/constraints/Constraint.ts @@ -18,24 +18,25 @@ export interface HighlightInfo { export default abstract class Constraint { public static readonly NAME: string; /** - * @param undoBlocks Current undo block for each state of the puzzle - * @param targetConditions - * @param puzzle This is not available in the puzzle maker, so any constraints which require it will not be - * usable within PuzzleMaker for now + * @param undoBlocks + * @param targetConditions This is not available in the puzzle maker, so any constraints which require it will not + * be usable within PuzzleMaker for now + * @param puzzle This is not available in the puzzle maker, so any constraints which require it will not + * be usable within PuzzleMaker for now */ - public abstract evaluate(undoBlocks: UndoBlock[], targetConditions: any[], puzzle?: Puzzle): ConstraintStatus; + public abstract evaluate(undoBlocks: UndoBlock[], targetConditions?: any[], puzzle?: Puzzle): ConstraintStatus; public abstract getConstraintBoxConfig( status: ConstraintStatus, + forMissionScreen: boolean, undoBlocks: UndoBlock[], - targetConditions: any[], - forMissionScreen: boolean + targetConditions?: any[], ): ConstraintBoxConfig; public getHighlight( status: ConstraintStatus, undoBlocks: UndoBlock[], - targetConditions: any[] + targetConditions?: any[] ): HighlightInfo { return null; } diff --git a/src/eterna/constraints/ConstraintBar.ts b/src/eterna/constraints/ConstraintBar.ts index dd4a72fb6..fa2f8fe7d 100644 --- a/src/eterna/constraints/ConstraintBar.ts +++ b/src/eterna/constraints/ConstraintBar.ts @@ -131,13 +131,13 @@ export default class ConstraintBar extends ContainerObject { } } - public updateConstraints(undoBlocks: UndoBlock[], targetConditions: any[], puzzle?: Puzzle): boolean { + public updateConstraints(undoBlocks: UndoBlock[], targetConditions?: any[], puzzle?: Puzzle): boolean { let satisfied = true; for (let constraint of this._constraints) { let status = constraint.constraint.evaluate(undoBlocks, targetConditions, puzzle); constraint.constraintBox.setContent( - constraint.constraint.getConstraintBoxConfig(status, undoBlocks, targetConditions, false) + constraint.constraint.getConstraintBoxConfig(status, false, undoBlocks, targetConditions) ); constraint.highlightCache = status.satisfied ? null : constraint.constraint.getHighlight(status, undoBlocks, targetConditions); diff --git a/src/eterna/constraints/constraints/BarcodeConstraint.ts b/src/eterna/constraints/constraints/BarcodeConstraint.ts index d4e45c141..7d49da1ea 100644 --- a/src/eterna/constraints/constraints/BarcodeConstraint.ts +++ b/src/eterna/constraints/constraints/BarcodeConstraint.ts @@ -19,8 +19,6 @@ export default class BarcodeConstraint extends Constraint public getConstraintBoxConfig( status: BaseConstraintStatus, - undoBlocks: UndoBlock[], - targetConditions: any[], forMissionScreen: boolean ): ConstraintBoxConfig { let tooltip = ConstraintBox.createTextStyle(); diff --git a/src/eterna/constraints/constraints/BindingConstraint.ts b/src/eterna/constraints/constraints/BindingConstraint.ts index 8d84da7d4..f9ad09f75 100644 --- a/src/eterna/constraints/constraints/BindingConstraint.ts +++ b/src/eterna/constraints/constraints/BindingConstraint.ts @@ -32,9 +32,9 @@ abstract class BindingsConstraint public getConstraintBoxConfig( status: BaseConstraintStatus, + forMissionScreen: boolean, undoBlocks: UndoBlock[], - targetConditions: any[], - forMissionScreen: boolean + targetConditions: any[] ): ConstraintBoxConfig { let oligos = this._getOligoInfo(targetConditions); diff --git a/src/eterna/constraints/constraints/BoostConstraint.ts b/src/eterna/constraints/constraints/BoostConstraint.ts index 0085c3fe7..c9890e1df 100644 --- a/src/eterna/constraints/constraints/BoostConstraint.ts +++ b/src/eterna/constraints/constraints/BoostConstraint.ts @@ -21,15 +21,13 @@ class BoostConstraint extends Constraint { throw new Error('BOOST constraint is unimplemented'); } - public evaluate(undoBlocks: UndoBlock[]): BoostConstraintStatus { + public evaluate(): BoostConstraintStatus { throw new Error('BOOST constraint is unimplemented'); } public getConstraintBoxConfig( status: BoostConstraintStatus, - undoBlocks: UndoBlock[], - targetConditions: any[], - forMissionScreen: boolean + forMissionScreen: boolean, ): ConstraintBoxConfig { let tooltip = ConstraintBox.createTextStyle(); if (forMissionScreen) { diff --git a/src/eterna/constraints/constraints/ConsecutiveBaseConstraint.ts b/src/eterna/constraints/constraints/ConsecutiveBaseConstraint.ts index d645bb0ca..df0e565f0 100644 --- a/src/eterna/constraints/constraints/ConsecutiveBaseConstraint.ts +++ b/src/eterna/constraints/constraints/ConsecutiveBaseConstraint.ts @@ -33,8 +33,6 @@ abstract class ConsecutiveBaseConstraint extends Constraint public getConstraintBoxConfig( status: MaxBaseConstraintStatus, - undoBlocks: UndoBlock[], - targetConditions: any[], forMissionScreen: boolean ): ConstraintBoxConfig { let tooltip = ConstraintBox.createTextStyle(); diff --git a/src/eterna/constraints/constraints/MaximumPairConstraint.ts b/src/eterna/constraints/constraints/MaximumPairConstraint.ts index 2b0481e81..3b9c9c589 100644 --- a/src/eterna/constraints/constraints/MaximumPairConstraint.ts +++ b/src/eterna/constraints/constraints/MaximumPairConstraint.ts @@ -34,8 +34,6 @@ abstract class MaximumPairConstraint extends Constraint public getConstraintBoxConfig( status: MaxPairConstraintStatus, - undoBlocks: UndoBlock[], - targetConditions: any[], forMissionScreen: boolean ): ConstraintBoxConfig { let tooltip = ConstraintBox.createTextStyle(); @@ -74,12 +72,10 @@ export class MaximumGCConstraint extends MaximumPairConstraint { /** @override */ public getConstraintBoxConfig( status: MaxPairConstraintStatus, - undoBlocks: UndoBlock[], - targetConditions: any[], forMissionScreen: boolean ): ConstraintBoxConfig { return { - ...super.getConstraintBoxConfig(status, undoBlocks, targetConditions, forMissionScreen), + ...super.getConstraintBoxConfig(status, forMissionScreen), fullTexture: forMissionScreen ? BitmapManager.getBitmap(Bitmaps.NovaGCMissionReq) : BitmapManager.getBitmap(Bitmaps.NovaGCReq) @@ -97,12 +93,10 @@ export class MaximumAUConstraint extends MaximumPairConstraint { /** @override */ public getConstraintBoxConfig( status: MaxPairConstraintStatus, - undoBlocks: UndoBlock[], - targetConditions: any[], forMissionScreen: boolean ): ConstraintBoxConfig { return { - ...super.getConstraintBoxConfig(status, undoBlocks, targetConditions, forMissionScreen), + ...super.getConstraintBoxConfig(status, forMissionScreen), fullTexture: forMissionScreen ? BitmapManager.getBitmap(Bitmaps.NovaAUMissionReq) : BitmapManager.getBitmap(Bitmaps.NovaAUReq) @@ -120,12 +114,10 @@ export class MaximumGUConstraint extends MaximumPairConstraint { /** @override */ public getConstraintBoxConfig( status: MaxPairConstraintStatus, - undoBlocks: UndoBlock[], - targetConditions: any[], forMissionScreen: boolean ): ConstraintBoxConfig { return { - ...super.getConstraintBoxConfig(status, undoBlocks, targetConditions, forMissionScreen), + ...super.getConstraintBoxConfig(status, forMissionScreen), fullTexture: forMissionScreen ? BitmapManager.getBitmap(Bitmaps.NovaGUMissionReq) : BitmapManager.getBitmap(Bitmaps.NovaGUReq) diff --git a/src/eterna/constraints/constraints/MinimumBaseConstraint.ts b/src/eterna/constraints/constraints/MinimumBaseConstraint.ts index 8aeeddd8d..969a6b126 100644 --- a/src/eterna/constraints/constraints/MinimumBaseConstraint.ts +++ b/src/eterna/constraints/constraints/MinimumBaseConstraint.ts @@ -32,8 +32,6 @@ abstract class MinimumBaseConstraint extends Constraint public getConstraintBoxConfig( status: MinBaseConstraintStatus, - undoBlocks: UndoBlock[], - targetConditions: any[], forMissionScreen: boolean ): ConstraintBoxConfig { let tooltip = ConstraintBox.createTextStyle(); diff --git a/src/eterna/constraints/constraints/MinimumPairConstraint.ts b/src/eterna/constraints/constraints/MinimumPairConstraint.ts index 98b2b7b77..35c3d5178 100644 --- a/src/eterna/constraints/constraints/MinimumPairConstraint.ts +++ b/src/eterna/constraints/constraints/MinimumPairConstraint.ts @@ -34,8 +34,6 @@ abstract class MinimumPairConstraint extends Constraint public getConstraintBoxConfig( status: MinPairConstraintStatus, - undoBlocks: UndoBlock[], - targetConditions: any[], forMissionScreen: boolean ): ConstraintBoxConfig { let tooltip = ConstraintBox.createTextStyle(); @@ -73,12 +71,10 @@ export class MinimumGCConstraint extends MinimumPairConstraint { /** @override */ public getConstraintBoxConfig( status: MinPairConstraintStatus, - undoBlocks: UndoBlock[], - targetConditions: any[], forMissionScreen: boolean ): ConstraintBoxConfig { return { - ...super.getConstraintBoxConfig(status, undoBlocks, targetConditions, forMissionScreen), + ...super.getConstraintBoxConfig(status, forMissionScreen), fullTexture: forMissionScreen ? BitmapManager.getBitmap(Bitmaps.NovaGCMissionReq) : BitmapManager.getBitmap(Bitmaps.NovaGCReq) @@ -96,12 +92,10 @@ export class MinimumAUConstraint extends MinimumPairConstraint { /** @override */ public getConstraintBoxConfig( status: MinPairConstraintStatus, - undoBlocks: UndoBlock[], - targetConditions: any[], forMissionScreen: boolean ): ConstraintBoxConfig { return { - ...super.getConstraintBoxConfig(status, undoBlocks, targetConditions, forMissionScreen), + ...super.getConstraintBoxConfig(status, forMissionScreen), fullTexture: forMissionScreen ? BitmapManager.getBitmap(Bitmaps.NovaAUMissionReq) : BitmapManager.getBitmap(Bitmaps.NovaAUReq) @@ -119,12 +113,10 @@ export class MinimumGUConstraint extends MinimumPairConstraint { /** @override */ public getConstraintBoxConfig( status: MinPairConstraintStatus, - undoBlocks: UndoBlock[], - targetConditions: any[], forMissionScreen: boolean ): ConstraintBoxConfig { return { - ...super.getConstraintBoxConfig(status, undoBlocks, targetConditions, forMissionScreen), + ...super.getConstraintBoxConfig(status, forMissionScreen), fullTexture: forMissionScreen ? BitmapManager.getBitmap(Bitmaps.NovaGUMissionReq) : BitmapManager.getBitmap(Bitmaps.NovaGUReq) @@ -158,8 +150,6 @@ export class MinimumAnyPairConstraint extends MinimumPairConstraint { /** @override */ public getConstraintBoxConfig( status: MinPairConstraintStatus, - undoBlocks: UndoBlock[], - targetConditions: any[], forMissionScreen: boolean ): ConstraintBoxConfig { let tooltip = ConstraintBox.createTextStyle(); @@ -175,7 +165,7 @@ export class MinimumAnyPairConstraint extends MinimumPairConstraint { } return { - ...super.getConstraintBoxConfig(status, undoBlocks, targetConditions, forMissionScreen), + ...super.getConstraintBoxConfig(status, forMissionScreen), tooltip, fullTexture: forMissionScreen ? BitmapManager.getBitmap(Bitmaps.NovaPairsMissionReq) diff --git a/src/eterna/constraints/constraints/ScriptConstraint.ts b/src/eterna/constraints/constraints/ScriptConstraint.ts index a08feebe3..82af55c6e 100644 --- a/src/eterna/constraints/constraints/ScriptConstraint.ts +++ b/src/eterna/constraints/constraints/ScriptConstraint.ts @@ -22,7 +22,7 @@ export default class ScriptConstraint extends Constraint this.scriptID = scriptID; } - public evaluate(_1: UndoBlock[], _2: any[], puzzle?: Puzzle): ScriptConstraintStatus { + public evaluate(undoBlocks: UndoBlock[], targetConditions: any[], puzzle: Puzzle): ScriptConstraintStatus { const scriptResult = ExternalInterface.runScriptSync( this.scriptID, {params: {puzzleInfo: puzzle.toJSON() || null}} @@ -41,8 +41,6 @@ export default class ScriptConstraint extends Constraint public getConstraintBoxConfig( status: ScriptConstraintStatus, - undoBlocks: UndoBlock[], - targetConditions: any[], forMissionScreen: boolean ): ConstraintBoxConfig { return { diff --git a/src/eterna/constraints/constraints/ShapeConstraint.ts b/src/eterna/constraints/constraints/ShapeConstraint.ts index 9b7aad133..cf33e1197 100644 --- a/src/eterna/constraints/constraints/ShapeConstraint.ts +++ b/src/eterna/constraints/constraints/ShapeConstraint.ts @@ -2,9 +2,6 @@ import UndoBlock from 'eterna/UndoBlock'; import EPars from 'eterna/EPars'; import PoseThumbnail, {PoseThumbnailType} from 'eterna/ui/PoseThumbnail'; import {HighlightType} from 'eterna/pose2D/HighlightBox'; -import Eterna from 'eterna/Eterna'; -import {Sprite} from 'pixi.js'; -import {TextureUtil} from 'flashbang'; import ConstraintBox, {ConstraintBoxConfig} from '../ConstraintBox'; import Constraint, {BaseConstraintStatus, HighlightInfo} from '../Constraint'; @@ -80,14 +77,15 @@ abstract class BaseShapeConstraint extends Constraint { public getConstraintBoxConfig( status: ShapeConstraintStatus, + forMissionScreen: boolean, undoBlocks: UndoBlock[], - targetConditions: any[] + targetConditions?: any[] ): ConstraintBoxConfig { return { satisfied: status.satisfied, tooltip: '', thumbnailBG: true, - stateNumber: targetConditions.length > 1 ? this.stateIndex + 1 : null + stateNumber: undoBlocks.length > 1 ? this.stateIndex + 1 : null }; } @@ -118,7 +116,7 @@ abstract class BaseShapeConstraint extends Constraint { export default class ShapeConstraint extends BaseShapeConstraint { public static readonly NAME = 'SHAPE'; - public evaluate(undoBlocks: UndoBlock[], targetConditions: any[]): ShapeConstraintStatus { + public evaluate(undoBlocks: UndoBlock[], targetConditions?: any[]): ShapeConstraintStatus { let undoBlock = undoBlocks[this.stateIndex]; let targetAlignedConstraints: boolean[] = null; @@ -137,10 +135,10 @@ export default class ShapeConstraint extends BaseShapeConstraint { public getConstraintBoxConfig( status: ShapeConstraintStatus, - undoBlocks: UndoBlock[], - targetConditions: any[] + forMissionScreen: boolean, + undoBlocks: UndoBlock[] ): ConstraintBoxConfig { - let details = super.getConstraintBoxConfig(status, undoBlocks, targetConditions); + let details = super.getConstraintBoxConfig(status, forMissionScreen, undoBlocks); let undoBlock = undoBlocks[this.stateIndex]; let naturalPairs = this._targetAlignedNaturalPairs(undoBlock); return { @@ -220,10 +218,11 @@ export class AntiShapeConstraint extends BaseShapeConstraint { public getConstraintBoxConfig( status: ShapeConstraintStatus, + forMissionScreen: boolean, undoBlocks: UndoBlock[], targetConditions: any[] ): ConstraintBoxConfig { - let details = super.getConstraintBoxConfig(status, undoBlocks, targetConditions); + let details = super.getConstraintBoxConfig(status, forMissionScreen, undoBlocks); let undoBlock = undoBlocks[this.stateIndex]; let naturalPairs = this._targetAlignedNaturalPairs(undoBlock); return { diff --git a/src/eterna/constraints/constraints/SynthesisConstraint.ts b/src/eterna/constraints/constraints/SynthesisConstraint.ts index f039917a2..cedd9d8d3 100644 --- a/src/eterna/constraints/constraints/SynthesisConstraint.ts +++ b/src/eterna/constraints/constraints/SynthesisConstraint.ts @@ -37,8 +37,6 @@ export default class SynthesisConstraint extends Constraint Date: Fri, 9 Aug 2019 15:30:01 -0400 Subject: [PATCH 32/39] Remove dead code --- src/eterna/mode/PoseEdit/PoseEditMode.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/eterna/mode/PoseEdit/PoseEditMode.ts b/src/eterna/mode/PoseEdit/PoseEditMode.ts index eba2efe34..408e9def8 100644 --- a/src/eterna/mode/PoseEdit/PoseEditMode.ts +++ b/src/eterna/mode/PoseEdit/PoseEditMode.ts @@ -2935,13 +2935,7 @@ export default class PoseEditMode extends GameMode { private _hintBoxRef: GameObjectRef = GameObjectRef.NULL; - // / constraints && scoring display private _constraintBar: ConstraintBar; - // private _constraintBoxes: ConstraintBox[]; - // private _constraintShapeBoxes: ConstraintBox[]; - // private _constraintAntishapeBoxes: ConstraintBox[]; - // private _unstableShapeConstraintIdx: number; - // private _constraintsOffset: number; private _dockedSpecBox: SpecBox; private _exitButton: GameButton; From 685b0c95ccd869f1326284db91a6388922a31c87 Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Fri, 9 Aug 2019 15:41:27 -0400 Subject: [PATCH 33/39] Reject promise if script preload fails --- src/eterna/util/ExternalInterface.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/eterna/util/ExternalInterface.ts b/src/eterna/util/ExternalInterface.ts index cc1466c7b..e7114adc7 100644 --- a/src/eterna/util/ExternalInterface.ts +++ b/src/eterna/util/ExternalInterface.ts @@ -111,6 +111,9 @@ export default class ExternalInterface { () => { ExternalInterface._preloadedScripts.push(`${scriptID}`); resolve(); + }, + () => { + reject(new Error(`Script preloading failed for script ${scriptID}`)); } ); }); From c9c638f6f7736fdb0bd1fce625f4f48f45448d6a Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Fri, 9 Aug 2019 15:42:58 -0400 Subject: [PATCH 34/39] More dead code --- src/eterna/puzzle/PuzzleManager.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/eterna/puzzle/PuzzleManager.ts b/src/eterna/puzzle/PuzzleManager.ts index 789fd6bcf..74ca172f6 100644 --- a/src/eterna/puzzle/PuzzleManager.ts +++ b/src/eterna/puzzle/PuzzleManager.ts @@ -345,7 +345,6 @@ export default class PuzzleManager { } let puzzle = this.parsePuzzle(data['puzzle']); - let scriptConstraints = puzzle.constraints.filter(constraint => constraint instanceof ScriptConstraint); let isScriptConstraint = ( constraint: Constraint | ScriptConstraint From fdcd546bdcbd4d2c9b5dc38f53c139bd844c598f Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Fri, 9 Aug 2019 23:08:57 -0400 Subject: [PATCH 35/39] runPendingScript -> runScriptInternal, delegating pending script/script lock stuff to maybeRunNextScript --- .../constraints/ScriptConstraint.ts | 22 +-- src/eterna/util/ExternalInterface.ts | 134 ++++++++++-------- 2 files changed, 84 insertions(+), 72 deletions(-) diff --git a/src/eterna/constraints/constraints/ScriptConstraint.ts b/src/eterna/constraints/constraints/ScriptConstraint.ts index 82af55c6e..f54fabd9a 100644 --- a/src/eterna/constraints/constraints/ScriptConstraint.ts +++ b/src/eterna/constraints/constraints/ScriptConstraint.ts @@ -23,19 +23,23 @@ export default class ScriptConstraint extends Constraint } public evaluate(undoBlocks: UndoBlock[], targetConditions: any[], puzzle: Puzzle): ScriptConstraintStatus { - const scriptResult = ExternalInterface.runScriptSync( + const {result, error} = ExternalInterface.runScriptSync( this.scriptID, {params: {puzzleInfo: puzzle.toJSON() || null}} - ).result; + ); + + if (error) { + throw new Error(`Script constraint ${this.scriptID} failed to evaluate. Error: ${error}`); + } return { - goal: scriptResult.cause.goal != null ? scriptResult.cause.goal : '', - resultValue: scriptResult.cause.value != null ? scriptResult.cause.value : '', - stateIndex: scriptResult.cause.index != null && scriptResult.cause.index >= 0 - ? scriptResult.cause.index : null, - highlightRanges: scriptResult.cause.highlight ? scriptResult.cause.highlight : [], - dataPNG: scriptResult.cause.icon_b64 != null ? scriptResult.cause.icon_b64 : '', - satisfied: !!scriptResult.cause.satisfied + goal: result.cause.goal != null ? result.cause.goal : '', + resultValue: result.cause.value != null ? result.cause.value : '', + stateIndex: result.cause.index != null && result.cause.index >= 0 + ? result.cause.index : null, + highlightRanges: result.cause.highlight ? result.cause.highlight : [], + dataPNG: result.cause.icon_b64 != null ? result.cause.icon_b64 : '', + satisfied: !!result.cause.satisfied }; } diff --git a/src/eterna/util/ExternalInterface.ts b/src/eterna/util/ExternalInterface.ts index e7114adc7..abc888605 100644 --- a/src/eterna/util/ExternalInterface.ts +++ b/src/eterna/util/ExternalInterface.ts @@ -109,7 +109,7 @@ export default class ExternalInterface { 'Script.get_script', scriptID, () => { - ExternalInterface._preloadedScripts.push(`${scriptID}`); + this._preloadedScripts.push(`${scriptID}`); resolve(); }, () => { @@ -132,8 +132,7 @@ export default class ExternalInterface { scriptID: `${scriptID}`, options, resolve, - reject, - synchronous: false + reject }); this.maybeRunNextScript(); @@ -156,34 +155,22 @@ export default class ExternalInterface { */ public static runScriptSync( scriptID: string | number, options: RunScriptOptions - ): {result: any; error: any} { + ): {result?: any; error?: any} { if (!this._preloadedScripts.includes(`${scriptID}`)) { // If we try to do this it's almost certainly going to break (scripts have to be asynchronously loaded once, // so this can't be synchronous), so just... don't. throw new Error('runScriptSync attempted to run a script which has not been preloaded'); } - let completed = false; - let scriptReturn = null; - const complete = (result: any, error: any) => { - if (completed) { - return; - } - completed = true; - scriptReturn = {result, error}; - }; + let scriptReturn: {result?: any; error?: any} = null; - ExternalInterface.runPendingScript({ - scriptID: `${scriptID}`, + this.runScriptInternal( + `${scriptID}`, options, - resolve: result => complete(result, undefined), - reject: err => complete(undefined, err), - synchronous: true - }, true); - - if (!completed) { - throw new Error(`Script did not complete synchronously, but it was supposed to! [scriptID=${scriptID}]`); - } + true, + (result) => { scriptReturn = {result}; }, + (error) => { scriptReturn = {error}; } + ); return scriptReturn; } @@ -204,7 +191,25 @@ export default class ExternalInterface { if (nextScript.options.checkValid != null && !nextScript.options.checkValid()) { log.info(`Not running stale request for script ${nextScript.scriptID}`); } else { - this.runPendingScript(nextScript); + this._curSyncScript = nextScript; + let cleanup = () => { + this._curSyncScript = null; + this.maybeRunNextScript(); + }; + + this.runScriptInternal( + nextScript.scriptID, + nextScript.options, + false, + (result) => { + nextScript.resolve(result); + cleanup(); + }, + (error) => { + nextScript.reject(error instanceof Error ? error : new Error(error)); + cleanup(); + }, + ); } } @@ -215,78 +220,82 @@ export default class ExternalInterface { } } - private static runPendingScript(script: PendingScript, sync: boolean = false): void { - let {ctx} = script.options; - if (ctx == null) { - ctx = new ExternalInterfaceCtx(); - } + /** + * Runs a named script. Calls a callback with the result of the script, or a different one if + * the script has an error. + * + * This function uses callbacks instead of a Promise because Promise callbacks never run syncronously + * + * @param script The name of the script + * @param options RunScriptOptions + * @param synchronous If true, and the script doesn't complete immediately, the error callback will be caleld. + * @param onSuccess Callback on successful script execution + * @param onError Callback on unsuccessful script execution + */ + private static runScriptInternal( + scriptID: string, + options: RunScriptOptions, + synchronous: boolean, + onSuccess: (result: any) => void, + onError: (reason: any) => void + ): void { + let ctx = options.ctx || new ExternalInterfaceCtx(); let isComplete = false; - let isAsync = false; + let declaredAsync = false; const complete = (successValue: any, error: any) => { if (isComplete) { + // We can only resolve/reject once return; } isComplete = true; this.popContext(ctx); - if (this._curSyncScript === script) { - this._curSyncScript = null; - } - if (error !== undefined) { - log.warn(`Script ${script.scriptID}: error: ${error}`); - script.reject(error); + log.warn(`Script ${scriptID}: error: ${error}`); + onError(error); } else { - log.info(`Completed ${isAsync ? 'async' : ''} script ${script.scriptID}`); - script.resolve(successValue); - } - - if (!sync) { - this.maybeRunNextScript(); + log.info(`Completed ${declaredAsync ? 'async' : ''} script ${scriptID}`); + onSuccess(successValue); } }; - // Create a new "end_" callback - ctx.addCallback(`end_${script.scriptID}`, (returnValue: any) => { + ctx.addCallback(`end_${scriptID}`, (returnValue: any) => { if (!this.isAsync(returnValue)) { complete(returnValue, undefined); - } else if (!isAsync) { - if (sync) { - throw new Error(`Script requested to run asynchronously, which is not supported for this script type [scriptID=${script.scriptID}]`); + } else if (!declaredAsync) { + // This should only be run once, if the script indicates that it's async multiple times, ignore it + + if (synchronous) { + complete(undefined, `Script requested to run asynchronously, which is not supported for this script type [scriptID=${scriptID}]`); } // Scripts can indicate that they run asynchronously by calling their end_ // function with { "cause": { "async": "true" } }. (They must later // call the end_ function normally, when they've actually completed.) - // If the script indicates that it's async, we immediately relinquish - // our lock on curSyncScript, and allow other scripts to run. - - log.info(`Script ${script.scriptID} is async. Allowing other scripts to run.`); - isAsync = true; - if (this._curSyncScript === script) { - this._curSyncScript = null; - this.maybeRunNextScript(); - } + declaredAsync = true; } }); this.pushContext(ctx); - log.info(`Running script ${script.scriptID}...`); - this._curSyncScript = script; + log.info(`Running script ${scriptID}...`); try { this.call( 'ScriptInterface.evaluate_script_with_nid', - script.scriptID, - script.options.params || {}, + scriptID, + options.params || {}, null, - script.synchronous + synchronous ); } catch (err) { - complete(undefined, err || `Unknown error in script ${script.scriptID}`); + complete(undefined, err || `Unknown error in script ${scriptID}`); + } + + if (!isComplete && synchronous) { + complete(undefined, `Script did not complete synchronously, but it was supposed to! [scriptID=${scriptID}]`); } } @@ -331,7 +340,6 @@ interface PendingScript { options: RunScriptOptions; resolve: (value?: any) => void; reject: (reason?: any) => void; - synchronous: boolean; } interface RegisteredCtx { From 6e04ffdff72e4336968a909f0d785d65d7a2c4f3 Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Fri, 9 Aug 2019 23:10:18 -0400 Subject: [PATCH 36/39] Even more dead code --- src/eterna/mode/PoseEdit/PoseEditMode.ts | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/eterna/mode/PoseEdit/PoseEditMode.ts b/src/eterna/mode/PoseEdit/PoseEditMode.ts index 408e9def8..e95c5af8f 100644 --- a/src/eterna/mode/PoseEdit/PoseEditMode.ts +++ b/src/eterna/mode/PoseEdit/PoseEditMode.ts @@ -78,14 +78,6 @@ export interface PoseEditParams { solutions?: Solution[]; } -interface ConstraintInfo { - wrongPairs: number[]; - restrictedLocal: number[][]; - maxAllowedGuanine: number; - maxAllowedCytosine: number; - maxAllowedAdenine: number; -} - export interface OligoDef { sequence: string; malus: number; @@ -95,10 +87,6 @@ export interface OligoDef { label?: string; } -enum ConstraintStatus { - SATISFIED = 'satisfied', UNSATISFIED = 'unsatisfied', PENDING = 'pending' -} - export default class PoseEditMode extends GameMode { constructor(puzzle: Puzzle, params: PoseEditParams, autosaveData: any[] = null) { super(); From c6a6c7069faee9bd2ddc594270f8c40abc3d9d43 Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Fri, 27 Sep 2019 14:37:38 -0400 Subject: [PATCH 37/39] synchronous -> requireSynchronous --- src/eterna/util/ExternalInterface.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/eterna/util/ExternalInterface.ts b/src/eterna/util/ExternalInterface.ts index abc888605..2afbae539 100644 --- a/src/eterna/util/ExternalInterface.ts +++ b/src/eterna/util/ExternalInterface.ts @@ -228,14 +228,17 @@ export default class ExternalInterface { * * @param script The name of the script * @param options RunScriptOptions - * @param synchronous If true, and the script doesn't complete immediately, the error callback will be caleld. + * @param requireSynchronous If true: + * 1. if the script doesn't complete immediately, the error callback will be called + * 2. The syncronous flag is passed ScriptInterface.evaluate_script_with_nid (forcing the preloaded script to + * be returned immediately in Script.get_script) * @param onSuccess Callback on successful script execution * @param onError Callback on unsuccessful script execution */ private static runScriptInternal( scriptID: string, options: RunScriptOptions, - synchronous: boolean, + requireSynchronous: boolean, onSuccess: (result: any) => void, onError: (reason: any) => void ): void { @@ -268,7 +271,7 @@ export default class ExternalInterface { } else if (!declaredAsync) { // This should only be run once, if the script indicates that it's async multiple times, ignore it - if (synchronous) { + if (requireSynchronous) { complete(undefined, `Script requested to run asynchronously, which is not supported for this script type [scriptID=${scriptID}]`); } // Scripts can indicate that they run asynchronously by calling their end_ @@ -288,13 +291,13 @@ export default class ExternalInterface { scriptID, options.params || {}, null, - synchronous + requireSynchronous ); } catch (err) { complete(undefined, err || `Unknown error in script ${scriptID}`); } - if (!isComplete && synchronous) { + if (!isComplete && requireSynchronous) { complete(undefined, `Script did not complete synchronously, but it was supposed to! [scriptID=${scriptID}]`); } } From d43c98b40f55db4163ed2c6d26cdcf62f8e28b50 Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Fri, 27 Sep 2019 14:40:11 -0400 Subject: [PATCH 38/39] runScript -> runScriptThroughQueue --- src/eterna/mode/PoseEdit/Booster.ts | 2 +- src/eterna/mode/PoseEdit/PoseEditMode.ts | 2 +- src/eterna/util/ExternalInterface.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/eterna/mode/PoseEdit/Booster.ts b/src/eterna/mode/PoseEdit/Booster.ts index d1588df2e..bbf8f0a40 100644 --- a/src/eterna/mode/PoseEdit/Booster.ts +++ b/src/eterna/mode/PoseEdit/Booster.ts @@ -177,7 +177,7 @@ export default class Booster { param: baseNum.toString() }; - ExternalInterface.runScript(this._scriptID, {params: scriptParams, ctx: scriptInterface}) + ExternalInterface.runScriptThroughQueue(this._scriptID, {params: scriptParams, ctx: scriptInterface}) .then((ret) => { if (useUILock) { this._view.popUILock(LOCK_NAME); diff --git a/src/eterna/mode/PoseEdit/PoseEditMode.ts b/src/eterna/mode/PoseEdit/PoseEditMode.ts index e95c5af8f..6d11ba3fe 100644 --- a/src/eterna/mode/PoseEdit/PoseEditMode.ts +++ b/src/eterna/mode/PoseEdit/PoseEditMode.ts @@ -965,7 +965,7 @@ export default class PoseEditMode extends GameMode { const LOCK_NAME = 'RunScript'; this.pushUILock(LOCK_NAME); - ExternalInterface.runScript(nid) + ExternalInterface.runScriptThroughQueue(nid) .then((ret) => { log.info(ret); if (typeof (ret['cause']) === 'string') { diff --git a/src/eterna/util/ExternalInterface.ts b/src/eterna/util/ExternalInterface.ts index 2afbae539..84e9132db 100644 --- a/src/eterna/util/ExternalInterface.ts +++ b/src/eterna/util/ExternalInterface.ts @@ -126,7 +126,7 @@ export default class ExternalInterface { * * @return a Promise that will resolve with the results of the script. */ - public static runScript(scriptID: string | number, options: RunScriptOptions = {}): Promise { + public static runScriptThroughQueue(scriptID: string | number, options: RunScriptOptions = {}): Promise { return new Promise((resolve, reject) => { this._pendingScripts.push({ scriptID: `${scriptID}`, From 4ab2d6afccf832a424986203504be53bea3aa420 Mon Sep 17 00:00:00 2001 From: Jonathan Romano Date: Fri, 27 Sep 2019 14:48:02 -0400 Subject: [PATCH 39/39] ExternalInterface.runScriptSync: just throw an error on error, don't bother doing the weird error return thing --- src/eterna/constraints/constraints/ScriptConstraint.ts | 6 +----- src/eterna/util/ExternalInterface.ts | 10 ++++------ 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/eterna/constraints/constraints/ScriptConstraint.ts b/src/eterna/constraints/constraints/ScriptConstraint.ts index f54fabd9a..cf81d6238 100644 --- a/src/eterna/constraints/constraints/ScriptConstraint.ts +++ b/src/eterna/constraints/constraints/ScriptConstraint.ts @@ -23,15 +23,11 @@ export default class ScriptConstraint extends Constraint } public evaluate(undoBlocks: UndoBlock[], targetConditions: any[], puzzle: Puzzle): ScriptConstraintStatus { - const {result, error} = ExternalInterface.runScriptSync( + const result = ExternalInterface.runScriptSync( this.scriptID, {params: {puzzleInfo: puzzle.toJSON() || null}} ); - if (error) { - throw new Error(`Script constraint ${this.scriptID} failed to evaluate. Error: ${error}`); - } - return { goal: result.cause.goal != null ? result.cause.goal : '', resultValue: result.cause.value != null ? result.cause.value : '', diff --git a/src/eterna/util/ExternalInterface.ts b/src/eterna/util/ExternalInterface.ts index 84e9132db..c11b9a251 100644 --- a/src/eterna/util/ExternalInterface.ts +++ b/src/eterna/util/ExternalInterface.ts @@ -153,23 +153,21 @@ export default class ExternalInterface { * The primary reason for the existance of this function is for SCRIPT constraints, which are designed to be * executed synchronously. If at all possible, use the async version of this function. */ - public static runScriptSync( - scriptID: string | number, options: RunScriptOptions - ): {result?: any; error?: any} { + public static runScriptSync(scriptID: string | number, options: RunScriptOptions): any { if (!this._preloadedScripts.includes(`${scriptID}`)) { // If we try to do this it's almost certainly going to break (scripts have to be asynchronously loaded once, // so this can't be synchronous), so just... don't. throw new Error('runScriptSync attempted to run a script which has not been preloaded'); } - let scriptReturn: {result?: any; error?: any} = null; + let scriptReturn: any = null; this.runScriptInternal( `${scriptID}`, options, true, - (result) => { scriptReturn = {result}; }, - (error) => { scriptReturn = {error}; } + (result) => { scriptReturn = result; }, + (error) => { throw new Error(error); } ); return scriptReturn;