Merge pull request #8 from presenton/deps-and-env-cleanup

update deps and streamline env config
This commit is contained in:
Shiva Raj Badu 2025-05-11 20:02:29 +05:45 committed by GitHub
commit 1fd42a58cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 297450 additions and 25228 deletions

View file

@ -6,7 +6,8 @@ import { startFastApiServer, startNextJsServer } from "./servers";
import { ChildProcessByStdio } from "child_process";
import { localhost } from "./constants";
var isDev = !app.isPackaged;
var isDev = false;
// var isDev = !app.isPackaged;
var baseDir = app.getAppPath();
var fastapiDir = isDev ? path.join(baseDir, "servers/fastapi") : path.join(baseDir, "resources/fastapi");
var nextjsDir = isDev ? path.join(baseDir, "servers/nextjs") : path.join(baseDir, "resources/nextjs");
@ -19,10 +20,13 @@ var win: BrowserWindow | undefined;
var fastApiProcess: ChildProcessByStdio<any, any, any> | undefined;
var nextjsProcess: ChildProcessByStdio<any, any, any> | undefined;
const createWindow = () => {
win = new BrowserWindow({
webPreferences: {
webSecurity: false,
preload: path.join(__dirname, 'preload.js'),
},
width: 1280,
height: 720,
@ -31,6 +35,12 @@ const createWindow = () => {
async function startServers(fastApiPort: number, nextjsPort: number) {
try {
process.env.NEXT_PUBLIC_FAST_API = `${localhost}:${fastApiPort}`;
process.env.NEXT_PUBLIC_URL = `${localhost}:${nextjsPort}`;
process.env.TEMP_DIRECTORY = tempDir;
process.env.NEXT_PUBLIC_USER_CONFIG_PATH = userConfigPath;
fastApiProcess = await startFastApiServer(
fastapiDir,
fastApiPort,
@ -53,7 +63,7 @@ async function startServers(fastApiPort: number, nextjsPort: number) {
NEXT_PUBLIC_FAST_API: `${localhost}:${fastApiPort}`,
TEMP_DIRECTORY: tempDir,
NEXT_PUBLIC_URL: `${localhost}:${nextjsPort}`,
USER_CONFIG_PATH: userConfigPath,
NEXT_PUBLIC_USER_CONFIG_PATH: userConfigPath,
},
isDev
);

8
app/preload.ts Normal file
View file

@ -0,0 +1,8 @@
import { contextBridge } from 'electron';
contextBridge.exposeInMainWorld('env', {
NEXT_PUBLIC_FAST_API: process.env.NEXT_PUBLIC_FAST_API || '',
NEXT_PUBLIC_URL: process.env.NEXT_PUBLIC_URL || '',
TEMP_DIRECTORY: process.env.TEMP_DIRECTORY || '',
NEXT_PUBLIC_USER_CONFIG_PATH: process.env.NEXT_PUBLIC_USER_CONFIG_PATH || '',
});

View file

@ -13,7 +13,7 @@ interface NextJsEnv {
NEXT_PUBLIC_FAST_API?: string,
TEMP_DIRECTORY?: string,
NEXT_PUBLIC_URL?: string,
USER_CONFIG_PATH?: string,
NEXT_PUBLIC_USER_CONFIG_PATH?: string,
}
interface UserConfig {

3667
package-lock.json generated

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
('/home/viristo/prog/presentation_generator/presenton_open_source/servers/fastapi/build/fastapi/fastapi',
('/home/badu/workspace/badu/presenton/servers/fastapi/build/fastapi/fastapi',
True,
False,
True,
@ -12,46 +12,52 @@
None,
None,
None,
'/home/viristo/prog/presentation_generator/presenton_open_source/servers/fastapi/build/fastapi/fastapi.pkg',
'/home/badu/workspace/badu/presenton/servers/fastapi/build/fastapi/fastapi.pkg',
[('pyi-contents-directory _internal', '', 'OPTION'),
('PYZ-00.pyz',
'/home/viristo/prog/presentation_generator/presenton_open_source/servers/fastapi/build/fastapi/PYZ-00.pyz',
'/home/badu/workspace/badu/presenton/servers/fastapi/build/fastapi/PYZ-00.pyz',
'PYZ'),
('struct',
'/home/viristo/prog/presentation_generator/presenton_open_source/servers/fastapi/build/fastapi/localpycs/struct.pyc',
'/home/badu/workspace/badu/presenton/servers/fastapi/build/fastapi/localpycs/struct.pyc',
'PYMODULE'),
('pyimod01_archive',
'/home/viristo/prog/presentation_generator/presenton_open_source/servers/fastapi/build/fastapi/localpycs/pyimod01_archive.pyc',
'/home/badu/workspace/badu/presenton/servers/fastapi/build/fastapi/localpycs/pyimod01_archive.pyc',
'PYMODULE'),
('pyimod02_importers',
'/home/viristo/prog/presentation_generator/presenton_open_source/servers/fastapi/build/fastapi/localpycs/pyimod02_importers.pyc',
'/home/badu/workspace/badu/presenton/servers/fastapi/build/fastapi/localpycs/pyimod02_importers.pyc',
'PYMODULE'),
('pyimod03_ctypes',
'/home/viristo/prog/presentation_generator/presenton_open_source/servers/fastapi/build/fastapi/localpycs/pyimod03_ctypes.pyc',
'/home/badu/workspace/badu/presenton/servers/fastapi/build/fastapi/localpycs/pyimod03_ctypes.pyc',
'PYMODULE'),
('pyiboot01_bootstrap',
'/home/viristo/prog/presentation_generator/presenton_open_source/servers/fastapi/env/lib/python3.11/site-packages/PyInstaller/loader/pyiboot01_bootstrap.py',
'/home/badu/workspace/badu/presenton/servers/fastapi/.venv/lib/python3.11/site-packages/PyInstaller/loader/pyiboot01_bootstrap.py',
'PYSOURCE'),
('pyi_rth_inspect',
'/home/viristo/prog/presentation_generator/presenton_open_source/servers/fastapi/env/lib/python3.11/site-packages/PyInstaller/hooks/rthooks/pyi_rth_inspect.py',
'/home/badu/workspace/badu/presenton/servers/fastapi/.venv/lib/python3.11/site-packages/PyInstaller/hooks/rthooks/pyi_rth_inspect.py',
'PYSOURCE'),
('pyi_rth_pkgutil',
'/home/viristo/prog/presentation_generator/presenton_open_source/servers/fastapi/env/lib/python3.11/site-packages/PyInstaller/hooks/rthooks/pyi_rth_pkgutil.py',
'/home/badu/workspace/badu/presenton/servers/fastapi/.venv/lib/python3.11/site-packages/PyInstaller/hooks/rthooks/pyi_rth_pkgutil.py',
'PYSOURCE'),
('pyi_rth_multiprocessing',
'/home/viristo/prog/presentation_generator/presenton_open_source/servers/fastapi/env/lib/python3.11/site-packages/PyInstaller/hooks/rthooks/pyi_rth_multiprocessing.py',
'/home/badu/workspace/badu/presenton/servers/fastapi/.venv/lib/python3.11/site-packages/PyInstaller/hooks/rthooks/pyi_rth_multiprocessing.py',
'PYSOURCE'),
('pyi_rth_pkgres',
'/home/viristo/prog/presentation_generator/presenton_open_source/servers/fastapi/env/lib/python3.11/site-packages/PyInstaller/hooks/rthooks/pyi_rth_pkgres.py',
'/home/badu/workspace/badu/presenton/servers/fastapi/.venv/lib/python3.11/site-packages/PyInstaller/hooks/rthooks/pyi_rth_pkgres.py',
'PYSOURCE'),
('pyi_rth_setuptools',
'/home/badu/workspace/badu/presenton/servers/fastapi/.venv/lib/python3.11/site-packages/PyInstaller/hooks/rthooks/pyi_rth_setuptools.py',
'PYSOURCE'),
('pyi_rth_cryptography_openssl',
'/home/badu/workspace/badu/presenton/servers/fastapi/.venv/lib/python3.11/site-packages/_pyinstaller_hooks_contrib/rthooks/pyi_rth_cryptography_openssl.py',
'PYSOURCE'),
('server',
'/home/viristo/prog/presentation_generator/presenton_open_source/servers/fastapi/server.py',
'/home/badu/workspace/badu/presenton/servers/fastapi/server.py',
'PYSOURCE')],
[],
False,
False,
1746723975,
1746965123,
[('run',
'/home/viristo/prog/presentation_generator/presenton_open_source/servers/fastapi/env/lib/python3.11/site-packages/PyInstaller/bootloader/Linux-64bit-intel/run',
'/home/badu/workspace/badu/presenton/servers/fastapi/.venv/lib/python3.11/site-packages/PyInstaller/bootloader/Linux-64bit-intel/run',
'EXECUTABLE')],
'/lib/x86_64-linux-gnu/libpython3.11.so')
'/lib/x86_64-linux-gnu/libpython3.11.so.1.0')

View file

@ -1,4 +1,4 @@
('/home/viristo/prog/presentation_generator/presenton_open_source/servers/fastapi/build/fastapi/fastapi.pkg',
('/home/badu/workspace/badu/presenton/servers/fastapi/build/fastapi/fastapi.pkg',
{'BINARY': True,
'DATA': True,
'EXECUTABLE': True,
@ -10,39 +10,45 @@
'SYMLINK': False},
[('pyi-contents-directory _internal', '', 'OPTION'),
('PYZ-00.pyz',
'/home/viristo/prog/presentation_generator/presenton_open_source/servers/fastapi/build/fastapi/PYZ-00.pyz',
'/home/badu/workspace/badu/presenton/servers/fastapi/build/fastapi/PYZ-00.pyz',
'PYZ'),
('struct',
'/home/viristo/prog/presentation_generator/presenton_open_source/servers/fastapi/build/fastapi/localpycs/struct.pyc',
'/home/badu/workspace/badu/presenton/servers/fastapi/build/fastapi/localpycs/struct.pyc',
'PYMODULE'),
('pyimod01_archive',
'/home/viristo/prog/presentation_generator/presenton_open_source/servers/fastapi/build/fastapi/localpycs/pyimod01_archive.pyc',
'/home/badu/workspace/badu/presenton/servers/fastapi/build/fastapi/localpycs/pyimod01_archive.pyc',
'PYMODULE'),
('pyimod02_importers',
'/home/viristo/prog/presentation_generator/presenton_open_source/servers/fastapi/build/fastapi/localpycs/pyimod02_importers.pyc',
'/home/badu/workspace/badu/presenton/servers/fastapi/build/fastapi/localpycs/pyimod02_importers.pyc',
'PYMODULE'),
('pyimod03_ctypes',
'/home/viristo/prog/presentation_generator/presenton_open_source/servers/fastapi/build/fastapi/localpycs/pyimod03_ctypes.pyc',
'/home/badu/workspace/badu/presenton/servers/fastapi/build/fastapi/localpycs/pyimod03_ctypes.pyc',
'PYMODULE'),
('pyiboot01_bootstrap',
'/home/viristo/prog/presentation_generator/presenton_open_source/servers/fastapi/env/lib/python3.11/site-packages/PyInstaller/loader/pyiboot01_bootstrap.py',
'/home/badu/workspace/badu/presenton/servers/fastapi/.venv/lib/python3.11/site-packages/PyInstaller/loader/pyiboot01_bootstrap.py',
'PYSOURCE'),
('pyi_rth_inspect',
'/home/viristo/prog/presentation_generator/presenton_open_source/servers/fastapi/env/lib/python3.11/site-packages/PyInstaller/hooks/rthooks/pyi_rth_inspect.py',
'/home/badu/workspace/badu/presenton/servers/fastapi/.venv/lib/python3.11/site-packages/PyInstaller/hooks/rthooks/pyi_rth_inspect.py',
'PYSOURCE'),
('pyi_rth_pkgutil',
'/home/viristo/prog/presentation_generator/presenton_open_source/servers/fastapi/env/lib/python3.11/site-packages/PyInstaller/hooks/rthooks/pyi_rth_pkgutil.py',
'/home/badu/workspace/badu/presenton/servers/fastapi/.venv/lib/python3.11/site-packages/PyInstaller/hooks/rthooks/pyi_rth_pkgutil.py',
'PYSOURCE'),
('pyi_rth_multiprocessing',
'/home/viristo/prog/presentation_generator/presenton_open_source/servers/fastapi/env/lib/python3.11/site-packages/PyInstaller/hooks/rthooks/pyi_rth_multiprocessing.py',
'/home/badu/workspace/badu/presenton/servers/fastapi/.venv/lib/python3.11/site-packages/PyInstaller/hooks/rthooks/pyi_rth_multiprocessing.py',
'PYSOURCE'),
('pyi_rth_pkgres',
'/home/viristo/prog/presentation_generator/presenton_open_source/servers/fastapi/env/lib/python3.11/site-packages/PyInstaller/hooks/rthooks/pyi_rth_pkgres.py',
'/home/badu/workspace/badu/presenton/servers/fastapi/.venv/lib/python3.11/site-packages/PyInstaller/hooks/rthooks/pyi_rth_pkgres.py',
'PYSOURCE'),
('pyi_rth_setuptools',
'/home/badu/workspace/badu/presenton/servers/fastapi/.venv/lib/python3.11/site-packages/PyInstaller/hooks/rthooks/pyi_rth_setuptools.py',
'PYSOURCE'),
('pyi_rth_cryptography_openssl',
'/home/badu/workspace/badu/presenton/servers/fastapi/.venv/lib/python3.11/site-packages/_pyinstaller_hooks_contrib/rthooks/pyi_rth_cryptography_openssl.py',
'PYSOURCE'),
('server',
'/home/viristo/prog/presentation_generator/presenton_open_source/servers/fastapi/server.py',
'/home/badu/workspace/badu/presenton/servers/fastapi/server.py',
'PYSOURCE')],
'libpython3.11.so',
'libpython3.11.so.1.0',
True,
False,
False,

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

View file

@ -3,7 +3,6 @@
import { useEditor, EditorContent, BubbleMenu } from "@tiptap/react";
import StarterKit from "@tiptap/starter-kit";
import { Markdown } from "tiptap-markdown";
import Placeholder from "@tiptap/extension-placeholder";
import Underline from "@tiptap/extension-underline";
import { useDispatch, useSelector } from "react-redux";
import {
@ -74,26 +73,7 @@ const TipTapEditor = ({
return `${baseStyle} slide-description text-sm sm:text-base lg:text-[20px] leading-[20px] lg:leading-[30px] font-normal`;
}
};
const getPlaceholder = () => {
switch (type) {
case "title":
return "Enter title";
case "heading":
return "Enter heading";
case "description-body":
return "Enter description";
case "description":
return "Enter description";
case "heading-description":
return "Enter description";
case "info-heading":
return "Enter heading";
case "info-description":
return "Enter description";
default:
return "Enter text";
}
};
const updateSlide = (type: string, value: string) => {
switch (type) {
case "title": {
@ -173,41 +153,36 @@ const TipTapEditor = ({
<div className="flex bg-white rounded-lg shadow-lg p-2 gap-1 border-r pr-2">
<button
onClick={() => editor?.chain().focus().toggleBold().run()}
className={`p-1 rounded hover:bg-gray-100 ${
editor?.isActive("bold") ? "bg-gray-200" : ""
}`}
className={`p-1 rounded hover:bg-gray-100 ${editor?.isActive("bold") ? "bg-gray-200" : ""
}`}
>
<Bold className="h-4 w-4" />
</button>
<button
onClick={() => editor?.chain().focus().toggleItalic().run()}
className={`p-1 rounded hover:bg-gray-100 ${
editor?.isActive("italic") ? "bg-gray-200" : ""
}`}
className={`p-1 rounded hover:bg-gray-100 ${editor?.isActive("italic") ? "bg-gray-200" : ""
}`}
>
<Italic className="h-4 w-4" />
</button>
<button
onClick={() => editor?.chain().focus().toggleUnderline().run()}
className={`p-1 rounded hover:bg-gray-100 ${
editor?.isActive("underline") ? "bg-gray-200" : ""
}`}
className={`p-1 rounded hover:bg-gray-100 ${editor?.isActive("underline") ? "bg-gray-200" : ""
}`}
>
<UnderlinedIcon className="h-4 w-4" />
</button>
<button
onClick={() => editor?.chain().focus().toggleStrike().run()}
className={`p-1 rounded hover:bg-gray-100 ${
editor?.isActive("strike") ? "bg-gray-200" : ""
}`}
className={`p-1 rounded hover:bg-gray-100 ${editor?.isActive("strike") ? "bg-gray-200" : ""
}`}
>
<Strikethrough className="h-4 w-4" />
</button>
<button
onClick={() => editor?.chain().focus().toggleCode().run()}
className={`p-1 rounded hover:bg-gray-100 ${
editor?.isActive("codeBlock") ? "bg-gray-200" : ""
}`}
className={`p-1 rounded hover:bg-gray-100 ${editor?.isActive("codeBlock") ? "bg-gray-200" : ""
}`}
>
<Code className="h-4 w-4" />
</button>
@ -215,9 +190,8 @@ const TipTapEditor = ({
</BubbleMenu>
<EditorContent
className={`min-w-[100px] w-full max-md:pointer-events-none ${getTextStyle()} ${
editor?.getText() ? "" : `hover:outline hover:outline-gray-400`
} `}
className={`min-w-[100px] w-full max-md:pointer-events-none ${getTextStyle()} ${editor?.getText() ? "" : `hover:outline hover:outline-gray-400`
} `}
onBlur={() => {
const markdown = editor?.storage.markdown.getMarkdown();
updateSlide(type, markdown || "");

View file

@ -47,6 +47,7 @@ import Modal from "./Modal";
import Announcement from "@/components/Announcement";
import { getHeader } from "../../services/api/header";
import { getEnv } from "@/utils/constant";
const Header = ({
presentation_id,
@ -68,6 +69,7 @@ const Header = ({
(state: RootState) => state.presentationGeneration
);
const dispatch = useDispatch();
const urls = getEnv();
const handleThemeSelect = async (value: string) => {
if (isStreaming) return;
if (value === "custom") {
@ -128,7 +130,7 @@ const Header = ({
const getSlideMetadata = async () => {
try {
const response = await fetch(
`${process.env.NEXT_PUBLIC_URL}/api/slide-metadata`,
`${urls.NEXT_PUBLIC_URL}/api/slide-metadata`,
{
method: "POST",
headers: getHeader(),
@ -136,6 +138,7 @@ const Header = ({
url: window.location.href,
theme: currentTheme,
customColors: currentColors,
tempDirectory: urls.TEMP_DIRECTORY,
}),
}
);

View file

@ -1,7 +1,9 @@
import { BASE_URL } from "@/utils/constant";
import { getEnv } from "@/utils/constant";
import { getHeader, getHeaderForFormData } from "./header";
import { IconSearch, ImageGenerate, ImageSearch } from "./params";
const urls = getEnv();
const BASE_URL = urls.BASE_URL;
export class PresentationGenerationApi {
// static BASE_URL="https://api.presenton.ai";
// static BASE_URL="https://presentation-generator-fragrant-mountain-1643.fly.dev";

View file

@ -102,7 +102,7 @@ export async function POST(request: NextRequest) {
let browser;
try {
const body = await request.json();
const { url, theme, customColors } = body;
const { url, theme, customColors,tempDirectory } = body;
if (!url) {
return NextResponse.json({ error: "Missing URL" }, { status: 400 });
@ -367,7 +367,7 @@ export async function POST(request: NextRequest) {
});
try {
const tempDir = process.env.TEMP_DIRECTORY || os.tmpdir();
const tempDir = tempDirectory || os.tmpdir();
// Generate a unique filename
const filename = `chart-${graphId}-${Date.now()}.jpg`;

View file

@ -2,8 +2,10 @@ import {
getHeader,
getHeaderForFormData,
} from "@/app/(presentation-generator)/services/api/header";
import { BASE_URL } from "@/utils/constant";
import { getEnv } from "@/utils/constant";
const urls = getEnv();
const BASE_URL = urls.BASE_URL;
export interface PresentationResponse {
id: string;
title: string;

View file

@ -4,8 +4,6 @@ import { Fraunces, Montserrat, Inria_Serif } from "next/font/google";
import "./globals.css";
import { Providers } from "./providers";
import { Toaster } from "@/components/ui/toaster";
import Script from "next/script";
import { GoogleTagManager } from "@next/third-parties/google";
const fraunces = Fraunces({
subsets: ["latin"],

View file

@ -15,11 +15,11 @@ const SettingsPage = () => {
const [apiConfigs, setApiConfigs] = useState<Record<string, APIConfig>>({
openai: {
provider: 'OpenAI',
apiKey: localStorage.getItem('openai_api_key') || '',
apiKey: '',
},
google: {
provider: 'Google',
apiKey: localStorage.getItem('google_api_key') || '',
apiKey: '',
}
});

File diff suppressed because it is too large Load diff

View file

@ -14,8 +14,6 @@
"@dnd-kit/core": "^6.3.1",
"@dnd-kit/sortable": "^10.0.0",
"@dnd-kit/utilities": "^3.2.2",
"@mdxeditor/editor": "^3.21.2",
"@next/third-parties": "^15.2.2",
"@radix-ui/react-accordion": "^1.2.1",
"@radix-ui/react-avatar": "^1.1.2",
"@radix-ui/react-dialog": "^1.1.6",
@ -36,28 +34,18 @@
"@radix-ui/react-toggle": "^1.1.0",
"@radix-ui/react-tooltip": "^1.1.6",
"@reduxjs/toolkit": "^2.2.8",
"@tiptap/extension-bold": "^2.11.5",
"@tiptap/extension-color": "^2.0.0",
"@tiptap/extension-placeholder": "^2.11.5",
"@tiptap/extension-task-item": "^2.0.0",
"@tiptap/extension-task-list": "^2.0.0",
"@tiptap/extension-text-align": "^2.0.0",
"@tiptap/extension-text-style": "^2.0.0",
"@tiptap/extension-underline": "^2.0.0",
"@tiptap/pm": "^2.11.5",
"@tiptap/react": "^2.11.5",
"@tiptap/starter-kit": "^2.11.5",
"@types/webfontloader": "^1.6.38",
"animejs": "^3.2.2",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"cmdk": "^1.0.0",
"date-fns": "^4.1.0",
"html-to-image": "^1.11.13",
"jsonrepair": "^3.12.0",
"license-checker-rseidelsohn": "^4.4.2",
"lucide-react": "^0.447.0",
"mermaid": "^11.6.0",
"marked": "^15.0.11",
"next": "^14.2.14",
"puppeteer": "^24.8.2",
"react": "^18",
@ -65,10 +53,8 @@
"react-redux": "^9.1.2",
"recharts": "^2.15.0",
"shadcn-ui": "^0.9.2",
"sharp": "^0.34.1",
"sqlite": "^5.1.1",
"sqlite3": "^5.1.7",
"stripe": "^17.4.0",
"tailwind-merge": "^2.5.3",
"tailwind-scrollbar-hide": "^2.0.0",
"tailwindcss-animate": "^1.0.7",

View file

@ -1 +1,26 @@
export const BASE_URL = process.env.NEXT_PUBLIC_FAST_API || 'http://localhost:8000';
// lib/env.client.ts
'use client';
export const getEnv = () => {
if (typeof window !== 'undefined') {
return {
// @ts-ignore
BASE_URL: window.env?.NEXT_PUBLIC_FAST_API || 'http://localhost:8000',
// @ts-ignore
USER_CONFIG_PATH: window.env?.NEXT_PUBLIC_USER_CONFIG_PATH || '',
// @ts-ignore
NEXT_PUBLIC_URL: window.env?.NEXT_PUBLIC_URL || '',
// @ts-ignore
TEMP_DIRECTORY: window.env?.TEMP_DIRECTORY || '',
};
}
return {
BASE_URL: 'http://localhost:8000',
USER_CONFIG_PATH: '',
NEXT_PUBLIC_URL: '',
TEMP_DIRECTORY: '',
};
};