pyreact-framework 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyreact_framework-1.0.0/LICENSE +21 -0
- pyreact_framework-1.0.0/PKG-INFO +363 -0
- pyreact_framework-1.0.0/README.md +327 -0
- pyreact_framework-1.0.0/pyproject.toml +146 -0
- pyreact_framework-1.0.0/pyreact/__init__.py +144 -0
- pyreact_framework-1.0.0/pyreact/cli/__init__.py +3 -0
- pyreact_framework-1.0.0/pyreact/cli/main.py +512 -0
- pyreact_framework-1.0.0/pyreact/core/__init__.py +80 -0
- pyreact_framework-1.0.0/pyreact/core/component.py +372 -0
- pyreact_framework-1.0.0/pyreact/core/context.py +173 -0
- pyreact_framework-1.0.0/pyreact/core/element.py +208 -0
- pyreact_framework-1.0.0/pyreact/core/error_boundary.py +145 -0
- pyreact_framework-1.0.0/pyreact/core/hooks.py +550 -0
- pyreact_framework-1.0.0/pyreact/core/memo.py +221 -0
- pyreact_framework-1.0.0/pyreact/core/portal.py +159 -0
- pyreact_framework-1.0.0/pyreact/core/reconciler.py +399 -0
- pyreact_framework-1.0.0/pyreact/core/refs.py +213 -0
- pyreact_framework-1.0.0/pyreact/core/renderer.py +112 -0
- pyreact_framework-1.0.0/pyreact/core/scheduler.py +304 -0
- pyreact_framework-1.0.0/pyreact/devtools/__init__.py +18 -0
- pyreact_framework-1.0.0/pyreact/devtools/debugger.py +314 -0
- pyreact_framework-1.0.0/pyreact/devtools/profiler.py +288 -0
- pyreact_framework-1.0.0/pyreact/dom/__init__.py +64 -0
- pyreact_framework-1.0.0/pyreact/dom/attributes.py +317 -0
- pyreact_framework-1.0.0/pyreact/dom/dom_operations.py +333 -0
- pyreact_framework-1.0.0/pyreact/dom/events.py +349 -0
- pyreact_framework-1.0.0/pyreact/server/__init__.py +34 -0
- pyreact_framework-1.0.0/pyreact/server/hydration.py +216 -0
- pyreact_framework-1.0.0/pyreact/server/ssr.py +344 -0
- pyreact_framework-1.0.0/pyreact/styles/__init__.py +19 -0
- pyreact_framework-1.0.0/pyreact/styles/css_module.py +231 -0
- pyreact_framework-1.0.0/pyreact/styles/styled.py +303 -0
- pyreact_framework-1.0.0/pyreact/testing/__init__.py +71 -0
- pyreact_framework-1.0.0/pyreact/testing/fire_event.py +355 -0
- pyreact_framework-1.0.0/pyreact/testing/screen.py +267 -0
- pyreact_framework-1.0.0/pyreact/testing/test_renderer.py +232 -0
- pyreact_framework-1.0.0/pyreact/utils/__init__.py +17 -0
- pyreact_framework-1.0.0/pyreact/utils/diff.py +182 -0
- pyreact_framework-1.0.0/pyreact/utils/object_pool.py +216 -0
- pyreact_framework-1.0.0/pyreact_framework.egg-info/PKG-INFO +363 -0
- pyreact_framework-1.0.0/pyreact_framework.egg-info/SOURCES.txt +48 -0
- pyreact_framework-1.0.0/pyreact_framework.egg-info/dependency_links.txt +1 -0
- pyreact_framework-1.0.0/pyreact_framework.egg-info/entry_points.txt +2 -0
- pyreact_framework-1.0.0/pyreact_framework.egg-info/requires.txt +8 -0
- pyreact_framework-1.0.0/pyreact_framework.egg-info/top_level.txt +1 -0
- pyreact_framework-1.0.0/setup.cfg +4 -0
- pyreact_framework-1.0.0/tests/test_core.py +237 -0
- pyreact_framework-1.0.0/tests/test_dom.py +257 -0
- pyreact_framework-1.0.0/tests/test_hooks.py +317 -0
- pyreact_framework-1.0.0/tests/test_ssr.py +197 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 PyReact Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyreact-framework
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Framework web declarativo inspirado no React, construído nativamente para Python
|
|
5
|
+
Author-email: PyReact Team <pyreact@example.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/pyreact/pyreact
|
|
8
|
+
Project-URL: Documentation, https://pyreact.readthedocs.io
|
|
9
|
+
Project-URL: Repository, https://github.com/pyreact/pyreact
|
|
10
|
+
Project-URL: Issues, https://github.com/pyreact/pyreact/issues
|
|
11
|
+
Keywords: react,ui,frontend,declarative,components,virtual-dom,web,framework
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Classifier: Topic :: Software Development :: User Interfaces
|
|
25
|
+
Requires-Python: >=3.8
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
30
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
31
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
32
|
+
Requires-Dist: isort>=5.12.0; extra == "dev"
|
|
33
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
34
|
+
Requires-Dist: flake8>=6.0.0; extra == "dev"
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
# 🐍 PyReact - Framework Web Declarativo para Python
|
|
38
|
+
|
|
39
|
+
[](https://pypi.org/project/pyreact/)
|
|
40
|
+
[](https://pypi.org/project/pyreact/)
|
|
41
|
+
[](https://opensource.org/licenses/MIT)
|
|
42
|
+
|
|
43
|
+
**PyReact** é um framework web declarativo inspirado no React, mas construído nativamente para Python. Permite criar interfaces de usuário reativas, com componentes, hooks e renderização eficiente.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## 📦 Instalação
|
|
48
|
+
|
|
49
|
+
### Via pip (Recomendado)
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pip install pyreact-framework
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Via pip (GitHub)
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pip install git+https://github.com/seu-usuario/pyreact.git
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Desenvolvimento Local
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
git clone https://github.com/seu-usuario/pyreact.git
|
|
65
|
+
cd pyreact
|
|
66
|
+
pip install -e .
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## 🚀 Início Rápido
|
|
72
|
+
|
|
73
|
+
### Criar um Novo Projeto
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# Criar projeto
|
|
77
|
+
pyreact-framework create meu-app
|
|
78
|
+
|
|
79
|
+
# Entrar no diretório
|
|
80
|
+
cd meu-app
|
|
81
|
+
|
|
82
|
+
# Iniciar servidor de desenvolvimento
|
|
83
|
+
pyreact-framework dev
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Exemplo de Contador
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
from pyreact import h, render, use_state, Component
|
|
90
|
+
|
|
91
|
+
def Counter(props):
|
|
92
|
+
"""Componente de contador funcional"""
|
|
93
|
+
count, set_count = use_state(0)
|
|
94
|
+
|
|
95
|
+
return h('div', {'className': 'counter'},
|
|
96
|
+
h('h1', None, f'Contador: {count}'),
|
|
97
|
+
h('button', {'onClick': lambda: set_count(count + 1)}, '+'),
|
|
98
|
+
h('button', {'onClick': lambda: set_count(count - 1)}, '-')
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
# Renderizar
|
|
102
|
+
root = document.getElementById('root')
|
|
103
|
+
render(h(Counter, None), root)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## ✨ Funcionalidades
|
|
109
|
+
|
|
110
|
+
### Componentes Funcionais
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
def Button(props):
|
|
114
|
+
"""Componente de botão reutilizável"""
|
|
115
|
+
return h('button', {
|
|
116
|
+
'className': 'btn',
|
|
117
|
+
'onClick': props.get('onClick')
|
|
118
|
+
}, props.get('children'))
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Componentes de Classe
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
class Counter(Component):
|
|
125
|
+
"""Componente de contador com estado"""
|
|
126
|
+
|
|
127
|
+
def __init__(self, props):
|
|
128
|
+
super().__init__(props)
|
|
129
|
+
self.state = {'count': 0}
|
|
130
|
+
|
|
131
|
+
def render(self):
|
|
132
|
+
return h('div', None,
|
|
133
|
+
h('h1', None, f'Count: {self.state["count"]}'),
|
|
134
|
+
h('button', {
|
|
135
|
+
'onClick': lambda: self.set_state({'count': self.state['count'] + 1})
|
|
136
|
+
}, 'Increment')
|
|
137
|
+
)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Hooks
|
|
141
|
+
|
|
142
|
+
```python
|
|
143
|
+
from pyreact import use_state, use_effect, use_ref
|
|
144
|
+
|
|
145
|
+
def MyComponent(props):
|
|
146
|
+
# Estado local
|
|
147
|
+
count, set_count = use_state(0)
|
|
148
|
+
|
|
149
|
+
# Efeito colateral
|
|
150
|
+
use_effect(lambda: print(f'Count: {count}'), [count])
|
|
151
|
+
|
|
152
|
+
# Referência
|
|
153
|
+
input_ref = use_ref(None)
|
|
154
|
+
|
|
155
|
+
return h('div', None, f'Count: {count}')
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## 📖 Documentação
|
|
161
|
+
|
|
162
|
+
### CLI Commands
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
# Criar novo projeto
|
|
166
|
+
pyreact create <nome>
|
|
167
|
+
|
|
168
|
+
# Iniciar servidor de desenvolvimento
|
|
169
|
+
pyreact-framework dev [--port PORT]
|
|
170
|
+
|
|
171
|
+
# Gerar componente
|
|
172
|
+
pyreact generate component <nome>
|
|
173
|
+
|
|
174
|
+
# Gerar hook
|
|
175
|
+
pyreact generate hook <nome>
|
|
176
|
+
|
|
177
|
+
# Build para produção
|
|
178
|
+
pyreact build
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### API Principal
|
|
182
|
+
|
|
183
|
+
#### `h(type, props, *children)`
|
|
184
|
+
|
|
185
|
+
Cria um elemento virtual (VNode).
|
|
186
|
+
|
|
187
|
+
```python
|
|
188
|
+
h('div', {'className': 'container'},
|
|
189
|
+
h('h1', None, 'Título'),
|
|
190
|
+
h('p', None, 'Parágrafo')
|
|
191
|
+
)
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
#### `render(element, container)`
|
|
195
|
+
|
|
196
|
+
Renderiza um elemento no container.
|
|
197
|
+
|
|
198
|
+
```python
|
|
199
|
+
render(h(App, None), document.getElementById('root'))
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
#### `create_root(container)`
|
|
203
|
+
|
|
204
|
+
Cria uma raiz de renderização (API moderna).
|
|
205
|
+
|
|
206
|
+
```python
|
|
207
|
+
root = create_root(document.getElementById('root'))
|
|
208
|
+
root.render(h(App, None))
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## 🧪 Testes
|
|
214
|
+
|
|
215
|
+
### Executar Testes
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
# Testes unitários
|
|
219
|
+
pytest tests/
|
|
220
|
+
|
|
221
|
+
# Testes E2E
|
|
222
|
+
python tests/e2e/test_simple_e2e.py
|
|
223
|
+
|
|
224
|
+
# Testes A/B
|
|
225
|
+
python tests/e2e/test_ab_counter.py
|
|
226
|
+
|
|
227
|
+
# Com cobertura
|
|
228
|
+
pytest tests/ --cov=pyreact
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Documentação de Testes
|
|
232
|
+
|
|
233
|
+
Ver `Teste_Documentos/README.md` para mais detalhes.
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## 📁 Estrutura do Projeto
|
|
238
|
+
|
|
239
|
+
```
|
|
240
|
+
pyreact/
|
|
241
|
+
├── pyreact/ # Código fonte
|
|
242
|
+
│ ├── cli/ # Interface de linha de comando
|
|
243
|
+
│ ├── core/ # Núcleo do framework
|
|
244
|
+
│ ├── dom/ # Operações DOM
|
|
245
|
+
│ ├── server/ # Renderização servidor
|
|
246
|
+
│ └── utils/ # Utilitários
|
|
247
|
+
├── tests/ # Testes
|
|
248
|
+
│ ├── e2e/ # Testes end-to-end
|
|
249
|
+
│ └── unit/ # Testes unitários
|
|
250
|
+
├── examples/ # Exemplos
|
|
251
|
+
├── Teste_Documentos/ # Documentação de testes
|
|
252
|
+
├── pyproject.toml # Configuração do projeto
|
|
253
|
+
├── README.md # Este arquivo
|
|
254
|
+
├── INSTALL.md # Guia de instalação
|
|
255
|
+
├── PUBLISH.md # Guia de publicação
|
|
256
|
+
└── LICENSE # Licença MIT
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## 🛠️ Desenvolvimento
|
|
262
|
+
|
|
263
|
+
### Configurar Ambiente
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
# Clonar repositório
|
|
267
|
+
git clone https://github.com/seu-usuario/pyreact.git
|
|
268
|
+
cd pyreact
|
|
269
|
+
|
|
270
|
+
# Criar ambiente virtual
|
|
271
|
+
python -m venv venv
|
|
272
|
+
source venv/bin/activate # Linux/Mac
|
|
273
|
+
venv\Scripts\activate # Windows
|
|
274
|
+
|
|
275
|
+
# Instalar dependências
|
|
276
|
+
pip install -e .
|
|
277
|
+
|
|
278
|
+
# Instalar dependências de desenvolvimento
|
|
279
|
+
pip install pytest pytest-cov playwright
|
|
280
|
+
playwright install chromium
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Executar em Desenvolvimento
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
# Instalar em modo editável
|
|
287
|
+
pip install -e .
|
|
288
|
+
|
|
289
|
+
# Executar testes
|
|
290
|
+
pytest tests/ -v
|
|
291
|
+
|
|
292
|
+
# Criar build
|
|
293
|
+
python -m build
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## 📦 Publicação
|
|
299
|
+
|
|
300
|
+
### Build
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
# Limpar builds anteriores
|
|
304
|
+
python -c "import shutil; from pathlib import Path; [shutil.rmtree(p, ignore_errors=True) for p in ['build', 'dist', 'pyreact.egg-info']]"
|
|
305
|
+
|
|
306
|
+
# Criar build
|
|
307
|
+
python -m build
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### Publicar no PyPI
|
|
311
|
+
|
|
312
|
+
```bash
|
|
313
|
+
# Instalar twine
|
|
314
|
+
pip install twine
|
|
315
|
+
|
|
316
|
+
# Verificar build
|
|
317
|
+
twine check dist/*
|
|
318
|
+
|
|
319
|
+
# Publicar no TestPyPI (teste)
|
|
320
|
+
twine upload --repository testpypi dist/*
|
|
321
|
+
|
|
322
|
+
# Publicar no PyPI (oficial)
|
|
323
|
+
twine upload dist/*
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
Ver `PUBLISH.md` para mais detalhes.
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
## 🤝 Contribuindo
|
|
331
|
+
|
|
332
|
+
Contribuições são bem-vindas! Por favor:
|
|
333
|
+
|
|
334
|
+
1. Fork o projeto
|
|
335
|
+
2. Crie uma branch para sua feature (`git checkout -b feature/AmazingFeature`)
|
|
336
|
+
3. Commit suas mudanças (`git commit -m 'Add some AmazingFeature'`)
|
|
337
|
+
4. Push para a branch (`git push origin feature/AmazingFeature`)
|
|
338
|
+
5. Abra um Pull Request
|
|
339
|
+
|
|
340
|
+
---
|
|
341
|
+
|
|
342
|
+
## 📝 Licença
|
|
343
|
+
|
|
344
|
+
Este projeto está licenciado sob a licença MIT - veja o arquivo [LICENSE](LICENSE) para detalhes.
|
|
345
|
+
|
|
346
|
+
---
|
|
347
|
+
|
|
348
|
+
## 📞 Contato
|
|
349
|
+
|
|
350
|
+
- **GitHub Issues:** https://github.com/seu-usuario/pyreact/issues
|
|
351
|
+
- **Documentação:** https://pyreact.readthedocs.io/
|
|
352
|
+
- **Email:** contato@pyreact.dev
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
356
|
+
## 🙏 Agradecimentos
|
|
357
|
+
|
|
358
|
+
- Inspirado no [React](https://reactjs.org/)
|
|
359
|
+
- Construído com ❤️ pela comunidade Python
|
|
360
|
+
|
|
361
|
+
---
|
|
362
|
+
|
|
363
|
+
**Feito com ❤️ pela comunidade Python**
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
# 🐍 PyReact - Framework Web Declarativo para Python
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/pyreact/)
|
|
4
|
+
[](https://pypi.org/project/pyreact/)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
**PyReact** é um framework web declarativo inspirado no React, mas construído nativamente para Python. Permite criar interfaces de usuário reativas, com componentes, hooks e renderização eficiente.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 📦 Instalação
|
|
12
|
+
|
|
13
|
+
### Via pip (Recomendado)
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install pyreact-framework
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Via pip (GitHub)
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install git+https://github.com/seu-usuario/pyreact.git
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Desenvolvimento Local
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
git clone https://github.com/seu-usuario/pyreact.git
|
|
29
|
+
cd pyreact
|
|
30
|
+
pip install -e .
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 🚀 Início Rápido
|
|
36
|
+
|
|
37
|
+
### Criar um Novo Projeto
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# Criar projeto
|
|
41
|
+
pyreact-framework create meu-app
|
|
42
|
+
|
|
43
|
+
# Entrar no diretório
|
|
44
|
+
cd meu-app
|
|
45
|
+
|
|
46
|
+
# Iniciar servidor de desenvolvimento
|
|
47
|
+
pyreact-framework dev
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Exemplo de Contador
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from pyreact import h, render, use_state, Component
|
|
54
|
+
|
|
55
|
+
def Counter(props):
|
|
56
|
+
"""Componente de contador funcional"""
|
|
57
|
+
count, set_count = use_state(0)
|
|
58
|
+
|
|
59
|
+
return h('div', {'className': 'counter'},
|
|
60
|
+
h('h1', None, f'Contador: {count}'),
|
|
61
|
+
h('button', {'onClick': lambda: set_count(count + 1)}, '+'),
|
|
62
|
+
h('button', {'onClick': lambda: set_count(count - 1)}, '-')
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
# Renderizar
|
|
66
|
+
root = document.getElementById('root')
|
|
67
|
+
render(h(Counter, None), root)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## ✨ Funcionalidades
|
|
73
|
+
|
|
74
|
+
### Componentes Funcionais
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
def Button(props):
|
|
78
|
+
"""Componente de botão reutilizável"""
|
|
79
|
+
return h('button', {
|
|
80
|
+
'className': 'btn',
|
|
81
|
+
'onClick': props.get('onClick')
|
|
82
|
+
}, props.get('children'))
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Componentes de Classe
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
class Counter(Component):
|
|
89
|
+
"""Componente de contador com estado"""
|
|
90
|
+
|
|
91
|
+
def __init__(self, props):
|
|
92
|
+
super().__init__(props)
|
|
93
|
+
self.state = {'count': 0}
|
|
94
|
+
|
|
95
|
+
def render(self):
|
|
96
|
+
return h('div', None,
|
|
97
|
+
h('h1', None, f'Count: {self.state["count"]}'),
|
|
98
|
+
h('button', {
|
|
99
|
+
'onClick': lambda: self.set_state({'count': self.state['count'] + 1})
|
|
100
|
+
}, 'Increment')
|
|
101
|
+
)
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Hooks
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
from pyreact import use_state, use_effect, use_ref
|
|
108
|
+
|
|
109
|
+
def MyComponent(props):
|
|
110
|
+
# Estado local
|
|
111
|
+
count, set_count = use_state(0)
|
|
112
|
+
|
|
113
|
+
# Efeito colateral
|
|
114
|
+
use_effect(lambda: print(f'Count: {count}'), [count])
|
|
115
|
+
|
|
116
|
+
# Referência
|
|
117
|
+
input_ref = use_ref(None)
|
|
118
|
+
|
|
119
|
+
return h('div', None, f'Count: {count}')
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## 📖 Documentação
|
|
125
|
+
|
|
126
|
+
### CLI Commands
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
# Criar novo projeto
|
|
130
|
+
pyreact create <nome>
|
|
131
|
+
|
|
132
|
+
# Iniciar servidor de desenvolvimento
|
|
133
|
+
pyreact-framework dev [--port PORT]
|
|
134
|
+
|
|
135
|
+
# Gerar componente
|
|
136
|
+
pyreact generate component <nome>
|
|
137
|
+
|
|
138
|
+
# Gerar hook
|
|
139
|
+
pyreact generate hook <nome>
|
|
140
|
+
|
|
141
|
+
# Build para produção
|
|
142
|
+
pyreact build
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### API Principal
|
|
146
|
+
|
|
147
|
+
#### `h(type, props, *children)`
|
|
148
|
+
|
|
149
|
+
Cria um elemento virtual (VNode).
|
|
150
|
+
|
|
151
|
+
```python
|
|
152
|
+
h('div', {'className': 'container'},
|
|
153
|
+
h('h1', None, 'Título'),
|
|
154
|
+
h('p', None, 'Parágrafo')
|
|
155
|
+
)
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
#### `render(element, container)`
|
|
159
|
+
|
|
160
|
+
Renderiza um elemento no container.
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
render(h(App, None), document.getElementById('root'))
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
#### `create_root(container)`
|
|
167
|
+
|
|
168
|
+
Cria uma raiz de renderização (API moderna).
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
root = create_root(document.getElementById('root'))
|
|
172
|
+
root.render(h(App, None))
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## 🧪 Testes
|
|
178
|
+
|
|
179
|
+
### Executar Testes
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
# Testes unitários
|
|
183
|
+
pytest tests/
|
|
184
|
+
|
|
185
|
+
# Testes E2E
|
|
186
|
+
python tests/e2e/test_simple_e2e.py
|
|
187
|
+
|
|
188
|
+
# Testes A/B
|
|
189
|
+
python tests/e2e/test_ab_counter.py
|
|
190
|
+
|
|
191
|
+
# Com cobertura
|
|
192
|
+
pytest tests/ --cov=pyreact
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Documentação de Testes
|
|
196
|
+
|
|
197
|
+
Ver `Teste_Documentos/README.md` para mais detalhes.
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## 📁 Estrutura do Projeto
|
|
202
|
+
|
|
203
|
+
```
|
|
204
|
+
pyreact/
|
|
205
|
+
├── pyreact/ # Código fonte
|
|
206
|
+
│ ├── cli/ # Interface de linha de comando
|
|
207
|
+
│ ├── core/ # Núcleo do framework
|
|
208
|
+
│ ├── dom/ # Operações DOM
|
|
209
|
+
│ ├── server/ # Renderização servidor
|
|
210
|
+
│ └── utils/ # Utilitários
|
|
211
|
+
├── tests/ # Testes
|
|
212
|
+
│ ├── e2e/ # Testes end-to-end
|
|
213
|
+
│ └── unit/ # Testes unitários
|
|
214
|
+
├── examples/ # Exemplos
|
|
215
|
+
├── Teste_Documentos/ # Documentação de testes
|
|
216
|
+
├── pyproject.toml # Configuração do projeto
|
|
217
|
+
├── README.md # Este arquivo
|
|
218
|
+
├── INSTALL.md # Guia de instalação
|
|
219
|
+
├── PUBLISH.md # Guia de publicação
|
|
220
|
+
└── LICENSE # Licença MIT
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## 🛠️ Desenvolvimento
|
|
226
|
+
|
|
227
|
+
### Configurar Ambiente
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
# Clonar repositório
|
|
231
|
+
git clone https://github.com/seu-usuario/pyreact.git
|
|
232
|
+
cd pyreact
|
|
233
|
+
|
|
234
|
+
# Criar ambiente virtual
|
|
235
|
+
python -m venv venv
|
|
236
|
+
source venv/bin/activate # Linux/Mac
|
|
237
|
+
venv\Scripts\activate # Windows
|
|
238
|
+
|
|
239
|
+
# Instalar dependências
|
|
240
|
+
pip install -e .
|
|
241
|
+
|
|
242
|
+
# Instalar dependências de desenvolvimento
|
|
243
|
+
pip install pytest pytest-cov playwright
|
|
244
|
+
playwright install chromium
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Executar em Desenvolvimento
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
# Instalar em modo editável
|
|
251
|
+
pip install -e .
|
|
252
|
+
|
|
253
|
+
# Executar testes
|
|
254
|
+
pytest tests/ -v
|
|
255
|
+
|
|
256
|
+
# Criar build
|
|
257
|
+
python -m build
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## 📦 Publicação
|
|
263
|
+
|
|
264
|
+
### Build
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
# Limpar builds anteriores
|
|
268
|
+
python -c "import shutil; from pathlib import Path; [shutil.rmtree(p, ignore_errors=True) for p in ['build', 'dist', 'pyreact.egg-info']]"
|
|
269
|
+
|
|
270
|
+
# Criar build
|
|
271
|
+
python -m build
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### Publicar no PyPI
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
# Instalar twine
|
|
278
|
+
pip install twine
|
|
279
|
+
|
|
280
|
+
# Verificar build
|
|
281
|
+
twine check dist/*
|
|
282
|
+
|
|
283
|
+
# Publicar no TestPyPI (teste)
|
|
284
|
+
twine upload --repository testpypi dist/*
|
|
285
|
+
|
|
286
|
+
# Publicar no PyPI (oficial)
|
|
287
|
+
twine upload dist/*
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Ver `PUBLISH.md` para mais detalhes.
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
## 🤝 Contribuindo
|
|
295
|
+
|
|
296
|
+
Contribuições são bem-vindas! Por favor:
|
|
297
|
+
|
|
298
|
+
1. Fork o projeto
|
|
299
|
+
2. Crie uma branch para sua feature (`git checkout -b feature/AmazingFeature`)
|
|
300
|
+
3. Commit suas mudanças (`git commit -m 'Add some AmazingFeature'`)
|
|
301
|
+
4. Push para a branch (`git push origin feature/AmazingFeature`)
|
|
302
|
+
5. Abra um Pull Request
|
|
303
|
+
|
|
304
|
+
---
|
|
305
|
+
|
|
306
|
+
## 📝 Licença
|
|
307
|
+
|
|
308
|
+
Este projeto está licenciado sob a licença MIT - veja o arquivo [LICENSE](LICENSE) para detalhes.
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
## 📞 Contato
|
|
313
|
+
|
|
314
|
+
- **GitHub Issues:** https://github.com/seu-usuario/pyreact/issues
|
|
315
|
+
- **Documentação:** https://pyreact.readthedocs.io/
|
|
316
|
+
- **Email:** contato@pyreact.dev
|
|
317
|
+
|
|
318
|
+
---
|
|
319
|
+
|
|
320
|
+
## 🙏 Agradecimentos
|
|
321
|
+
|
|
322
|
+
- Inspirado no [React](https://reactjs.org/)
|
|
323
|
+
- Construído com ❤️ pela comunidade Python
|
|
324
|
+
|
|
325
|
+
---
|
|
326
|
+
|
|
327
|
+
**Feito com ❤️ pela comunidade Python**
|