Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
reorganize components and add root import plugin
Danny Avila9d41ed46157b
diff --git a/.babelrc b/.babelrcindex fd78320fc2..4fddc17734 100644--- a/.babelrc+++ b/.babelrc@@ -11,6 +11,13 @@Babel's code transformations are enabled by applying plugins (or presets) to your configuration file.*/"plugins": [- "@babel/plugin-transform-runtime"+ "@babel/plugin-transform-runtime",+ [+ "babel-plugin-root-import",+ {+ "rootPathPrefix": "~/",+ "rootPathSuffix": "./src"+ }+ ]]}\ No newline at end of filediff --git a/.gitignore b/.gitignoreindex c2e0375e5e..f9c5a49088 100644--- a/.gitignore+++ b/.gitignore@@ -22,6 +22,7 @@ coveragebuild/dist/public/main.js+public/main.js.map# Dependency directorys# Deployed apps should consider commenting these lines out:diff --git a/index.js b/index.jsindex 0c4778e53d..9edd6a9f29 100644--- a/index.js+++ b/index.js@@ -2,7 +2,7 @@ import React from 'react';// import reactDom from 'react-dom'; ---> deprecatedimport { createRoot } from 'react-dom/client';import { Provider } from 'react-redux';-import { store } from './store';+import { store } from './src/store';import App from './src/App';import './src/style.css';diff --git a/package-lock.json b/package-lock.jsonindex 90ff233694..f8041cf9da 100644--- a/package-lock.json+++ b/package-lock.json@@ -35,6 +35,7 @@"@babel/preset-react": "^7.18.6","@babel/runtime": "^7.20.13","babel-loader": "^9.1.2",+ "babel-plugin-root-import": "^6.6.0","babel-preset-react": "^6.24.1","css-loader": "^6.7.3","eslint": "^8.33.0",@@ -4711,6 +4712,24 @@"@babel/core": "^7.0.0-0"}},+ "node_modules/babel-plugin-root-import": {+ "version": "6.6.0",+ "resolved": "https://registry.npmjs.org/babel-plugin-root-import/-/babel-plugin-root-import-6.6.0.tgz",+ "integrity": "sha512-SPzVOHd7nDh5loZwZBxtX/oOu1MXeKjTkz+1VnnzLWC0dk8sJIGC2IDQ2uWIBjE5mUtXlQ35MTHSqN0Xn7qHrg==",+ "dev": true,+ "dependencies": {+ "slash": "^3.0.0"+ }+ },+ "node_modules/babel-plugin-root-import/node_modules/slash": {+ "version": "3.0.0",+ "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",+ "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",+ "dev": true,+ "engines": {+ "node": ">=8"+ }+ },"node_modules/babel-plugin-syntax-flow": {"version": "6.18.0","resolved": "https://registry.npmjs.org/babel-plugin-syntax-flow/-/babel-plugin-syntax-flow-6.18.0.tgz",@@ -15958,6 +15977,23 @@"@babel/helper-define-polyfill-provider": "^0.3.3"}},+ "babel-plugin-root-import": {+ "version": "6.6.0",+ "resolved": "https://registry.npmjs.org/babel-plugin-root-import/-/babel-plugin-root-import-6.6.0.tgz",+ "integrity": "sha512-SPzVOHd7nDh5loZwZBxtX/oOu1MXeKjTkz+1VnnzLWC0dk8sJIGC2IDQ2uWIBjE5mUtXlQ35MTHSqN0Xn7qHrg==",+ "dev": true,+ "requires": {+ "slash": "^3.0.0"+ },+ "dependencies": {+ "slash": {+ "version": "3.0.0",+ "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",+ "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",+ "dev": true+ }+ }+ },"babel-plugin-syntax-flow": {"version": "6.18.0","resolved": "https://registry.npmjs.org/babel-plugin-syntax-flow/-/babel-plugin-syntax-flow-6.18.0.tgz",diff --git a/package.json b/package.jsonindex 518308a8db..db2278b98b 100644--- a/package.json+++ b/package.json@@ -47,6 +47,7 @@"@babel/preset-react": "^7.18.6","@babel/runtime": "^7.20.13","babel-loader": "^9.1.2",+ "babel-plugin-root-import": "^6.6.0","babel-preset-react": "^6.24.1","css-loader": "^6.7.3","eslint": "^8.33.0",diff --git a/public/index.html b/public/index.htmlindex ee4cdcdd76..8410c7a892 100644--- a/public/index.html+++ b/public/index.html@@ -2,7 +2,8 @@<html><head><meta charset="utf-8">- <title>Webpack App</title>+ <title>ChatGPT Clone</title>+ <link rel="shortcut icon" href="#"><meta name="viewport" content="width=device-width, initial-scale=1"><script defer src="main.js"></script></head><body><div id="root"></div>diff --git a/src/App.jsx b/src/App.jsxindex 276ff608ea..8a9153ac6d 100644--- a/src/App.jsx+++ b/src/App.jsx@@ -1,9 +1,9 @@import React from 'react';import { useSelector } from 'react-redux';-import Messages from './components/Messages';-import TextChat from './components/TextChat';+import Messages from './components/main/Messages';+import TextChat from './components/main/TextChat';import Nav from './components/Nav';-import MobileNav from './components/MobileNav';+import MobileNav from './components/Nav/MobileNav';import useSWR from 'swr';const fetcher = (url) => fetch(url).then((res) => res.json());diff --git a/src/components/Conversation.jsx b/src/components/Conversations/Conversation.jsxsimilarity index 93%rename from src/components/Conversation.jsxrename to src/components/Conversations/Conversation.jsxindex 3b56a9db0c..81c4e0fcb3 100644--- a/src/components/Conversation.jsx+++ b/src/components/Conversations/Conversation.jsx@@ -2,8 +2,8 @@ import React from 'react';import RenameButton from './RenameButton';import DeleteButton from './DeleteButton';import { useSelector, useDispatch } from 'react-redux';-import { setConversation } from '../../store/convoSlice';-import { setMessages } from '../../store/messageSlice';+import { setConversation } from '~/store/convoSlice';+import { setMessages } from '~/store/messageSlice';import useSWRMutation from 'swr/mutation';const fetcher = (url) => fetch(url).then((res) => res.json());diff --git a/src/components/DeleteButton.jsx b/src/components/Conversations/DeleteButton.jsxsimilarity index 89%rename from src/components/DeleteButton.jsxrename to src/components/Conversations/DeleteButton.jsxindex 99ec4394b7..bd8be47bf4 100644--- a/src/components/DeleteButton.jsx+++ b/src/components/Conversations/DeleteButton.jsx@@ -1,9 +1,11 @@import React from 'react';+import TrashIcon from '../svg/TrashIcon';export default function DeleteButton({ onClick, disabled }) {return (<button className="p-1 hover:text-white">- <svg+ <TrashIcon />+ {/* <svgstroke="currentColor"fill="none"strokeWidth="2"@@ -29,7 +31,7 @@ export default function DeleteButton({ onClick, disabled }) {x2="14"y2="17"/>- </svg>+ </svg> */}</button>);}diff --git a/src/components/RenameButton.jsx b/src/components/Conversations/RenameButton.jsxsimilarity index 100%rename from src/components/RenameButton.jsxrename to src/components/Conversations/RenameButton.jsxdiff --git a/src/components/Conversations.jsx b/src/components/Conversations/index.jsxsimilarity index 100%rename from src/components/Conversations.jsxrename to src/components/Conversations/index.jsxdiff --git a/src/components/MobileNav.jsx b/src/components/Nav/MobileNav.jsxsimilarity index 100%rename from src/components/MobileNav.jsxrename to src/components/Nav/MobileNav.jsxdiff --git a/src/components/NavLink.jsx b/src/components/Nav/NavLink.jsxsimilarity index 100%rename from src/components/NavLink.jsxrename to src/components/Nav/NavLink.jsxdiff --git a/src/components/NavLinks.jsx b/src/components/Nav/NavLinks.jsxsimilarity index 72%rename from src/components/NavLinks.jsxrename to src/components/Nav/NavLinks.jsxindex 4dac9d9f63..586baccedc 100644--- a/src/components/NavLinks.jsx+++ b/src/components/Nav/NavLinks.jsx@@ -1,8 +1,8 @@import React from 'react';import NavLink from './NavLink';-import TrashIcon from './svg/TrashIcon';-import DarkModeIcon from './svg/DarkModeIcon';-import LogOutIcon from './svg/LogOutIcon';+import TrashIcon from '../svg/TrashIcon';+import DarkModeIcon from '../svg/DarkModeIcon';+import LogOutIcon from '../svg/LogOutIcon';export default function NavLinks() {return (diff --git a/src/components/NewChat.jsx b/src/components/Nav/NewChat.jsxsimilarity index 100%rename from src/components/NewChat.jsxrename to src/components/Nav/NewChat.jsxdiff --git a/src/components/Nav.jsx b/src/components/Nav/index.jsxsimilarity index 93%rename from src/components/Nav.jsxrename to src/components/Nav/index.jsxindex c070c7f9f1..a11cbe2cd4 100644--- a/src/components/Nav.jsx+++ b/src/components/Nav/index.jsx@@ -1,6 +1,6 @@import React from 'react';import NewChat from './NewChat';-import Conversations from './Conversations';+import Conversations from '../Conversations';import NavLinks from './NavLinks';export default function Nav({ conversations }) {diff --git a/src/components/Message.jsx b/src/components/main/Message.jsxsimilarity index 100%rename from src/components/Message.jsxrename to src/components/main/Message.jsxdiff --git a/src/components/Messages.jsx b/src/components/main/Messages.jsxsimilarity index 100%rename from src/components/Messages.jsxrename to src/components/main/Messages.jsxdiff --git a/src/components/SubmitButton.jsx b/src/components/main/SubmitButton.jsxsimilarity index 100%rename from src/components/SubmitButton.jsxrename to src/components/main/SubmitButton.jsxdiff --git a/src/components/TextChat.jsx b/src/components/main/TextChat.jsxsimilarity index 95%rename from src/components/TextChat.jsxrename to src/components/main/TextChat.jsxindex 70a17927ef..48d7c395d7 100644--- a/src/components/TextChat.jsx+++ b/src/components/main/TextChat.jsx@@ -1,10 +1,10 @@import React, { useState } from 'react';import SubmitButton from './SubmitButton';import TextareaAutosize from 'react-textarea-autosize';-import handleSubmit from '../utils/handleSubmit';+import handleSubmit from '~/utils/handleSubmit';import { useSelector, useDispatch } from 'react-redux';-import { setConversation } from '../../store/convoSlice';-import { setMessages } from '../../store/messageSlice';+import { setConversation } from '~/store/convoSlice';+import { setMessages } from '~/store/messageSlice';export default function TextChat({ messages, reloadConvos }) {const [text, setText] = useState('');diff --git a/src/components/svg/DarkModeIcon.jsx b/src/components/svg/DarkModeIcon.jsxindex aaa66d2b02..29b002b512 100644--- a/src/components/svg/DarkModeIcon.jsx+++ b/src/components/svg/DarkModeIcon.jsx@@ -14,7 +14,7 @@ export default function DarkModeIcon() {width="1em"xmlns="http://www.w3.org/2000/svg">- <path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path>+ <path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" /></svg>);}diff --git a/src/components/svg/LogOutIcon.jsx b/src/components/svg/LogOutIcon.jsxindex faee97e80b..757e85fb79 100644--- a/src/components/svg/LogOutIcon.jsx+++ b/src/components/svg/LogOutIcon.jsx@@ -14,14 +14,14 @@ export default function LogOutIcon() {width="1em"xmlns="http://www.w3.org/2000/svg">- <path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"></path>- <polyline points="16 17 21 12 16 7"></polyline>+ <path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" />+ <polyline points="16 17 21 12 16 7" /><linex1="21"y1="12"x2="9"y2="12"- ></line>+ /></svg>);}diff --git a/src/components/svg/TrashIcon.jsx b/src/components/svg/TrashIcon.jsxindex e72ed7b6b8..357fbf05ad 100644--- a/src/components/svg/TrashIcon.jsx+++ b/src/components/svg/TrashIcon.jsx@@ -14,20 +14,20 @@ export default function TrashIcon() {width="1em"xmlns="http://www.w3.org/2000/svg">- <polyline points="3 6 5 6 21 6"></polyline>- <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path>+ <polyline points="3 6 5 6 21 6" />+ <path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" /><linex1="10"y1="11"x2="10"y2="17"- ></line>+ /><linex1="14"y1="11"x2="14"y2="17"- ></line>+ /></svg>);}diff --git a/store/convoSlice.js b/src/store/convoSlice.jssimilarity index 100%rename from store/convoSlice.jsrename to src/store/convoSlice.jsdiff --git a/store/index.js b/src/store/index.jssimilarity index 98%rename from store/index.jsrename to src/store/index.jsindex e37b91b014..491bc473ff 100644--- a/store/index.js+++ b/src/store/index.js@@ -8,4 +8,4 @@ export const store = configureStore({convo: convoReducer,messages: messageReducer,},-});+});\ No newline at end of filediff --git a/store/messageSlice.js b/src/store/messageSlice.jssimilarity index 100%rename from store/messageSlice.jsrename to src/store/messageSlice.jsdiff --git a/webpack.config.js b/webpack.config.jsindex 5cec748e50..2a671a37cc 100644--- a/webpack.config.js+++ b/webpack.config.js@@ -1,4 +1,5 @@const path = require('path');+require('dotenv').config();const HtmlWebpackPlugin = require('html-webpack-plugin');/*We are basically telling webpack to take index.js from entry. Then check for all file extensions in resolve.@@ -9,7 +10,7 @@ module.exports = {* the environment - development, production, none. tells webpack* to use its built-in optimizations accordingly. default is production*/- mode: 'development',+ mode: process.env.NODE_ENV,/** "entry"* the entry point*/