\n\n","src/main.tsx":"import React from 'react';\nimport ReactDOM from 'react-dom/client';\nimport App from './App';\nimport './index.css';\n\nconst root = ReactDOM.createRoot(document.getElementById('root')!);\nroot.render();","src/App.tsx":"import React from 'react';\nimport HomePage from './pages/HomePage';\n\nfunction App() {\n return (\n
\n \n
\n );\n}\n\nexport default App;","src/pages/Home.tsx":"import React from 'react';\n\nexport function Home() {\n return (\n
\n

سلام دنیا

\n
\n );\n}\n","src/components/BackgroundComponent.tsx":"import React from 'react';\n\ninterface BackgroundComponentProps {\n color: string;\n children?: React.ReactNode;\n}\n\nconst BackgroundComponent: React.FC = ({ color, children }) => {\n return (\n
\n {children}\n
\n );\n};\n\nexport default BackgroundComponent;\n","src/components/TextComponent.tsx":"import React from 'react';\nimport classNames from 'classnames';\n\ninterface TextComponentProps {\n text: string;\n alignment: 'left' | 'center' | 'right';\n font_size: 'small' | 'medium' | 'large';\n color: string;\n}\n\nconst TextComponent: React.FC = ({ text, alignment, font_size, color }) => {\n const alignmentClass = {\n left: 'text-left',\n center: 'text-center',\n right: 'text-right',\n }[alignment];\n\n const fontSizeClass = {\n small: 'text-sm',\n medium: 'text-base',\n large: 'text-lg',\n }[font_size];\n\n return (\n \n {text}\n \n );\n};\n\nexport default TextComponent;","src/pages/HomePage.tsx":"import React from 'react';\n\nconst HomePage: React.FC = () => {\n return (\n
\n

سلام دنیا

\n
\n );\n};\n\nexport default HomePage;","src/routes.tsx":"import React from 'react';\nimport { BrowserRouter as Router, Route, Switch } from 'react-router-dom';\nimport HomePage from './pages/HomePage';\n\nconst Routes: React.FC = () => {\n return (\n \n \n \n \n \n );\n};\n\nexport default Routes;\n","src/styles/global.css":"/* Global Styles */\n@tailwind base;\n@tailwind components;\n@tailwind utilities;\n\nbody {\n @apply bg-red-500 text-white;\n}\n\nh1 {\n @apply text-4xl text-center;\n}"}; function resolvePath(base, relative) { if (!relative.startsWith('.')) return relative; const stack = base.split('/'); stack.pop(); const parts = relative.split('/'); for (let i = 0; i < parts.length; i++) { if (parts[i] === '.') continue; if (parts[i] === '..') stack.pop(); else stack.push(parts[i]); } return stack.join('/'); } function getFileContent(path) { if (window.__SOURCES__[path]) return { content: window.__SOURCES__[path], finalPath: path }; const extensions = ['.tsx', '.ts', '.jsx', '.js', '.css', '.json']; for (let ext of extensions) { if (window.__SOURCES__[path + ext]) return { content: window.__SOURCES__[path + ext], finalPath: path + ext }; } for (let ext of extensions) { if (window.__SOURCES__[path + '/index' + ext]) return { content: window.__SOURCES__[path + '/index' + ext], finalPath: path + '/index' + ext }; } return null; } window.require = function(path, base = '') { // --- BUILT-INS --- if (path === 'react') return window.React; if (path === 'react-dom') return window.ReactDOM; if (path === 'react-dom/client') return window.ReactDOM; if (path === '@supabase/supabase-js') return window.supabase || createSafeProxy({}, '@supabase/supabase-js'); if (path === 'lucide-react') return window.lucide || createSafeProxy({}, 'lucide-react'); // --- ROUTER SHIM (STRICT FIX) --- if (path === 'react-router-dom' || path === 'react-router') { const rrd = window.ReactRouterDOM || {}; const Passthrough = ({ children }) => children; return { ...rrd, BrowserRouter: Passthrough, HashRouter: Passthrough, MemoryRouter: Passthrough, }; } const resolvedPath = resolvePath(base, path); const fileInfo = getFileContent(resolvedPath); if (!fileInfo) { console.warn('Module not found:', path, 'Resolved:', resolvedPath); return createSafeProxy({}, path); } const { content, finalPath } = fileInfo; // 1. Check Cache if (window.__MODULES__[finalPath]) return window.__MODULES__[finalPath].exports; if (finalPath.endsWith('.css')) { const style = document.createElement('style'); style.textContent = content; document.head.appendChild(style); window.__MODULES__[finalPath] = { exports: {} }; return {}; } if (finalPath.endsWith('.json')) { try { const json = JSON.parse(content); window.__MODULES__[finalPath] = { exports: json }; return json; } catch(e) {} } // --- COMPILATION (CIRCULAR DEP FIX) --- // 2. Register Module EARLY to support circular dependencies const module = { exports: {} }; window.__MODULES__[finalPath] = module; try { // Guard: Check for hallucinated text files acting as code if (content.trim().indexOf('import ') !== 0 && content.trim().indexOf('export ') === -1 && content.trim().indexOf('<') === -1) { if (content.length < 500 && (content.includes('Remove') || content.includes('Note:') || content.includes('Instructions:'))) { throw new Error("File content appears to be text instructions, not code."); } } const presets = [['env', { modules: 'commonjs' }], 'react']; if (finalPath.endsWith('.ts') || finalPath.endsWith('.tsx')) { presets.push('typescript'); } const transformed = Babel.transform(content, { presets, filename: finalPath }).code; const wrapper = new Function('module', 'exports', 'require', transformed); wrapper(module, module.exports, (p) => window.require(p, finalPath)); return module.exports; } catch (e) { console.error('Compilation Error in ' + finalPath, e); const ErrorComponent = () => window.React.createElement('div', { style: { color: 'red', padding: 10, background: '#fee2e2', border: '1px solid red' } }, 'Error compiling ' + finalPath + ': ' + e.message); // Update the cache with the error component so we don't retry infinite loops window.__MODULES__[finalPath].exports = { default: ErrorComponent, ErrorComponent }; return window.__MODULES__[finalPath].exports; } }; // --- BOOTSTRAP --- window.onload = function() { try { const rootEl = document.getElementById('root'); if (!rootEl) throw new Error("Missing #root element"); // 1. AUTO-DETECT APP COMPONENT const appFile = ['src/App.tsx', 'src/App.jsx', 'src/App.js', 'App.tsx', 'App.jsx', 'App.js'].find(p => window.__SOURCES__[p]); let mounted = false; if (appFile) { try { const mod = window.require(appFile); // Support both default and named 'App' exports const App = mod.default || mod.App; if (App) { const React = window.React; const ReactDOM = window.ReactDOM; // Use REAL HashRouter from global UMD for the root context const RealHashRouter = window.ReactRouterDOM.HashRouter; const root = ReactDOM.createRoot(rootEl); root.render(React.createElement(RealHashRouter, {}, React.createElement(App))); mounted = true; console.log('Mounted App via ' + appFile); } else { throw new Error("App component not found in exports. Ensure 'export default App' or 'export const App'."); } } catch(e) { console.warn('Auto-mount failed:', e); throw e; // Re-throw to show error overlay } } // 2. FALLBACK: EXECUTE ENTRY FILE (main.tsx) if (!mounted) { const entry = "src/main.tsx"; if (entry && window.__SOURCES__[entry]) { console.log('Executing entry: ' + entry); window.require(entry); } else if (!appFile) { document.body.innerHTML = '
Waiting for entry point...
'; } } } catch (e) { console.error('Bootstrap Error:', e); window.onerror(e.message, '', 0, 0, e); } };