diff --git a/analyze/nodejs.html b/analyze/nodejs.html new file mode 100644 index 0000000..fcb1d89 --- /dev/null +++ b/analyze/nodejs.html @@ -0,0 +1,39 @@ + + + + + + secureshare [24 Sep 2023 at 13:18] + + + + + + + + +
+ + + \ No newline at end of file diff --git a/next.config.js b/next.config.js index cbc8a71..12539b6 100644 --- a/next.config.js +++ b/next.config.js @@ -1,3 +1,8 @@ +const withPlugins = require('next-compose-plugins'); +const withBundleAnalyzer = require('@next/bundle-analyzer')({ + enabled: process.env.ANALYZE === 'true', +}) + /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, @@ -13,4 +18,4 @@ const nextConfig = { }, } -module.exports = nextConfig +module.exports = withPlugins([withBundleAnalyzer], nextConfig); diff --git a/package-lock.json b/package-lock.json index 197753b..1bcb5af 100644 --- a/package-lock.json +++ b/package-lock.json @@ -42,6 +42,7 @@ "livekit-server-sdk": "^1.2.6", "lucide-react": "^0.263.2-beta.0", "next": "13.4.9", + "next-compose-plugins": "^2.2.1", "next-superjson-plugin": "^0.5.9", "next-themes": "^0.2.1", "react": "18.2.0", @@ -53,10 +54,12 @@ "zod": "^3.21.4" }, "devDependencies": { + "@next/bundle-analyzer": "^13.5.2", "@types/formidable": "^3.4.0", "@typescript-eslint/eslint-plugin": "^6.7.0", "@typescript-eslint/parser": "^6.7.0", "autoprefixer": "^10.4.14", + "cross-env": "^7.0.3", "daisyui": "^3.2.1", "eslint-config-prettier": "^9.0.0", "eslint-plugin-next": "^0.0.0", @@ -470,6 +473,15 @@ "node": ">=14" } }, + "node_modules/@next/bundle-analyzer": { + "version": "13.5.2", + "resolved": "https://registry.npmjs.org/@next/bundle-analyzer/-/bundle-analyzer-13.5.2.tgz", + "integrity": "sha512-njvZIrbOHe4IK4Zzo4w4M9WLaVs3t1Uqu/mm4hx1XmaUmj9fWr0OfeJG+ZkemPTm07WeZVuJRzuklkV+cD8BKQ==", + "dev": true, + "dependencies": { + "webpack-bundle-analyzer": "4.7.0" + } + }, "node_modules/@next/env": { "version": "13.4.9", "resolved": "https://registry.npmjs.org/@next/env/-/env-13.4.9.tgz", @@ -705,6 +717,12 @@ "url": "https://opencollective.com/unts" } }, + "node_modules/@polka/url": { + "version": "1.0.0-next.23", + "resolved": "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.23.tgz", + "integrity": "sha512-C16M+IYz0rgRhWZdCmK+h58JMv8vijAA61gmz2rspCSwKwzBebpdcsiUmwrtJRdphuY30i6BSLEOP8ppbNLyLg==", + "dev": true + }, "node_modules/@prisma/client": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/@prisma/client/-/client-5.0.0.tgz", @@ -2059,6 +2077,15 @@ "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, + "node_modules/acorn-walk": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", + "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", @@ -2766,6 +2793,24 @@ "url": "https://github.com/sponsors/mesqueeb" } }, + "node_modules/cross-env": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", + "integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.1" + }, + "bin": { + "cross-env": "src/bin/cross-env.js", + "cross-env-shell": "src/bin/cross-env-shell.js" + }, + "engines": { + "node": ">=10.14", + "npm": ">=6", + "yarn": ">=1" + } + }, "node_modules/cross-fetch": { "version": "3.1.8", "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.8.tgz", @@ -3061,6 +3106,12 @@ "tslib": "^2.0.3" } }, + "node_modules/duplexer": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.2.tgz", + "integrity": "sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg==", + "dev": true + }, "node_modules/eastasianwidth": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", @@ -4266,6 +4317,21 @@ "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==" }, + "node_modules/gzip-size": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-6.0.0.tgz", + "integrity": "sha512-ax7ZYomf6jqPTQ4+XCpUGyXKHk5WweS+e05MBO4/y3WJ5RkmPXNKvX+bx1behVILVwr6JSQvZAku021CHPXG3Q==", + "dev": true, + "dependencies": { + "duplexer": "^0.1.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", @@ -5183,6 +5249,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true + }, "node_modules/lodash.includes": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", @@ -5409,6 +5481,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/mrmime": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/mrmime/-/mrmime-1.0.1.tgz", + "integrity": "sha512-hzzEagAgDyoU1Q6yg5uI+AorQgdvMCur3FcKf7NhMKWsaYg+RnbTyHRa/9IlLF9rf455MOCtcqqrQQ83pPP7Uw==", + "dev": true, + "engines": { + "node": ">=10" + } + }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -5497,6 +5578,11 @@ } } }, + "node_modules/next-compose-plugins": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/next-compose-plugins/-/next-compose-plugins-2.2.1.tgz", + "integrity": "sha512-OjJ+fV15FXO2uQXQagLD4C0abYErBjyjE0I0FHpOEIB8upw0hg1ldFP6cqHTJBH1cZqy96OeR3u1dJ+Ez2D4Bg==" + }, "node_modules/next-superjson-plugin": { "version": "0.5.9", "resolved": "https://registry.npmjs.org/next-superjson-plugin/-/next-superjson-plugin-0.5.9.tgz", @@ -5785,6 +5871,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/opener": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/opener/-/opener-1.5.2.tgz", + "integrity": "sha512-ur5UIdyw5Y7yEj9wLzhqXiy6GZ3Mwx0yGI+5sMn2r0N0v3cKJvUmFH5yPP+WXh9e0xfyzyJX95D8l088DNFj7A==", + "dev": true, + "bin": { + "opener": "bin/opener-bin.js" + } + }, "node_modules/optionator": { "version": "0.9.3", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz", @@ -6690,6 +6785,20 @@ "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" }, + "node_modules/sirv": { + "version": "1.0.19", + "resolved": "https://registry.npmjs.org/sirv/-/sirv-1.0.19.tgz", + "integrity": "sha512-JuLThK3TnZG1TAKDwNIqNq6QA2afLOCcm+iE8D1Kj3GA40pSPsxQjjJl0J8X3tsR7T+CP1GavpzLwYkgVLWrZQ==", + "dev": true, + "dependencies": { + "@polka/url": "^1.0.0-next.20", + "mrmime": "^1.0.0", + "totalist": "^1.0.0" + }, + "engines": { + "node": ">= 10" + } + }, "node_modules/slash": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", @@ -7205,6 +7314,15 @@ "to-no-case": "^1.0.0" } }, + "node_modules/totalist": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/totalist/-/totalist-1.1.0.tgz", + "integrity": "sha512-gduQwd1rOdDMGxFG1gEvhV88Oirdo2p+KjoYFU7k2g+i7n6AFFbDQ5kMPUsW0pNbfQsB/cwXvT1i4Bue0s9g5g==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/tr46": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", @@ -7553,6 +7671,38 @@ "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" }, + "node_modules/webpack-bundle-analyzer": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/webpack-bundle-analyzer/-/webpack-bundle-analyzer-4.7.0.tgz", + "integrity": "sha512-j9b8ynpJS4K+zfO5GGwsAcQX4ZHpWV+yRiHDiL+bE0XHJ8NiPYLTNVQdlFYWxtpg9lfAQNlwJg16J9AJtFSXRg==", + "dev": true, + "dependencies": { + "acorn": "^8.0.4", + "acorn-walk": "^8.0.0", + "chalk": "^4.1.0", + "commander": "^7.2.0", + "gzip-size": "^6.0.0", + "lodash": "^4.17.20", + "opener": "^1.5.2", + "sirv": "^1.0.7", + "ws": "^7.3.1" + }, + "bin": { + "webpack-bundle-analyzer": "lib/bin/analyzer.js" + }, + "engines": { + "node": ">= 10.13.0" + } + }, + "node_modules/webpack-bundle-analyzer/node_modules/commander": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz", + "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==", + "dev": true, + "engines": { + "node": ">= 10" + } + }, "node_modules/webrtc-adapter": { "version": "8.2.3", "resolved": "https://registry.npmjs.org/webrtc-adapter/-/webrtc-adapter-8.2.3.tgz", @@ -7750,6 +7900,27 @@ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" }, + "node_modules/ws": { + "version": "7.5.9", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", + "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", + "dev": true, + "engines": { + "node": ">=8.3.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/yaeti": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz", @@ -8099,6 +8270,15 @@ "resolved": "https://registry.npmjs.org/@livekit/components-styles/-/components-styles-1.0.6.tgz", "integrity": "sha512-/toY2NFJCU0NdeP9AB+CWW9kPf8gdpndIoR0hYTKjDb8pHPdXDu5NE7XyO8qKIeV4biRFGsQ9+C3giPNgYm9TA==" }, + "@next/bundle-analyzer": { + "version": "13.5.2", + "resolved": "https://registry.npmjs.org/@next/bundle-analyzer/-/bundle-analyzer-13.5.2.tgz", + "integrity": "sha512-njvZIrbOHe4IK4Zzo4w4M9WLaVs3t1Uqu/mm4hx1XmaUmj9fWr0OfeJG+ZkemPTm07WeZVuJRzuklkV+cD8BKQ==", + "dev": true, + "requires": { + "webpack-bundle-analyzer": "4.7.0" + } + }, "@next/env": { "version": "13.4.9", "resolved": "https://registry.npmjs.org/@next/env/-/env-13.4.9.tgz", @@ -8232,6 +8412,12 @@ "tslib": "^2.6.0" } }, + "@polka/url": { + "version": "1.0.0-next.23", + "resolved": "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.23.tgz", + "integrity": "sha512-C16M+IYz0rgRhWZdCmK+h58JMv8vijAA61gmz2rspCSwKwzBebpdcsiUmwrtJRdphuY30i6BSLEOP8ppbNLyLg==", + "dev": true + }, "@prisma/client": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/@prisma/client/-/client-5.0.0.tgz", @@ -9094,6 +9280,12 @@ "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", "requires": {} }, + "acorn-walk": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", + "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", + "dev": true + }, "ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", @@ -9580,6 +9772,15 @@ "is-what": "^4.1.8" } }, + "cross-env": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", + "integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==", + "dev": true, + "requires": { + "cross-spawn": "^7.0.1" + } + }, "cross-fetch": { "version": "3.1.8", "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.8.tgz", @@ -9794,6 +9995,12 @@ "tslib": "^2.0.3" } }, + "duplexer": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.2.tgz", + "integrity": "sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg==", + "dev": true + }, "eastasianwidth": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", @@ -10679,6 +10886,15 @@ "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==" }, + "gzip-size": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/gzip-size/-/gzip-size-6.0.0.tgz", + "integrity": "sha512-ax7ZYomf6jqPTQ4+XCpUGyXKHk5WweS+e05MBO4/y3WJ5RkmPXNKvX+bx1behVILVwr6JSQvZAku021CHPXG3Q==", + "dev": true, + "requires": { + "duplexer": "^0.1.2" + } + }, "has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", @@ -11296,6 +11512,12 @@ "p-locate": "^5.0.0" } }, + "lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true + }, "lodash.includes": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", @@ -11461,6 +11683,12 @@ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==" }, + "mrmime": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/mrmime/-/mrmime-1.0.1.tgz", + "integrity": "sha512-hzzEagAgDyoU1Q6yg5uI+AorQgdvMCur3FcKf7NhMKWsaYg+RnbTyHRa/9IlLF9rf455MOCtcqqrQQ83pPP7Uw==", + "dev": true + }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -11523,6 +11751,11 @@ } } }, + "next-compose-plugins": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/next-compose-plugins/-/next-compose-plugins-2.2.1.tgz", + "integrity": "sha512-OjJ+fV15FXO2uQXQagLD4C0abYErBjyjE0I0FHpOEIB8upw0hg1ldFP6cqHTJBH1cZqy96OeR3u1dJ+Ez2D4Bg==" + }, "next-superjson-plugin": { "version": "0.5.9", "resolved": "https://registry.npmjs.org/next-superjson-plugin/-/next-superjson-plugin-0.5.9.tgz", @@ -11700,6 +11933,12 @@ "is-wsl": "^2.2.0" } }, + "opener": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/opener/-/opener-1.5.2.tgz", + "integrity": "sha512-ur5UIdyw5Y7yEj9wLzhqXiy6GZ3Mwx0yGI+5sMn2r0N0v3cKJvUmFH5yPP+WXh9e0xfyzyJX95D8l088DNFj7A==", + "dev": true + }, "optionator": { "version": "0.9.3", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz", @@ -12272,6 +12511,17 @@ "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" }, + "sirv": { + "version": "1.0.19", + "resolved": "https://registry.npmjs.org/sirv/-/sirv-1.0.19.tgz", + "integrity": "sha512-JuLThK3TnZG1TAKDwNIqNq6QA2afLOCcm+iE8D1Kj3GA40pSPsxQjjJl0J8X3tsR7T+CP1GavpzLwYkgVLWrZQ==", + "dev": true, + "requires": { + "@polka/url": "^1.0.0-next.20", + "mrmime": "^1.0.0", + "totalist": "^1.0.0" + } + }, "slash": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", @@ -12627,6 +12877,12 @@ "to-no-case": "^1.0.0" } }, + "totalist": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/totalist/-/totalist-1.1.0.tgz", + "integrity": "sha512-gduQwd1rOdDMGxFG1gEvhV88Oirdo2p+KjoYFU7k2g+i7n6AFFbDQ5kMPUsW0pNbfQsB/cwXvT1i4Bue0s9g5g==", + "dev": true + }, "tr46": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", @@ -12866,6 +13122,31 @@ "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" }, + "webpack-bundle-analyzer": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/webpack-bundle-analyzer/-/webpack-bundle-analyzer-4.7.0.tgz", + "integrity": "sha512-j9b8ynpJS4K+zfO5GGwsAcQX4ZHpWV+yRiHDiL+bE0XHJ8NiPYLTNVQdlFYWxtpg9lfAQNlwJg16J9AJtFSXRg==", + "dev": true, + "requires": { + "acorn": "^8.0.4", + "acorn-walk": "^8.0.0", + "chalk": "^4.1.0", + "commander": "^7.2.0", + "gzip-size": "^6.0.0", + "lodash": "^4.17.20", + "opener": "^1.5.2", + "sirv": "^1.0.7", + "ws": "^7.3.1" + }, + "dependencies": { + "commander": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz", + "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==", + "dev": true + } + } + }, "webrtc-adapter": { "version": "8.2.3", "resolved": "https://registry.npmjs.org/webrtc-adapter/-/webrtc-adapter-8.2.3.tgz", @@ -13012,6 +13293,13 @@ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" }, + "ws": { + "version": "7.5.9", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", + "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", + "dev": true, + "requires": {} + }, "yaeti": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz", diff --git a/package.json b/package.json index aff5320..3c80955 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "livekit-server-sdk": "^1.2.6", "lucide-react": "^0.263.2-beta.0", "next": "13.4.9", + "next-compose-plugins": "^2.2.1", "next-superjson-plugin": "^0.5.9", "next-themes": "^0.2.1", "react": "18.2.0", @@ -59,10 +60,12 @@ "zod": "^3.21.4" }, "devDependencies": { + "@next/bundle-analyzer": "^13.5.2", "@types/formidable": "^3.4.0", "@typescript-eslint/eslint-plugin": "^6.7.0", "@typescript-eslint/parser": "^6.7.0", "autoprefixer": "^10.4.14", + "cross-env": "^7.0.3", "daisyui": "^3.2.1", "eslint-config-prettier": "^9.0.0", "eslint-plugin-next": "^0.0.0", diff --git a/src/components/home-content.tsx b/src/components/home-content.tsx index 350ce67..1661ab3 100644 --- a/src/components/home-content.tsx +++ b/src/components/home-content.tsx @@ -1,6 +1,6 @@ import React from 'react' -export function HomeContent({ children }: { children: React.ReactNode }) { +export default function HomeContent({ children }: { children: React.ReactNode }) { return (
diff --git a/src/components/message-dialog.tsx b/src/components/message-dialog.tsx index 8087740..f6015b0 100644 --- a/src/components/message-dialog.tsx +++ b/src/components/message-dialog.tsx @@ -16,7 +16,7 @@ interface MessageProps { onClose: () => void } -export function MessageDialog({ open, url, onClose }: MessageProps) { +export default function MessageDialog({ open, url, onClose }: MessageProps) { // memos const message = React.useMemo(() => { return `Hey, this is a SecureShare link. It will self-destruct after viewing. Make sure to copy it before closing it: ${url}` diff --git a/src/components/message-form.tsx b/src/components/message-form.tsx index 2af45f8..3b24988 100644 --- a/src/components/message-form.tsx +++ b/src/components/message-form.tsx @@ -1,5 +1,5 @@ import React from 'react' -import * as z from 'zod' +import { z } from 'zod' import { zodResolver } from '@hookform/resolvers/zod' import { Loader2, Paperclip, X } from 'lucide-react' import { useForm } from 'react-hook-form' @@ -61,7 +61,7 @@ interface MessageFormProps { onSubmit?: (url: string) => void } -export function MessageForm({ onSubmit: onFormSubmit }: MessageFormProps) { +export default function MessageForm({ onSubmit: onFormSubmit }: MessageFormProps) { // state const [progress, setProgress] = React.useState(0) const [status, setStatus] = React.useState('') diff --git a/src/pages/api/chat/url.ts b/src/pages/api/chat/url.ts deleted file mode 100644 index 81f900b..0000000 --- a/src/pages/api/chat/url.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { NextApiRequest, NextApiResponse } from 'next' -import { getLiveKitURL } from '../../../shared/utils' - -export default async function handleServerUrl( - req: NextApiRequest, - res: NextApiResponse -) { - try { - const { region } = req.query - - if (Array.isArray(region)) { - throw Error('provide max one region string') - } - const url = getLiveKitURL(region) - res.status(200).json({ url }) - } catch (e) { - res.statusMessage = (e as Error).message - res.status(500).end() - } -} diff --git a/src/pages/chats/[roomName].tsx b/src/pages/chats/[roomName].tsx index 25ab66f..90235b4 100644 --- a/src/pages/chats/[roomName].tsx +++ b/src/pages/chats/[roomName].tsx @@ -1,11 +1,14 @@ import React from 'react' +import dynamic from 'next/dynamic' import { ExternalE2EEKeyProvider, Room, RoomOptions } from 'livekit-client' import { LiveKitRoom, useToken } from '@livekit/components-react' import MainLayout from '../../layouts/main' -import { HomeContent } from '../../components/home-content' + import { useRouter } from 'next/router' import { LiveKitChat } from '../../components/livekit-chat' import { NewChatDialog } from '../../components/new-chat-dialog' +const HomeContent = dynamic(() => import('../../components/home-content'), { ssr: true }) + export default function ChatPage() { const [isClient, setIsClient] = React.useState(false) diff --git a/src/pages/index.tsx b/src/pages/index.tsx index df7b655..8e6a7b7 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -1,8 +1,9 @@ import React from 'react' -import { HomeContent } from '../components/home-content' +import dynamic from 'next/dynamic' import MainLayout from '../layouts/main' -import { MessageDialog } from '../components/message-dialog' -import { MessageForm } from '../components/message-form' +const HomeContent = dynamic(() => import('../components/home-content'), { ssr: true }) +const MessageDialog = dynamic(() => import('../components/message-dialog'), { ssr: false }) +const MessageForm = dynamic(() => import('../components/message-form'), { ssr: false }) export default function Home() { // state diff --git a/src/pages/messages/[publicId].tsx b/src/pages/messages/[publicId].tsx index eabcb44..4225dd7 100644 --- a/src/pages/messages/[publicId].tsx +++ b/src/pages/messages/[publicId].tsx @@ -1,5 +1,6 @@ import React from 'react' import { useRouter } from 'next/router' +import dynamic from 'next/dynamic' import { GetServerSideProps } from 'next' import { Message, Prisma } from '@prisma/client' import { getAuth } from '@clerk/nextjs/server' @@ -12,10 +13,10 @@ import { EventType, MessageStatus } from '../../shared/enums' import { decryptFile, decryptText } from '../../shared/encrypt-decrypt' // components -import { HomeContent } from '../../components/home-content' import MainLayout from '../../layouts/main' import { TextMessageDialog } from '../../components/text-message-dialog' -import { MessageForm } from '../../components/message-form' +const HomeContent = dynamic(() => import('../../components/home-content'), { ssr: true }) +const MessageForm = dynamic(() => import('../../components/message-form'), { ssr: false }) import { FileDownloadDialog } from '../../components/file-download-dialog' import { CounterDialog } from '../../components/counter-dialog' import { ErrorDialog } from '../../components/error-dialog' diff --git a/src/shared/hooks.ts b/src/shared/hooks.ts deleted file mode 100644 index fc4ef82..0000000 --- a/src/shared/hooks.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { useEffect, useState } from 'react'; - -export function useServerUrl(region?: string) { - const [serverUrl, setServerUrl] = useState(); - useEffect(() => { - let endpoint = `/api/chat/url`; - if (region) { - endpoint += `?region=${region}`; - } - fetch(endpoint).then(async (res) => { - if (res.ok) { - const body = await res.json(); - console.log(body); - setServerUrl(body.url); - } else { - throw Error('Error fetching server url, check server logs'); - } - }); - }); - return serverUrl; -} - diff --git a/src/shared/types.ts b/src/shared/types.ts index 1d4c781..e5f41fb 100644 --- a/src/shared/types.ts +++ b/src/shared/types.ts @@ -1,4 +1,3 @@ -import { LocalAudioTrack, LocalVideoTrack } from 'livekit-client'; import { Prisma } from '@prisma/client'; export interface EncryptionDetails { version: number @@ -29,16 +28,6 @@ export interface MessageEvent extends ClientInfo { } -export interface SessionProps { - roomName: string; - identity: string; - audioTrack?: LocalAudioTrack; - videoTrack?: LocalVideoTrack; - region?: string; - // turnServer?: RTCIceServer; - forceRelay?: boolean; -} - export interface TokenResult { identity: string; accessToken: string; diff --git a/src/shared/utils.ts b/src/shared/utils.ts index e30b148..42863aa 100644 --- a/src/shared/utils.ts +++ b/src/shared/utils.ts @@ -1,4 +1,3 @@ -import { RoomServiceClient } from 'livekit-server-sdk' import { addDays, addWeeks, addMonths } from 'date-fns' import { NextApiRequest } from 'next' import { ClientInfo, IpAddressInfo } from './types' @@ -147,33 +146,6 @@ export function generateRoomId(length: number = 10): string { return randomString } -function checkKeys() { - if (typeof process.env.LIVEKIT_API_KEY === 'undefined') { - throw new Error('LIVEKIT_API_KEY is not defined') - } - if (typeof process.env.LIVEKIT_API_SECRET === 'undefined') { - throw new Error('LIVEKIT_API_SECRET is not defined') - } -} - -export function getRoomClient(): RoomServiceClient { - checkKeys() - return new RoomServiceClient(getLiveKitURL()) -} - -export function getLiveKitURL(region?: string | string[]): string { - let targetKey = 'LIVEKIT_URL' - if (region && !Array.isArray(region)) { - targetKey = `LIVEKIT_URL_${region}`.toUpperCase() - } - const url = process.env[targetKey] - if (!url) { - throw new Error(`${targetKey} is not defined`) - } - return url -} - -// add return type export async function getIpAddressInfo(): Promise { try {