diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c7a14995..ec9d3b1d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -19,17 +19,23 @@ jobs: with: persist-credentials: false - - uses: actions/setup-node@v3 + - name: Setup Node 🧰 + uses: actions/setup-node@v3 with: node-version: 16 - - run: npm ci + - name: Install Dependencies 🗂 + run: npm ci - - run: npm run build --if-present + - name: Build 🛠 + run: | + export NODE_OPTIONS="--max_old_space_size=4096" + npm run build --if-present - - run: npm run test + - name: Test 🔧 + run: npm run test lint: - name: format and lint + name: Format & Lint runs-on: ubuntu-latest steps: - name: Checkout 🛎️ @@ -37,11 +43,13 @@ jobs: with: persist-credentials: false - - uses: actions/setup-node@v3 + - name: Setup Node 🧰 + uses: actions/setup-node@v3 with: node-version: 16 - - run: npm ci - - run: npm run format + - name: Install Dependencies 🗂 + run: npm ci - - run: npm run lint + - name: Lint 💄 + run: npm run lint diff --git a/.gitignore b/.gitignore index 72eca3f1..71e917b9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,13 @@ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. # dependencies -/node_modules +**/node_modules /.pnp .pnp.js -pnpm-lock.yaml +**/pnpm-lock.yaml # testing -/coverage +**/coverage # next.js /.next/ @@ -15,7 +15,9 @@ pnpm-lock.yaml /out/ # production -/build +**/build +**/dist +**/.turbo # misc .DS_Store @@ -29,6 +31,7 @@ yarn-error.log* # local env files .env*.local +.env # vercel .vercel @@ -36,10 +39,10 @@ yarn-error.log* # typescript *.tsbuildinfo next-env.d.ts + +# intellij .idea -/dist +# generated public/sitemap-0.xml src/assets/resources/**/*.json - -.env diff --git a/package-lock.json b/package-lock.json index 8f464550..a38ca9d2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2997,6 +2997,10 @@ "react": ">=18" } }, + "node_modules/@click-prompt/click-prompt-button": { + "resolved": "packages/click-prompt-button", + "link": true + }, "node_modules/@corex/deepmerge": { "version": "4.0.37", "resolved": "https://registry.npmjs.org/@corex/deepmerge/-/deepmerge-4.0.37.tgz", @@ -6552,6 +6556,28 @@ "type-fest": "^2.0.0" } }, + "node_modules/@rollup/plugin-url": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/@rollup/plugin-url/-/plugin-url-8.0.1.tgz", + "integrity": "sha512-8ajztphXb5e19dk3Iwjtm2eSYJR8jFQubZ8pJ1GG2MBMM7/qUedLnZAN+Vt4jqbcT/m27jfjIBocvrzV0giNRw==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "make-dir": "^3.1.0", + "mime": "^3.0.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, "node_modules/@rollup/pluginutils": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.0.2.tgz", @@ -7040,6 +7066,43 @@ "@svgr/core": "*" } }, + "node_modules/@svgr/rollup": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/@svgr/rollup/-/rollup-6.5.1.tgz", + "integrity": "sha512-GeUfq0grJfpcn2jRWRaZ4npn27nnWK21vUj6MqDqknuJnEqGADcZZjO9wrUAaPLr3InAnQi0Z7nwiNUdzkaj6A==", + "dev": true, + "dependencies": { + "@babel/core": "^7.19.6", + "@babel/plugin-transform-react-constant-elements": "^7.18.12", + "@babel/preset-env": "^7.19.4", + "@babel/preset-react": "^7.18.6", + "@babel/preset-typescript": "^7.18.6", + "@rollup/pluginutils": "^4.2.1", + "@svgr/core": "^6.5.1", + "@svgr/plugin-jsx": "^6.5.1", + "@svgr/plugin-svgo": "^6.5.1" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/gregberge" + } + }, + "node_modules/@svgr/rollup/node_modules/@rollup/pluginutils": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-4.2.1.tgz", + "integrity": "sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==", + "dev": true, + "dependencies": { + "estree-walker": "^2.0.1", + "picomatch": "^2.2.2" + }, + "engines": { + "node": ">= 8.0.0" + } + }, "node_modules/@svgr/webpack": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/@svgr/webpack/-/webpack-6.5.1.tgz", @@ -7657,16 +7720,6 @@ "resolved": "https://registry.npmjs.org/@types/direction/-/direction-1.0.0.tgz", "integrity": "sha512-et1wmqXm/5smJ8lTJfBnwD12/2Y7eVJLKbuaRT0h2xaKAoo1h8Dz2Io22GObDLFwxY1ddXRTLH3Gq5v44Fl/2w==" }, - "node_modules/@types/eslint": { - "version": "8.4.10", - "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.4.10.tgz", - "integrity": "sha512-Sl/HOqN8NKPmhWo2VBEPm0nvHnu2LL3v9vKo8MEq0EtbJ4eVzGPl41VNPvn5E1i5poMk4/XD8UriLHpJvEP/Nw==", - "dev": true, - "dependencies": { - "@types/estree": "*", - "@types/json-schema": "*" - } - }, "node_modules/@types/estree": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.0.tgz", @@ -8438,38 +8491,6 @@ "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, - "node_modules/acorn-node": { - "version": "1.8.2", - "resolved": "https://registry.npmjs.org/acorn-node/-/acorn-node-1.8.2.tgz", - "integrity": "sha512-8mt+fslDufLYntIoPAaIMUe/lrbrehIiwmR3t2k9LljIzoigEPF27eLk2hy8zSGzmR/ogr7zbRKINMo1u0yh5A==", - "dev": true, - "dependencies": { - "acorn": "^7.0.0", - "acorn-walk": "^7.0.0", - "xtend": "^4.0.2" - } - }, - "node_modules/acorn-node/node_modules/acorn": { - "version": "7.4.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", - "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", - "dev": true, - "bin": { - "acorn": "bin/acorn" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/acorn-node/node_modules/acorn-walk": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.2.0.tgz", - "integrity": "sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA==", - "dev": true, - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/acorn-walk": { "version": "8.2.0", "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", @@ -8567,6 +8588,12 @@ "node": ">=4" } }, + "node_modules/any-promise": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", + "integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==", + "dev": true + }, "node_modules/anymatch": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", @@ -9437,10 +9464,6 @@ "resolved": "packages/click-prompt", "link": true }, - "node_modules/click-prompt-button": { - "resolved": "packages/click-prompt-button", - "link": true - }, "node_modules/client-only": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/client-only/-/client-only-0.0.1.tgz", @@ -10532,15 +10555,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/defined": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.1.tgz", - "integrity": "sha512-hsBd2qSVCRE+5PmNdHt1uzyrFu5d3RwmFDKzyNZMFq/EwDNJF7Ee5+D5oEKF0hU6LhtoUF1macFvOe4AskQC1Q==", - "dev": true, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/delaunator": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/delaunator/-/delaunator-5.0.0.tgz", @@ -10587,23 +10601,6 @@ "resolved": "https://registry.npmjs.org/detect-node-es/-/detect-node-es-1.1.0.tgz", "integrity": "sha512-ypdmJU/TbBby2Dxibuv7ZLW3Bs1QEmM7nHjEANfohJLvE0XVujisn1qPJcZxg+qDucsr+bP6fLD1rPS3AhJ7EQ==" }, - "node_modules/detective": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/detective/-/detective-5.2.1.tgz", - "integrity": "sha512-v9XE1zRnz1wRtgurGu0Bs8uHKFSTdteYZNbIPFVhUZ39L/S79ppMpdmVOZAnoz1jfEFodc48n6MX483Xo3t1yw==", - "dev": true, - "dependencies": { - "acorn-node": "^1.8.2", - "defined": "^1.0.0", - "minimist": "^1.2.6" - }, - "bin": { - "detective": "bin/detective.js" - }, - "engines": { - "node": ">=0.8.0" - } - }, "node_modules/didyoumean": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz", @@ -11205,6 +11202,10 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/eslint-config-custom": { + "resolved": "packages/eslint-config-custom", + "link": true + }, "node_modules/eslint-config-next": { "version": "13.2.3", "resolved": "https://registry.npmjs.org/eslint-config-next/-/eslint-config-next-13.2.3.tgz", @@ -15330,6 +15331,15 @@ "url": "https://github.com/chalk/supports-color?sponsor=1" } }, + "node_modules/jiti": { + "version": "1.18.2", + "resolved": "https://registry.npmjs.org/jiti/-/jiti-1.18.2.tgz", + "integrity": "sha512-QAdOptna2NYiSSpv0O/BwoHBSmz4YhpzJHyi+fnMRTXFjp7B8i/YG5Z8IfusxB1ufjcD2Sre1F3R+nX3fvy7gg==", + "dev": true, + "bin": { + "jiti": "bin/jiti.js" + } + }, "node_modules/jju": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/jju/-/jju-1.4.0.tgz", @@ -17040,6 +17050,18 @@ "node": ">=8.6" } }, + "node_modules/mime": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-3.0.0.tgz", + "integrity": "sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==", + "dev": true, + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=10.0.0" + } + }, "node_modules/mime-db": { "version": "1.52.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", @@ -17176,6 +17198,17 @@ } } }, + "node_modules/mz": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", + "integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==", + "dev": true, + "dependencies": { + "any-promise": "^1.0.0", + "object-assign": "^4.0.1", + "thenify-all": "^1.0.0" + } + }, "node_modules/nano-css": { "version": "5.3.5", "resolved": "https://registry.npmjs.org/nano-css/-/nano-css-5.3.5.tgz", @@ -20129,6 +20162,56 @@ "resolved": "https://registry.npmjs.org/stylis/-/stylis-4.1.3.tgz", "integrity": "sha512-GP6WDNWf+o403jrEp9c5jibKavrtLW+/qYGhFxFrG8maXhwTBI7gLLhiBb0o7uFccWN+EOS9aMO6cGHWAO07OA==" }, + "node_modules/sucrase": { + "version": "3.31.0", + "resolved": "https://registry.npmjs.org/sucrase/-/sucrase-3.31.0.tgz", + "integrity": "sha512-6QsHnkqyVEzYcaiHsOKkzOtOgdJcb8i54x6AV2hDwyZcY9ZyykGZVw6L/YN98xC0evwTP6utsWWrKRaa8QlfEQ==", + "dev": true, + "dependencies": { + "commander": "^4.0.0", + "glob": "7.1.6", + "lines-and-columns": "^1.1.6", + "mz": "^2.7.0", + "pirates": "^4.0.1", + "ts-interface-checker": "^0.1.9" + }, + "bin": { + "sucrase": "bin/sucrase", + "sucrase-node": "bin/sucrase-node" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/sucrase/node_modules/commander": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", + "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", + "dev": true, + "engines": { + "node": ">= 6" + } + }, + "node_modules/sucrase/node_modules/glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "dependencies": { + "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" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -20228,20 +20311,20 @@ } }, "node_modules/tailwindcss": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.2.7.tgz", - "integrity": "sha512-B6DLqJzc21x7wntlH/GsZwEXTBttVSl1FtCzC8WP4oBc/NKef7kaax5jeihkkCEWc831/5NDJ9gRNDK6NEioQQ==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.3.0.tgz", + "integrity": "sha512-hOXlFx+YcklJ8kXiCAfk/FMyr4Pm9ck477G0m/us2344Vuj355IpoEDB5UmGAsSpTBmr+4ZhjzW04JuFXkb/fw==", "dev": true, "dependencies": { "arg": "^5.0.2", "chokidar": "^3.5.3", "color-name": "^1.1.4", - "detective": "^5.2.1", "didyoumean": "^1.2.2", "dlv": "^1.1.3", "fast-glob": "^3.2.12", "glob-parent": "^6.0.2", "is-glob": "^4.0.3", + "jiti": "^1.17.2", "lilconfig": "^2.0.6", "micromatch": "^4.0.5", "normalize-path": "^3.0.0", @@ -20255,7 +20338,8 @@ "postcss-selector-parser": "^6.0.11", "postcss-value-parser": "^4.2.0", "quick-lru": "^5.1.1", - "resolve": "^1.22.1" + "resolve": "^1.22.1", + "sucrase": "^3.29.0" }, "bin": { "tailwind": "lib/cli.js", @@ -20329,6 +20413,27 @@ "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "dev": true }, + "node_modules/thenify": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz", + "integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==", + "dev": true, + "dependencies": { + "any-promise": "^1.0.0" + } + }, + "node_modules/thenify-all": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz", + "integrity": "sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==", + "dev": true, + "dependencies": { + "thenify": ">= 3.1.0 < 4" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/throttle-debounce": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/throttle-debounce/-/throttle-debounce-3.0.1.tgz", @@ -20457,6 +20562,12 @@ "resolved": "https://registry.npmjs.org/ts-easing/-/ts-easing-0.2.0.tgz", "integrity": "sha512-Z86EW+fFFh/IFB1fqQ3/+7Zpf9t2ebOAxNI/V6Wo7r5gqiqtxmgTlQ1qbqQcjLKYeSHPTsEmvlJUDg/EuL0uHQ==" }, + "node_modules/ts-interface-checker": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz", + "integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==", + "dev": true + }, "node_modules/ts-morph": { "version": "17.0.1", "resolved": "https://registry.npmjs.org/ts-morph/-/ts-morph-17.0.1.tgz", @@ -20487,6 +20598,10 @@ } } }, + "node_modules/tsconfig": { + "resolved": "packages/tsconfig", + "link": true + }, "node_modules/tsconfig-paths": { "version": "3.14.2", "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.2.tgz", @@ -21230,224 +21345,6 @@ "node": ">=12" } }, - "node_modules/vite-plugin-linter": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/vite-plugin-linter/-/vite-plugin-linter-2.0.2.tgz", - "integrity": "sha512-ssIrqn9k+eVFw5D6jPyNA7qWmzQBilTZQyv0SxPGl1TZacae/mzue9253kT1VklcrVtPMua1KOSmrop95Vp/gg==", - "dev": true, - "dependencies": { - "@rollup/pluginutils": "5.0.2", - "@types/eslint": "8.4.10", - "chokidar": "3.5.3", - "eslint": "8.29.0", - "typescript": "4.9.3" - }, - "bin": { - "vite-plugin-linter": "dist/lintCommand.js" - } - }, - "node_modules/vite-plugin-linter/node_modules/@eslint/eslintrc": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.4.1.tgz", - "integrity": "sha512-XXrH9Uarn0stsyldqDYq8r++mROmWRI1xKMXa640Bb//SY1+ECYX6VzT6Lcx5frD0V30XieqJ0oX9I2Xj5aoMA==", - "dev": true, - "dependencies": { - "ajv": "^6.12.4", - "debug": "^4.3.2", - "espree": "^9.4.0", - "globals": "^13.19.0", - "ignore": "^5.2.0", - "import-fresh": "^3.2.1", - "js-yaml": "^4.1.0", - "minimatch": "^3.1.2", - "strip-json-comments": "^3.1.1" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/vite-plugin-linter/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/vite-plugin-linter/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/vite-plugin-linter/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/vite-plugin-linter/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "node_modules/vite-plugin-linter/node_modules/eslint": { - "version": "8.29.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.29.0.tgz", - "integrity": "sha512-isQ4EEiyUjZFbEKvEGJKKGBwXtvXX+zJbkVKCgTuB9t/+jUBcy8avhkEwWJecI15BkRkOYmvIM5ynbhRjEkoeg==", - "dev": true, - "dependencies": { - "@eslint/eslintrc": "^1.3.3", - "@humanwhocodes/config-array": "^0.11.6", - "@humanwhocodes/module-importer": "^1.0.1", - "@nodelib/fs.walk": "^1.2.8", - "ajv": "^6.10.0", - "chalk": "^4.0.0", - "cross-spawn": "^7.0.2", - "debug": "^4.3.2", - "doctrine": "^3.0.0", - "escape-string-regexp": "^4.0.0", - "eslint-scope": "^7.1.1", - "eslint-utils": "^3.0.0", - "eslint-visitor-keys": "^3.3.0", - "espree": "^9.4.0", - "esquery": "^1.4.0", - "esutils": "^2.0.2", - "fast-deep-equal": "^3.1.3", - "file-entry-cache": "^6.0.1", - "find-up": "^5.0.0", - "glob-parent": "^6.0.2", - "globals": "^13.15.0", - "grapheme-splitter": "^1.0.4", - "ignore": "^5.2.0", - "import-fresh": "^3.0.0", - "imurmurhash": "^0.1.4", - "is-glob": "^4.0.0", - "is-path-inside": "^3.0.3", - "js-sdsl": "^4.1.4", - "js-yaml": "^4.1.0", - "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.4.1", - "lodash.merge": "^4.6.2", - "minimatch": "^3.1.2", - "natural-compare": "^1.4.0", - "optionator": "^0.9.1", - "regexpp": "^3.2.0", - "strip-ansi": "^6.0.1", - "strip-json-comments": "^3.1.0", - "text-table": "^0.2.0" - }, - "bin": { - "eslint": "bin/eslint.js" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/vite-plugin-linter/node_modules/eslint-scope": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.1.tgz", - "integrity": "sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw==", - "dev": true, - "dependencies": { - "esrecurse": "^4.3.0", - "estraverse": "^5.2.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - } - }, - "node_modules/vite-plugin-linter/node_modules/globals": { - "version": "13.20.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", - "integrity": "sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==", - "dev": true, - "dependencies": { - "type-fest": "^0.20.2" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/vite-plugin-linter/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/vite-plugin-linter/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/vite-plugin-linter/node_modules/type-fest": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", - "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/vite-plugin-linter/node_modules/typescript": { - "version": "4.9.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.3.tgz", - "integrity": "sha512-CIfGzTelbKNEnLpLdGFgdyKhG23CKdKgQPOBc+OUNrkJ2vr+KSzsSV5kq5iWhEQbok+quxgGzrAtGWCyU7tHnA==", - "dev": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } - }, "node_modules/vite-tsconfig-paths": { "version": "4.0.7", "resolved": "https://registry.npmjs.org/vite-tsconfig-paths/-/vite-tsconfig-paths-4.0.7.tgz", @@ -21992,8 +21889,9 @@ "@chakra-ui/react": "^2.5.1", "@chakra-ui/spinner": "^2.0.13", "@chakra-ui/system": "^2.5.1", - "@emotion/react": "^11.10.6", - "@emotion/styled": "^11.10.6", + "@click-prompt/click-prompt-button": "*", + "@emotion/react": "11.10.6", + "@emotion/styled": "11.10.6", "@formatjs/intl-localematcher": "^0.2.32", "@planetscale/database": "^1.6.0", "@remirror/pm": "^2.0.4", @@ -22037,7 +21935,6 @@ "server-only": "^0.0.1", "sharp": "^0.31.3", "svg-pan-zoom": "^3.6.1", - "typescript": "4.9.5", "use-debounce": "^9.0.3" }, "devDependencies": { @@ -22062,6 +21959,7 @@ "autoprefixer": "^10.4.13", "cross-env": "^7.0.3", "eslint": "8.35.0", + "eslint-config-custom": "*", "eslint-config-next": "13.2.3", "eslint-config-prettier": "^8.6.0", "eslint-plugin-prettier": "^4.2.1", @@ -22072,7 +21970,9 @@ "postcss": "^8.4.21", "prettier": "^2.8.4", "tailwindcss": "^3.2.7", + "tsconfig": "*", "tunnel": "^0.0.6", + "typescript": "4.9.5", "walkdir": "^0.4.1", "yaml-loader": "^0.8.0" }, @@ -22082,38 +21982,67 @@ } }, "packages/click-prompt-button": { + "name": "@click-prompt/click-prompt-button", "version": "0.1.0", "license": "MIT", "dependencies": { - "@chakra-ui/icons": "^2.0.17", "@chakra-ui/react": "^2.5.1", - "@chakra-ui/spinner": "^2.0.13", "@chakra-ui/system": "^2.5.1", - "@emotion/react": "^11.10.6", - "@emotion/styled": "^11.10.6", + "@emotion/react": "11.10.6", + "@emotion/styled": "11.10.6", "client-only": "^0.0.1", + "framer-motion": "^10.0.1", "mermaid": "^10.0.2", - "react": "^18.2.0", - "react-dom": "^18.2.0", + "next": "13.2.4", + "react": "18.2.0", + "react-dom": "18.2.0", "react-markdown": "^8.0.5", "react-spinners": "^0.13.8", "react-syntax-highlighter": "^15.5.0", "remark-gfm": "^3.0.1", - "svg-pan-zoom": "^3.6.1" + "svg-pan-zoom": "^3.6.1", + "use-debounce": "^9.0.3" }, "devDependencies": { + "@rollup/plugin-url": "^8.0.1", + "@svgr/rollup": "^6.5.1", + "@types/node": "18.14.5", + "@types/react": "18.0.28", + "@types/react-dom": "18.0.11", + "@types/react-syntax-highlighter": "^15.5.6", + "@typescript-eslint/eslint-plugin": "^5.54.1", "@vitejs/plugin-react": "^3.1.0", + "autoprefixer": "^10.4.13", + "eslint": "8.35.0", + "eslint-config-custom": "*", + "eslint-config-prettier": "^8.6.0", + "postcss": "^8.4.21", + "prettier": "^2.8.4", + "tailwindcss": "^3.2.7", + "tsconfig": "*", + "typescript": "4.9.5", "vite": "^4.2.1", "vite-plugin-dts": "^2.1.0", - "vite-plugin-linter": "^2.0.2", "vite-tsconfig-paths": "^4.0.7" }, "peerDependencies": { - "next": ">=13.0.0", - "react": ">=16.8.0", - "react-dom": ">=16.8.0" + "@emotion/react": "11.10.6", + "@emotion/styled": "11.10.6", + "next": "^13.2.4", + "react": "^18.2.0", + "react-dom": "^18.2.0" } - } + }, + "packages/click-prompt/click-prompt-button": { + "extraneous": true + }, + "packages/eslint-config-custom": { + "version": "1.0.0", + "devDependencies": { + "eslint": "latest" + } + }, + "packages/tsconfig": {} }, "dependencies": { "@adobe/css-tools": { @@ -24261,6 +24190,47 @@ "integrity": "sha512-WWULIiucYRBIewHKFA7BssQ2ABLHLVd9lrUo3N3SZgR0u4ZRDDVEUNOy+r+9ruDze8+36dGbN9wsN1IdELtdOw==", "requires": {} }, + "@click-prompt/click-prompt-button": { + "version": "file:packages/click-prompt-button", + "requires": { + "@chakra-ui/react": "^2.5.1", + "@chakra-ui/system": "^2.5.1", + "@emotion/react": "11.10.6", + "@emotion/styled": "11.10.6", + "@rollup/plugin-url": "^8.0.1", + "@svgr/rollup": "^6.5.1", + "@types/node": "18.14.5", + "@types/react": "18.0.28", + "@types/react-dom": "18.0.11", + "@types/react-syntax-highlighter": "^15.5.6", + "@typescript-eslint/eslint-plugin": "^5.54.1", + "@vitejs/plugin-react": "^3.1.0", + "autoprefixer": "^10.4.13", + "client-only": "^0.0.1", + "eslint": "8.35.0", + "eslint-config-custom": "*", + "eslint-config-prettier": "^8.6.0", + "framer-motion": "^10.0.1", + "mermaid": "^10.0.2", + "next": "13.2.4", + "postcss": "^8.4.21", + "prettier": "^2.8.4", + "react": "18.2.0", + "react-dom": "18.2.0", + "react-markdown": "^8.0.5", + "react-spinners": "^0.13.8", + "react-syntax-highlighter": "^15.5.0", + "remark-gfm": "^3.0.1", + "svg-pan-zoom": "^3.6.1", + "tailwindcss": "^3.2.7", + "tsconfig": "*", + "typescript": "4.9.5", + "use-debounce": "^9.0.3", + "vite": "^4.2.1", + "vite-plugin-dts": "^2.1.0", + "vite-tsconfig-paths": "^4.0.7" + } + }, "@corex/deepmerge": { "version": "4.0.37", "resolved": "https://registry.npmjs.org/@corex/deepmerge/-/deepmerge-4.0.37.tgz", @@ -26688,6 +26658,17 @@ "type-fest": "^2.0.0" } }, + "@rollup/plugin-url": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/@rollup/plugin-url/-/plugin-url-8.0.1.tgz", + "integrity": "sha512-8ajztphXb5e19dk3Iwjtm2eSYJR8jFQubZ8pJ1GG2MBMM7/qUedLnZAN+Vt4jqbcT/m27jfjIBocvrzV0giNRw==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^5.0.1", + "make-dir": "^3.1.0", + "mime": "^3.0.0" + } + }, "@rollup/pluginutils": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.0.2.tgz", @@ -27018,6 +26999,35 @@ "svgo": "^2.8.0" } }, + "@svgr/rollup": { + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/@svgr/rollup/-/rollup-6.5.1.tgz", + "integrity": "sha512-GeUfq0grJfpcn2jRWRaZ4npn27nnWK21vUj6MqDqknuJnEqGADcZZjO9wrUAaPLr3InAnQi0Z7nwiNUdzkaj6A==", + "dev": true, + "requires": { + "@babel/core": "^7.19.6", + "@babel/plugin-transform-react-constant-elements": "^7.18.12", + "@babel/preset-env": "^7.19.4", + "@babel/preset-react": "^7.18.6", + "@babel/preset-typescript": "^7.18.6", + "@rollup/pluginutils": "^4.2.1", + "@svgr/core": "^6.5.1", + "@svgr/plugin-jsx": "^6.5.1", + "@svgr/plugin-svgo": "^6.5.1" + }, + "dependencies": { + "@rollup/pluginutils": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-4.2.1.tgz", + "integrity": "sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==", + "dev": true, + "requires": { + "estree-walker": "^2.0.1", + "picomatch": "^2.2.2" + } + } + } + }, "@svgr/webpack": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/@svgr/webpack/-/webpack-6.5.1.tgz", @@ -27553,16 +27563,6 @@ "resolved": "https://registry.npmjs.org/@types/direction/-/direction-1.0.0.tgz", "integrity": "sha512-et1wmqXm/5smJ8lTJfBnwD12/2Y7eVJLKbuaRT0h2xaKAoo1h8Dz2Io22GObDLFwxY1ddXRTLH3Gq5v44Fl/2w==" }, - "@types/eslint": { - "version": "8.4.10", - "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.4.10.tgz", - "integrity": "sha512-Sl/HOqN8NKPmhWo2VBEPm0nvHnu2LL3v9vKo8MEq0EtbJ4eVzGPl41VNPvn5E1i5poMk4/XD8UriLHpJvEP/Nw==", - "dev": true, - "requires": { - "@types/estree": "*", - "@types/json-schema": "*" - } - }, "@types/estree": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.0.tgz", @@ -28201,31 +28201,6 @@ "dev": true, "requires": {} }, - "acorn-node": { - "version": "1.8.2", - "resolved": "https://registry.npmjs.org/acorn-node/-/acorn-node-1.8.2.tgz", - "integrity": "sha512-8mt+fslDufLYntIoPAaIMUe/lrbrehIiwmR3t2k9LljIzoigEPF27eLk2hy8zSGzmR/ogr7zbRKINMo1u0yh5A==", - "dev": true, - "requires": { - "acorn": "^7.0.0", - "acorn-walk": "^7.0.0", - "xtend": "^4.0.2" - }, - "dependencies": { - "acorn": { - "version": "7.4.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", - "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", - "dev": true - }, - "acorn-walk": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.2.0.tgz", - "integrity": "sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA==", - "dev": true - } - } - }, "acorn-walk": { "version": "8.2.0", "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", @@ -28294,6 +28269,12 @@ "color-convert": "^1.9.0" } }, + "any-promise": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", + "integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==", + "dev": true + }, "anymatch": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", @@ -28905,8 +28886,9 @@ "@chakra-ui/react": "^2.5.1", "@chakra-ui/spinner": "^2.0.13", "@chakra-ui/system": "^2.5.1", - "@emotion/react": "^11.10.6", - "@emotion/styled": "^11.10.6", + "@click-prompt/click-prompt-button": "*", + "@emotion/react": "11.10.6", + "@emotion/styled": "11.10.6", "@formatjs/intl-localematcher": "^0.2.32", "@planetscale/database": "^1.6.0", "@remirror/pm": "^2.0.4", @@ -28942,6 +28924,7 @@ "dagre": "^0.8.5", "dotparser": "^1.1.1", "eslint": "8.35.0", + "eslint-config-custom": "*", "eslint-config-next": "13.2.3", "eslint-config-prettier": "^8.6.0", "eslint-plugin-prettier": "^4.2.1", @@ -28981,6 +28964,7 @@ "sharp": "^0.31.3", "svg-pan-zoom": "^3.6.1", "tailwindcss": "^3.2.7", + "tsconfig": "*", "tunnel": "^0.0.6", "typescript": "4.9.5", "use-debounce": "^9.0.3", @@ -28988,31 +28972,6 @@ "yaml-loader": "^0.8.0" } }, - "click-prompt-button": { - "version": "file:packages/click-prompt-button", - "requires": { - "@chakra-ui/icons": "^2.0.17", - "@chakra-ui/react": "^2.5.1", - "@chakra-ui/spinner": "^2.0.13", - "@chakra-ui/system": "^2.5.1", - "@emotion/react": "^11.10.6", - "@emotion/styled": "^11.10.6", - "@vitejs/plugin-react": "^3.1.0", - "client-only": "^0.0.1", - "mermaid": "^10.0.2", - "react": "^18.2.0", - "react-dom": "^18.2.0", - "react-markdown": "^8.0.5", - "react-spinners": "^0.13.8", - "react-syntax-highlighter": "^15.5.0", - "remark-gfm": "^3.0.1", - "svg-pan-zoom": "^3.6.1", - "vite": "^4.2.1", - "vite-plugin-dts": "^2.1.0", - "vite-plugin-linter": "^2.0.2", - "vite-tsconfig-paths": "^4.0.7" - } - }, "client-only": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/client-only/-/client-only-0.0.1.tgz", @@ -29846,12 +29805,6 @@ "object-keys": "^1.1.1" } }, - "defined": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.1.tgz", - "integrity": "sha512-hsBd2qSVCRE+5PmNdHt1uzyrFu5d3RwmFDKzyNZMFq/EwDNJF7Ee5+D5oEKF0hU6LhtoUF1macFvOe4AskQC1Q==", - "dev": true - }, "delaunator": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/delaunator/-/delaunator-5.0.0.tgz", @@ -29886,17 +29839,6 @@ "resolved": "https://registry.npmjs.org/detect-node-es/-/detect-node-es-1.1.0.tgz", "integrity": "sha512-ypdmJU/TbBby2Dxibuv7ZLW3Bs1QEmM7nHjEANfohJLvE0XVujisn1qPJcZxg+qDucsr+bP6fLD1rPS3AhJ7EQ==" }, - "detective": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/detective/-/detective-5.2.1.tgz", - "integrity": "sha512-v9XE1zRnz1wRtgurGu0Bs8uHKFSTdteYZNbIPFVhUZ39L/S79ppMpdmVOZAnoz1jfEFodc48n6MX483Xo3t1yw==", - "dev": true, - "requires": { - "acorn-node": "^1.8.2", - "defined": "^1.0.0", - "minimist": "^1.2.6" - } - }, "didyoumean": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz", @@ -30436,6 +30378,12 @@ } } }, + "eslint-config-custom": { + "version": "file:packages/eslint-config-custom", + "requires": { + "eslint": "latest" + } + }, "eslint-config-next": { "version": "13.2.3", "resolved": "https://registry.npmjs.org/eslint-config-next/-/eslint-config-next-13.2.3.tgz", @@ -33348,6 +33296,12 @@ } } }, + "jiti": { + "version": "1.18.2", + "resolved": "https://registry.npmjs.org/jiti/-/jiti-1.18.2.tgz", + "integrity": "sha512-QAdOptna2NYiSSpv0O/BwoHBSmz4YhpzJHyi+fnMRTXFjp7B8i/YG5Z8IfusxB1ufjcD2Sre1F3R+nX3fvy7gg==", + "dev": true + }, "jju": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/jju/-/jju-1.4.0.tgz", @@ -34524,6 +34478,12 @@ "picomatch": "^2.3.1" } }, + "mime": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-3.0.0.tgz", + "integrity": "sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==", + "dev": true + }, "mime-db": { "version": "1.52.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", @@ -34618,6 +34578,17 @@ "w3c-keyname": "^2.2.4" } }, + "mz": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", + "integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==", + "dev": true, + "requires": { + "any-promise": "^1.0.0", + "object-assign": "^4.0.1", + "thenify-all": "^1.0.0" + } + }, "nano-css": { "version": "5.3.5", "resolved": "https://registry.npmjs.org/nano-css/-/nano-css-5.3.5.tgz", @@ -36755,6 +36726,42 @@ "resolved": "https://registry.npmjs.org/stylis/-/stylis-4.1.3.tgz", "integrity": "sha512-GP6WDNWf+o403jrEp9c5jibKavrtLW+/qYGhFxFrG8maXhwTBI7gLLhiBb0o7uFccWN+EOS9aMO6cGHWAO07OA==" }, + "sucrase": { + "version": "3.31.0", + "resolved": "https://registry.npmjs.org/sucrase/-/sucrase-3.31.0.tgz", + "integrity": "sha512-6QsHnkqyVEzYcaiHsOKkzOtOgdJcb8i54x6AV2hDwyZcY9ZyykGZVw6L/YN98xC0evwTP6utsWWrKRaa8QlfEQ==", + "dev": true, + "requires": { + "commander": "^4.0.0", + "glob": "7.1.6", + "lines-and-columns": "^1.1.6", + "mz": "^2.7.0", + "pirates": "^4.0.1", + "ts-interface-checker": "^0.1.9" + }, + "dependencies": { + "commander": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", + "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", + "dev": true + }, + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "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" + } + } + } + }, "supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -36832,20 +36839,20 @@ } }, "tailwindcss": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.2.7.tgz", - "integrity": "sha512-B6DLqJzc21x7wntlH/GsZwEXTBttVSl1FtCzC8WP4oBc/NKef7kaax5jeihkkCEWc831/5NDJ9gRNDK6NEioQQ==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.3.0.tgz", + "integrity": "sha512-hOXlFx+YcklJ8kXiCAfk/FMyr4Pm9ck477G0m/us2344Vuj355IpoEDB5UmGAsSpTBmr+4ZhjzW04JuFXkb/fw==", "dev": true, "requires": { "arg": "^5.0.2", "chokidar": "^3.5.3", "color-name": "^1.1.4", - "detective": "^5.2.1", "didyoumean": "^1.2.2", "dlv": "^1.1.3", "fast-glob": "^3.2.12", "glob-parent": "^6.0.2", "is-glob": "^4.0.3", + "jiti": "^1.17.2", "lilconfig": "^2.0.6", "micromatch": "^4.0.5", "normalize-path": "^3.0.0", @@ -36859,7 +36866,8 @@ "postcss-selector-parser": "^6.0.11", "postcss-value-parser": "^4.2.0", "quick-lru": "^5.1.1", - "resolve": "^1.22.1" + "resolve": "^1.22.1", + "sucrase": "^3.29.0" }, "dependencies": { "color-name": { @@ -36916,6 +36924,24 @@ "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "dev": true }, + "thenify": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz", + "integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==", + "dev": true, + "requires": { + "any-promise": "^1.0.0" + } + }, + "thenify-all": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz", + "integrity": "sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==", + "dev": true, + "requires": { + "thenify": ">= 3.1.0 < 4" + } + }, "throttle-debounce": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/throttle-debounce/-/throttle-debounce-3.0.1.tgz", @@ -37018,6 +37044,12 @@ "resolved": "https://registry.npmjs.org/ts-easing/-/ts-easing-0.2.0.tgz", "integrity": "sha512-Z86EW+fFFh/IFB1fqQ3/+7Zpf9t2ebOAxNI/V6Wo7r5gqiqtxmgTlQ1qbqQcjLKYeSHPTsEmvlJUDg/EuL0uHQ==" }, + "ts-interface-checker": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz", + "integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==", + "dev": true + }, "ts-morph": { "version": "17.0.1", "resolved": "https://registry.npmjs.org/ts-morph/-/ts-morph-17.0.1.tgz", @@ -37035,6 +37067,9 @@ "dev": true, "requires": {} }, + "tsconfig": { + "version": "file:packages/tsconfig" + }, "tsconfig-paths": { "version": "3.14.2", "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.2.tgz", @@ -37509,165 +37544,6 @@ } } }, - "vite-plugin-linter": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/vite-plugin-linter/-/vite-plugin-linter-2.0.2.tgz", - "integrity": "sha512-ssIrqn9k+eVFw5D6jPyNA7qWmzQBilTZQyv0SxPGl1TZacae/mzue9253kT1VklcrVtPMua1KOSmrop95Vp/gg==", - "dev": true, - "requires": { - "@rollup/pluginutils": "5.0.2", - "@types/eslint": "8.4.10", - "chokidar": "3.5.3", - "eslint": "8.29.0", - "typescript": "4.9.3" - }, - "dependencies": { - "@eslint/eslintrc": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.4.1.tgz", - "integrity": "sha512-XXrH9Uarn0stsyldqDYq8r++mROmWRI1xKMXa640Bb//SY1+ECYX6VzT6Lcx5frD0V30XieqJ0oX9I2Xj5aoMA==", - "dev": true, - "requires": { - "ajv": "^6.12.4", - "debug": "^4.3.2", - "espree": "^9.4.0", - "globals": "^13.19.0", - "ignore": "^5.2.0", - "import-fresh": "^3.2.1", - "js-yaml": "^4.1.0", - "minimatch": "^3.1.2", - "strip-json-comments": "^3.1.1" - } - }, - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "eslint": { - "version": "8.29.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.29.0.tgz", - "integrity": "sha512-isQ4EEiyUjZFbEKvEGJKKGBwXtvXX+zJbkVKCgTuB9t/+jUBcy8avhkEwWJecI15BkRkOYmvIM5ynbhRjEkoeg==", - "dev": true, - "requires": { - "@eslint/eslintrc": "^1.3.3", - "@humanwhocodes/config-array": "^0.11.6", - "@humanwhocodes/module-importer": "^1.0.1", - "@nodelib/fs.walk": "^1.2.8", - "ajv": "^6.10.0", - "chalk": "^4.0.0", - "cross-spawn": "^7.0.2", - "debug": "^4.3.2", - "doctrine": "^3.0.0", - "escape-string-regexp": "^4.0.0", - "eslint-scope": "^7.1.1", - "eslint-utils": "^3.0.0", - "eslint-visitor-keys": "^3.3.0", - "espree": "^9.4.0", - "esquery": "^1.4.0", - "esutils": "^2.0.2", - "fast-deep-equal": "^3.1.3", - "file-entry-cache": "^6.0.1", - "find-up": "^5.0.0", - "glob-parent": "^6.0.2", - "globals": "^13.15.0", - "grapheme-splitter": "^1.0.4", - "ignore": "^5.2.0", - "import-fresh": "^3.0.0", - "imurmurhash": "^0.1.4", - "is-glob": "^4.0.0", - "is-path-inside": "^3.0.3", - "js-sdsl": "^4.1.4", - "js-yaml": "^4.1.0", - "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.4.1", - "lodash.merge": "^4.6.2", - "minimatch": "^3.1.2", - "natural-compare": "^1.4.0", - "optionator": "^0.9.1", - "regexpp": "^3.2.0", - "strip-ansi": "^6.0.1", - "strip-json-comments": "^3.1.0", - "text-table": "^0.2.0" - } - }, - "eslint-scope": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.1.tgz", - "integrity": "sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw==", - "dev": true, - "requires": { - "esrecurse": "^4.3.0", - "estraverse": "^5.2.0" - } - }, - "globals": { - "version": "13.20.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", - "integrity": "sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==", - "dev": true, - "requires": { - "type-fest": "^0.20.2" - } - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - }, - "type-fest": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", - "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", - "dev": true - }, - "typescript": { - "version": "4.9.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.3.tgz", - "integrity": "sha512-CIfGzTelbKNEnLpLdGFgdyKhG23CKdKgQPOBc+OUNrkJ2vr+KSzsSV5kq5iWhEQbok+quxgGzrAtGWCyU7tHnA==", - "dev": true - } - } - }, "vite-tsconfig-paths": { "version": "4.0.7", "resolved": "https://registry.npmjs.org/vite-tsconfig-paths/-/vite-tsconfig-paths-4.0.7.tgz", diff --git a/package.json b/package.json index 61db01e7..183ac0a7 100644 --- a/package.json +++ b/package.json @@ -4,14 +4,17 @@ "scripts": { "prepare": "husky install", "build": "turbo run build", + "start": "turbo run start", "test": "turbo run test", "format": "turbo run format", "lint": "turbo run lint", "dev": "turbo run dev --filter=click-prompt" }, "devDependencies": { - "turbo": "^1.8.3", - "husky": "^8.0.3" + "husky": "^8.0.3", + "turbo": "^1.8.3" }, - "workspaces": ["packages/*"] + "workspaces": [ + "packages/*" + ] } diff --git a/packages/click-prompt-button/.eslintrc.json b/packages/click-prompt-button/.eslintrc.json new file mode 100644 index 00000000..5333793e --- /dev/null +++ b/packages/click-prompt-button/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "root": true, + "extends": ["custom"] +} diff --git a/packages/click-prompt-button/.prettierrc.json b/packages/click-prompt-button/.prettierrc.json new file mode 100644 index 00000000..6fa83211 --- /dev/null +++ b/packages/click-prompt-button/.prettierrc.json @@ -0,0 +1,13 @@ +{ + "$schema": "https://json.schemastore.org/prettierrc", + "trailingComma": "all", + "tabWidth": 2, + "semi": true, + "singleQuote": false, + "jsxSingleQuote": true, + "endOfLine": "lf", + "printWidth": 120, + "bracketSpacing": true, + "arrowParens": "always", + "useTabs": false +} diff --git a/packages/click-prompt-button/package.json b/packages/click-prompt-button/package.json index 1a026b3b..d15b8154 100644 --- a/packages/click-prompt-button/package.json +++ b/packages/click-prompt-button/package.json @@ -1,39 +1,73 @@ { - "name": "click-prompt-button", + "name": "@click-prompt/click-prompt-button", "version": "0.1.0", "description": "click prompt button is react component that can be used to execute a prompt from ChatGPT in any web page. It is a part of the ClickPrompt", - "main": "index.js", + "type": "module", + "module": "./dist/click-prompt-button.js", + "types": "./dist/index.d.ts", "license": "MIT", + "exports": { + ".": "./dist/click-prompt-button.js", + "./style.css": "./dist/style.css" + }, + "files": [ + "dist" + ], "scripts": { - "build": "echo build" + "build": "tsc && vite build", + "lint": "eslint --ext .js,.jsx,.ts,.tsx ./src", + "lint:fix": "eslint --ext .js,.jsx,.ts,.tsx ./src --fix", + "format": "prettier --check ./src -u", + "format:fix": "prettier --write ./src -u" }, "dependencies": { - "@chakra-ui/icons": "^2.0.17", - "@chakra-ui/react": "^2.5.1", - "@chakra-ui/spinner": "^2.0.13", - "@chakra-ui/system": "^2.5.1", - "@emotion/react": "^11.10.6", - "@emotion/styled": "^11.10.6", "client-only": "^0.0.1", + "framer-motion": "^10.0.1", "mermaid": "^10.0.2", - "react": "^18.2.0", - "react-dom": "^18.2.0", "react-markdown": "^8.0.5", "react-spinners": "^0.13.8", "react-syntax-highlighter": "^15.5.0", "remark-gfm": "^3.0.1", - "svg-pan-zoom": "^3.6.1" + "svg-pan-zoom": "^3.6.1", + "tailwindcss": "^3.2.7", + "use-debounce": "^9.0.3" }, "devDependencies": { + "@chakra-ui/react": "^2.5.1", + "@chakra-ui/system": "^2.5.1", + "@emotion/react": "11.10.6", + "@emotion/styled": "11.10.6", + "@types/node": "18.14.5", + "@types/react": "18.0.28", + "@types/react-dom": "18.0.11", + "@types/react-syntax-highlighter": "^15.5.6", + "@typescript-eslint/eslint-plugin": "^5.54.1", + "autoprefixer": "^10.4.13", + "eslint": "8.35.0", + "eslint-config-custom": "*", + "eslint-config-prettier": "^8.6.0", + "next": "13.2.4", + "react": "18.2.0", + "react-dom": "18.2.0", + "postcss": "^8.4.21", + "prettier": "^2.8.4", + "tailwindcss": "^3.2.7", + "tsconfig": "*", + "typescript": "4.9.5", "@vitejs/plugin-react": "^3.1.0", "vite": "^4.2.1", "vite-plugin-dts": "^2.1.0", - "vite-plugin-linter": "^2.0.2", - "vite-tsconfig-paths": "^4.0.7" + "vite-tsconfig-paths": "^4.0.7", + "@rollup/plugin-url": "^8.0.1", + "@svgr/rollup": "^6.5.1" }, "peerDependencies": { - "next": ">=13.0.0", - "react": ">=16.8.0", - "react-dom": ">=16.8.0" + "@chakra-ui/react": "^2.5.1", + "@chakra-ui/system": "^2.5.1", + "@emotion/react": "11.10.6", + "@emotion/styled": "11.10.6", + "next": "^13.2.4", + "react": "^18.2.0", + "react-dom": "^18.2.0" } } diff --git a/packages/click-prompt-button/postcss.config.cjs b/packages/click-prompt-button/postcss.config.cjs new file mode 100644 index 00000000..12a703d9 --- /dev/null +++ b/packages/click-prompt-button/postcss.config.cjs @@ -0,0 +1,6 @@ +module.exports = { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +}; diff --git a/packages/click-prompt-button/src/ClickPromptBird.tsx b/packages/click-prompt-button/src/ClickPromptBird.tsx new file mode 100644 index 00000000..356bc00b --- /dev/null +++ b/packages/click-prompt-button/src/ClickPromptBird.tsx @@ -0,0 +1,16 @@ +import clickPromptLogoUrl from "@/assets/clickprompt-light.svg"; +import React from "react"; +import styled from "@emotion/styled"; +import Image from "next/image"; + +type ClickPromptBirdProps = { width?: number; height?: number }; + +const StyledBird = styled(Image)` + position: absolute; + top: -20px; + right: -20px; +`; + +export const ClickPromptBird = ({ width = 38, height = 32 }: ClickPromptBirdProps) => ( + +); diff --git a/packages/click-prompt-button/src/ClickPromptButton.tsx b/packages/click-prompt-button/src/ClickPromptButton.tsx index 82eea456..7e7dbf9e 100644 --- a/packages/click-prompt-button/src/ClickPromptButton.tsx +++ b/packages/click-prompt-button/src/ClickPromptButton.tsx @@ -1,58 +1,37 @@ import React, { MouseEventHandler, useState } from "react"; -import { Box, Button, Text, Tooltip, useDisclosure } from "@chakra-ui/react"; +import { Box, Button, ButtonProps, Text, Tooltip, useDisclosure } from "@chakra-ui/react"; import { BeatLoader } from "react-spinners"; -import { ClickPromptSmall } from "./CustomIcon"; -import clickPromptLogo from "@/assets/clickprompt-light.svg?url"; -import { ButtonSize, StyledBird, StyledPromptButton } from "./Button.shared"; -import { LoggingDrawer } from "./LoggingDrawer"; +import { ClickPromptSmall } from "@/CustomIcon"; +import { ButtonSize, StyledPromptButton } from "@/SharedButton"; +import { LoggingDrawer } from "@/LoggingDrawer"; +import { ClickPromptBird } from "@/ClickPromptBird"; +import type { LlmServiceApi } from "@/types/llmServiceApi"; -interface ClickPromptButtonProps { +export interface ClickPromptButtonProps extends ButtonProps { loading?: boolean; onClick?: MouseEventHandler; size?: ButtonSize; text: string; children?: React.ReactNode; - isLoggedInApi: () => Promise; - changeConversationNameApi: (conversation_id: number, name: string) => Promise; - createConversationApi: (name?: string) => Promise; - getChatsByConversationIdApi: (conversationId: number) => Promise; - deleteConversationApi: (conversationId: number) => Promise; - deleteAllConversationsApi: () => Promise; - sendMsgWithStreamResApi: (conversageId: number, message: string, name?: string) => Promise; - logoutApi: () => Promise; -} - -export type ClickPromptBirdParams = { width?: number; height?: number }; - -export function ClickPromptBird(props: ClickPromptBirdParams) { - const width = props.width || 38; - const height = props.height || 32; - - return ; + llmServiceApi: LlmServiceApi; } export function ClickPromptButton({ - isLoggedInApi, children, size, text, onClick, loading, - changeConversationNameApi, - createConversationApi, - getChatsByConversationIdApi, - deleteConversationApi, - deleteAllConversationsApi, - sendMsgWithStreamResApi, - logoutApi, + llmServiceApi, + ...rest }: ClickPromptButtonProps) { const [isLoading, setIsLoading] = useState(loading); const [isLoggedIn, setIsLoggedIn] = useState(false); const { isOpen, onOpen, onClose } = useDisclosure(); - const handleClick = async (event: any) => { + const handleClick = async (event: React.MouseEvent) => { setIsLoading(true); - const isLoggedIn = await isLoggedInApi(); + const isLoggedIn = await llmServiceApi.isLoggedIn(); setIsLoggedIn(isLoggedIn); onOpen(); onClick && onClick(event); @@ -66,11 +45,10 @@ export function ClickPromptButton({ function NormalSize() { return ( - {/*TODO: check ...props with what is passed in*/} - @@ -79,10 +57,9 @@ export function ClickPromptButton({ function SmallSize() { return ( - // TODO: check ...props with what is passed in - @@ -99,13 +76,7 @@ export function ClickPromptButton({ handleClose, isLoggedIn, initMessage: text, - changeConversationNameApi, - createConversationApi, - getChatsByConversationIdApi, - deleteConversationApi, - deleteAllConversationsApi, - sendMsgWithStreamResApi, - logoutApi, + llmServiceApi, })} ); diff --git a/packages/click-prompt-button/src/CustomIcon.tsx b/packages/click-prompt-button/src/CustomIcon.tsx index 42991712..df3a248f 100644 --- a/packages/click-prompt-button/src/CustomIcon.tsx +++ b/packages/click-prompt-button/src/CustomIcon.tsx @@ -1,7 +1,15 @@ import React from "react"; import Image from "next/image"; -import clickPromptSmall from "@/assets/clickprompt-small.svg?url"; +import clickPromptSmallUrl from "@/assets/clickprompt-small.svg"; export function ClickPromptSmall({ width = 32, height = 32 }) { - return ClickPrompt Logo; + return ( + ClickPrompt Logo + ); } diff --git a/packages/click-prompt-button/src/ExecutePromptButton.tsx b/packages/click-prompt-button/src/ExecutePromptButton.tsx index fc4ce470..40862ca9 100644 --- a/packages/click-prompt-button/src/ExecutePromptButton.tsx +++ b/packages/click-prompt-button/src/ExecutePromptButton.tsx @@ -1,27 +1,31 @@ -import React, { MouseEventHandler, useEffect, useState } from "react"; +import React, { useEffect, useState } from "react"; import { Button, Text, useDisclosure } from "@chakra-ui/react"; import { BeatLoader } from "react-spinners"; -import { ClickPromptBird } from "./ClickPromptButton"; -import { ButtonSize, StyledPromptButton } from "./Button.shared"; -import { LoggingDrawer } from "./LoggingDrawer"; +import { StyledPromptButton } from "@/SharedButton"; +import { LoggingDrawer } from "@/LoggingDrawer"; +import { ClickPromptBird } from "@/ClickPromptBird"; +import type { Chat, LlmServiceApi } from "@/types/llmServiceApi"; -export type ExecButtonProps = { +export interface ExecButtonProps { loading?: boolean; - onClick?: MouseEventHandler; - name: string; text: string; - size?: ButtonSize; children?: React.ReactNode; - handleResponse?: (response: any) => void; + handleResponse?: (response: ReadableStream | Chat[] | null) => void; conversationId?: number; updateConversationId?: (conversationId: number) => void; - isLoggedIn: () => Promise; - createConversation: (name?: string) => Promise; - sendMessage: (conversageId: number, message: string, name?: string) => Promise; -}; + llmServiceApi: LlmServiceApi; +} -function ExecutePromptButton(props: ExecButtonProps) { - const [isLoading, setIsLoading] = useState(props.loading); +export const ExecutePromptButton = ({ + loading, + text, + children, + handleResponse, + conversationId, + updateConversationId, + llmServiceApi, +}: ExecButtonProps) => { + const [isLoading, setIsLoading] = useState(loading); const { isOpen, onOpen, onClose } = useDisclosure(); const [hasLogin, setHasLogin] = useState(false); @@ -29,8 +33,8 @@ function ExecutePromptButton(props: ExecButtonProps) { setIsLoading(true); try { - const isLoggedIn = await props.isLoggedIn(); - if (!isLoggedIn) { + const isUserLoggedIn = await llmServiceApi.isLoggedIn(); + if (!isUserLoggedIn) { onOpen(); setIsLoading(false); return; @@ -40,21 +44,23 @@ function ExecutePromptButton(props: ExecButtonProps) { setHasLogin(false); } - let conversationId = props.conversationId; - if (!props.conversationId) { - const conversation = await props.createConversation(); + let newConversationId = conversationId; + if (!conversationId) { + const conversation = await llmServiceApi.createConversation(); if (!conversation) { return; } - conversationId = conversation.id as number; - props.updateConversationId ? props.updateConversationId(conversationId) : null; + newConversationId = conversation.id as number; + updateConversationId ? updateConversationId(newConversationId) : null; } - if (conversationId) { - const response: any = await props.sendMessage(conversationId, props.text); - if (response && props.handleResponse) { - props.handleResponse(response as any); + if (newConversationId) { + const response = llmServiceApi.sendMsgWithStreamRes + ? await llmServiceApi.sendMsgWithStreamRes(newConversationId, text) + : await llmServiceApi.sendMessage?.(newConversationId, text); + if (response && handleResponse) { + handleResponse(response); } } @@ -82,16 +88,22 @@ function ExecutePromptButton(props: ExecButtonProps) { return ( <> - - {!hasLogin && LoggingDrawer(isOpen, handleClose, hasLogin, props, updateLoginStatus)} + {!hasLogin && + LoggingDrawer({ + isOpen, + handleClose, + updateStatus: updateLoginStatus, + isLoggedIn: hasLogin, + initMessage: text, + llmServiceApi, + })} ); -} - -export default ExecutePromptButton; +}; diff --git a/packages/click-prompt-button/src/LoggingDrawer.tsx b/packages/click-prompt-button/src/LoggingDrawer.tsx index 64ab1178..0a7f770b 100644 --- a/packages/click-prompt-button/src/LoggingDrawer.tsx +++ b/packages/click-prompt-button/src/LoggingDrawer.tsx @@ -1,6 +1,7 @@ import { Drawer, DrawerBody, DrawerCloseButton, DrawerContent, DrawerOverlay } from "@chakra-ui/react"; import { ChatGPTApp } from "@/chatgpt/ChatGPTApp"; import React from "react"; +import type { LlmServiceApi } from "@/types/llmServiceApi"; interface LoggingDrawerProps { isOpen: boolean; @@ -8,13 +9,7 @@ interface LoggingDrawerProps { isLoggedIn: boolean; updateStatus?: (loggedIn: boolean) => void; initMessage: string; - changeConversationNameApi: (conversation_id: number, name: string) => Promise; - createConversationApi: (name?: string) => Promise; - getChatsByConversationIdApi: (conversationId: number) => Promise; - deleteConversationApi: (conversationId: number) => Promise; - deleteAllConversationsApi: () => Promise; - sendMsgWithStreamResApi: (conversageId: number, message: string, name?: string) => Promise; - logoutApi: () => Promise; + llmServiceApi: LlmServiceApi; } export function LoggingDrawer({ @@ -23,32 +18,20 @@ export function LoggingDrawer({ isLoggedIn, updateStatus, initMessage, - changeConversationNameApi, - createConversationApi, - getChatsByConversationIdApi, - deleteConversationApi, - deleteAllConversationsApi, - sendMsgWithStreamResApi, - logoutApi, + llmServiceApi, }: LoggingDrawerProps) { return ( - + - + -
+
diff --git a/packages/click-prompt-button/src/Button.shared.tsx b/packages/click-prompt-button/src/SharedButton.tsx similarity index 61% rename from packages/click-prompt-button/src/Button.shared.tsx rename to packages/click-prompt-button/src/SharedButton.tsx index 9a85677f..7c6feb64 100644 --- a/packages/click-prompt-button/src/Button.shared.tsx +++ b/packages/click-prompt-button/src/SharedButton.tsx @@ -1,15 +1,8 @@ -import Image from "next/image"; import React from "react"; import styled from "@emotion/styled"; export type ButtonSize = "sm" | "md" | "lg"; -export const StyledBird = styled(Image)` - position: absolute; - top: -20px; - right: -20px; -`; - export const StyledPromptButton = styled.div` position: relative; width: min-content; diff --git a/packages/click-prompt-button/src/assets/clickprompt-light.svg b/packages/click-prompt-button/src/assets/clickprompt-light.svg new file mode 100644 index 00000000..71967b83 --- /dev/null +++ b/packages/click-prompt-button/src/assets/clickprompt-light.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/packages/click-prompt-button/src/assets/icons/send.svg b/packages/click-prompt-button/src/assets/icons/send.svg new file mode 100644 index 00000000..8d97864f --- /dev/null +++ b/packages/click-prompt-button/src/assets/icons/send.svg @@ -0,0 +1 @@ + diff --git a/packages/click-prompt-button/src/chatgpt/ChatGPTApp.tsx b/packages/click-prompt-button/src/chatgpt/ChatGPTApp.tsx index 37d9f684..d20c0e7d 100644 --- a/packages/click-prompt-button/src/chatgpt/ChatGPTApp.tsx +++ b/packages/click-prompt-button/src/chatgpt/ChatGPTApp.tsx @@ -1,31 +1,15 @@ import { ChatRoom } from "@/chatgpt/ChatRoom"; import { LoginPage } from "@/chatgpt/LoginPage"; import React, { useEffect, useState } from "react"; +import type { LlmServiceApi } from "@/types/llmServiceApi"; -type ChatGPTAppProps = { +export interface ChatGPTAppProps { loggedIn?: boolean; updateLoginStatus?: (loggedIn: boolean) => void; initMessage?: string; - changeConversationNameApi: (conversation_id: number, name: string) => Promise; - createConversationApi: (name?: string) => Promise; - getChatsByConversationIdApi: (conversationId: number) => Promise; - deleteConversationApi: (conversationId: number) => Promise; - deleteAllConversationsApi: () => Promise; - sendMsgWithStreamResApi: (conversageId: number, message: string, name?: string) => Promise; - logoutApi: () => Promise; -}; -export const ChatGPTApp = ({ - loggedIn, - initMessage, - updateLoginStatus, - changeConversationNameApi, - createConversationApi, - getChatsByConversationIdApi, - deleteConversationApi, - deleteAllConversationsApi, - sendMsgWithStreamResApi, - logoutApi, -}: ChatGPTAppProps) => { + llmServiceApi: LlmServiceApi; +} +export const ChatGPTApp = ({ loggedIn, initMessage, updateLoginStatus, llmServiceApi }: ChatGPTAppProps) => { const [isLoggedIn, setIsLoggedIn] = useState(loggedIn ?? false); useEffect(() => { @@ -35,23 +19,8 @@ export const ChatGPTApp = ({ }, [isLoggedIn]); return isLoggedIn ? ( - + ) : ( - { - throw new Error("Function not implemented."); - }} - /> + ); }; diff --git a/packages/click-prompt-button/src/chatgpt/ChatRoom.tsx b/packages/click-prompt-button/src/chatgpt/ChatRoom.tsx index e0a59e08..d93a2d66 100644 --- a/packages/click-prompt-button/src/chatgpt/ChatRoom.tsx +++ b/packages/click-prompt-button/src/chatgpt/ChatRoom.tsx @@ -1,15 +1,16 @@ -import NewChat from "@/assets/icons/new-chat.svg"; -import TrashcanIcon from "@/assets/icons/trashcan.svg"; -import LogoutIcon from "@/assets/icons/logout.svg"; +import { ReactComponent as NewChat } from "@/assets/icons/new-chat.svg"; +import { ReactComponent as TrashcanIcon } from "@/assets/icons/trashcan.svg"; +import { ReactComponent as LogoutIcon } from "@/assets/icons/logout.svg"; import Image from "next/image"; import content from "@/assets/images/content.png"; -import send from "@/assets/icons/send.svg?url"; +import sendIconUrl from "@/assets/icons/send.svg"; import React, { Dispatch, SetStateAction, useEffect, useState } from "react"; import styled from "@emotion/styled"; import { BeatLoader } from "react-spinners"; import { useDebouncedCallback } from "use-debounce"; import { Input } from "@chakra-ui/react"; import SimpleMarkdown from "@/markdown/SimpleMarkdown"; +import type { Chat, Conversation, LlmServiceApi } from "@/types/llmServiceApi"; const ChatInput = styled("input")` background: #ffffff; @@ -65,7 +66,7 @@ const ChatSendButton = styled("button")` right: 8px; width: 48px; height: 48px; - background-image: url(${send}); + background-image: url(${sendIconUrl}); background-size: 24px; background-position: center; background-repeat: no-repeat; @@ -74,33 +75,19 @@ const ChatSendButton = styled("button")` outline: none; `; -export const ChatRoom = ({ - setIsLoggedIn, - initMessage, - changeConversationNameApi, - createConversationApi, - getChatsByConversationIdApi, - deleteConversationApi, - deleteAllConversationsApi, - sendMsgWithStreamResApi, - logoutApi, -}: { +interface ChatRoomProps { setIsLoggedIn: Dispatch>; initMessage?: string; - changeConversationNameApi: (conversation_id: number, name: string) => Promise; - createConversationApi: (name?: string) => Promise; - getChatsByConversationIdApi: (conversationId: number) => Promise; - deleteConversationApi: (conversationId: number) => Promise; - deleteAllConversationsApi: () => Promise; - sendMsgWithStreamResApi: (conversageId: number, message: string, name?: string) => Promise; - logoutApi: () => Promise; -}) => { + llmServiceApi: Omit; +} + +export const ChatRoom = ({ setIsLoggedIn, initMessage, llmServiceApi }: ChatRoomProps) => { const chatsWrapper = React.useRef(null); const [disable, setDisable] = React.useState(false); - const [chatHistory, setChatHistory] = React.useState([]); + const [chatHistory, setChatHistory] = React.useState([]); const [message, setMessage] = React.useState(initMessage ?? ""); - const [conversations, setConversations] = useState([]); + const [conversations, setConversations] = useState([]); const [currentConversation, setCurrentConversation] = useState(null); // editing conversation name const [editing, setEditing] = useState(null); @@ -114,11 +101,11 @@ export const ChatRoom = ({ method: "POST", body: JSON.stringify({ action: "get_conversations", - } as any), + }), }); - const data = (await response.json()) as any; + const data = await response.json(); if (!response.ok) { - alert("Error: " + JSON.stringify((data as any).error)); + alert("Error: " + JSON.stringify(data.error)); return; } setConversations(data); @@ -147,7 +134,7 @@ export const ChatRoom = ({ }; async function createConversation() { - const data = await createConversationApi(); + const data = await llmServiceApi.createConversation(); if (!data) { return; } @@ -157,9 +144,9 @@ export const ChatRoom = ({ } async function changeConversationName(conversationId: number, name: string) { - await changeConversationNameApi(conversationId, name); + await changeConversationName(conversationId, name); - setConversations((c: any[]) => + setConversations((c) => c.map((conversation) => { if (conversation.id === conversationId) { return { @@ -168,7 +155,7 @@ export const ChatRoom = ({ }; } return conversation; - }) + }), ); } @@ -179,7 +166,7 @@ export const ChatRoom = ({ if (conversationId == null) { return; } - setEditingName(conversations.find((c: any) => c.id === conversationId)?.name ?? ""); + setEditingName(conversations.find((c) => c.id === conversationId)?.name ?? ""); setEditing(conversationId); return; } @@ -193,7 +180,7 @@ export const ChatRoom = ({ try { setCurrentConversation(conversationId); - const data = await getChatsByConversationIdApi(conversationId); + const data = await llmServiceApi.getChatsByConversationId(conversationId); if (!data) { return; } @@ -204,19 +191,19 @@ export const ChatRoom = ({ setDisable(false); } }, - 200 + 200, ); async function deleteConversation(conversationId: number) { - const data = await deleteConversationApi(conversationId); + const data = await llmServiceApi.deleteConversation(conversationId); if (!data) { return; } - setConversations(conversations.filter((conversation: any) => conversation.id !== conversationId)); + setConversations(conversations.filter((conversation) => conversation.id !== conversationId)); } async function deleteAllConversations() { - const data = await deleteAllConversationsApi(); + const data = await llmServiceApi.deleteAllConversations(); if (!data) { return; } @@ -246,11 +233,11 @@ export const ChatRoom = ({ // TODO(CGQAQ): custom name of user // name: "User", }, - ] as any; + ] as Chat[]; setChatHistory([...updatedHistory]); - const data = await sendMsgWithStreamResApi(currentConversation as number, message); + const data = await llmServiceApi.sendMsgWithStreamRes?.(currentConversation as number, message); if (!data) { setDisable(false); setChatHistory([...updatedHistory.slice(0, updatedHistory.length - 1)]); @@ -300,28 +287,30 @@ export const ChatRoom = ({ } async function logout() { - await logoutApi(); + await logout(); setIsLoggedIn(false); } return ( -
+
{/* left */} -
+
- + New chat
-
- {conversations.map((conversation: any) => ( +
+ {conversations.map((conversation) => (
{ handleConversation(conversation.id!, event); }} @@ -351,12 +340,12 @@ export const ChatRoom = ({ /> ) : ( <> -
+
{conversation.name}
{/* delete button */}
{ e.stopPropagation(); if (confirm("Are you sure to delete this conversation?")) { @@ -364,7 +353,7 @@ export const ChatRoom = ({ } }} > - +
)} @@ -373,7 +362,7 @@ export const ChatRoom = ({
{ e.stopPropagation(); if (confirm("Are you sure to delete ALL conversations?")) { @@ -381,41 +370,43 @@ export const ChatRoom = ({ } }} > - + Clear conversations
- + Log out
{/* right */} -
- {chatHistory.length === 0 && background image} +
+ {chatHistory.length === 0 && ( + background image + )} {/* chats */} - {chatHistory.map((chat: any, index: number) => { + {chatHistory.map((chat, index) => { return ( -
+
{chat.role === "user" ? ( -
+
{/* chat bubble badge */} -
+
) : ( -
-
+
+
@@ -425,19 +416,24 @@ export const ChatRoom = ({ })} - + setMessage(ev.target.value)} onKeyDown={onEnterForSendMessage} - className="w-full pr-10 md:w-11/12 border-0 md:pr-0 focus:ring-0" + className='button-w-full button-pr-10 md:button-w-11/12 button-border-0 md:button-pr-0 focus:button-ring-0' /> {disable ? ( - + // check this + ) : ( - + )}
diff --git a/packages/click-prompt-button/src/chatgpt/LoginPage.tsx b/packages/click-prompt-button/src/chatgpt/LoginPage.tsx index 1953e11a..c140b621 100644 --- a/packages/click-prompt-button/src/chatgpt/LoginPage.tsx +++ b/packages/click-prompt-button/src/chatgpt/LoginPage.tsx @@ -1,12 +1,13 @@ import React, { Dispatch, SetStateAction } from "react"; import { Button, Input } from "@chakra-ui/react"; +import { LlmServiceApi } from "@/types/llmServiceApi"; export const LoginPage = ({ setIsLoggedIn, - loginApi, + login: loginApi, }: { setIsLoggedIn: Dispatch>; - loginApi: (key: string) => Promise; + login: LlmServiceApi["login"]; }) => { const [openAiKey, setOpenAiKey] = React.useState(""); @@ -26,32 +27,32 @@ export const LoginPage = ({ } return ( -
-

ChatGPT

-

You need to login first use your own key.

-
+
+

ChatGPT

+

You need to login first use your own key.

+
1. Sign up for the   - + OpenAI Platform.
2. Create a new secret key in   - + Settings → API keys.
3. Copy and paste your API key here:
-
+
setOpenAiKey(ev.target.value)} > + + + + + + + ); +}; diff --git a/packages/click-prompt/src/app/[lang]/page.tsx b/packages/click-prompt/src/app/[lang]/page.tsx index e8f04d48..3c315244 100644 --- a/packages/click-prompt/src/app/[lang]/page.tsx +++ b/packages/click-prompt/src/app/[lang]/page.tsx @@ -1,56 +1,11 @@ import React from "react"; -import { Box, Button, Container, Heading, Stack, Text } from "@/components/ChakraUI"; -import { ClickPromptHome } from "@/components/CustomIcon"; -import { GITHUB_URL } from "@/configs/constants"; -import { ClickPromptButton } from "@/components/ClickPrompt/ClickPromptButton"; import { getAppData } from "@/i18n"; +import { HomeClient } from "@/app/[lang]/page.client"; async function Page() { const { i18n } = await getAppData(); - const t = i18n.tFactory("/"); - return ( - - - - - - - {t("title")} - - - - {t("description")} - - - - - - - - - - - ); + return ; } export default Page; diff --git a/packages/click-prompt/src/app/[lang]/stable-diffusion-generator/page.client.tsx b/packages/click-prompt/src/app/[lang]/stable-diffusion-generator/page.client.tsx index 39ea908c..5b40cae8 100644 --- a/packages/click-prompt/src/app/[lang]/stable-diffusion-generator/page.client.tsx +++ b/packages/click-prompt/src/app/[lang]/stable-diffusion-generator/page.client.tsx @@ -4,21 +4,21 @@ import React, { ChangeEvent, useEffect, useMemo, useState } from "react"; import { Button, Flex, + FormControl, Grid, Heading, Input, InputGroup, InputRightElement, Link, + Radio, + RadioGroup, SimpleGrid, Stack, - Text, Tag, TagCloseButton, - FormControl, TagLabel, - RadioGroup, - Radio, + Text, } from "@chakra-ui/react"; import { useFormik } from "formik"; import Image from "next/image"; @@ -26,10 +26,11 @@ import CopyComponent from "@/components/CopyComponent"; import PromptFieldForm, { SdPromptField } from "@/app/[lang]/stable-diffusion-generator/PromptFieldForm"; import sdImage from "@/assets/images/stable-diffusion-demo.jpeg"; import { WebStorage } from "@/storage/webstorage"; -import { ClickPromptButton } from "@/components/ClickPrompt/ClickPromptButton"; +import { ClickPromptButton } from "@/components/ClickPromptButton"; import { HuggingFaceTxt2Img } from "@/components/StableDiffusion/HuggingFaceTxt2Img"; import { SdPrompt } from "@/components/StableDiffusion/SdPrompt"; import { StableDiffusionGenData } from "@/data-processor/StableDiffusionGenData"; +import { llmServiceApiWithStream } from "@/api/llmService"; const sdDetailedPromptFields: SdPromptField[] = [ { @@ -520,7 +521,7 @@ function StableDiffusionGenerator({ i18n }: GeneralI18nProps) { - + diff --git a/packages/click-prompt/src/components/ClickPrompt/Button.shared.tsx b/packages/click-prompt/src/components/ClickPrompt/Button.shared.tsx deleted file mode 100644 index 87b880e5..00000000 --- a/packages/click-prompt/src/components/ClickPrompt/Button.shared.tsx +++ /dev/null @@ -1,27 +0,0 @@ -"use client"; - -import Image from "next/image"; -import React, { MouseEventHandler } from "react"; -import styled from "@emotion/styled"; - -export type ButtonSize = "sm" | "md" | "lg"; - -export const StyledBird = styled(Image)` - position: absolute; - top: -20px; - right: -20px; -`; - -export const StyledPromptButton = styled.div` - position: relative; - width: min-content; -`; - -export type CPButtonProps = { - loading?: boolean; - onClick?: MouseEventHandler; - size?: ButtonSize; - text: string; - children?: React.ReactNode; - [key: string]: any; -}; diff --git a/packages/click-prompt/src/components/ClickPrompt/ClickPromptButton.tsx b/packages/click-prompt/src/components/ClickPrompt/ClickPromptButton.tsx deleted file mode 100644 index 0d13c9c8..00000000 --- a/packages/click-prompt/src/components/ClickPrompt/ClickPromptButton.tsx +++ /dev/null @@ -1,72 +0,0 @@ -"use client"; - -import React, { useState } from "react"; -import { Box, Text, Tooltip, useDisclosure } from "@chakra-ui/react"; -import { Button } from "@/components/ChakraUI"; -import { BeatLoader } from "react-spinners"; -import { ClickPromptSmall } from "@/components/CustomIcon"; -import clickPromptLogo from "@/assets/clickprompt-light.svg?url"; -import { CPButtonProps, StyledBird, StyledPromptButton } from "@/components/ClickPrompt/Button.shared"; -import { LoggingDrawer } from "@/components/ClickPrompt/LoggingDrawer"; -import * as UserAPI from "@/api/user"; - -export type ClickPromptBirdParams = { width?: number; height?: number }; - -export function ClickPromptBird(props: ClickPromptBirdParams) { - const width = props.width || 38; - const height = props.height || 32; - - return ; -} - -export function ClickPromptButton(props: CPButtonProps) { - const [isLoading, setIsLoading] = useState(props.loading); - const [isLoggedIn, setIsLoggedIn] = useState(false); - const { isOpen, onOpen, onClose } = useDisclosure(); - - const handleClick = async (event: any) => { - setIsLoading(true); - const isLoggedIn = await UserAPI.isLoggedIn(); - setIsLoggedIn(isLoggedIn); - onOpen(); - props.onClick && props.onClick(event); - }; - - const handleClose = () => { - setIsLoading(false); - onClose(); - }; - - function NormalSize() { - return ( - - - - - ); - } - - function SmallSize() { - return ( - - ); - } - - return ( - - {props.size !== "sm" && } - {props.size === "sm" && } - - {LoggingDrawer(isOpen, handleClose, isLoggedIn, props)} - - ); -} diff --git a/packages/click-prompt/src/components/ClickPrompt/ExecutePromptButton.tsx b/packages/click-prompt/src/components/ClickPrompt/ExecutePromptButton.tsx deleted file mode 100644 index 8b4fc324..00000000 --- a/packages/click-prompt/src/components/ClickPrompt/ExecutePromptButton.tsx +++ /dev/null @@ -1,102 +0,0 @@ -"use client"; - -import React, { MouseEventHandler, useEffect, useState } from "react"; -import { Text, useDisclosure } from "@chakra-ui/react"; -import * as UserAPI from "@/api/user"; -import { ResponseCreateConversation } from "@/pages/api/chatgpt/conversation"; -import { createConversation } from "@/api/conversation"; -import { sendMessage } from "@/api/chat"; -import { ResponseSend } from "@/pages/api/chatgpt/chat"; -import { Button } from "@/components/ChakraUI"; -import { BeatLoader } from "react-spinners"; -import { ClickPromptBird } from "@/components/ClickPrompt/ClickPromptButton"; -import { ButtonSize, StyledPromptButton } from "./Button.shared"; -import { LoggingDrawer } from "@/components/ClickPrompt/LoggingDrawer"; - -export type ExecButtonProps = { - loading?: boolean; - onClick?: MouseEventHandler; - name: string; - text: string; - size?: ButtonSize; - children?: React.ReactNode; - handleResponse?: (response: ResponseSend) => void; - conversationId?: number; - updateConversationId?: (conversationId: number) => void; -}; - -function ExecutePromptButton(props: ExecButtonProps) { - const [isLoading, setIsLoading] = useState(props.loading); - const { isOpen, onOpen, onClose } = useDisclosure(); - const [hasLogin, setHasLogin] = useState(false); - - const handleClick = async () => { - setIsLoading(true); - - try { - const isLoggedIn = await UserAPI.isLoggedIn(); - if (!isLoggedIn) { - onOpen(); - setIsLoading(false); - return; - } - } catch (e) { - console.log(e); - setHasLogin(false); - } - - let conversationId = props.conversationId; - if (!props.conversationId) { - const conversation: ResponseCreateConversation = await createConversation(); - if (!conversation) { - return; - } - - conversationId = conversation.id as number; - props.updateConversationId ? props.updateConversationId(conversationId) : null; - } - - if (conversationId) { - const response: any = await sendMessage(conversationId, props.text); - if (response && props.handleResponse) { - props.handleResponse(response as ResponseSend); - } - } - - setIsLoading(false); - }; - - useEffect(() => { - console.log(`hasLogin: ${hasLogin}`); - if (hasLogin) { - onClose(); - } - }, [hasLogin]); - - const handleClose = () => { - onClose(); - }; - - const updateLoginStatus = (status: boolean) => { - if (status) { - setHasLogin(true); - onClose(); - } - }; - - return ( - <> - - - - - {!hasLogin && LoggingDrawer(isOpen, handleClose, hasLogin, props, updateLoginStatus)} - - ); -} - -export default ExecutePromptButton; diff --git a/packages/click-prompt/src/components/ClickPrompt/LoggingDrawer.tsx b/packages/click-prompt/src/components/ClickPrompt/LoggingDrawer.tsx deleted file mode 100644 index fa38b142..00000000 --- a/packages/click-prompt/src/components/ClickPrompt/LoggingDrawer.tsx +++ /dev/null @@ -1,28 +0,0 @@ -"use client"; - -import { Drawer, DrawerBody, DrawerCloseButton, DrawerContent, DrawerOverlay } from "@chakra-ui/react"; -import { ChatGPTApp } from "@/components/chatgpt/ChatGPTApp"; -import React from "react"; -import { CPButtonProps } from "@/components/ClickPrompt/Button.shared"; - -export function LoggingDrawer( - isOpen: boolean, - handleClose: () => void, - isLoggedIn: boolean, - props: CPButtonProps, - updateStatus?: (loggedIn: boolean) => void, -) { - return ( - - - - - -
- -
-
-
-
- ); -} diff --git a/packages/click-prompt/src/components/ClickPromptButton/index.tsx b/packages/click-prompt/src/components/ClickPromptButton/index.tsx new file mode 100644 index 00000000..0decded3 --- /dev/null +++ b/packages/click-prompt/src/components/ClickPromptButton/index.tsx @@ -0,0 +1,32 @@ +"use client"; + +import "@click-prompt/click-prompt-button/style.css"; +import dynamic from "next/dynamic"; +import type { Chat, ClickPromptButtonProps, LlmServiceApi } from "@click-prompt/click-prompt-button"; + +// TODO: investigate why this is needed - it should be possible to import the components directly(before monorepo it can) +export const ClickPromptButton = (props: ClickPromptButtonProps) => { + const CPB = dynamic(() => import("@click-prompt/click-prompt-button").then((module) => module.ClickPromptButton), { + ssr: false, + }); + + return ; +}; + +export const ChatGPTApp = (props: ClickPromptButtonProps) => { + const GPT = dynamic(() => import("@click-prompt/click-prompt-button").then((module) => module.ChatGPTApp), { + ssr: false, + }); + + return ; +}; + +export const ExecutePromptButton = (props: ClickPromptButtonProps) => { + const EPB = dynamic(() => import("@click-prompt/click-prompt-button").then((module) => module.ExecutePromptButton), { + ssr: false, + }); + + return ; +}; + +export type { Chat, LlmServiceApi, ClickPromptButtonProps }; diff --git a/packages/click-prompt/src/components/chatgpt/ChatGPTApp.tsx b/packages/click-prompt/src/components/chatgpt/ChatGPTApp.tsx deleted file mode 100644 index 8884d571..00000000 --- a/packages/click-prompt/src/components/chatgpt/ChatGPTApp.tsx +++ /dev/null @@ -1,26 +0,0 @@ -"use client"; - -import { ChatRoom } from "@/components/chatgpt/ChatRoom"; -import { LoginPage } from "@/components/chatgpt/LoginPage"; -import React, { useEffect, useState } from "react"; - -type ChatGPTAppProps = { - loggedIn?: boolean; - updateLoginStatus?: (loggedIn: boolean) => void; - initMessage?: string; -}; -export const ChatGPTApp = ({ loggedIn, initMessage, updateLoginStatus }: ChatGPTAppProps) => { - const [isLoggedIn, setIsLoggedIn] = useState(loggedIn ?? false); - - useEffect(() => { - if (updateLoginStatus) { - updateLoginStatus(isLoggedIn); - } - }, [isLoggedIn]); - - return isLoggedIn ? ( - - ) : ( - - ); -}; diff --git a/packages/click-prompt/src/components/chatgpt/ChatRoom.tsx b/packages/click-prompt/src/components/chatgpt/ChatRoom.tsx deleted file mode 100644 index 8d7df4e0..00000000 --- a/packages/click-prompt/src/components/chatgpt/ChatRoom.tsx +++ /dev/null @@ -1,439 +0,0 @@ -"use client"; - -import NewChat from "@/assets/icons/new-chat.svg"; -import TrashcanIcon from "@/assets/icons/trashcan.svg"; -import LogoutIcon from "@/assets/icons/logout.svg"; -import Image from "next/image"; -import content from "@/assets/images/content.png"; -import send from "@/assets/icons/send.svg?url"; -import React, { Dispatch, SetStateAction, useEffect, useState } from "react"; -import styled from "@emotion/styled"; -import type { RequestGetConversations, ResponseGetConversations } from "@/pages/api/chatgpt/conversation"; -import { ResponseGetChats, ResponseSend } from "@/pages/api/chatgpt/chat"; -import { BeatLoader } from "react-spinners"; -import { useDebouncedCallback } from "use-debounce"; -import { Input } from "@chakra-ui/react"; -import * as ChatAPI from "@/api/chat"; -import * as ConversationAPI from "@/api/conversation"; -import * as UserAPI from "@/api/user"; -import SimpleMarkdown from "@/components/markdown/SimpleMarkdown"; - -const ChatInput = styled("input")` - background: #ffffff; - border-radius: 8px; - border: none; - padding: 0.5rem 1rem; - width: 768px; - height: 48px; - font-size: 1rem; - font-weight: 500; - color: #1e1e1e; - outline: none; - transition: all 0.2s ease-in-out; - - &:focus { - box-shadow: 0 0 0 2px #1e1e1e; - } - - &:focus::placeholder { - color: #1e1e1e; - } -`; -const ChatInputWrapper = styled("div")` - position: absolute; - bottom: 8px; - width: 768px; - height: 48px; - background-color: #fff; - border-radius: 8px; -`; -const ChatsWrapper = styled("div")` - // good looking scrollbar - &::-webkit-scrollbar { - width: 8px; - } - - &::-webkit-scrollbar-track { - background: #f1f1f1; - } - - &::-webkit-scrollbar-thumb { - background: #888; - } - - &::-webkit-scrollbar-thumb:hover { - background: #555; - } -`; -const ChatSendButton = styled("button")` - position: absolute; - top: 0; - bottom: 0; - right: 8px; - width: 48px; - height: 48px; - background-image: url(${send}); - background-size: 24px; - background-position: center; - background-repeat: no-repeat; - cursor: pointer; - border: none; - outline: none; -`; - -export const ChatRoom = ({ - setIsLoggedIn, - initMessage, -}: { - setIsLoggedIn: Dispatch>; - initMessage?: string; -}) => { - const chatsWrapper = React.useRef(null); - const [disable, setDisable] = React.useState(false); - const [chatHistory, setChatHistory] = React.useState([]); - const [message, setMessage] = React.useState(initMessage ?? ""); - - const [conversations, setConversations] = useState([]); - const [currentConversation, setCurrentConversation] = useState(null); - // editing conversation name - const [editing, setEditing] = useState(null); - const [editingName, setEditingName] = useState(""); - - // get conversations - useEffect(() => { - (async () => { - try { - const response = await fetch("/api/chatgpt/conversation", { - method: "POST", - body: JSON.stringify({ - action: "get_conversations", - } as RequestGetConversations), - }); - const data = (await response.json()) as ResponseGetConversations; - if (!response.ok) { - alert("Error: " + JSON.stringify((data as any).error)); - return; - } - setConversations(data); - } catch (error) { - setConversations([]); - alert("Error: " + JSON.stringify(error)); - } - })(); - }, []); - - // scroll to bottom - useEffect(() => { - setTimeout(() => { - if (chatsWrapper.current) { - chatsWrapper.current.scrollTop = chatsWrapper.current.scrollHeight; - } - }); - }, [chatHistory]); - - const onEnterForSendMessage: React.KeyboardEventHandler = (event) => { - if (event.code === "Enter" || event.code === "NumpadEnter") { - event.preventDefault(); - - sendMessage(); - } - }; - - async function createConversation() { - const data = await ConversationAPI.createConversation(); - if (!data) { - return; - } - - setConversations([data, ...conversations]); - return data; - } - - async function changeConversationName(conversationId: number, name: string) { - await ConversationAPI.changeConversationName(conversationId, name); - - setConversations((c) => - c.map((conversation) => { - if (conversation.id === conversationId) { - return { - ...conversation, - name, - }; - } - return conversation; - }), - ); - } - - const handleConversation = useDebouncedCallback( - async (conversationId: number | null, event: React.MouseEvent) => { - if (event.detail > 1) { - // double click - if (conversationId == null) { - return; - } - setEditingName(conversations.find((c) => c.id === conversationId)?.name ?? ""); - setEditing(conversationId); - return; - } - - if (conversationId == null) { - setCurrentConversation(null); - setChatHistory([]); - return; - } - setDisable(true); - - try { - setCurrentConversation(conversationId); - const data = await ChatAPI.getChatsByConversationId(conversationId); - if (!data) { - return; - } - setChatHistory(data); - } catch (e) { - console.log("changeConversation: ", e); - } finally { - setDisable(false); - } - }, - 200, - ); - - async function deleteConversation(conversationId: number) { - const data = await ConversationAPI.deleteConversation(conversationId); - if (!data) { - return; - } - setConversations(conversations.filter((conversation) => conversation.id !== conversationId)); - } - - async function deleteAllConversations() { - const data = await ConversationAPI.deleteAllConversations(); - if (!data) { - return; - } - setConversations([]); - } - // FIXME anti-pattern, should use `useState` - let codeMark = ""; - async function sendMessage() { - if (message.length === 0) { - alert("Please enter your message first."); - return; - } - - try { - setDisable(true); - if (currentConversation == null) { - const created = await createConversation(); - setCurrentConversation(created?.id ?? null); - } - - setMessage(""); - let updatedHistory = [ - ...chatHistory, - { - role: "user", - content: message, - // TODO(CGQAQ): custom name of user - // name: "User", - }, - ] as ResponseSend; - - setChatHistory([...updatedHistory]); - - const data = await ChatAPI.sendMsgWithStreamRes(currentConversation as number, message); - if (!data) { - setDisable(false); - setChatHistory([...updatedHistory.slice(0, updatedHistory.length - 1)]); - return; - } - const reader = data.getReader(); - const decoder = new TextDecoder(); - let isDone = false; - while (!isDone) { - const { value, done } = await reader.read(); - isDone = done; - const chunkValue = decoder.decode(value); - const lines = chunkValue.split("\n").filter((line) => line.trim() !== ""); - for (const line of lines) { - const message = line.replace(/^data: /, ""); - if (message === "[DONE]") { - setDisable(false); - } else { - const parsed = JSON.parse(message).choices[0].delta; - if (parsed && Object.keys(parsed).length > 0) { - if (!!parsed.role) { - parsed.content = ""; - updatedHistory = [...updatedHistory, parsed]; - } else if (!!parsed.content) { - if (parsed.content === "```") { - // code block start - if (!codeMark) { - codeMark = parsed.content; - } else { - // code block end remove it - codeMark = ""; - } - } - updatedHistory[updatedHistory.length - 1].content += parsed.content; - } - setChatHistory([...updatedHistory]); - } - } - } - } - } catch (err) { - console.log(err); - setDisable(false); - } finally { - // setDisable(false); - } - } - - async function logout() { - await UserAPI.logout(); - setIsLoggedIn(false); - } - - return ( -
- {/* left */} -
-
- - New chat -
-
- {conversations.map((conversation) => ( -
{ - handleConversation(conversation.id!, event); - }} - > - {editing === conversation.id ? ( - { - setEditingName(ev.currentTarget.value); - }} - onKeyDown={(ev) => { - if (ev.key === "Enter" || ev.key === "NumpadEnter") { - ev.preventDefault(); - changeConversationName(conversation.id!, ev.currentTarget.value).finally(() => { - setEditing(null); - }); - } else if (ev.key === "Escape") { - ev.preventDefault(); - setEditing(null); - } - }} - onBlur={async (ev) => { - await changeConversationName(conversation.id!, ev.currentTarget.value); - setEditing(null); - }} - /> - ) : ( - <> -
- {conversation.name} -
- {/* delete button */} -
{ - e.stopPropagation(); - if (confirm("Are you sure to delete this conversation?")) { - deleteConversation(conversation.id!); - } - }} - > - -
- - )} -
- ))} -
-
-
{ - e.stopPropagation(); - if (confirm("Are you sure to delete ALL conversations?")) { - deleteAllConversations(); - } - }} - > - - Clear conversations -
-
- - Log out -
-
-
- - {/* right */} -
- {chatHistory.length === 0 && background image} - - {/* chats */} - - {chatHistory.map((chat, index) => { - return ( -
- {chat.role === "user" ? ( -
- {/* chat bubble badge */} -
- -
-
- ) : ( -
-
- -
-
- )} -
- ); - })} -
- - - setMessage(ev.target.value)} - onKeyDown={onEnterForSendMessage} - className='w-full pr-10 md:w-11/12 border-0 md:pr-0 focus:ring-0' - /> - {disable ? ( - - ) : ( - - )} - -
-
- ); -}; diff --git a/packages/click-prompt/src/components/chatgpt/LoginPage.tsx b/packages/click-prompt/src/components/chatgpt/LoginPage.tsx deleted file mode 100644 index 625a4c06..00000000 --- a/packages/click-prompt/src/components/chatgpt/LoginPage.tsx +++ /dev/null @@ -1,61 +0,0 @@ -"use client"; - -import { Button, Input } from "@/components/ChakraUI"; -import React, { Dispatch, SetStateAction } from "react"; -import * as UserApi from "@/api/user"; - -export const LoginPage = ({ setIsLoggedIn }: { setIsLoggedIn: Dispatch> }) => { - const [openAiKey, setOpenAiKey] = React.useState(""); - - async function login(key: string) { - if (key.length === 0) { - alert("Please enter your OpenAI API key first."); - return; - } - - const data = await UserApi.login(key); - if (data) { - setIsLoggedIn(true); - } else { - alert("Login failed. Please check your API key."); - setIsLoggedIn(false); - } - } - - return ( -
-

ChatGPT

-

You need to login first use your own key.

-
-
- 1. Sign up for the   - - OpenAI Platform. - -
-
- 2. Create a new secret key in   - - Settings → API keys. - -
-
3. Copy and paste your API key here:
-
-
- setOpenAiKey(ev.target.value)} - > - -
-
- ); -}; diff --git a/packages/click-prompt/src/layout/NavBar.tsx b/packages/click-prompt/src/layout/NavBar.tsx index 7c14615b..302ac913 100644 --- a/packages/click-prompt/src/layout/NavBar.tsx +++ b/packages/click-prompt/src/layout/NavBar.tsx @@ -32,7 +32,7 @@ export default async function NavBar({ locale }: { locale: string }) { { url: `/chatgpt-interactive-game/`, title: g("chatgpt-interactive-game") }, { url: `/chatgpt-samples/`, title: g("chatgpt-samples") }, { url: `/chatgpt/`, title: g("chatgpt") }, - { url: `/chatgpt-visual-novel/`, title: g("chatgpt-visual-novel") }, + { url: `https://chatvisualnovel.com/`, title: g("chatgpt-visual-novel") }, ], }, { diff --git a/packages/click-prompt/tsconfig.json b/packages/click-prompt/tsconfig.json index b5cde3c3..ba94e280 100644 --- a/packages/click-prompt/tsconfig.json +++ b/packages/click-prompt/tsconfig.json @@ -1,26 +1,8 @@ { + "extends": "tsconfig/base.json", "baseUrl": ".", // This has to be specified if "paths" is. "compilerOptions": { "baseUrl": ".", - "target": "ES2020", - "lib": [ - "dom", - "dom.iterable", - "ES2021.String", - "esnext" - ], - "allowJs": true, - "skipLibCheck": true, - "strict": true, - "forceConsistentCasingInFileNames": true, - "noEmit": true, - "esModuleInterop": true, - "module": "esnext", - "moduleResolution": "node", - "resolveJsonModule": true, - "isolatedModules": true, - "jsx": "preserve", - "incremental": true, "plugins": [ { "name": "next" @@ -33,15 +15,13 @@ "@i18n/*": [ "./i18n/*" ] - } + }, + "strictNullChecks": true }, "include": [ "next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts" - ], - "exclude": [ - "node_modules" ] } diff --git a/packages/eslint-config-custom/index.js b/packages/eslint-config-custom/index.js new file mode 100644 index 00000000..8ae4dd9f --- /dev/null +++ b/packages/eslint-config-custom/index.js @@ -0,0 +1,11 @@ +module.exports = { + root: true, + plugins: ["@typescript-eslint"], + extends: ["plugin:@typescript-eslint/recommended", "prettier"], + rules: { + "react-hooks/exhaustive-deps": "off", + "no-console": "off", + "@typescript-eslint/no-unused-vars": "off", + "@typescript-eslint/no-explicit-any": "off", + }, +}; diff --git a/packages/eslint-config-custom/package.json b/packages/eslint-config-custom/package.json new file mode 100644 index 00000000..2bb0b55d --- /dev/null +++ b/packages/eslint-config-custom/package.json @@ -0,0 +1,8 @@ +{ + "name": "eslint-config-custom", + "main": "index.js", + "version": "1.0.0", + "devDependencies": { + "eslint": "latest" + } +} diff --git a/packages/tsconfig/base.json b/packages/tsconfig/base.json new file mode 100644 index 00000000..87ee9647 --- /dev/null +++ b/packages/tsconfig/base.json @@ -0,0 +1,21 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "compilerOptions": { + "target": "ESNext", + "lib": ["dom", "dom.iterable", "ES2021.String", "esnext"], + "allowJs": true, + "skipLibCheck": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "noEmit": true, + "esModuleInterop": true, + "module": "esnext", + "moduleResolution": "node", + "resolveJsonModule": true, + "isolatedModules": true, + "jsx": "preserve", + "incremental": true, + "strictNullChecks": true + }, + "exclude": ["node_modules"] +} diff --git a/packages/tsconfig/package.json b/packages/tsconfig/package.json new file mode 100644 index 00000000..f4735add --- /dev/null +++ b/packages/tsconfig/package.json @@ -0,0 +1,3 @@ +{ + "name": "tsconfig" +} diff --git a/turbo.json b/turbo.json index 5cd710a1..147d6d25 100644 --- a/turbo.json +++ b/turbo.json @@ -13,6 +13,11 @@ "lint": { "dependsOn": ["format"] }, - "dev": {} + "dev": { + "dependsOn": ["^build"] + }, + "start": { + "dependsOn": ["build"] + } } }