migrating to Vite

This commit is contained in:
Your Name 2023-05-10 23:30:09 +05:30
commit 39b965d502
20 changed files with 1135 additions and 14093 deletions

View file

@ -4,12 +4,12 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<link rel="icon" href="/favicon.ico" />
<title>LangFlow</title>
</head>
<body id='body' style="width: 100%; height:100%">
<noscript>You need to enable JavaScript to run this app.</noscript>
<div style="width: 100vw; height:100vh" id='root'>
</div>
<div style="width: 100vw; height:100vh" id='root'></div>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>

File diff suppressed because it is too large Load diff

View file

@ -10,13 +10,6 @@
"@mui/material": "^5.11.9",
"@tailwindcss/forms": "^0.5.3",
"@tailwindcss/line-clamp": "^0.4.4",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.5.2",
"@types/node": "^16.18.12",
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
"ace-builds": "^1.16.0",
"ansi-to-html": "^0.7.2",
"axios": "^1.3.2",
@ -30,18 +23,15 @@
"react-icons": "^4.8.0",
"react-laag": "^2.0.5",
"react-router-dom": "^6.8.1",
"react-scripts": "5.0.1",
"react-tabs": "^6.0.0",
"reactflow": "^11.5.5",
"tailwindcss": "^3.2.6",
"typescript": "^4.9.5",
"uuid": "^9.0.0",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"start": "vite",
"build": "vite build",
"derve": "vite preview"
},
"eslintConfig": {
"extends": [
@ -61,5 +51,22 @@
"last 1 safari version"
]
},
"proxy": "http://127.0.0.1:7860"
}
"proxy": "http://127.0.0.1:7860",
"devDependencies": {
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.5.2",
"@types/lodash": "^4.14.194",
"@types/node": "^16.18.12",
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"@types/uuid": "^9.0.1",
"@vitejs/plugin-react-swc": "^3.0.0",
"autoprefixer": "^10.4.14",
"postcss": "^8.4.23",
"tailwindcss": "^3.3.2",
"typescript": "^5.0.2",
"vite": "^4.3.5"
}
}

View file

@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}

View file

@ -2,6 +2,8 @@ import "reactflow/dist/style.css";
import { useState, useEffect, useContext } from "react";
import "./App.css";
import { useLocation } from "react-router-dom";
import _ from "lodash";
import ErrorAlert from "./alerts/error";
import NoticeAlert from "./alerts/notice";
import SuccessAlert from "./alerts/success";
@ -14,7 +16,6 @@ import CrashErrorComponent from "./components/CrashErrorComponent";
import { TabsContext } from "./contexts/tabsContext";
export default function App() {
var _ = require("lodash");
let { setCurrent, setShowSideBar, setIsStackedOpen } =
useContext(locationContext);

View file

@ -2,7 +2,7 @@ import { ChatBubbleLeftEllipsisIcon, ChatBubbleOvalLeftEllipsisIcon, PlusSmallIc
import { useState } from "react";
import { ChatMessageType } from "../../../types/chat";
import { nodeColors } from "../../../utils";
var Convert = require('ansi-to-html');
import Convert from "ansi-to-html";
var convert = new Convert({newline:true});
export default function ChatMessage({ chat }: { chat: ChatMessageType }) {

View file

@ -4,7 +4,7 @@ import { ChatMessageType, ChatType } from "../../types/chat";
import ChatTrigger from "./chatTrigger";
import ChatModal from "../../modals/chatModal";
const _ = require("lodash");
import _ from "lodash";
export default function Chat({ flow }: ChatType) {
const [open, setOpen] = useState(false);

View file

@ -2,7 +2,7 @@ import { PlusIcon, XMarkIcon } from "@heroicons/react/24/outline";
import { useEffect, useState } from "react";
import { InputListComponentType } from "../../types/components";
var _ = require("lodash");
import _ from "lodash";
export default function InputListComponent({ value, onChange, disabled}:InputListComponentType) {
const [inputList, setInputList] = useState(value ?? [""]);

View file

@ -1,7 +1,7 @@
import { createContext, ReactNode, useState } from "react";
import { AlertItemType } from "../types/alerts";
var _ = require("lodash");
import _ from "lodash";
//types for alertContextType
type alertContextType = {

View file

@ -12,7 +12,7 @@ import { normalCaseToSnakeCase, updateObject, updateTemplate } from "../utils";
import { alertContext } from "./alertContext";
import { typesContext } from "./typesContext";
import { APITemplateType, TemplateVariableType } from "../types/api";
const { v4: uuidv4 } = require("uuid");
import { v4 as uuidv4 } from "uuid";
const TabsContextInitialValue: TabsContextType = {
save: () => {},

View file

@ -1,4 +1,6 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
body {
margin: 0;

View file

@ -5,6 +5,8 @@ import reportWebVitals from "./reportWebVitals";
import { BrowserRouter } from "react-router-dom";
import ContextWrapper from "./contexts";
import './index.css';
const root = ReactDOM.createRoot(
document.getElementById("root") as HTMLElement
);

View file

@ -5,7 +5,7 @@ import { classNames } from "../../../utils";
import AiIcon from "../../../assets/Gooey Ring-5s-271px.svg";
import { UserIcon } from "@heroicons/react/24/solid";
import FileCard from "../fileComponent";
var Convert = require("ansi-to-html");
import Convert from "ansi-to-html";
var convert = new Convert({ newline: true });
export default function ChatMessage({ chat }: { chat: ChatMessageType }) {

View file

@ -17,7 +17,7 @@ import { sendAllProps } from "../../types/api";
import { ChatMessageType, ChatType } from "../../types/chat";
import ChatInput from "./chatInput";
const _ = require("lodash");
import _ from "lodash";
export default function ChatModal({
flow,
@ -56,10 +56,7 @@ export default function ChatModal({
function connectWS() {
console.log("conectou");
try {
const urlWs =
process.env.NODE_ENV === "development"
? `ws://localhost:7860/chat/${flow.id}`
: `${window.location.protocol === "https:" ? "wss" : "ws"}://${
const urlWs = `${window.location.protocol === "https:" ? "wss" : "ws"}://${
window.location.host
}/chat/${flow.id}`;

View file

@ -7,7 +7,7 @@ import "ace-builds/src-noconflict/mode-python";
import "ace-builds/src-noconflict/theme-github";
import "ace-builds/src-noconflict/theme-twilight";
import "ace-builds/src-noconflict/ext-language_tools";
import "ace-builds/webpack-resolver";
// import "ace-builds/webpack-resolver";
import { darkContext } from "../../contexts/darkContext";
import { checkCode } from "../../controllers/API";
import { alertContext } from "../../contexts/alertContext";

View file

@ -3,7 +3,7 @@ import { useContext, useState } from "react";
import { TabsContext } from "../../../../contexts/tabsContext";
import { FlowType } from "../../../../types/flow";
var _ = require("lodash");
import _ from "lodash";
export default function TabComponent({ selected, flow, onClick }:{flow:FlowType,selected:boolean,onClick:()=>void}) {
const { removeFlow, updateFlow, flows } =

View file

@ -11,6 +11,7 @@ import ReactFlow, {
Connection,
Edge,
} from "reactflow";
import _ from "lodash";
import { locationContext } from "../../contexts/locationContext";
import ExtraSidebar from "./components/extraSidebarComponent";
import Chat from "../../components/chatComponent";
@ -27,7 +28,6 @@ const nodeTypes = {
genericNode: GenericNode,
};
var _ = require("lodash");
export default function FlowPage({ flow }:{flow:FlowType}) {
let { updateFlow, incrementNodeId} =

View file

@ -19,7 +19,7 @@ import {
import { Connection, Edge, Node, ReactFlowInstance } from "reactflow";
import { FlowType } from "./types/flow";
import { APITemplateType, TemplateVariableType } from "./types/api";
var _ = require("lodash");
import _ from "lodash";
export function classNames(...classes: Array<string>) {
return classes.filter(Boolean).join(" ");

View file

@ -1,7 +1,10 @@
/** @type {import('tailwindcss').Config} */
const plugin = require("tailwindcss/plugin");
import plugin from "tailwindcss/plugin";
module.exports = {
content: ["./src/**/*.{js,ts,tsx,jsx}"],
content: [
"./index.html",
"./src/**/*.{js,ts,tsx,jsx}",
],
darkMode: "class",
important: true,
theme: {

View file

@ -0,0 +1,34 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react-swc';
const apiRoutes = [
'/all',
'/predict',
'^/validate/*',
'^/chat/*',
];
const proxyTargets = apiRoutes.reduce((proxyObj, route) => {
proxyObj[route] = {
target: 'http://127.0.0.1:7860',
changeOrigin: true,
secure: false,
ws: true,
};
return proxyObj;
}, {});
export default defineConfig(() => {
return {
build: {
outDir: 'build',
},
plugins: [react()],
server: {
port: 3000,
proxy: {
...proxyTargets
}
},
};
});