From 40eb812a06337c3e835fb0e269fb7349e21f0413 Mon Sep 17 00:00:00 2001 From: Piotr Rogowski Date: Sun, 26 Sep 2021 18:58:55 +0200 Subject: [PATCH] Remove INI parser (#210) --- package-lock.json | 390 ++------------- package.json | 6 - src/parser/ini.ts | 1181 --------------------------------------------- 3 files changed, 44 insertions(+), 1533 deletions(-) delete mode 100644 src/parser/ini.ts diff --git a/package-lock.json b/package-lock.json index d300e2a..050f566 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,10 +15,8 @@ "@speedy-tuner/types": "^0.1.1", "antd": "^4.16.13", "electron-squirrel-startup": "^1.0.0", - "js-yaml": "^4.1.0 ", "mlg-converter": "^0.5.1", "pako": "^2.0.4", - "parsimmon": "^1.18.0", "react": "^17.0.1", "react-dom": "^17.0.2", "react-perfect-scrollbar": "^1.5.8", @@ -36,10 +34,8 @@ "@electron-forge/maker-rpm": "^6.0.0-beta.61", "@electron-forge/maker-squirrel": "^6.0.0-beta.61", "@electron-forge/maker-zip": "^6.0.0-beta.61", - "@types/js-yaml": "^4.0.3", "@types/node": "^16.9.6", "@types/pako": "^1.0.2", - "@types/parsimmon": "^1.10.6", "@types/react": "^17.0.24", "@types/react-dom": "^17.0.9", "@types/react-redux": "^7.1.18", @@ -2504,31 +2500,6 @@ "node": "^10.12.0 || >=12.0.0" } }, - "node_modules/@eslint/eslintrc/node_modules/argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dependencies": { - "sprintf-js": "~1.0.2" - } - }, - "node_modules/@eslint/eslintrc/node_modules/js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", - "dependencies": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, - "node_modules/@eslint/eslintrc/node_modules/sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" - }, "node_modules/@gar/promisify": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@gar/promisify/-/promisify-1.1.2.tgz", @@ -2606,14 +2577,6 @@ "node": ">=8" } }, - "node_modules/@istanbuljs/load-nyc-config/node_modules/argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dependencies": { - "sprintf-js": "~1.0.2" - } - }, "node_modules/@istanbuljs/load-nyc-config/node_modules/camelcase": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", @@ -2634,18 +2597,6 @@ "node": ">=8" } }, - "node_modules/@istanbuljs/load-nyc-config/node_modules/js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", - "dependencies": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, "node_modules/@istanbuljs/load-nyc-config/node_modules/locate-path": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", @@ -2690,11 +2641,6 @@ "node": ">=8" } }, - "node_modules/@istanbuljs/load-nyc-config/node_modules/sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" - }, "node_modules/@istanbuljs/schema": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", @@ -3866,12 +3812,6 @@ "@types/istanbul-lib-report": "*" } }, - "node_modules/@types/js-yaml": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.3.tgz", - "integrity": "sha512-5t9BhoORasuF5uCPr+d5/hdB++zRFUTMIZOzbNkr+jZh3yQht4HYbRDyj9fY8n2TZT30iW9huzav73x4NikqWg==", - "dev": true - }, "node_modules/@types/json-schema": { "version": "7.0.9", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.9.tgz", @@ -3917,12 +3857,6 @@ "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==" }, - "node_modules/@types/parsimmon": { - "version": "1.10.6", - "resolved": "https://registry.npmjs.org/@types/parsimmon/-/parsimmon-1.10.6.tgz", - "integrity": "sha512-FwAQwMRbkhx0J6YELkwIpciVzCcgEqXEbIrIn3a2P5d3kGEHQ3wVhlN3YdVepYP+bZzCYO6OjmD4o9TGOZ40rA==", - "dev": true - }, "node_modules/@types/prettier": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.4.0.tgz", @@ -4740,9 +4674,12 @@ } }, "node_modules/argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dependencies": { + "sprintf-js": "~1.0.2" + } }, "node_modules/aria-query": { "version": "4.2.2", @@ -7600,14 +7537,6 @@ "node": ">=6.9.0" } }, - "node_modules/cssnano/node_modules/argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dependencies": { - "sprintf-js": "~1.0.2" - } - }, "node_modules/cssnano/node_modules/cosmiconfig": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.2.1.tgz", @@ -7634,18 +7563,6 @@ "node": ">=4" } }, - "node_modules/cssnano/node_modules/js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", - "dependencies": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, "node_modules/cssnano/node_modules/parse-json": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", @@ -7666,11 +7583,6 @@ "node": ">=4" } }, - "node_modules/cssnano/node_modules/sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" - }, "node_modules/csso": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/csso/-/csso-4.2.0.tgz", @@ -10385,14 +10297,6 @@ "url": "https://opencollective.com/webpack" } }, - "node_modules/eslint/node_modules/argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dependencies": { - "sprintf-js": "~1.0.2" - } - }, "node_modules/eslint/node_modules/eslint-utils": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", @@ -10415,23 +10319,6 @@ "node": ">=4" } }, - "node_modules/eslint/node_modules/js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", - "dependencies": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, - "node_modules/eslint/node_modules/sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" - }, "node_modules/espree": { "version": "7.3.1", "resolved": "https://registry.npmjs.org/espree/-/espree-7.3.1.tgz", @@ -15329,11 +15216,12 @@ "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" }, "node_modules/js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", "dependencies": { - "argparse": "^2.0.1" + "argparse": "^1.0.7", + "esprima": "^4.0.0" }, "bin": { "js-yaml": "bin/js-yaml.js" @@ -17795,11 +17683,6 @@ "node": ">= 0.8" } }, - "node_modules/parsimmon": { - "version": "1.18.0", - "resolved": "https://registry.npmjs.org/parsimmon/-/parsimmon-1.18.0.tgz", - "integrity": "sha512-EtVsGuQfDgwGgXzsSDe+5egRPwbcgKRd/omQ1L3Oj2pHy0gYqd+Q7zrBIQ7P/BN6DWUP9vV45HIgZHCmssdzMg==" - }, "node_modules/pascal-case": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/pascal-case/-/pascal-case-3.1.2.tgz", @@ -18576,14 +18459,6 @@ "url": "https://opencollective.com/postcss/" } }, - "node_modules/postcss-load-config/node_modules/argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dependencies": { - "sprintf-js": "~1.0.2" - } - }, "node_modules/postcss-load-config/node_modules/cosmiconfig": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.2.1.tgz", @@ -18610,18 +18485,6 @@ "node": ">=4" } }, - "node_modules/postcss-load-config/node_modules/js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", - "dependencies": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, "node_modules/postcss-load-config/node_modules/parse-json": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", @@ -18642,11 +18505,6 @@ "node": ">=4" } }, - "node_modules/postcss-load-config/node_modules/sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" - }, "node_modules/postcss-loader": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/postcss-loader/-/postcss-loader-3.0.0.tgz", @@ -22042,6 +21900,13 @@ "node": ">=8.0" } }, + "node_modules/roarr/node_modules/sprintf-js": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.2.tgz", + "integrity": "sha512-VE0SOVEHCk7Qc8ulkWw3ntAzXuqf7S2lvwQaDLRnUeIEaKNQJzV6BwmLKhOqT61aGhfUMrXeaBk+oDGCzvhcug==", + "dev": true, + "optional": true + }, "node_modules/rollup": { "version": "1.32.1", "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.32.1.tgz", @@ -23287,11 +23152,9 @@ } }, "node_modules/sprintf-js": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.2.tgz", - "integrity": "sha512-VE0SOVEHCk7Qc8ulkWw3ntAzXuqf7S2lvwQaDLRnUeIEaKNQJzV6BwmLKhOqT61aGhfUMrXeaBk+oDGCzvhcug==", - "dev": true, - "optional": true + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" }, "node_modules/sshpk": { "version": "1.16.1", @@ -23832,14 +23695,6 @@ "node": ">=4" } }, - "node_modules/svgo/node_modules/argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dependencies": { - "sprintf-js": "~1.0.2" - } - }, "node_modules/svgo/node_modules/chalk": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", @@ -23927,18 +23782,6 @@ "node": ">=4" } }, - "node_modules/svgo/node_modules/js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", - "dependencies": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, "node_modules/svgo/node_modules/nth-check": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.2.tgz", @@ -23947,11 +23790,6 @@ "boolbase": "~1.0.0" } }, - "node_modules/svgo/node_modules/sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" - }, "node_modules/svgo/node_modules/supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -29163,30 +29001,6 @@ "js-yaml": "^3.13.1", "minimatch": "^3.0.4", "strip-json-comments": "^3.1.1" - }, - "dependencies": { - "argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "requires": { - "sprintf-js": "~1.0.2" - } - }, - "js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", - "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - } - }, - "sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" - } } }, "@gar/promisify": { @@ -29255,14 +29069,6 @@ "resolve-from": "^5.0.0" }, "dependencies": { - "argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "requires": { - "sprintf-js": "~1.0.2" - } - }, "camelcase": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", @@ -29277,15 +29083,6 @@ "path-exists": "^4.0.0" } }, - "js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", - "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - } - }, "locate-path": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", @@ -29314,11 +29111,6 @@ "version": "5.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==" - }, - "sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" } } }, @@ -30204,12 +29996,6 @@ "@types/istanbul-lib-report": "*" } }, - "@types/js-yaml": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.3.tgz", - "integrity": "sha512-5t9BhoORasuF5uCPr+d5/hdB++zRFUTMIZOzbNkr+jZh3yQht4HYbRDyj9fY8n2TZT30iW9huzav73x4NikqWg==", - "dev": true - }, "@types/json-schema": { "version": "7.0.9", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.9.tgz", @@ -30255,12 +30041,6 @@ "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==" }, - "@types/parsimmon": { - "version": "1.10.6", - "resolved": "https://registry.npmjs.org/@types/parsimmon/-/parsimmon-1.10.6.tgz", - "integrity": "sha512-FwAQwMRbkhx0J6YELkwIpciVzCcgEqXEbIrIn3a2P5d3kGEHQ3wVhlN3YdVepYP+bZzCYO6OjmD4o9TGOZ40rA==", - "dev": true - }, "@types/prettier": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.4.0.tgz", @@ -30918,9 +30698,12 @@ } }, "argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "requires": { + "sprintf-js": "~1.0.2" + } }, "aria-query": { "version": "4.2.2", @@ -33127,14 +32910,6 @@ "postcss": "^7.0.0" }, "dependencies": { - "argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "requires": { - "sprintf-js": "~1.0.2" - } - }, "cosmiconfig": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.2.1.tgz", @@ -33155,15 +32930,6 @@ "resolve-from": "^3.0.0" } }, - "js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", - "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - } - }, "parse-json": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", @@ -33177,11 +32943,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-3.0.0.tgz", "integrity": "sha1-six699nWiBvItuZTM17rywoYh0g=" - }, - "sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" } } }, @@ -34914,14 +34675,6 @@ "v8-compile-cache": "^2.0.3" }, "dependencies": { - "argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "requires": { - "sprintf-js": "~1.0.2" - } - }, "eslint-utils": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", @@ -34936,20 +34689,6 @@ "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==" } } - }, - "js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", - "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - } - }, - "sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" } } }, @@ -39132,11 +38871,12 @@ "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" }, "js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", "requires": { - "argparse": "^2.0.1" + "argparse": "^1.0.7", + "esprima": "^4.0.0" } }, "jsbn": { @@ -41076,11 +40816,6 @@ "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" }, - "parsimmon": { - "version": "1.18.0", - "resolved": "https://registry.npmjs.org/parsimmon/-/parsimmon-1.18.0.tgz", - "integrity": "sha512-EtVsGuQfDgwGgXzsSDe+5egRPwbcgKRd/omQ1L3Oj2pHy0gYqd+Q7zrBIQ7P/BN6DWUP9vV45HIgZHCmssdzMg==" - }, "pascal-case": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/pascal-case/-/pascal-case-3.1.2.tgz", @@ -41686,14 +41421,6 @@ "import-cwd": "^2.0.0" }, "dependencies": { - "argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "requires": { - "sprintf-js": "~1.0.2" - } - }, "cosmiconfig": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.2.1.tgz", @@ -41714,15 +41441,6 @@ "resolve-from": "^3.0.0" } }, - "js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", - "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - } - }, "parse-json": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", @@ -41736,11 +41454,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-3.0.0.tgz", "integrity": "sha1-six699nWiBvItuZTM17rywoYh0g=" - }, - "sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" } } }, @@ -44383,6 +44096,15 @@ "json-stringify-safe": "^5.0.1", "semver-compare": "^1.0.0", "sprintf-js": "^1.1.2" + }, + "dependencies": { + "sprintf-js": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.2.tgz", + "integrity": "sha512-VE0SOVEHCk7Qc8ulkWw3ntAzXuqf7S2lvwQaDLRnUeIEaKNQJzV6BwmLKhOqT61aGhfUMrXeaBk+oDGCzvhcug==", + "dev": true, + "optional": true + } } }, "rollup": { @@ -45408,11 +45130,9 @@ } }, "sprintf-js": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.2.tgz", - "integrity": "sha512-VE0SOVEHCk7Qc8ulkWw3ntAzXuqf7S2lvwQaDLRnUeIEaKNQJzV6BwmLKhOqT61aGhfUMrXeaBk+oDGCzvhcug==", - "dev": true, - "optional": true + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" }, "sshpk": { "version": "1.16.1", @@ -45832,14 +45552,6 @@ "color-convert": "^1.9.0" } }, - "argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "requires": { - "sprintf-js": "~1.0.2" - } - }, "chalk": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", @@ -45914,15 +45626,6 @@ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" }, - "js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", - "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - } - }, "nth-check": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.2.tgz", @@ -45931,11 +45634,6 @@ "boolbase": "~1.0.0" } }, - "sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" - }, "supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", diff --git a/package.json b/package.json index 30f5be6..b5bb027 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,6 @@ "electron:package": "npm run build && npm run electron:compile && electron-forge package", "electron:make": "npm run build && npm run electron:compile && electron-forge make", "ini:compile": "tsc -p tsconfig.custom.json", - "ini:start": "npm run ini:compile && node src/parser/ini.js", - "ini:watch": "npx onchange src/parser/ini.ts -- npm run ini:start", "test": "craco test", "lint": "tsc && eslint --max-warnings=0 src", "lint-fix": "eslint --fix src", @@ -44,10 +42,8 @@ "@speedy-tuner/types": "^0.1.1", "antd": "^4.16.13", "electron-squirrel-startup": "^1.0.0", - "js-yaml": "^4.1.0 ", "mlg-converter": "^0.5.1", "pako": "^2.0.4", - "parsimmon": "^1.18.0", "react": "^17.0.1", "react-dom": "^17.0.2", "react-perfect-scrollbar": "^1.5.8", @@ -65,10 +61,8 @@ "@electron-forge/maker-rpm": "^6.0.0-beta.61", "@electron-forge/maker-squirrel": "^6.0.0-beta.61", "@electron-forge/maker-zip": "^6.0.0-beta.61", - "@types/js-yaml": "^4.0.3", "@types/node": "^16.9.6", "@types/pako": "^1.0.2", - "@types/parsimmon": "^1.10.6", "@types/react": "^17.0.24", "@types/react-dom": "^17.0.9", "@types/react-redux": "^7.1.18", diff --git a/src/parser/ini.ts b/src/parser/ini.ts deleted file mode 100644 index a34202b..0000000 --- a/src/parser/ini.ts +++ /dev/null @@ -1,1181 +0,0 @@ -import fs from 'fs'; -import path from 'path'; -import yaml from 'js-yaml'; -import * as P from 'parsimmon'; - -import { - Config as ConfigType, - Constant, -} from '@speedy-tuner/types'; - -console.log('------- start --------'); - -class INI { - space: P.Parser; - - expression: P.Parser; - - numbers: P.Parser; - - name: P.Parser; - - equal: P.Parser; - - quote: P.Parser; - - quotes: [P.Parser, P.Parser]; - - comma: P.Parser; - - size: P.Parser; - - delimiter: [P.Parser, P.Parser, P.Parser]; - - notQuote: P.Parser; - - sqrBrackets: [P.Parser, P.Parser]; - - inQuotes: P.Parser; - - values: P.Parser; - - lines: string[]; - - currentPage?: number; - - currentDialog?: string; - - currentPanel?: string; - - currentMenu?: string; - - currentCurve?: string; - - currentTable?: string; - - result: ConfigType; - - constructor(buffer: string) { - this.space = P.optWhitespace; - this.expression = P.regexp(/{.+?}/); - this.numbers = P.regexp(/[0-9.-]*/); - this.name = P.regexp(/[0-9a-z_]*/i); - this.equal = P.string('='); - this.quote = P.string('"'); - this.quotes = [this.quote, this.quote]; - this.comma = P.string(','); - this.size = P.regexp(/U08|S08|U16|S16|U32|S32|S64|F32|ASCII/); - this.delimiter = [this.space, this.comma, this.space]; - this.notQuote = P.regexp(/[^"]*/); - this.sqrBrackets = [P.string('['), P.string(']')]; - this.inQuotes = this.notQuote.trim(this.space).wrap(...this.quotes); - this.values = P.regexp(/[^,;]*/).trim(this.space).sepBy(this.comma); - - this.lines = buffer.toString().split('\n'); - - this.currentPage = undefined; - this.currentDialog = undefined; - this.currentPanel = undefined; - this.currentMenu = undefined; - this.currentCurve = undefined; - this.currentTable = undefined; - - this.result = { - megaTune: { - signature: '', - MTversion: 0, - queryCommand: '', - versionInfo: '', - }, - tunerStudio: { - iniSpecVersion: 0, - }, - defines: {}, - pcVariables: {}, - constants: { - pages: [], - }, - menus: {}, - dialogs: {}, - curves: {}, - tables: {}, - outputChannels: {}, - datalog: {}, - help: {}, - }; - } - - parse() { - this.parseSections(); - return this.result; - } - - private parseSections() { - let section: string; - - this.lines.forEach((raw) => { - const line = raw.trim(); - // skip empty lines and lines with comments only - // skip #if for now - if (line === '' || line.startsWith(';') || (line.startsWith('#') && !line.startsWith('#define'))) { - return; - } - - const result = P - .seqObj( - ['section', P.letters.wrap(P.string('['), P.string(']'))], - P.all, - ).parse(line); - - // top level section found - if (result.status) { - section = result.value.section.trim(); - return; - } - - if (section) { - this.parseSectionLine(section, line); - } - }); - } - - private parseSectionLine(section: string, line: string) { - switch (section) { - case 'MegaTune': - this.parseKeyValueFor('megaTune', line); - break; - case 'TunerStudio': - this.parseKeyValueFor('tunerStudio', line); - break; - case 'PcVariables': - this.parsePcVariables(line); - break; - case 'Constants': - this.parseConstants(line); - break; - case 'Menu': - this.parseMenu(line); - break; - case 'SettingContextHelp': - this.parseKeyValueFor('help', line); - break; - case 'UserDefined': - this.parseDialogs(line); - break; - case 'CurveEditor': - this.parseCurves(line); - break; - case 'TableEditor': - this.parseTables(line); - break; - case 'OutputChannels': - this.parseOutputChannels(line); - break; - case 'Datalog': - this.parseDatalog(line); - break; - default: - break; - } - } - - private parseDatalog(line: string) { - const base: any = [ - P.string('entry'), - this.space, this.equal, this.space, - ['name', this.name], - ...this.delimiter, - ]; - const type: any = [ - ...this.delimiter, - ['type', P.regexp(/float|int/)], - ]; - const format: any = [ - ...this.delimiter, - ['format', this.notQuote.wrap(...this.quotes)], - ]; - const noConditions = [ - ...base, - ['label', this.notQuote.wrap(...this.quotes)], - ...type, - ...format, - ]; - const withConditions = [ - ...noConditions, - ...this.delimiter, - ['condition', this.expression], - ]; - const labelExpression = [ - ...base, - ['label', this.expression], - ...type, - ...format, - ]; - const labelExpressionWithCondition = [ - ...labelExpression, - ...this.delimiter, - ['condition', this.expression], - ]; - - const result: any = P.seqObj(...labelExpressionWithCondition, P.all) - .or(P.seqObj(...withConditions, P.all)) - .or(P.seqObj(...labelExpression, P.all)) - .or(P.seqObj(...noConditions, P.all)) - .tryParse(line); - - this.result.datalog[result.name] = { - name: result.name, - label: INI.sanitize(result.label), - type: result.type, - format: INI.sanitize(result.format), - condition: result.condition ? INI.sanitize(result.condition) : '', - }; - } - - private parseOutputChannels(line: string) { - try { - const result = this.parseConstAndVar(line); - - this.result.outputChannels[result.name] = { - type: result.type, - size: result.size, - offset: Number(result.offset), - units: INI.sanitize(result.units), - scale: INI.isNumber(result.scale) ? Number(result.scale) : INI.sanitize(result.scale), - transform: INI.isNumber(result.transform) ? Number(result.transform) : INI.sanitize(result.transform), - }; - return; - } catch (_) { - const base: any = [ - ['name', this.name], - this.space, this.equal, this.space, - ]; - - // TODO: throttle = { tps }, "%" - // ochGetCommand = "r\$tsCanId\x30%2o%2c" - // ochBlockSize = 117 - // coolant = { coolantRaw - 40 } - const result = P - .seqObj( - ...base, - ['value', this.notQuote.wrap(...this.quotes)], - P.all, - ) - .or(P.seqObj( - ...base, - ['value', this.expression], - P.all, - )) - .or(P.seqObj( - ...base, - ['value', this.numbers], - P.all, - )) - .tryParse(line); - - this.result.outputChannels[result.name] = { - value: INI.sanitize(result.value), - }; - } - } - - private parseTables(line: string) { - // table = veTable1Tbl, veTable1Map, "VE Table", 2 - const tableResult = P.seqObj( - P.string('table'), - this.space, this.equal, this.space, - ['name', this.name], - ...this.delimiter, - ['map', this.name], - ...this.delimiter, - ['title', this.inQuotes], - ...this.delimiter, - ['page', P.digits], - P.all, - ).parse(line); - - if (tableResult.status) { - this.currentTable = tableResult.value.name; - this.result.tables[this.currentTable!] = { - map: tableResult.value.map, - title: INI.sanitize(tableResult.value.title), - page: Number(tableResult.value.page), - xBins: [], - yBins: [], - xyLabels: [], - zBins: [], - gridHeight: 0, - gridOrient: [], - upDownLabel: [], - }; - - return; - } - - // topicHelp = "http://speeduino.com/wiki/index.php/Tuning" - const helpResult = P.seqObj( - P.string('topicHelp'), - this.space, this.equal, this.space, - ['help', this.inQuotes], - P.all, - ).parse(line); - - if (helpResult.status) { - if (!this.currentTable) { - throw new Error('Table not set'); - } - this.result.tables[this.currentTable].help = INI.sanitize(helpResult.value.help); - - return; - } - - // xBins = rpmBins, rpm - // yBins = fuelLoadBins, fuelLoad - // xyLabels = "RPM", "Fuel Load: " - // zBins = veTable - // gridOrient = 250, 0, 340 - // upDownLabel = "(RICHER)", "(LEANER)" - const parseBins = (name: string) => P.seqObj( - P.string(name), - this.space, this.equal, this.space, - ['values', this.values], - P.all, - ).parse(line); - - const xBinsResult = parseBins('xBins'); - if (xBinsResult.status) { - if (!this.currentTable) { - throw new Error('Table not set'); - } - this.result.tables[this.currentTable].xBins = xBinsResult - .value - .values - .map(INI.sanitize); - - return; - } - - const yBinsResult = parseBins('yBins'); - if (yBinsResult.status) { - if (!this.currentTable) { - throw new Error('Table not set'); - } - this.result.tables[this.currentTable].yBins = yBinsResult - .value - .values - .map(INI.sanitize); - - return; - } - - const yxLabelsResult = parseBins('xyLabels'); - if (yxLabelsResult.status) { - if (!this.currentTable) { - throw new Error('Table not set'); - } - this.result.tables[this.currentTable].xyLabels = yxLabelsResult - .value - .values - .map(INI.sanitize); - - return; - } - - const zBinsResult = parseBins('zBins'); - if (zBinsResult.status) { - if (!this.currentTable) { - throw new Error('Table not set'); - } - this.result.tables[this.currentTable].zBins = zBinsResult - .value - .values - .map(INI.sanitize); - - return; - } - - // gridHeight = 2.0 - const gridHeightResult = P.seqObj( - P.string('gridHeight'), - this.space, this.equal, this.space, - ['gridHeight', this.numbers], - P.all, - ).parse(line); - - if (gridHeightResult.status) { - if (!this.currentTable) { - throw new Error('Table not set'); - } - this.result.tables[this.currentTable].gridHeight = Number(gridHeightResult.value.gridHeight); - - return; - } - - const gridOrientResult = parseBins('gridOrient'); - if (gridOrientResult.status) { - if (!this.currentTable) { - throw new Error('Table not set'); - } - this.result.tables[this.currentTable].gridOrient = gridOrientResult - .value - .values - .map(Number); - - return; - } - - const upDownResult = parseBins('upDownLabel'); - if (upDownResult.status) { - if (!this.currentTable) { - throw new Error('Table not set'); - } - this.result.tables[this.currentTable].upDownLabel = upDownResult - .value - .values - .map(INI.sanitize); - } - } - - private parseCurves(line: string) { - // curve = time_accel_tpsdot_curve, "TPS based AE" - const curveResult = P.seqObj( - P.string('curve'), - this.space, this.equal, this.space, - ['name', this.name], - ...this.delimiter, - ['title', this.inQuotes], - P.all, - ).parse(line); - - if (curveResult.status) { - this.currentCurve = curveResult.value.name; - this.result.curves[this.currentCurve!] = { - title: INI.sanitize(curveResult.value.title), - labels: [], - xAxis: [], - yAxis: [], - xBins: [], - yBins: [], - size: [], - }; - - return; - } - - // columnLabel = "TPSdot", "Added" - const labelsResult = P.seqObj( - P.string('columnLabel'), - this.space, this.equal, this.space, - ['labels', this.values], - P.all, - ).parse(line); - - if (labelsResult.status) { - if (!this.currentCurve) { - throw new Error('Curve not set'); - } - this.result.curves[this.currentCurve].labels = labelsResult - .value - .labels - .map(INI.sanitize); - - return; - } - - // xAxis = 0, 1200, 6 - // yAxis = 0, 1200, 6 - // xBins = taeBins, TPSdot - // yBins = taeRates - const parseAxis = (name: string) => P.seqObj( - P.string(name), - this.space, this.equal, this.space, - ['values', this.values], - P.all, - ).parse(line); - - const xAxisResult = parseAxis('xAxis'); - if (xAxisResult.status) { - if (!this.currentCurve) { - throw new Error('Curve not set'); - } - this.result.curves[this.currentCurve].xAxis = xAxisResult - .value - .values - .map((val: string) => INI.isNumber(val) ? Number(val) : INI.sanitize(val)); - - return; - } - - const yAxisResult = parseAxis('yAxis'); - if (yAxisResult.status) { - if (!this.currentCurve) { - throw new Error('Curve not set'); - } - this.result.curves[this.currentCurve].yAxis = yAxisResult - .value - .values - .map((val: string) => INI.isNumber(val) ? Number(val) : INI.sanitize(val)); - - return; - } - - const xBinsResult = parseAxis('xBins'); - if (xBinsResult.status) { - if (!this.currentCurve) { - throw new Error('Curve not set'); - } - this.result.curves[this.currentCurve].xBins = xBinsResult - .value - .values - .map((val: string) => INI.isNumber(val) ? Number(val) : INI.sanitize(val)); - - return; - } - - const yBinsResult = parseAxis('yBins'); - if (yBinsResult.status) { - if (!this.currentCurve) { - throw new Error('Curve not set'); - } - this.result.curves[this.currentCurve].yBins = yBinsResult - .value - .values - .map((val: string) => INI.isNumber(val) ? Number(val) : INI.sanitize(val)); - - return; - } - - const size = parseAxis('size'); - if (size.status) { - if (!this.currentCurve) { - throw new Error('Curve not set'); - } - this.result.curves[this.currentCurve].size = size - .value - .values - .map((val: string) => INI.isNumber(val) ? Number(val) : INI.sanitize(val)); - } - } - - private parseDialogs(line: string) { - const dialogBase: any = [ - P.string('dialog'), - this.space, this.equal, this.space, - ['name', this.name], - ...this.delimiter, - ['title', this.inQuotes], - ]; - const dialogResult = P - .seqObj( - ...dialogBase, - ...this.delimiter, - ['layout', this.name], - P.all, - ) - .or(P.seqObj(...dialogBase, P.all)) - .parse(line); - - if (dialogResult.status) { - this.currentDialog = dialogResult.value.name; - this.result.dialogs[this.currentDialog!] = { - title: INI.sanitize(dialogResult.value.title), - layout: dialogResult.value.layout, - panels: {}, - fields: [], - }; - - return; - } - - // panel = knock_window_angle_curve - const panelBase: any = [ - P.string('panel'), - this.space, this.equal, this.space, - ['name', this.name], - ]; - - // panel = knock_window_angle_curve, West - const panelWithLayout = [ - ...panelBase, - ...this.delimiter, - ['layout', this.name], - ]; - - // panel = flex_fuel_curve, { flexEnabled } - const panelWithCondition = [ - ...panelBase, - ...this.delimiter, - ['condition', this.expression], - ]; - - const panelResult = P - .seqObj( - ...panelWithLayout, - ...this.delimiter, - ['condition', this.expression], - P.all, - ) - .or(P.seqObj( - ...panelWithCondition, - P.all, - )) - .or(P.seqObj( - ...panelWithLayout, - P.all, - )) - .or(P.seqObj( - ...panelBase, - P.all, - )) - .parse(line); - - if (panelResult.status) { - if (!this.currentDialog) { - throw new Error('Dialog not set'); - } - this.currentPanel = panelResult.value.name; - - this.result.dialogs[this.currentDialog!].panels[this.currentPanel!] = { - layout: panelResult.value.layout, - condition: panelResult.value.condition, - fields: [], - panels: {}, - }; - - return; - } - - // field = "Injector Layout" - const fieldBase: any = [ - P.string('field'), - this.space, this.equal, this.space, - ['title', this.notQuote.wrap(...this.quotes)], - ]; - - // field = "Injector Layout", injLayout - const fieldWithName = [ - ...fieldBase, - ...this.delimiter, - ['name', this.name], - ]; - - // field = "Low (E0) ", flexFreqLow, { flexEnabled } - const fieldWithCondition = [ - ...fieldWithName, - ...this.delimiter, - ['condition', this.expression], - ]; - - // NOTE: this is probably a mistake, investigate that - // field = "AUX Input 0", caninput_sel0a, {}, { (!enable_secondarySerial && (!enable_intcan || (enable_intcan && intcan_available == 0))) } - const fieldWithDoubleCondition = [ - ...fieldWithName, - ...this.delimiter, - P.regexp(/{.*?}/), - ...this.delimiter, - ['condition', this.expression], - ]; - - const fieldResult = P - .seqObj( - ...fieldWithDoubleCondition, - P.all, - ) - .or(P.seqObj( - ...fieldWithCondition, - P.all, - )) - .or(P.seqObj( - ...fieldWithName, - P.all, - )) - .or(P.seqObj( - ...fieldBase, - P.all, - )) - .parse(line); - - if (fieldResult.status) { - if (!this.currentDialog) { - throw new Error('Dialog not set'); - } - - this.result.dialogs[this.currentDialog!].fields.push({ - name: fieldResult.value.name || '_fieldText_', - title: INI.sanitize(fieldResult.value.title), - condition: fieldResult.value.condition, - }); - - return; - } - - // topicHelp = "https://wiki.speeduino.com/en/configuration/Engine_Constants" - const helpResult = P - .seqObj( - P.string('topicHelp'), - this.space, this.equal, this.space, - ['help', this.notQuote.wrap(...this.quotes)], - P.all, - ) - .parse(line); - - if (!this.currentDialog) { - throw new Error('Dialog not set'); - } - - if (helpResult.status) { - this.result.dialogs[this.currentDialog!].help = INI.sanitize( - helpResult.value.help, - ); - } - - // TODO: missing fields: - // - settingSelector - // - commandButton - // - displayOnlyField - } - - private parseKeyValueFor(section: string, line: string) { - const { key, value } = this.parseKeyValue(line); - - if (this.result[section][key]) { - // TODO: enable this for linting duplicates - return; - // throw new Error(`Key: ${key} for section: ${section} already exist`); - } - - this.result[section][key] = value; - } - - private parseKeyValue(line: string) { - const base: any = [ - ['key', this.name], - this.space, this.equal, this.space, - ]; - - const result = P - .seqObj( - ...base, - ['value', this.notQuote.wrap(...this.quotes)], - P.all, - ) - .or(P.seqObj( - ...base, - ['value', this.numbers], - P.all, - )) - .tryParse(line); - - return { - key: result.key as string, - value: INI.isNumber(result.value) - ? Number(result.value) - : INI.sanitize(result.value), - }; - } - - private parseMenu(line: string) { - // skip root "menuDialog = main" for now - if (line.startsWith('menuDialog')) { - return; - } - - const menuResult = P - .seqObj( - P.string('menu'), - this.space, this.equal, this.space, - ['name', this.inQuotes], - P.all, - ).parse(line); - - if (menuResult.status) { - const title = INI - .sanitize(menuResult.value.name) - .replace(/&/g, ''); - const name = title - .toLowerCase() - .replace(/([^\w]\w)/g, (g) => g[1].toUpperCase()); // camelCase - - this.currentMenu = name; - this.result.menus[this.currentMenu] = { - title: INI.sanitize(title), - subMenus: {}, - }; - return; - } - - if (this.currentMenu) { - // subMenu = std_separator - const base: any = [ - P.string('subMenu'), - this.space, this.equal, this.space, - ['name', this.name], - ]; - - // subMenu = io_summary, "I/O Summary" - const withTitle: any = [ - ...base, - ...this.delimiter, - ['title', this.notQuote.wrap(...this.quotes)], - ]; - - // subMenu = egoControl, "AFR/O2", 3 - const withPage: any = [ - ...withTitle, - ...this.delimiter, - ['page', P.digits], - ]; - - // subMenu = fuelTemp_curve, "Fuel Temp Correction", { flexEnabled } - const withCondition: any = [ - ...withTitle, - ...this.delimiter, - ['condition', this.expression], - P.all, - ]; - - // subMenu = inj_trimad_B, "Sequential fuel trim (5-8)", 9, { nFuelChannels >= 5 } - const full: any = [ - ...withPage, - ...this.delimiter, - ['condition', this.expression], - ]; - - const subMenuResult = P.seqObj(...full, P.all) - .or(P.seqObj(...withCondition, P.all)) - .or(P.seqObj(...withPage, P.all)) - .or(P.seqObj(...withTitle, P.all)) - .or(P.seqObj(...base, P.all)) - .tryParse(line); - - this.result.menus[this.currentMenu].subMenus[subMenuResult.name] = { - title: INI.sanitize(subMenuResult.title), - page: Number(subMenuResult.page || 0), - condition: subMenuResult.condition ? INI.sanitize(subMenuResult.condition) : '', - }; - } - } - - private parseDefines(line: string) { - const result = P.seqObj( - P.string('#define'), - this.space, - ['name', this.name], - this.space, this.equal, this.space, - ['values', this.values], - P.all, - ).tryParse(line); - - this.result.defines[result.name] = result.values.map(INI.sanitize); - - const resolved = this.result.defines[result.name].map((val) => ( - val.startsWith('$') - ? this.result.defines[val.slice(1)] - : val - )).flat(); - - this.result.defines[result.name] = resolved; - } - - private parsePcVariables(line: string) { - if (line.startsWith('#define')) { - this.parseDefines(line); - return; - } - - const result = this.parseConstAndVar(line, true); - - let constant = {} as Constant; - switch (result.type) { - case 'scalar': - constant = { - type: result.type, - size: result.size, - units: INI.sanitize(result.units), - scale: INI.numberOrExpression(result.scale), - transform: INI.numberOrExpression(result.transform), - min: INI.numberOrExpression(result.min), - max: INI.numberOrExpression(result.max), - digits: Number(result.digits), - }; - break; - case 'array': - constant = { - type: result.type, - size: result.size, - shape: INI.arrayShape(result.shape), - units: INI.sanitize(result.units), - scale: INI.numberOrExpression(result.scale), - transform: INI.numberOrExpression(result.transform), - min: INI.numberOrExpression(result.min), - max: INI.numberOrExpression(result.max), - digits: Number(result.digits), - }; - break; - case 'bits': - constant = { - type: result.type, - size: result.size, - address: result.address.split(':').map(Number), - values: this.resolveBitsValues(result.name, result.values || []), - }; - break; - case 'string': - constant = { - type: result.type, - size: result.size, - length: Number(result.length), - }; - break; - default: - break; - } - - this.result.pcVariables[result.name] = constant; - } - - private parseConstants(line: string) { - if (line.startsWith('#define')) { - this.parseDefines(line); - return; - } - - const page = P - .seqObj( - P.string('page'), - this.space, this.equal, this.space, - ['page', P.digits], - P.all, - ).parse(line); - - if (page.status) { - this.currentPage = Number(page.value.page) - 1; - return; - } - - if (INI.isNumber(this.currentPage)) { - const result = this.parseConstAndVar(line); - - if (!this.result.constants.pages[this.currentPage!]) { - this.result.constants.pages[this.currentPage!] = { - number: this.currentPage! + 1, - size: 0, - data: {}, - }; - } - - let constant = {} as Constant; - switch (result.type) { - case 'scalar': - constant = { - type: result.type, - size: result.size, - offset: Number(result.offset), - units: INI.sanitize(result.units), - scale: INI.numberOrExpression(result.scale), - transform: INI.numberOrExpression(result.transform), - min: INI.numberOrExpression(result.min), - max: INI.numberOrExpression(result.max), - digits: Number(result.digits), - }; - break; - case 'array': - constant = { - type: result.type, - size: result.size, - offset: Number(result.offset), - shape: INI.arrayShape(result.shape), - units: INI.sanitize(result.units), - scale: INI.numberOrExpression(result.scale), - transform: INI.numberOrExpression(result.transform), - min: INI.numberOrExpression(result.min), - max: INI.numberOrExpression(result.max), - digits: Number(result.digits), - }; - break; - case 'bits': - constant = { - type: result.type, - size: result.size, - offset: Number(result.offset), - address: result.address.split(':').map(Number), - values: this.resolveBitsValues(result.name, result.values || []), - }; - break; - default: - break; - } - - if (this.result.constants.pages[this.currentPage!].data[result.name]) { - // TODO: if else - return; - } - - this.result.constants.pages[this.currentPage!].data[result.name] = constant; - } - } - - private resolveBitsValues(name: string, values: string[]) { - return values.map((val: string) => { - const resolve = () => { - const defineName = INI.sanitize(val.slice(1)); // name without $ - const resolved = this.result.defines[defineName]; - if (!resolved) { - throw new Error(`Unable to resolve bits values for ${name}`); - } - - return resolved; - }; - - return val.startsWith('$') ? resolve() : INI.sanitize(val); - }).flat().filter((val) => val !== ''); - } - - private parseConstAndVar(line: string, asPcVariable = false) { - const address: any = [ - ['address', P.regexp(/\d+:\d+/).trim(this.space).wrap(...this.sqrBrackets)], - ]; - - // first common (eg. name = scalar, U08, 3,) - const base: any = (type: string) => { - let list = [ - ['name', this.name], - this.space, this.equal, this.space, - ['type', P.string(type)], - ...this.delimiter, - ['size', this.size], - ]; - - // pcVariables don't have "offset" - if (!asPcVariable) { - list = [ - ...list, - ...[ - ...this.delimiter, - ['offset', P.digits], - ], - ]; - } - - return list; - }; - - const scalarShortRest: any = [ - ['units', P.alt( - this.expression, - this.inQuotes, - )], - ...this.delimiter, - ['scale', P.alt(this.expression, this.numbers)], - ...this.delimiter, - ['transform', P.alt(this.expression, this.numbers)], - ]; - - const scalarRest: any = [ - ...scalarShortRest, - ...this.delimiter, - ['min', P.alt(this.expression, this.numbers)], - ...this.delimiter, - ['max', P.alt(this.expression, this.numbers)], - ...this.delimiter, - ['digits', P.digits], - P.all, - ]; - - // normal scalar - const scalar = P.seqObj( - ...base('scalar'), - ...this.delimiter, - ...scalarRest, - ); - - // short version of scalar (e.g. 'divider') - const scalarShort = P.seqObj( - ...base('scalar'), - ...this.delimiter, - ...scalarShortRest, - P.all, - ); - - // normal version of array - const array = P.seqObj( - ...base('array'), - ...this.delimiter, - ['shape', P.regexp(/\d+\s*(x\s*\d+)*/).trim(this.space).wrap(...this.sqrBrackets)], - ...this.delimiter, - ...scalarRest, - ); - - // normal version of bits - const bits = P.seqObj( - ...base('bits'), - ...this.delimiter, - ...address, - ...this.delimiter, - ['values', this.values], - P.all, - ); - - // short version of bits - const bitsShort = P.seqObj( - ...base('bits'), - ...this.delimiter, - ...address, - P.all, - ); - - // string (in pcVariables) - const string = P.seqObj( - ...base('string'), - ...this.delimiter, - ['length', P.digits], - P.all, - ); - - return scalar - .or(scalarShort) - .or(array) - .or(bits) - .or(bitsShort) - .or(string) - .tryParse(line); - } - - private static numberOrExpression = (val: string | undefined | null) => INI.isNumber(val || '0') ? Number(val || 0) : INI.sanitize(`${val}`); - - private static sanitize = (val: any) => val === undefined ? '' : `${val}`.replace(/"/g, '').trim(); - - private static isNumber = (val: any) => !Number.isNaN(Number(val)); - - private static arrayShape = (val: string) => { - const parts = INI.sanitize(val).split('x'); - return { - columns: Number(parts[0]), - rows: parts[1] ? Number(parts[1]) : 0, - }; - }; -} - -const versions = [ - 202012, - 202103, -]; - -versions.forEach((version) => { - const result = new INI( - fs.readFileSync(path.join(__dirname, `/../../public/tunes/${version}.ini`), 'utf8'), - ).parse(); - - fs.writeFileSync(path.join(__dirname, `/../../public/tunes/${version}.yml`), yaml.dump(result)); - fs.writeFileSync(path.join(__dirname, `/../../public/tunes/${version}.json`), JSON.stringify(result)); -}); - -// const result = new INI( -// fs.readFileSync(path.join(__dirname, `/../../public/tunes/${versions[1]}.ini`), 'utf8'), -// ).parse(); -// console.dir( -// result.outputChannels, -// { depth: null, compact: false }, -// ); - -console.log('------- end --------');