Metadata-Version: 2.4
Name: Vit3l
Version: 0.22.0
Summary: Fork of Eel with Vite HMR support for modern web development
Home-page: https://github.com/JuanBrotenelle/vit3l
Author: Juan Brotenelle
Author-email: Juan Brotenelle <andrey.evstratenkov@mail.ru>
Maintainer-email: Juan Brotenelle <andrey.evstratenkov@mail.ru>
License-Expression: MIT
Project-URL: Homepage, https://github.com/JuanBrotenelle/vit3l
Project-URL: Documentation, https://github.com/JuanBrotenelle/vit3l#readme
Project-URL: Repository, https://github.com/JuanBrotenelle/vit3l
Project-URL: Issues, https://github.com/JuanBrotenelle/vit3l/issues
Project-URL: Changelog, https://github.com/JuanBrotenelle/vit3l/blob/main/CHANGELOG.md
Keywords: gui,html,javascript,electron,vite,hmr,webpack
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: User Interfaces
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: bottle>=0.12.0
Requires-Dist: bottle-websocket>=0.2.0
Requires-Dist: future>=0.18.0
Requires-Dist: pyparsing>=2.0.0
Requires-Dist: typing-extensions>=4.0.0
Requires-Dist: importlib-resources>=5.0.0
Requires-Dist: build>=0.10.0
Requires-Dist: twine>=4.0.2
Provides-Extra: jinja2
Requires-Dist: jinja2>=2.10; extra == "jinja2"
Provides-Extra: dev
Requires-Dist: pytest>=6.0; extra == "dev"
Requires-Dist: pytest-cov>=2.0; extra == "dev"
Requires-Dist: black>=22.0; extra == "dev"
Requires-Dist: flake8>=4.0; extra == "dev"
Requires-Dist: mypy>=0.900; extra == "dev"
Requires-Dist: pre-commit>=2.0; extra == "dev"
Dynamic: author
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python

# Vit3l

[![PyPI version](https://img.shields.io/pypi/v/Vit3l?style=for-the-badge)](https://pypi.org/project/Vit3l/)
[![PyPI Downloads](https://img.shields.io/pypi/dm/Vit3l?style=for-the-badge)](https://pypistats.org/packages/vit3l)
![Python](https://img.shields.io/pypi/pyversions/Vit3l?style=for-the-badge)
[![License](https://img.shields.io/pypi/l/Vit3l.svg?style=for-the-badge)](https://pypi.org/project/Vit3l/)

**Vit3l** is a fork of [Eel](https://github.com/python-eel/Eel) that adds support for external web servers, enabling modern development workflows with Vite HMR (Hot Module Replacement).

## What's New

- **External URL Support**: Connect to any external web server (Vite, Webpack, etc.)
- **Vite HMR**: Full support for Hot Module Replacement
- **Modern Development**: Use TypeScript, SCSS, PostCSS, and other modern tools
- **Backward Compatible**: All existing Eel functionality preserved
- **WebSocket Communication**: Python ↔ JavaScript communication via WebSocket

## 📦 Installation

### Using pip

```bash
pip install Vit3l
```

### Using uv (recommended)

```bash
uv add Vit3l
```

### With Jinja2 templates

```bash
pip install Vit3l[jinja2]
# or
uv add "Vit3l[jinja2]"
```

## 🎯 Quick Start

### Traditional Eel (still works)

```python
import vit3l as eel

eel.init('web')
eel.start('index.html')  # Runs on localhost:8000
```

### New: External URL Mode

```python
import vit3l as eel

@eel.expose
def say_hello(name):
    return f'Hello {name}!'

eel.init('web')
eel.start('http://localhost:5173', external_url='http://localhost:5173')
```

### JavaScript (same as Eel)

```javascript
const result = await eel.say_hello("World")();
console.log(result); // "Hello World!"
```

## Vite Integration

### 1. Setup Vite project

```bash
npm create vite@latest my-eel-app
cd my-eel-app
npm install
```

### 2. Configure Vite (`vite.config.js`)

```javascript
import { defineConfig } from "vite";

export default defineConfig({
  server: {
    port: 5173,
    cors: true,
  },
});
```

### 3. Add Eel to HTML

```html
<!DOCTYPE html>
<html>
  <head>
    <title>Vite + Vit3l</title>
  </head>
  <body>
    <h1>Hello from Vite + Vit3l!</h1>
    <button onclick="callPython()">Call Python</button>

    <!-- Connect to Eel WebSocket server -->
    <script src="http://localhost:8000/eel.js"></script>
    <script>
      function callPython() {
        eel.say_hello("from Vite!")();
      }
    </script>
  </body>
</html>
```

### 4. Python script

```python
import vit3l as eel

@eel.expose
def say_hello(message):
    print(f"Hello {message}")
    return f"Python received: {message}"

eel.init('src')  # Your Vite source folder
eel.start('http://localhost:5173', external_url='http://localhost:5173')
```

### 5. Run both servers

```bash
# Terminal 1: Vite dev server
npm run dev

# Terminal 2: Python script
python app.py
```

### Examples

```python
# External URL with custom settings
eel.start(
    'http://localhost:5173',
    external_url='http://localhost:5173',
    mode='chrome',
    port=8000,
    block=True
)

# Multiple URLs
eel.start(
    'http://localhost:5173',
    'http://localhost:3000',
    external_url='http://localhost:5173'
)
```

### External URL Mode

1. **Vite Server**: Serves static files with HMR on port 5173
2. **Eel WebSocket Server**: Runs on port 8000 for Python ↔ JavaScript communication
3. **Browser**: Connects to both servers
4. **Result**: Modern development with full Eel functionality

## Troubleshooting

### WebSocket Connection Issues

```javascript
// Check WebSocket status in browser console
console.log("WebSocket state:", eel._websocket.readyState);
// 0 = CONNECTING, 1 = OPEN, 2 = CLOSING, 3 = CLOSED
```

### CORS Errors

Ensure Vite is configured with CORS enabled:

```javascript
// vite.config.js
export default defineConfig({
  server: {
    cors: true,
  },
});
```

### Port Conflicts

Change Eel WebSocket port if 8000 is occupied:

```python
eel.start('http://localhost:5173', external_url='http://localhost:5173', port=8001)
```

## License

MIT License - see [LICENSE](LICENSE) file for details.

## Acknowledgments

- Original [Eel](https://github.com/python-eel/Eel) project by Chris Knott
