From 0ae92de54d0ff3fe1ef8f0a15312d46dd632c292 Mon Sep 17 00:00:00 2001 From: Francisco Hodge Date: Fri, 29 Dec 2023 11:43:42 -0500 Subject: [PATCH] Panel image, css support WIP --- package-lock.json | 275 ++++++++++++++-- package.json | 8 +- rollup.config.comp.js | 20 +- rollup.config.main.js | 35 +- src/components/Admin/Admin.ts | 17 +- src/components/Admin/BanId.tsx | 52 --- src/components/Admin/Bans.tsx | 89 ------ src/components/Admin/Content.tsx | 15 + src/components/Admin/Dashboard.tsx | 98 ------ src/components/Admin/Header.tsx | 53 +--- src/components/Admin/Login.tsx | 57 ---- src/components/Admin/Panel.tsx | 57 ++++ src/components/Admin/Setup.tsx | 98 ------ src/components/Admin/Visitors.tsx | 64 ---- src/components/Admin/assets/css/panel.css | 50 +++ src/components/Admin/assets/images/logo.svg | 13 + src/components/Admin/index.ts | 7 +- src/components/Page/Page.tsx | 22 +- src/components/Page/index.ts | 3 +- src/components/Page/utils.ts | 45 --- src/components/Static/staticPages.ts | 333 +++----------------- src/pages.ts | 9 +- 22 files changed, 503 insertions(+), 917 deletions(-) delete mode 100644 src/components/Admin/BanId.tsx delete mode 100644 src/components/Admin/Bans.tsx create mode 100644 src/components/Admin/Content.tsx delete mode 100644 src/components/Admin/Dashboard.tsx delete mode 100644 src/components/Admin/Login.tsx create mode 100644 src/components/Admin/Panel.tsx delete mode 100644 src/components/Admin/Setup.tsx delete mode 100644 src/components/Admin/Visitors.tsx create mode 100644 src/components/Admin/assets/css/panel.css create mode 100644 src/components/Admin/assets/images/logo.svg delete mode 100644 src/components/Page/utils.ts diff --git a/package-lock.json b/package-lock.json index dd6a6d5..eb47a61 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,10 @@ "name": "apiker", "version": "1.6.9", "license": "MIT", + "dependencies": { + "@types/react": "^18.2.45", + "@types/react-dom": "^18.2.18" + }, "bin": { "apiker": "bin/index.js" }, @@ -17,9 +21,11 @@ "@babel/plugin-transform-typescript": "^7.16.1", "@babel/preset-env": "^7.16.11", "@babel/preset-typescript": "^7.16.0", + "@rollup/plugin-alias": "^5.1.0", "@rollup/plugin-babel": "^5.3.1", "@rollup/plugin-commonjs": "^21.0.3", "@rollup/plugin-eslint": "^8.0.1", + "@rollup/plugin-image": "^3.0.3", "@rollup/plugin-node-resolve": "^13.1.3", "@rollup/plugin-replace": "^4.0.0", "@rollup/plugin-typescript": "^8.3.1", @@ -33,7 +39,7 @@ "prettier": "^2.6.2", "react": "^17.0.2", "react-dom": "^17.0.2", - "react-is": "^18.0.0", + "react-is": "^17.0.2", "rimraf": "^3.0.2", "rollup": "^2.74.0", "rollup-plugin-copy": "^3.4.0", @@ -41,6 +47,7 @@ "rollup-plugin-node-polyfills": "^0.2.1", "rollup-plugin-peer-deps-external": "^2.2.4", "rollup-plugin-prettier": "^2.2.2", + "rollup-plugin-string": "^3.0.0", "rollup-plugin-terser": "^7.0.2", "rollup-plugin-typescript2": "^0.31.2", "ts-jest": "^27.1.4", @@ -2251,6 +2258,38 @@ "node": ">= 8" } }, + "node_modules/@rollup/plugin-alias": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-alias/-/plugin-alias-5.1.0.tgz", + "integrity": "sha512-lpA3RZ9PdIG7qqhEfv79tBffNaoDuukFDrmhLqg9ifv99u/ehn+lOg30x2zmhf8AQqQUZaMk/B9fZraQ6/acDQ==", + "dev": true, + "dependencies": { + "slash": "^4.0.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-alias/node_modules/slash": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz", + "integrity": "sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/@rollup/plugin-babel": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/@rollup/plugin-babel/-/plugin-babel-5.3.1.tgz", @@ -2324,6 +2363,55 @@ "node": ">= 8.0.0" } }, + "node_modules/@rollup/plugin-image": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@rollup/plugin-image/-/plugin-image-3.0.3.tgz", + "integrity": "sha512-qXWQwsXpvD4trSb8PeFPFajp8JLpRtqqOeNYRUKnEQNHm7e5UP7fuSRcbjQAJ7wDZBbnJvSdY5ujNBQd9B1iFg==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "mini-svg-data-uri": "^1.4.4" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-image/node_modules/@rollup/pluginutils": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.1.0.tgz", + "integrity": "sha512-XTIWOPPcpvyKI6L1NHo0lFlCyznUEyPmPY1mc3KpPVDYulHSTvyeLNVW00QTLIAFNhR3kYnJTQHeGqU4M3n09g==", + "dev": true, + "dependencies": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-image/node_modules/@types/estree": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", + "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", + "dev": true + }, "node_modules/@rollup/plugin-node-resolve": { "version": "13.1.3", "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-13.1.3.tgz", @@ -2570,6 +2658,29 @@ "integrity": "sha512-Fo79ojj3vdEZOHg3wR9ksAMRz4P3S5fDB5e/YWZiFnyFQI1WY2Vftu9XoXVVtJfxB7Bpce/QTqWSSntkz2Znrw==", "dev": true }, + "node_modules/@types/prop-types": { + "version": "15.7.11", + "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.11.tgz", + "integrity": "sha512-ga8y9v9uyeiLdpKddhxYQkxNDrfvuPrlFb0N1qnZZByvcElJaXthF1UhvCh9TLWJBEHeNtdnbysW7Y6Uq8CVng==" + }, + "node_modules/@types/react": { + "version": "18.2.45", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.45.tgz", + "integrity": "sha512-TtAxCNrlrBp8GoeEp1npd5g+d/OejJHFxS3OWmrPBMFaVQMSN0OFySozJio5BHxTuTeug00AVXVAjfDSfk+lUg==", + "dependencies": { + "@types/prop-types": "*", + "@types/scheduler": "*", + "csstype": "^3.0.2" + } + }, + "node_modules/@types/react-dom": { + "version": "18.2.18", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.2.18.tgz", + "integrity": "sha512-TJxDm6OfAX2KJWJdMEVTwWke5Sc/E/RlnPGvGfS0W7+6ocy2xhDVQVh/KvC2Uf7kACs+gDytdusDSdWfWkaNzw==", + "dependencies": { + "@types/react": "*" + } + }, "node_modules/@types/resolve": { "version": "1.17.1", "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz", @@ -2579,6 +2690,11 @@ "@types/node": "*" } }, + "node_modules/@types/scheduler": { + "version": "0.16.8", + "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.8.tgz", + "integrity": "sha512-WZLiwShhwLRmeV6zH+GkbOFT6Z6VklCItrDioxUnv+u4Ll+8vKeFySoFyK/0ctcRpOmwAicELfmys1sDc/Rw+A==" + }, "node_modules/@types/semver": { "version": "7.3.9", "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.3.9.tgz", @@ -3659,6 +3775,11 @@ "integrity": "sha512-b0tGHbfegbhPJpxpiBPU2sCkigAqtM9O121le6bbOlgyV+NyGyCmVfJ6QW9eRjz8CpNfWEOYBIMIGRYkLwsIYg==", "dev": true }, + "node_modules/csstype": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", + "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==" + }, "node_modules/data-urls": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-2.0.0.tgz", @@ -5927,6 +6048,15 @@ "node": ">=6" } }, + "node_modules/mini-svg-data-uri": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/mini-svg-data-uri/-/mini-svg-data-uri-1.4.4.tgz", + "integrity": "sha512-r9deDe9p5FJUPZAk3A59wGH7Ii9YrjjWw0jmw/liSbHl2CHiyXj6FcDXDu2K3TjVAXqiJdaw3xxwlZZr9E6nHg==", + "dev": true, + "bin": { + "mini-svg-data-uri": "cli.js" + } + }, "node_modules/minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -5999,7 +6129,7 @@ "node_modules/object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", "dev": true, "engines": { "node": ">=0.10.0" @@ -6200,9 +6330,9 @@ "dev": true }, "node_modules/picomatch": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", - "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", "dev": true, "engines": { "node": ">=8.6" @@ -6282,12 +6412,6 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/pretty-format/node_modules/react-is": { - "version": "17.0.2", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", - "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==", - "dev": true - }, "node_modules/progress": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", @@ -6382,9 +6506,9 @@ } }, "node_modules/react-is": { - "version": "18.0.0", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.0.0.tgz", - "integrity": "sha512-yUcBYdBBbo3QiPsgYDcfQcIkGZHfxOaoE6HLSnr1sPzMhdyxusbfKOSUbSd/ocGi32dxcj366PsTj+5oggeKKw==", + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", + "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==", "dev": true }, "node_modules/regenerate": { @@ -6722,6 +6846,15 @@ "rollup": "^1.0.0 || ^2.0.0" } }, + "node_modules/rollup-plugin-string": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-string/-/rollup-plugin-string-3.0.0.tgz", + "integrity": "sha512-vqyzgn9QefAgeKi+Y4A7jETeIAU1zQmS6VotH6bzm/zmUQEnYkpIGRaOBPY41oiWYV4JyBoGAaBjYMYuv+6wVw==", + "dev": true, + "dependencies": { + "rollup-pluginutils": "^2.4.1" + } + }, "node_modules/rollup-plugin-terser": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz", @@ -9416,6 +9549,23 @@ "fastq": "^1.6.0" } }, + "@rollup/plugin-alias": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-alias/-/plugin-alias-5.1.0.tgz", + "integrity": "sha512-lpA3RZ9PdIG7qqhEfv79tBffNaoDuukFDrmhLqg9ifv99u/ehn+lOg30x2zmhf8AQqQUZaMk/B9fZraQ6/acDQ==", + "dev": true, + "requires": { + "slash": "^4.0.0" + }, + "dependencies": { + "slash": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-4.0.0.tgz", + "integrity": "sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==", + "dev": true + } + } + }, "@rollup/plugin-babel": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/@rollup/plugin-babel/-/plugin-babel-5.3.1.tgz", @@ -9463,6 +9613,35 @@ } } }, + "@rollup/plugin-image": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@rollup/plugin-image/-/plugin-image-3.0.3.tgz", + "integrity": "sha512-qXWQwsXpvD4trSb8PeFPFajp8JLpRtqqOeNYRUKnEQNHm7e5UP7fuSRcbjQAJ7wDZBbnJvSdY5ujNBQd9B1iFg==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^5.0.1", + "mini-svg-data-uri": "^1.4.4" + }, + "dependencies": { + "@rollup/pluginutils": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.1.0.tgz", + "integrity": "sha512-XTIWOPPcpvyKI6L1NHo0lFlCyznUEyPmPY1mc3KpPVDYulHSTvyeLNVW00QTLIAFNhR3kYnJTQHeGqU4M3n09g==", + "dev": true, + "requires": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^2.3.1" + } + }, + "@types/estree": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", + "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", + "dev": true + } + } + }, "@rollup/plugin-node-resolve": { "version": "13.1.3", "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-13.1.3.tgz", @@ -9680,6 +9859,29 @@ "integrity": "sha512-Fo79ojj3vdEZOHg3wR9ksAMRz4P3S5fDB5e/YWZiFnyFQI1WY2Vftu9XoXVVtJfxB7Bpce/QTqWSSntkz2Znrw==", "dev": true }, + "@types/prop-types": { + "version": "15.7.11", + "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.11.tgz", + "integrity": "sha512-ga8y9v9uyeiLdpKddhxYQkxNDrfvuPrlFb0N1qnZZByvcElJaXthF1UhvCh9TLWJBEHeNtdnbysW7Y6Uq8CVng==" + }, + "@types/react": { + "version": "18.2.45", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.45.tgz", + "integrity": "sha512-TtAxCNrlrBp8GoeEp1npd5g+d/OejJHFxS3OWmrPBMFaVQMSN0OFySozJio5BHxTuTeug00AVXVAjfDSfk+lUg==", + "requires": { + "@types/prop-types": "*", + "@types/scheduler": "*", + "csstype": "^3.0.2" + } + }, + "@types/react-dom": { + "version": "18.2.18", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.2.18.tgz", + "integrity": "sha512-TJxDm6OfAX2KJWJdMEVTwWke5Sc/E/RlnPGvGfS0W7+6ocy2xhDVQVh/KvC2Uf7kACs+gDytdusDSdWfWkaNzw==", + "requires": { + "@types/react": "*" + } + }, "@types/resolve": { "version": "1.17.1", "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz", @@ -9689,6 +9891,11 @@ "@types/node": "*" } }, + "@types/scheduler": { + "version": "0.16.8", + "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.8.tgz", + "integrity": "sha512-WZLiwShhwLRmeV6zH+GkbOFT6Z6VklCItrDioxUnv+u4Ll+8vKeFySoFyK/0ctcRpOmwAicELfmys1sDc/Rw+A==" + }, "@types/semver": { "version": "7.3.9", "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.3.9.tgz", @@ -10468,6 +10675,11 @@ } } }, + "csstype": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", + "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==" + }, "data-urls": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-2.0.0.tgz", @@ -12212,6 +12424,12 @@ "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", "dev": true }, + "mini-svg-data-uri": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/mini-svg-data-uri/-/mini-svg-data-uri-1.4.4.tgz", + "integrity": "sha512-r9deDe9p5FJUPZAk3A59wGH7Ii9YrjjWw0jmw/liSbHl2CHiyXj6FcDXDu2K3TjVAXqiJdaw3xxwlZZr9E6nHg==", + "dev": true + }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -12275,7 +12493,7 @@ "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", "dev": true }, "object-keys": { @@ -12428,9 +12646,9 @@ "dev": true }, "picomatch": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", - "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", "dev": true }, "pirates": { @@ -12476,12 +12694,6 @@ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", "dev": true - }, - "react-is": { - "version": "17.0.2", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", - "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==", - "dev": true } } }, @@ -12550,9 +12762,9 @@ } }, "react-is": { - "version": "18.0.0", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.0.0.tgz", - "integrity": "sha512-yUcBYdBBbo3QiPsgYDcfQcIkGZHfxOaoE6HLSnr1sPzMhdyxusbfKOSUbSd/ocGi32dxcj366PsTj+5oggeKKw==", + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", + "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==", "dev": true }, "regenerate": { @@ -12811,6 +13023,15 @@ "magic-string": "0.25.7" } }, + "rollup-plugin-string": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-string/-/rollup-plugin-string-3.0.0.tgz", + "integrity": "sha512-vqyzgn9QefAgeKi+Y4A7jETeIAU1zQmS6VotH6bzm/zmUQEnYkpIGRaOBPY41oiWYV4JyBoGAaBjYMYuv+6wVw==", + "dev": true, + "requires": { + "rollup-pluginutils": "^2.4.1" + } + }, "rollup-plugin-terser": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz", diff --git a/package.json b/package.json index e196bcb..db69001 100644 --- a/package.json +++ b/package.json @@ -40,9 +40,11 @@ "@babel/plugin-transform-typescript": "^7.16.1", "@babel/preset-env": "^7.16.11", "@babel/preset-typescript": "^7.16.0", + "@rollup/plugin-alias": "^5.1.0", "@rollup/plugin-babel": "^5.3.1", "@rollup/plugin-commonjs": "^21.0.3", "@rollup/plugin-eslint": "^8.0.1", + "@rollup/plugin-image": "^3.0.3", "@rollup/plugin-node-resolve": "^13.1.3", "@rollup/plugin-replace": "^4.0.0", "@rollup/plugin-typescript": "^8.3.1", @@ -56,7 +58,6 @@ "prettier": "^2.6.2", "react": "^17.0.2", "react-dom": "^17.0.2", - "react-is": "^18.0.0", "rimraf": "^3.0.2", "rollup": "^2.74.0", "rollup-plugin-copy": "^3.4.0", @@ -64,11 +65,16 @@ "rollup-plugin-node-polyfills": "^0.2.1", "rollup-plugin-peer-deps-external": "^2.2.4", "rollup-plugin-prettier": "^2.2.2", + "rollup-plugin-string": "^3.0.0", "rollup-plugin-terser": "^7.0.2", "rollup-plugin-typescript2": "^0.31.2", "ts-jest": "^27.1.4", "tslib": "^2.3.1", "typedoc": "^0.23.1", "typescript": "^4.6.3" + }, + "dependencies": { + "@types/react": "^18.2.45", + "@types/react-dom": "^18.2.18" } } diff --git a/rollup.config.comp.js b/rollup.config.comp.js index 56c45bd..aa94568 100644 --- a/rollup.config.comp.js +++ b/rollup.config.comp.js @@ -1,8 +1,10 @@ -import resolve from "@rollup/plugin-node-resolve"; import commonjs from "@rollup/plugin-commonjs"; import typescript from "@rollup/plugin-typescript"; -import nodePolyfills from 'rollup-plugin-node-polyfills'; import replace from '@rollup/plugin-replace'; +import { string } from "rollup-plugin-string"; +import image from '@rollup/plugin-image'; +import alias from '@rollup/plugin-alias'; +import path from 'path'; const globals = { "react": "React", @@ -27,12 +29,18 @@ export default [ replace({ "process.env.NODE_ENV": JSON.stringify("production") }), - nodePolyfills(), - resolve({ - browser: true - }), commonjs(), typescript({ tsconfig: "./tsconfig.comp.json" }), + alias({ + entries: { + '@panelAssets': path.resolve(__dirname, './src/components/Admin/assets') + } + }), + image(), + string({ + // Required to be specified + include: "**/*.css", + }), { name: 'modify-output', renderChunk: (source) => { diff --git a/rollup.config.main.js b/rollup.config.main.js index 202261c..dfb9452 100644 --- a/rollup.config.main.js +++ b/rollup.config.main.js @@ -5,10 +5,15 @@ import dts from "rollup-plugin-dts"; import copy from "rollup-plugin-copy"; import nodePolyfills from 'rollup-plugin-node-polyfills'; import replace from '@rollup/plugin-replace'; +import { string } from "rollup-plugin-string"; +import image from '@rollup/plugin-image'; +import alias from '@rollup/plugin-alias'; +import path from 'path'; -import React from 'react'; -import ReactIs from 'react-is'; -import ReactDOM from 'react-dom'; +const globals = { + "react": "React", + "react-dom": "ReactDOM" +}; const packageJson = require("./package.json"); @@ -19,16 +24,17 @@ export default [ { file: packageJson.main, format: "cjs", - sourcemap: true, name: "Apiker", - exports: "named" + exports: "named", + globals }, { file: packageJson.module, format: "esm", - sourcemap: true + globals } ], + external: Object.keys(globals), plugins: [ replace({ "process.env.NODE_ENV": JSON.stringify("production") @@ -37,15 +43,18 @@ export default [ resolve({ browser: true }), - commonjs({ - include: /node_modules/, - namedExports: { - 'react-is': Object.keys(ReactIs), - 'react': Object.keys(React), - 'react-dom': Object.keys(ReactDOM) + commonjs(), + typescript({ tsconfig: "./tsconfig.json" }), + alias({ + entries: { + '@panelAssets': path.resolve(__dirname, './src/components/Admin/assets') } }), - typescript({ tsconfig: "./tsconfig.json" }), + image(), + string({ + // Required to be specified + include: "**/*.css", + }), copy({ targets: [ { src: "plugins/PostBuild.js", dest: "dist/plugins" }, diff --git a/src/components/Admin/Admin.ts b/src/components/Admin/Admin.ts index 83da8d3..6df9190 100644 --- a/src/components/Admin/Admin.ts +++ b/src/components/Admin/Admin.ts @@ -1,23 +1,14 @@ -import { adminPanelBanId } from "./BanId"; -import { Handler, RequestParams } from "../Request"; +import { Handler } from "../Request"; import { resRaw } from "../Response"; import { apikerPagesStatic } from "../Static"; -import { adminPanelBans } from "./Bans"; -import { adminPanelDashboard } from "./Dashboard"; -import { adminWhitelistMiddleware } from "./middleware"; -import { adminPanelSetup } from "./Setup"; -import { adminPanelVisitors } from "./Visitors"; +import { adminPanelPage } from "./Panel"; /** * Responses */ export const getAdminRoutes = () => ({ - "/admp": adminPanelSetup, - "/admp/static.js": adminPanelStatic, - "/admp/dashboard": (params: RequestParams) => adminWhitelistMiddleware(params, adminPanelDashboard), - "/admp/visitors": (params: RequestParams) => adminWhitelistMiddleware(params, adminPanelVisitors), - "/admp/bans": (params: RequestParams) => adminWhitelistMiddleware(params, adminPanelBans), - "/admp/banid": (params: RequestParams) => adminWhitelistMiddleware(params, adminPanelBanId), + "/admp": adminPanelPage, + "/admp/static.js": adminPanelStatic }); export const adminPanelStatic: Handler = () => { diff --git a/src/components/Admin/BanId.tsx b/src/components/Admin/BanId.tsx deleted file mode 100644 index d75bd7e..0000000 --- a/src/components/Admin/BanId.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import { Handler } from '../Request'; -import React from "react"; -import { wrapReactPage } from '../Page'; -import { PanelHeader } from './Header'; -import { apiker } from '../Apiker'; -import { res_404 } from '../Response'; -import { banSignedIP, unbanSignedIP } from '../Bans'; - -export const adminPanelBanId: Handler = async (params) => { - const currentSection = "bans"; - const rateLimitMax = apiker.responseHeaders.get("X-RateLimit-Limit"); - const rateLimitRemaining = apiker.responseHeaders.get("X-RateLimit-Remaining"); - - const { body } = params; - const { id: bannedId, unbanid: unbannedId } = body || {}; - - if(!(bannedId || unbannedId)){ - return res_404(); - } - - if(bannedId){ - await banSignedIP(bannedId); - } else if(unbannedId){ - await unbanSignedIP(unbannedId); - } - - const operatingId = bannedId || unbannedId; - - const props = { operatingId, currentSection, rateLimitMax, rateLimitRemaining }; - return wrapReactPage('AdminPanelBanId', AdminPanelBanId, props); -} - -export const AdminPanelBanId: React.FC = ({ currentSection, operatingId, rateLimitMax, rateLimitRemaining }) => { - setTimeout(() => { - window.location.href = '/admp/bans'; - }, 2000); - - return ( - - -
-
-
-

- Operation completed on id {operatingId} -

-
-
-
-
- ) -}; diff --git a/src/components/Admin/Bans.tsx b/src/components/Admin/Bans.tsx deleted file mode 100644 index 1f2ff91..0000000 --- a/src/components/Admin/Bans.tsx +++ /dev/null @@ -1,89 +0,0 @@ -import { Handler } from '../Request'; -import React from "react"; -import { getFlagEmoji, wrapReactPage } from '../Page'; -import { getSignedIp } from '../Auth'; -import { PanelHeader } from './Header'; -import { LogObject } from '../Logging'; -import { getBannedSignedIPs } from '../Bans'; -import { apiker } from '../Apiker'; - -export const adminPanelBans: Handler = async (params) => { - const currentSection = "bans"; - - const latestBans = (await getBannedSignedIPs(50)).sort((a, b) => b.time - a.time); - const currentId = getSignedIp(); - const rateLimitMax = apiker.responseHeaders.get("X-RateLimit-Limit"); - const rateLimitRemaining = apiker.responseHeaders.get("X-RateLimit-Remaining"); - - const props = { currentSection, latestBans, currentId, rateLimitMax, rateLimitRemaining }; - return wrapReactPage('AdminPanelBans', AdminPanelBans, props); -} - -export const AdminPanelBans: React.FC = ({ currentSection, latestBans, currentId, rateLimitMax, rateLimitRemaining }) => { - return ( - - -
-
-
-
-
Ban user
-
-
-
- -
-
- -
-
-
-
-
-
-
-
Unban user
-
-
-
- -
-
- -
-
-
-
-
-
-
-
-
Latest Bans
- - - - - - - - - - - {latestBans.map(({ time, id, countryCode, pathname }: LogObject) => { - return ( - - - - - - - ); - })} - -
TimeClientIdCountryPathname
{new Date(time).toLocaleString()}
{id} {currentId === id && *}
{getFlagEmoji(countryCode)}{pathname}
-
-
-
-
- ) -}; diff --git a/src/components/Admin/Content.tsx b/src/components/Admin/Content.tsx new file mode 100644 index 0000000..b0b7d8c --- /dev/null +++ b/src/components/Admin/Content.tsx @@ -0,0 +1,15 @@ +import React from "react"; + +export const Content = ({ children } = {} as any) => { + return ( +
+
+
+
+ {children} +
+
+
+
+ ); +}; \ No newline at end of file diff --git a/src/components/Admin/Dashboard.tsx b/src/components/Admin/Dashboard.tsx deleted file mode 100644 index 3dbb98a..0000000 --- a/src/components/Admin/Dashboard.tsx +++ /dev/null @@ -1,98 +0,0 @@ -import { Handler } from '../Request'; -import React from "react"; -import { getFlagEmoji, wrapReactPage } from '../Page'; -import { getCurrentUser, getSignedIp, isUserAdmin } from '../Auth'; -import { adminPanelLogin } from './Login'; -import { PanelHeader } from './Header'; -import { getAllLogEntries, getLogEntries, LogObject } from '../Logging'; -import { getBannedSignedIPs } from '../Bans'; -import { FIREWALL_RATELIMIT_PREFIX } from '../Firewall'; -import { OBN } from '../ObjectBase'; -import { apiker } from '../Apiker'; -import { res_401 } from '../Response'; - -export const adminPanelDashboard: Handler = async (params) => { - const user = await getCurrentUser(); - - if(!user){ - return adminPanelLogin(params); - } - - if(!isUserAdmin(user.id)){ - return res_401(); - } - - const latestBans = (await getBannedSignedIPs()).sort((a, b) => b.time - a.time); - const latestVisitors = (await getLogEntries(FIREWALL_RATELIMIT_PREFIX, 5, OBN.RATELIMIT)).sort((a, b) => b.time - a.time); - const allVisitorsCount = (await getAllLogEntries(OBN.RATELIMIT)).length; - const currentId = getSignedIp(); - const rateLimitMax = apiker.responseHeaders.get("X-RateLimit-Limit"); - const rateLimitRemaining = apiker.responseHeaders.get("X-RateLimit-Remaining"); - - const props = { latestBans, latestVisitors, allVisitorsCount, currentId, rateLimitMax, rateLimitRemaining }; - return wrapReactPage('AdminPanelDashboard', AdminPanelDashboard, props); -} - -export const AdminPanelDashboard: React.FC = ({ latestBans, latestVisitors, allVisitorsCount, currentId, rateLimitMax, rateLimitRemaining }) => { - return ( - - -
-
-
-
Latest Visitors ({allVisitorsCount})
- - - - - - - - - - - {latestVisitors.map(({ time, id, countryCode, pathname }: LogObject) => { - return ( - - - - - - - ); - })} - -
TimeClientIdCountryPathname
{new Date(time).toLocaleString()}
{id} {currentId === id && *}
{getFlagEmoji(countryCode)}{pathname}
- -
-
-
Latest Bans
- - - - - - - - - - - {latestBans.map(({ time, id, countryCode, pathname }: LogObject) => { - return ( - - - - - - - ); - })} - -
TimeClientIdCountryPathname
{new Date(time).toLocaleString()}
{id} {currentId === id && *}
{getFlagEmoji(countryCode)}{pathname}
- -
-
-
-
- ) -}; diff --git a/src/components/Admin/Header.tsx b/src/components/Admin/Header.tsx index 89b5aa0..4a5e7e0 100644 --- a/src/components/Admin/Header.tsx +++ b/src/components/Admin/Header.tsx @@ -1,52 +1,13 @@ import React from "react"; -import { PortalSection, PortalSections } from "./interfaces"; -export const PanelHeader: React.FC = ({ currentSection = "home", rateLimitMax, rateLimitRemaining }) => { - const sections: PortalSections = [ - { - name: "home", - title: "Home", - link: "/admp/dashboard" - }, - { - name: "visitors", - title: "Visitors", - link: "/admp/visitors" - }, - { - name: "bans", - title: "Bans", - link: "/admp/bans" - } - ]; - - const renderSection = ({ name, title, children = [], link = "#" }: Partial) => { - return ( -
  • - {title} - {children.length ?
      {children.map(renderSection)}
    : null} -
  • - ); - } +//@ts-ignore +import logo from "@panelAssets/images/logo.svg"; +export const Header = ({ children } = {} as any) => { return ( -