pyreact-framework 1.0.0__py3-none-any.whl

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.
Files changed (41) hide show
  1. pyreact/__init__.py +144 -0
  2. pyreact/cli/__init__.py +3 -0
  3. pyreact/cli/main.py +512 -0
  4. pyreact/core/__init__.py +80 -0
  5. pyreact/core/component.py +372 -0
  6. pyreact/core/context.py +173 -0
  7. pyreact/core/element.py +208 -0
  8. pyreact/core/error_boundary.py +145 -0
  9. pyreact/core/hooks.py +550 -0
  10. pyreact/core/memo.py +221 -0
  11. pyreact/core/portal.py +159 -0
  12. pyreact/core/reconciler.py +399 -0
  13. pyreact/core/refs.py +213 -0
  14. pyreact/core/renderer.py +112 -0
  15. pyreact/core/scheduler.py +304 -0
  16. pyreact/devtools/__init__.py +18 -0
  17. pyreact/devtools/debugger.py +314 -0
  18. pyreact/devtools/profiler.py +288 -0
  19. pyreact/dom/__init__.py +64 -0
  20. pyreact/dom/attributes.py +317 -0
  21. pyreact/dom/dom_operations.py +333 -0
  22. pyreact/dom/events.py +349 -0
  23. pyreact/server/__init__.py +34 -0
  24. pyreact/server/hydration.py +216 -0
  25. pyreact/server/ssr.py +344 -0
  26. pyreact/styles/__init__.py +19 -0
  27. pyreact/styles/css_module.py +231 -0
  28. pyreact/styles/styled.py +303 -0
  29. pyreact/testing/__init__.py +71 -0
  30. pyreact/testing/fire_event.py +355 -0
  31. pyreact/testing/screen.py +267 -0
  32. pyreact/testing/test_renderer.py +232 -0
  33. pyreact/utils/__init__.py +17 -0
  34. pyreact/utils/diff.py +182 -0
  35. pyreact/utils/object_pool.py +216 -0
  36. pyreact_framework-1.0.0.dist-info/METADATA +363 -0
  37. pyreact_framework-1.0.0.dist-info/RECORD +41 -0
  38. pyreact_framework-1.0.0.dist-info/WHEEL +5 -0
  39. pyreact_framework-1.0.0.dist-info/entry_points.txt +2 -0
  40. pyreact_framework-1.0.0.dist-info/licenses/LICENSE +21 -0
  41. pyreact_framework-1.0.0.dist-info/top_level.txt +1 -0
@@ -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
+ [![PyPI version](https://badge.fury.io/py/pyreact.svg)](https://pypi.org/project/pyreact/)
40
+ [![Python](https://img.shields.io/pypi/pyversions/pyreact.svg)](https://pypi.org/project/pyreact/)
41
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](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,41 @@
1
+ pyreact/__init__.py,sha256=bQdXNSxGmy-gBrGk7XZgLMnpMDVwIO3tNOhWsWpNito,3109
2
+ pyreact/cli/__init__.py,sha256=Ri-R-tYpMHAsPB6079Jyo-5azMwL3HJ7UmlRctMbK-A,30
3
+ pyreact/cli/main.py,sha256=w5ULP6dkZSsL2umVEuScqOgQfkfz9fslNAE5E_mUxSY,15588
4
+ pyreact/core/__init__.py,sha256=Wr5iN6WrkLpK-hLQ4qbSKgZE4-fR1BsJrEKY6gAc9RE,1767
5
+ pyreact/core/component.py,sha256=4sWWIHcKkmynWXXYNpIyEx9prkXz3-pFWMoIOWyIO-A,10877
6
+ pyreact/core/context.py,sha256=CneI1fQ7XPE_1ZyMsbc7KGy2halg4okNoW4zUDN-rxU,5177
7
+ pyreact/core/element.py,sha256=_ZqvCAfh_v1WHgzw8hDZJcESHLoUghWTF5pmvQ6wm0A,6170
8
+ pyreact/core/error_boundary.py,sha256=pD0z0dP0kvZ4vVmVA2455WKD1SiMJgAXzpvQzzvXesQ,4070
9
+ pyreact/core/hooks.py,sha256=4xdGdctp77SP_j_49QUX3To_bAsLkhRwadXnOA48xrY,15878
10
+ pyreact/core/memo.py,sha256=ydBwTpfmciCGqsYHWR4BvMGG3Ba06-LTZiJESDPJsPA,6402
11
+ pyreact/core/portal.py,sha256=bpSpuOQIkKP0NGNMWVwFRx85EAOlTxcDZsbl21IdbHU,4338
12
+ pyreact/core/reconciler.py,sha256=9eNyuXPv5pa-YyWuKLI6IipjYFuHPF-wcOncwgTmuOU,13942
13
+ pyreact/core/refs.py,sha256=rhP6IB9FCxY2HasneTyNtifAMGxvh28cleOGwFG9ZPY,5226
14
+ pyreact/core/renderer.py,sha256=BUfbfBT6kVaX9qwgEW-Bw6Da67S33JL6KF0uotnrM0o,3627
15
+ pyreact/core/scheduler.py,sha256=V38B-CwPfIAYYrLypLPvDoZbZu8PBTUSmTOxEgcs0Bw,9115
16
+ pyreact/devtools/__init__.py,sha256=tV2VbI_rQ06oTHYAtRZRYrjIdgMAbDbWC4xyY5WC-BM,404
17
+ pyreact/devtools/debugger.py,sha256=SaURgqsMnFKJqMT4ywDvv_eSiZldGBuIQUOnFWOE_HA,8474
18
+ pyreact/devtools/profiler.py,sha256=GWqcsixZTRZq7o2FAysCkUIbVpp14Y7smv8cjAy-hdo,8033
19
+ pyreact/dom/__init__.py,sha256=03aB3z-OY3jpeilcZE2gV4XYlF08mwzCu9UYhXBXA3s,1386
20
+ pyreact/dom/attributes.py,sha256=XiP29AxI06ZgwSEPLs4FTuNNSJmuMFMkMBsKO1YmcZ8,7026
21
+ pyreact/dom/dom_operations.py,sha256=anvtZ0VEn_RP_xC_h3w1qKu12Xxbuw_sk2Xt_LC-0ns,11188
22
+ pyreact/dom/events.py,sha256=8OfnePGA0x9RgYR3L86eKjO7ZSLD6VDs-EjQIIixVng,12129
23
+ pyreact/server/__init__.py,sha256=ZYxAMML_vCy3JfldvXJYq6ECk7RhIwIMykzMGoPvGX4,761
24
+ pyreact/server/hydration.py,sha256=QNaALMVSBiZmE4aNdiT0ZAa_gtzafuKakGdZm5-dleo,5938
25
+ pyreact/server/ssr.py,sha256=61e2wHx-fluaUOTY5FyUEKO2rrpvoAiMTsjzeg8EA54,8871
26
+ pyreact/styles/__init__.py,sha256=nnZu5ZGigJR5ZBNtImFL_078dtAPa8Nkv7IrusrB_hc,371
27
+ pyreact/styles/css_module.py,sha256=SwuuYQ0LUc4EqI_ZeYQEfyyJJNNOqsBNhJZcz-_JQWk,5410
28
+ pyreact/styles/styled.py,sha256=QjCUnVDlpZRITpQJmcJNGdOZLUy1AdtatWbMSo5oO78,7543
29
+ pyreact/testing/__init__.py,sha256=O7eOW-qbymFTUkY7Q0zO2s_oq5LagwD4_fXqs9GktAY,1132
30
+ pyreact/testing/fire_event.py,sha256=NBotjOHNgKj8FFbSQXpoHVTVUrlehXzRYT30o1EsAOE,10350
31
+ pyreact/testing/screen.py,sha256=M9ogKT56vQEYSfGTwNy9D0Mc1sapp79hja0PTQyU7Mg,8953
32
+ pyreact/testing/test_renderer.py,sha256=WW-VMKse7X2dLjcUZk7uY_34-aQuXrd6fyFlIHtBNxo,7219
33
+ pyreact/utils/__init__.py,sha256=eaMMUkYy358rPjSVjB1wc_eEaXzcki9_ffyMHEavjLE,320
34
+ pyreact/utils/diff.py,sha256=N-1tUgNVO9LlpxusMJ5iVDIyUwCg9SOr-GtpEhxCSYY,4201
35
+ pyreact/utils/object_pool.py,sha256=e2Iz9jOba272weRc4CPxWQZaYCGgUl-U4aum0kqRMQE,5416
36
+ pyreact_framework-1.0.0.dist-info/licenses/LICENSE,sha256=Kp_vzqhu7sWtmkDjT1UxguEwN3vaIe62_d7qsSg4yME,1090
37
+ pyreact_framework-1.0.0.dist-info/METADATA,sha256=D7zabI7wpzkkfhC9w0jBosXbVFdT_BHneEKkQb5C2NU,8622
38
+ pyreact_framework-1.0.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
39
+ pyreact_framework-1.0.0.dist-info/entry_points.txt,sha256=rnTYkO8t9PHkXQ_jrwAsd2cBdlCdP4DoZxD8l7uUUPs,60
40
+ pyreact_framework-1.0.0.dist-info/top_level.txt,sha256=fXi82-i0hGELO6kYzU5KI5MvDCn_xz5_Gkizutz3Z9E,8
41
+ pyreact_framework-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ pyreact-framework = pyreact.cli.main:main
@@ -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 @@
1
+ pyreact