janelkit 0.1.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.
- janelkit-0.1.0/LICENSE +21 -0
- janelkit-0.1.0/PKG-INFO +179 -0
- janelkit-0.1.0/README.md +141 -0
- janelkit-0.1.0/pyproject.toml +55 -0
- janelkit-0.1.0/setup.cfg +4 -0
- janelkit-0.1.0/src/janelkit/__init__.py +107 -0
- janelkit-0.1.0/src/janelkit/cli/__init__.py +0 -0
- janelkit-0.1.0/src/janelkit/cli/build.py +84 -0
- janelkit-0.1.0/src/janelkit/cli/dev.py +101 -0
- janelkit-0.1.0/src/janelkit/cli/main.py +182 -0
- janelkit-0.1.0/src/janelkit/cli/scaffolding.py +87 -0
- janelkit-0.1.0/src/janelkit/compiler/__init__.py +251 -0
- janelkit-0.1.0/src/janelkit/compiler/ast_nodes.py +204 -0
- janelkit-0.1.0/src/janelkit/compiler/cascade.py +224 -0
- janelkit-0.1.0/src/janelkit/compiler/expressions.py +206 -0
- janelkit-0.1.0/src/janelkit/compiler/ir.py +286 -0
- janelkit-0.1.0/src/janelkit/compiler/layout_choice.py +282 -0
- janelkit-0.1.0/src/janelkit/compiler/lowering.py +1543 -0
- janelkit-0.1.0/src/janelkit/compiler/qml_generator.py +97 -0
- janelkit-0.1.0/src/janelkit/compiler/qml_interface.py +125 -0
- janelkit-0.1.0/src/janelkit/compiler/script_analysis.py +302 -0
- janelkit-0.1.0/src/janelkit/compiler/sfc_parser.py +80 -0
- janelkit-0.1.0/src/janelkit/compiler/template_parser.py +480 -0
- janelkit-0.1.0/src/janelkit/diagnostics.py +65 -0
- janelkit-0.1.0/src/janelkit/events.py +106 -0
- janelkit-0.1.0/src/janelkit/ext.py +32 -0
- janelkit-0.1.0/src/janelkit/inspect.py +588 -0
- janelkit-0.1.0/src/janelkit/lifecycle.py +199 -0
- janelkit-0.1.0/src/janelkit/locale.py +46 -0
- janelkit-0.1.0/src/janelkit/pages.py +441 -0
- janelkit-0.1.0/src/janelkit/qml/DevError.qml +27 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkBlocker.qml +18 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkBox.qml +220 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkButton.qml +68 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkCheckBox.qml +64 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkColumn.qml +10 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkContext.qml +18 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkFlex.qml +44 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkFlexColumn.qml +9 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkFlexRow.qml +8 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkHover.qml +10 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkImage.qml +43 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkList.qml +199 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkOutline.qml +19 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkPages.qml +101 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkProgressBar.qml +68 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkQtBox.qml +51 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkRadioGroup.qml +92 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkRemote.qml +13 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkRole.qml +72 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkRow.qml +9 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkScroll.qml +57 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkScroller.qml +24 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkSelect.qml +121 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkShadow.qml +40 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkShortcut.qml +20 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkSides.qml +38 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkSlider.qml +64 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkSpacer.qml +25 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkSwitch.qml +65 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkTabs.qml +93 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkTap.qml +15 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkText.qml +68 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkTextArea.qml +68 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkTextBox.qml +14 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkTextField.qml +60 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkTextInherit.qml +17 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkTextLinks.qml +9 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkTextSelect.qml +54 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkTransition.qml +84 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkTranslate.qml +8 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkVideo.qml +66 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/JkWindow.qml +34 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/flex.js +844 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/jk.js +317 -0
- janelkit-0.1.0/src/janelkit/qml/Janel/qmldir +31 -0
- janelkit-0.1.0/src/janelkit/qt_backend/__init__.py +0 -0
- janelkit-0.1.0/src/janelkit/qt_backend/application.py +536 -0
- janelkit-0.1.0/src/janelkit/qt_backend/controls.py +302 -0
- janelkit-0.1.0/src/janelkit/qt_backend/events.py +665 -0
- janelkit-0.1.0/src/janelkit/qt_backend/polish.py +35 -0
- janelkit-0.1.0/src/janelkit/reactivity/__init__.py +24 -0
- janelkit-0.1.0/src/janelkit/reactivity/collections.py +294 -0
- janelkit-0.1.0/src/janelkit/reactivity/computed.py +71 -0
- janelkit-0.1.0/src/janelkit/reactivity/effects.py +334 -0
- janelkit-0.1.0/src/janelkit/reactivity/history.py +248 -0
- janelkit-0.1.0/src/janelkit/reactivity/props.py +91 -0
- janelkit-0.1.0/src/janelkit/reactivity/state.py +74 -0
- janelkit-0.1.0/src/janelkit/runtime/__init__.py +3 -0
- janelkit-0.1.0/src/janelkit/runtime/component.py +1409 -0
- janelkit-0.1.0/src/janelkit/runtime/list_model.py +183 -0
- janelkit-0.1.0/src/janelkit/runtime/qt_bridge.py +119 -0
- janelkit-0.1.0/src/janelkit/storage.py +175 -0
- janelkit-0.1.0/src/janelkit/styling/__init__.py +0 -0
- janelkit-0.1.0/src/janelkit/styling/compiler.py +799 -0
- janelkit-0.1.0/src/janelkit/styling/parser.py +166 -0
- janelkit-0.1.0/src/janelkit/styling/theme.py +160 -0
- janelkit-0.1.0/src/janelkit/tasks.py +180 -0
- janelkit-0.1.0/src/janelkit/templates/starter/README.md.tmpl +25 -0
- janelkit-0.1.0/src/janelkit/templates/starter/assets/dot-gitkeep.tmpl +0 -0
- janelkit-0.1.0/src/janelkit/templates/starter/dot-gitignore.tmpl +6 -0
- janelkit-0.1.0/src/janelkit/templates/starter/main.py.tmpl +6 -0
- janelkit-0.1.0/src/janelkit/templates/starter/pyproject.toml.tmpl +5 -0
- janelkit-0.1.0/src/janelkit/templates/starter/src/App.janel.tmpl +39 -0
- janelkit-0.1.0/src/janelkit/templates/starter/src/components/Counter.janel.tmpl +28 -0
- janelkit-0.1.0/src/janelkit/templates/starter/src/pages/dot-gitkeep.tmpl +0 -0
- janelkit-0.1.0/src/janelkit/templates/starter/src/services/users.py.tmpl +6 -0
- janelkit-0.1.0/src/janelkit/testing.py +115 -0
- janelkit-0.1.0/src/janelkit/timers.py +133 -0
- janelkit-0.1.0/src/janelkit/video.py +240 -0
- janelkit-0.1.0/src/janelkit/windows.py +120 -0
- janelkit-0.1.0/src/janelkit.egg-info/PKG-INFO +179 -0
- janelkit-0.1.0/src/janelkit.egg-info/SOURCES.txt +154 -0
- janelkit-0.1.0/src/janelkit.egg-info/dependency_links.txt +1 -0
- janelkit-0.1.0/src/janelkit.egg-info/entry_points.txt +2 -0
- janelkit-0.1.0/src/janelkit.egg-info/requires.txt +7 -0
- janelkit-0.1.0/src/janelkit.egg-info/top_level.txt +1 -0
- janelkit-0.1.0/tests/test_accessibility_qt.py +61 -0
- janelkit-0.1.0/tests/test_async_qt.py +204 -0
- janelkit-0.1.0/tests/test_cli.py +120 -0
- janelkit-0.1.0/tests/test_collections.py +165 -0
- janelkit-0.1.0/tests/test_compiler.py +546 -0
- janelkit-0.1.0/tests/test_components_qt.py +280 -0
- janelkit-0.1.0/tests/test_controls_qt.py +156 -0
- janelkit-0.1.0/tests/test_dev.py +177 -0
- janelkit-0.1.0/tests/test_each_transfer.py +178 -0
- janelkit-0.1.0/tests/test_extensions.py +90 -0
- janelkit-0.1.0/tests/test_flex_components.py +143 -0
- janelkit-0.1.0/tests/test_flex_drag.py +154 -0
- janelkit-0.1.0/tests/test_flex_events.py +326 -0
- janelkit-0.1.0/tests/test_flex_inherit.py +179 -0
- janelkit-0.1.0/tests/test_flex_lazy.py +89 -0
- janelkit-0.1.0/tests/test_flex_position.py +179 -0
- janelkit-0.1.0/tests/test_flex_qt.py +254 -0
- janelkit-0.1.0/tests/test_flex_states.py +210 -0
- janelkit-0.1.0/tests/test_hidden_gate.py +167 -0
- janelkit-0.1.0/tests/test_history.py +185 -0
- janelkit-0.1.0/tests/test_inspect.py +136 -0
- janelkit-0.1.0/tests/test_layout_choice.py +218 -0
- janelkit-0.1.0/tests/test_lifecycle_qt.py +221 -0
- janelkit-0.1.0/tests/test_list_qt.py +184 -0
- janelkit-0.1.0/tests/test_list_scroll_qt.py +201 -0
- janelkit-0.1.0/tests/test_navigation.py +418 -0
- janelkit-0.1.0/tests/test_pages_qt.py +105 -0
- janelkit-0.1.0/tests/test_parser.py +197 -0
- janelkit-0.1.0/tests/test_persisted.py +92 -0
- janelkit-0.1.0/tests/test_public_api.py +56 -0
- janelkit-0.1.0/tests/test_qml_elements_qt.py +156 -0
- janelkit-0.1.0/tests/test_reactivity.py +202 -0
- janelkit-0.1.0/tests/test_runtime_qt.py +606 -0
- janelkit-0.1.0/tests/test_slots_qt.py +128 -0
- janelkit-0.1.0/tests/test_text_select.py +128 -0
- janelkit-0.1.0/tests/test_timers_qt.py +121 -0
- janelkit-0.1.0/tests/test_transitions_qt.py +133 -0
- janelkit-0.1.0/tests/test_video.py +247 -0
- janelkit-0.1.0/tests/test_windows_qt.py +118 -0
janelkit-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 d4ndres
|
|
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.
|
janelkit-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: janelkit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Componentes de archivo único (.janel) para aplicaciones de escritorio con Python y Qt Quick
|
|
5
|
+
Author-email: d4ndres <d4ndres@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/janelkit/janelkit
|
|
8
|
+
Project-URL: Documentation, https://github.com/janelkit/janelkit/tree/main/docs
|
|
9
|
+
Project-URL: Repository, https://github.com/janelkit/janelkit
|
|
10
|
+
Project-URL: Issues, https://github.com/janelkit/janelkit/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/janelkit/janelkit/blob/main/docs/cambios.md
|
|
12
|
+
Keywords: gui,desktop,qt,pyside6,qt-quick,reactive,components,framework
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
16
|
+
Classifier: Operating System :: MacOS
|
|
17
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
18
|
+
Classifier: Environment :: X11 Applications :: Qt
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
25
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
26
|
+
Classifier: Topic :: Software Development :: User Interfaces
|
|
27
|
+
Classifier: Natural Language :: Spanish
|
|
28
|
+
Requires-Python: >=3.10
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
License-File: LICENSE
|
|
31
|
+
Requires-Dist: PySide6!=6.12.0,>=6.8
|
|
32
|
+
Requires-Dist: qasync>=0.27
|
|
33
|
+
Provides-Extra: dev
|
|
34
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
35
|
+
Requires-Dist: build>=1; extra == "dev"
|
|
36
|
+
Requires-Dist: pyflakes>=3; extra == "dev"
|
|
37
|
+
Dynamic: license-file
|
|
38
|
+
|
|
39
|
+
# JanelKit
|
|
40
|
+
|
|
41
|
+
[](https://pypi.org/project/janelkit/)
|
|
42
|
+
[](https://pypi.org/project/janelkit/)
|
|
43
|
+
[](https://github.com/janelkit/janelkit/actions/workflows/ci.yml)
|
|
44
|
+
[](https://github.com/janelkit/janelkit/blob/main/LICENSE)
|
|
45
|
+
|
|
46
|
+
**Aplicaciones de escritorio con componentes de archivo único, escritas en Python.**
|
|
47
|
+
|
|
48
|
+
Cada componente `.janel` reúne en un archivo la lógica en Python, una plantilla declarativa y reactiva, y sus estilos en CSS. JanelKit lo compila a Qt Quick (PySide6): interfaces nativas y aceleradas por GPU en Windows, macOS y Linux, sin escribir JavaScript ni QML.
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pip install janelkit
|
|
52
|
+
janel new mi-app
|
|
53
|
+
cd mi-app
|
|
54
|
+
python main.py
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
<p align="center">
|
|
58
|
+
<img src="https://raw.githubusercontent.com/janelkit/janelkit/main/docs/img/tutorial.png" alt="La aplicación del tutorial: una lista de la compra con un campo, un botón Añadir y tres productos con casillas" width="360">
|
|
59
|
+
</p>
|
|
60
|
+
|
|
61
|
+
## Un componente
|
|
62
|
+
|
|
63
|
+
```html
|
|
64
|
+
<script lang="python">
|
|
65
|
+
from janelkit import state, computed
|
|
66
|
+
|
|
67
|
+
todos = state([{"id": 1, "title": "Probar JanelKit", "done": False}])
|
|
68
|
+
draft = state("")
|
|
69
|
+
|
|
70
|
+
@computed
|
|
71
|
+
def pending():
|
|
72
|
+
return sum(not t["done"] for t in todos.value)
|
|
73
|
+
|
|
74
|
+
def add():
|
|
75
|
+
todos.value.append({"id": len(todos.value) + 1, "title": draft.value, "done": False})
|
|
76
|
+
draft.value = ""
|
|
77
|
+
</script>
|
|
78
|
+
|
|
79
|
+
<Window title="Tareas" width={480} height={400}>
|
|
80
|
+
<Column class="page">
|
|
81
|
+
<Text class="title">{pending} pendientes</Text>
|
|
82
|
+
<Row class="new">
|
|
83
|
+
<TextField bind:value={draft} on:submit={add} placeholder="Nueva tarea" flex={1} />
|
|
84
|
+
<Button variant="primary" on:click={add}>Añadir</Button>
|
|
85
|
+
</Row>
|
|
86
|
+
{#each todos as todo (todo["id"])}
|
|
87
|
+
<Checkbox checked={todo["done"]} on:change={todo["done"] = event}>{todo["title"]}</Checkbox>
|
|
88
|
+
{:else}
|
|
89
|
+
<Text>No hay tareas.</Text>
|
|
90
|
+
{/each}
|
|
91
|
+
</Column>
|
|
92
|
+
</Window>
|
|
93
|
+
|
|
94
|
+
<style>
|
|
95
|
+
.page { padding: 24px; gap: 12px; }
|
|
96
|
+
.title { font-size: var(--font-size-xl); font-weight: 600; }
|
|
97
|
+
.new { gap: 8px; }
|
|
98
|
+
</style>
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Cuando cambia un `state`, solo se recalcula lo que lo leyó, y solo se actualiza en pantalla lo afectado. Las listas y diccionarios son reactivos también al modificarlos en el sitio (`append`, `todo["done"] = True`).
|
|
102
|
+
|
|
103
|
+
## Por qué JanelKit
|
|
104
|
+
|
|
105
|
+
- **Python de principio a fin.** La lógica, los manejadores y las expresiones de la plantilla son Python: tus módulos, tus bibliotecas y tus pruebas de siempre.
|
|
106
|
+
- **Rendimiento nativo.** Qt Quick dibuja; JanelKit solo avisa de lo que cambió. Una aplicación mediana arranca en menos de 300 ms y responde en menos de 70 ms. Una `<List>` virtualizada crea 10 000 filas en unos 40 ms.
|
|
107
|
+
- **Errores que ayudan.** Cada error indica archivo, línea y columna, con sugerencias («¿quisiste decir `on:click`?»), también los que vienen de Qt o de la ejecución.
|
|
108
|
+
- **Recarga al guardar.** `janel dev` recarga la vista y conserva el estado de los componentes cuyo script no cambió.
|
|
109
|
+
- **Probado a fondo.** Una suite extensa de pruebas que la CI ejecuta en Windows, Linux y macOS, y cinco aplicaciones grandes de validación (chat, panel en tiempo real, Kanban, hoja de cálculo y gestor de proyectos) construidas sin tocar el framework.
|
|
110
|
+
- **API pública explícita.** Qué es público está documentado y protegido por pruebas, con una [política de versiones](https://github.com/janelkit/janelkit/blob/main/docs/api.md#política-de-versiones) clara.
|
|
111
|
+
|
|
112
|
+
## Qué incluye
|
|
113
|
+
|
|
114
|
+
| Área | Contenido |
|
|
115
|
+
|---|---|
|
|
116
|
+
| **Reactividad** | `state`, `@computed`, `effect`, `batch`, colecciones reactivas, `persisted` (estado que se recuerda entre sesiones), deshacer y rehacer (`History`) |
|
|
117
|
+
| **Plantilla** | `{expr}` con formato (`{cpu:.1f}`), `on:evento`, `bind:value`, `class:x={cond}`, `{#if}`, `{#each}` con claves, `{#key}`, `{#hidden}`, transiciones |
|
|
118
|
+
| **Componentes** | Importados como módulos Python, `prop()` con tipos, `event()`, slots, `on_mount`/`on_destroy`, `ref`, `provide`/`inject` |
|
|
119
|
+
| **Asincronía** | Manejadores `async def`, `@task` con estados de carga y error, `background()` para trabajo bloqueante, temporizadores; todo se cancela al desmontar |
|
|
120
|
+
| **Disposición y estilos** | Flexbox de CSS (`<flex>`, `Column`, `Row`), posición, pseudo-clases y selectores, tokens `var(--primary)`, temas claro y oscuro intercambiables en caliente |
|
|
121
|
+
| **Controles** | Texto (también Markdown), botones, campos, casillas, `Select`, `Switch`, `Slider`, `RadioGroup`, `Tabs`, `Image`, `ProgressBar`, `<List>` virtualizada, `<Video>`, arrastrar y soltar |
|
|
122
|
+
| **Ventanas y navegación** | Varias ventanas, pilas de páginas, secciones que conservan su estado, `before_leave` para cambios sin guardar, Alt+← |
|
|
123
|
+
| **Accesibilidad** | Navegación con teclado, foco visible, nombres accesibles, derecha a izquierda |
|
|
124
|
+
| **Interoperabilidad** | Importa un `.qml` propio como si fuera un componente |
|
|
125
|
+
| **Pruebas** | `janelkit.inspect`: monta sin ventana, busca elementos, simula clics y teclas, lee el estado |
|
|
126
|
+
|
|
127
|
+
## Comandos
|
|
128
|
+
|
|
129
|
+
| Comando | Qué hace |
|
|
130
|
+
|---|---|
|
|
131
|
+
| `janel new <nombre>` | Crea un proyecto con `main.py` y `src/App.janel`. |
|
|
132
|
+
| `janel dev [carpeta]` | Ejecuta la aplicación y la recarga al guardar. |
|
|
133
|
+
| `janel build [carpeta]` | Valida todos los componentes y guarda el QML generado. |
|
|
134
|
+
| `janel compile <archivo>` | Muestra el QML generado de un componente. |
|
|
135
|
+
| `janel parse <archivo>` | Muestra el árbol sintáctico o los errores con línea y columna. |
|
|
136
|
+
|
|
137
|
+
## Probar una aplicación
|
|
138
|
+
|
|
139
|
+
```python
|
|
140
|
+
from janelkit import inspect
|
|
141
|
+
|
|
142
|
+
def test_add(tmp_path):
|
|
143
|
+
with inspect.mount("src/App.janel") as app:
|
|
144
|
+
app.find(placeholder="Nueva tarea").type("Pan")
|
|
145
|
+
app.find(text="Añadir").click()
|
|
146
|
+
assert app.find(text="1 pendientes")
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Ecosistema
|
|
150
|
+
|
|
151
|
+
| Paquete | Qué añade |
|
|
152
|
+
|---|---|
|
|
153
|
+
| [`janelkit-i18n`](https://pypi.org/project/janelkit-i18n/) | Traducciones, plurales, formatos según el idioma y cambio de idioma en caliente. |
|
|
154
|
+
| [`janelkit-desktop`](https://pypi.org/project/janelkit-desktop/) | Diálogos nativos, portapapeles y notificaciones del sistema. |
|
|
155
|
+
| [Resaltado para VS Code](https://github.com/janelkit/janelkit/tree/main/packages/janelkit-vscode) | Sintaxis de `.janel`: Python, plantilla y CSS. |
|
|
156
|
+
|
|
157
|
+
## Requisitos
|
|
158
|
+
|
|
159
|
+
- Python 3.10 o posterior.
|
|
160
|
+
- PySide6 6.8 o posterior, salvo la 6.12.0 (se instala solo).
|
|
161
|
+
- Windows, macOS o Linux.
|
|
162
|
+
|
|
163
|
+
## Estado
|
|
164
|
+
|
|
165
|
+
JanelKit está en **alfa** (serie 0.x). Lo público está [documentado](https://github.com/janelkit/janelkit/blob/main/docs/api.md). Una versión de parche nunca lo rompe; una versión menor puede hacerlo, pero cada cambio se anuncia en las [notas de la versión](https://github.com/janelkit/janelkit/blob/main/docs/cambios.md) con cómo migrar.
|
|
166
|
+
|
|
167
|
+
## Documentación
|
|
168
|
+
|
|
169
|
+
- [Tutorial](https://github.com/janelkit/janelkit/blob/main/docs/tutorial.md): una aplicación completa paso a paso. **Empieza aquí.**
|
|
170
|
+
- [El lenguaje `.janel`](https://github.com/janelkit/janelkit/blob/main/docs/lenguaje.md): expresiones, bloques, componentes y elementos.
|
|
171
|
+
- [Estilos y disposición](https://github.com/janelkit/janelkit/blob/main/docs/estilos.md): CSS soportado, flexbox, tokens y temas.
|
|
172
|
+
- [Desarrollo](https://github.com/janelkit/janelkit/blob/main/docs/desarrollo.md): `janel dev`, `janel build`, errores y editor.
|
|
173
|
+
- [API pública](https://github.com/janelkit/janelkit/blob/main/docs/api.md) y [cambios entre versiones](https://github.com/janelkit/janelkit/blob/main/docs/cambios.md).
|
|
174
|
+
- [Crear un ejecutable](https://github.com/janelkit/janelkit/blob/main/docs/empaquetado.md) con PyInstaller.
|
|
175
|
+
- [Ejemplos](https://github.com/janelkit/janelkit/tree/main/apps/examples): contador, tareas, notas, explorador de archivos, cliente de una API, idiomas, vídeo…
|
|
176
|
+
|
|
177
|
+
## Licencia
|
|
178
|
+
|
|
179
|
+
[MIT](https://github.com/janelkit/janelkit/blob/main/LICENSE). JanelKit usa [PySide6](https://pypi.org/project/PySide6/) (Qt for Python), que se distribuye bajo LGPL-3.0: si empaquetas tu aplicación con Qt incluido, revisa sus [condiciones](https://doc.qt.io/qtforpython-6/licenses.html).
|
janelkit-0.1.0/README.md
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# JanelKit
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/janelkit/)
|
|
4
|
+
[](https://pypi.org/project/janelkit/)
|
|
5
|
+
[](https://github.com/janelkit/janelkit/actions/workflows/ci.yml)
|
|
6
|
+
[](https://github.com/janelkit/janelkit/blob/main/LICENSE)
|
|
7
|
+
|
|
8
|
+
**Aplicaciones de escritorio con componentes de archivo único, escritas en Python.**
|
|
9
|
+
|
|
10
|
+
Cada componente `.janel` reúne en un archivo la lógica en Python, una plantilla declarativa y reactiva, y sus estilos en CSS. JanelKit lo compila a Qt Quick (PySide6): interfaces nativas y aceleradas por GPU en Windows, macOS y Linux, sin escribir JavaScript ni QML.
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pip install janelkit
|
|
14
|
+
janel new mi-app
|
|
15
|
+
cd mi-app
|
|
16
|
+
python main.py
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
<p align="center">
|
|
20
|
+
<img src="https://raw.githubusercontent.com/janelkit/janelkit/main/docs/img/tutorial.png" alt="La aplicación del tutorial: una lista de la compra con un campo, un botón Añadir y tres productos con casillas" width="360">
|
|
21
|
+
</p>
|
|
22
|
+
|
|
23
|
+
## Un componente
|
|
24
|
+
|
|
25
|
+
```html
|
|
26
|
+
<script lang="python">
|
|
27
|
+
from janelkit import state, computed
|
|
28
|
+
|
|
29
|
+
todos = state([{"id": 1, "title": "Probar JanelKit", "done": False}])
|
|
30
|
+
draft = state("")
|
|
31
|
+
|
|
32
|
+
@computed
|
|
33
|
+
def pending():
|
|
34
|
+
return sum(not t["done"] for t in todos.value)
|
|
35
|
+
|
|
36
|
+
def add():
|
|
37
|
+
todos.value.append({"id": len(todos.value) + 1, "title": draft.value, "done": False})
|
|
38
|
+
draft.value = ""
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<Window title="Tareas" width={480} height={400}>
|
|
42
|
+
<Column class="page">
|
|
43
|
+
<Text class="title">{pending} pendientes</Text>
|
|
44
|
+
<Row class="new">
|
|
45
|
+
<TextField bind:value={draft} on:submit={add} placeholder="Nueva tarea" flex={1} />
|
|
46
|
+
<Button variant="primary" on:click={add}>Añadir</Button>
|
|
47
|
+
</Row>
|
|
48
|
+
{#each todos as todo (todo["id"])}
|
|
49
|
+
<Checkbox checked={todo["done"]} on:change={todo["done"] = event}>{todo["title"]}</Checkbox>
|
|
50
|
+
{:else}
|
|
51
|
+
<Text>No hay tareas.</Text>
|
|
52
|
+
{/each}
|
|
53
|
+
</Column>
|
|
54
|
+
</Window>
|
|
55
|
+
|
|
56
|
+
<style>
|
|
57
|
+
.page { padding: 24px; gap: 12px; }
|
|
58
|
+
.title { font-size: var(--font-size-xl); font-weight: 600; }
|
|
59
|
+
.new { gap: 8px; }
|
|
60
|
+
</style>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Cuando cambia un `state`, solo se recalcula lo que lo leyó, y solo se actualiza en pantalla lo afectado. Las listas y diccionarios son reactivos también al modificarlos en el sitio (`append`, `todo["done"] = True`).
|
|
64
|
+
|
|
65
|
+
## Por qué JanelKit
|
|
66
|
+
|
|
67
|
+
- **Python de principio a fin.** La lógica, los manejadores y las expresiones de la plantilla son Python: tus módulos, tus bibliotecas y tus pruebas de siempre.
|
|
68
|
+
- **Rendimiento nativo.** Qt Quick dibuja; JanelKit solo avisa de lo que cambió. Una aplicación mediana arranca en menos de 300 ms y responde en menos de 70 ms. Una `<List>` virtualizada crea 10 000 filas en unos 40 ms.
|
|
69
|
+
- **Errores que ayudan.** Cada error indica archivo, línea y columna, con sugerencias («¿quisiste decir `on:click`?»), también los que vienen de Qt o de la ejecución.
|
|
70
|
+
- **Recarga al guardar.** `janel dev` recarga la vista y conserva el estado de los componentes cuyo script no cambió.
|
|
71
|
+
- **Probado a fondo.** Una suite extensa de pruebas que la CI ejecuta en Windows, Linux y macOS, y cinco aplicaciones grandes de validación (chat, panel en tiempo real, Kanban, hoja de cálculo y gestor de proyectos) construidas sin tocar el framework.
|
|
72
|
+
- **API pública explícita.** Qué es público está documentado y protegido por pruebas, con una [política de versiones](https://github.com/janelkit/janelkit/blob/main/docs/api.md#política-de-versiones) clara.
|
|
73
|
+
|
|
74
|
+
## Qué incluye
|
|
75
|
+
|
|
76
|
+
| Área | Contenido |
|
|
77
|
+
|---|---|
|
|
78
|
+
| **Reactividad** | `state`, `@computed`, `effect`, `batch`, colecciones reactivas, `persisted` (estado que se recuerda entre sesiones), deshacer y rehacer (`History`) |
|
|
79
|
+
| **Plantilla** | `{expr}` con formato (`{cpu:.1f}`), `on:evento`, `bind:value`, `class:x={cond}`, `{#if}`, `{#each}` con claves, `{#key}`, `{#hidden}`, transiciones |
|
|
80
|
+
| **Componentes** | Importados como módulos Python, `prop()` con tipos, `event()`, slots, `on_mount`/`on_destroy`, `ref`, `provide`/`inject` |
|
|
81
|
+
| **Asincronía** | Manejadores `async def`, `@task` con estados de carga y error, `background()` para trabajo bloqueante, temporizadores; todo se cancela al desmontar |
|
|
82
|
+
| **Disposición y estilos** | Flexbox de CSS (`<flex>`, `Column`, `Row`), posición, pseudo-clases y selectores, tokens `var(--primary)`, temas claro y oscuro intercambiables en caliente |
|
|
83
|
+
| **Controles** | Texto (también Markdown), botones, campos, casillas, `Select`, `Switch`, `Slider`, `RadioGroup`, `Tabs`, `Image`, `ProgressBar`, `<List>` virtualizada, `<Video>`, arrastrar y soltar |
|
|
84
|
+
| **Ventanas y navegación** | Varias ventanas, pilas de páginas, secciones que conservan su estado, `before_leave` para cambios sin guardar, Alt+← |
|
|
85
|
+
| **Accesibilidad** | Navegación con teclado, foco visible, nombres accesibles, derecha a izquierda |
|
|
86
|
+
| **Interoperabilidad** | Importa un `.qml` propio como si fuera un componente |
|
|
87
|
+
| **Pruebas** | `janelkit.inspect`: monta sin ventana, busca elementos, simula clics y teclas, lee el estado |
|
|
88
|
+
|
|
89
|
+
## Comandos
|
|
90
|
+
|
|
91
|
+
| Comando | Qué hace |
|
|
92
|
+
|---|---|
|
|
93
|
+
| `janel new <nombre>` | Crea un proyecto con `main.py` y `src/App.janel`. |
|
|
94
|
+
| `janel dev [carpeta]` | Ejecuta la aplicación y la recarga al guardar. |
|
|
95
|
+
| `janel build [carpeta]` | Valida todos los componentes y guarda el QML generado. |
|
|
96
|
+
| `janel compile <archivo>` | Muestra el QML generado de un componente. |
|
|
97
|
+
| `janel parse <archivo>` | Muestra el árbol sintáctico o los errores con línea y columna. |
|
|
98
|
+
|
|
99
|
+
## Probar una aplicación
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
from janelkit import inspect
|
|
103
|
+
|
|
104
|
+
def test_add(tmp_path):
|
|
105
|
+
with inspect.mount("src/App.janel") as app:
|
|
106
|
+
app.find(placeholder="Nueva tarea").type("Pan")
|
|
107
|
+
app.find(text="Añadir").click()
|
|
108
|
+
assert app.find(text="1 pendientes")
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Ecosistema
|
|
112
|
+
|
|
113
|
+
| Paquete | Qué añade |
|
|
114
|
+
|---|---|
|
|
115
|
+
| [`janelkit-i18n`](https://pypi.org/project/janelkit-i18n/) | Traducciones, plurales, formatos según el idioma y cambio de idioma en caliente. |
|
|
116
|
+
| [`janelkit-desktop`](https://pypi.org/project/janelkit-desktop/) | Diálogos nativos, portapapeles y notificaciones del sistema. |
|
|
117
|
+
| [Resaltado para VS Code](https://github.com/janelkit/janelkit/tree/main/packages/janelkit-vscode) | Sintaxis de `.janel`: Python, plantilla y CSS. |
|
|
118
|
+
|
|
119
|
+
## Requisitos
|
|
120
|
+
|
|
121
|
+
- Python 3.10 o posterior.
|
|
122
|
+
- PySide6 6.8 o posterior, salvo la 6.12.0 (se instala solo).
|
|
123
|
+
- Windows, macOS o Linux.
|
|
124
|
+
|
|
125
|
+
## Estado
|
|
126
|
+
|
|
127
|
+
JanelKit está en **alfa** (serie 0.x). Lo público está [documentado](https://github.com/janelkit/janelkit/blob/main/docs/api.md). Una versión de parche nunca lo rompe; una versión menor puede hacerlo, pero cada cambio se anuncia en las [notas de la versión](https://github.com/janelkit/janelkit/blob/main/docs/cambios.md) con cómo migrar.
|
|
128
|
+
|
|
129
|
+
## Documentación
|
|
130
|
+
|
|
131
|
+
- [Tutorial](https://github.com/janelkit/janelkit/blob/main/docs/tutorial.md): una aplicación completa paso a paso. **Empieza aquí.**
|
|
132
|
+
- [El lenguaje `.janel`](https://github.com/janelkit/janelkit/blob/main/docs/lenguaje.md): expresiones, bloques, componentes y elementos.
|
|
133
|
+
- [Estilos y disposición](https://github.com/janelkit/janelkit/blob/main/docs/estilos.md): CSS soportado, flexbox, tokens y temas.
|
|
134
|
+
- [Desarrollo](https://github.com/janelkit/janelkit/blob/main/docs/desarrollo.md): `janel dev`, `janel build`, errores y editor.
|
|
135
|
+
- [API pública](https://github.com/janelkit/janelkit/blob/main/docs/api.md) y [cambios entre versiones](https://github.com/janelkit/janelkit/blob/main/docs/cambios.md).
|
|
136
|
+
- [Crear un ejecutable](https://github.com/janelkit/janelkit/blob/main/docs/empaquetado.md) con PyInstaller.
|
|
137
|
+
- [Ejemplos](https://github.com/janelkit/janelkit/tree/main/apps/examples): contador, tareas, notas, explorador de archivos, cliente de una API, idiomas, vídeo…
|
|
138
|
+
|
|
139
|
+
## Licencia
|
|
140
|
+
|
|
141
|
+
[MIT](https://github.com/janelkit/janelkit/blob/main/LICENSE). JanelKit usa [PySide6](https://pypi.org/project/PySide6/) (Qt for Python), que se distribuye bajo LGPL-3.0: si empaquetas tu aplicación con Qt incluido, revisa sus [condiciones](https://doc.qt.io/qtforpython-6/licenses.html).
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "janelkit" # libre en PyPI (verificado el 28-10-2026; ver docs/estado.md, decisión 23)
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Componentes de archivo único (.janel) para aplicaciones de escritorio con Python y Qt Quick"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [{ name = "d4ndres", email = "d4ndres@gmail.com" }]
|
|
14
|
+
keywords = ["gui", "desktop", "qt", "pyside6", "qt-quick", "reactive", "components", "framework"]
|
|
15
|
+
dependencies = ["PySide6>=6.8,!=6.12.0", "qasync>=0.27"] # 6.12.0: segfault en el recolector de Python (Linux, macOS)
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 3 - Alpha",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Operating System :: Microsoft :: Windows",
|
|
20
|
+
"Operating System :: MacOS",
|
|
21
|
+
"Operating System :: POSIX :: Linux",
|
|
22
|
+
"Environment :: X11 Applications :: Qt",
|
|
23
|
+
"Programming Language :: Python :: 3",
|
|
24
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
25
|
+
"Programming Language :: Python :: 3.10",
|
|
26
|
+
"Programming Language :: Python :: 3.11",
|
|
27
|
+
"Programming Language :: Python :: 3.12",
|
|
28
|
+
"Programming Language :: Python :: 3.13",
|
|
29
|
+
"Topic :: Software Development :: Libraries :: Application Frameworks",
|
|
30
|
+
"Topic :: Software Development :: User Interfaces",
|
|
31
|
+
"Natural Language :: Spanish",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
[project.urls]
|
|
35
|
+
Homepage = "https://github.com/janelkit/janelkit"
|
|
36
|
+
Documentation = "https://github.com/janelkit/janelkit/tree/main/docs"
|
|
37
|
+
Repository = "https://github.com/janelkit/janelkit"
|
|
38
|
+
Issues = "https://github.com/janelkit/janelkit/issues"
|
|
39
|
+
Changelog = "https://github.com/janelkit/janelkit/blob/main/docs/cambios.md"
|
|
40
|
+
|
|
41
|
+
[project.optional-dependencies]
|
|
42
|
+
dev = ["pytest>=8", "build>=1", "pyflakes>=3"]
|
|
43
|
+
|
|
44
|
+
[project.scripts]
|
|
45
|
+
janel = "janelkit.cli.main:main"
|
|
46
|
+
|
|
47
|
+
[tool.setuptools.packages.find]
|
|
48
|
+
where = ["src"]
|
|
49
|
+
|
|
50
|
+
[tool.setuptools.package-data]
|
|
51
|
+
janelkit = ["templates/**/*", "qml/**/*"]
|
|
52
|
+
|
|
53
|
+
[tool.pytest.ini_options]
|
|
54
|
+
testpaths = ["tests"]
|
|
55
|
+
addopts = "--import-mode=importlib"
|
janelkit-0.1.0/setup.cfg
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"""JanelKit: componentes de archivo único para escritorio con Python y Qt Quick."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import os
|
|
5
|
+
from typing import TYPE_CHECKING
|
|
6
|
+
|
|
7
|
+
from .reactivity import (
|
|
8
|
+
Computed,
|
|
9
|
+
Effect,
|
|
10
|
+
Event,
|
|
11
|
+
History,
|
|
12
|
+
Prop,
|
|
13
|
+
PropError,
|
|
14
|
+
State,
|
|
15
|
+
batch,
|
|
16
|
+
computed,
|
|
17
|
+
effect,
|
|
18
|
+
event,
|
|
19
|
+
prop,
|
|
20
|
+
state,
|
|
21
|
+
untracked,
|
|
22
|
+
)
|
|
23
|
+
from .locale import locale
|
|
24
|
+
from .events import DragEvent, FocusEvent, KeyEvent, PointerEvent, ResizeEvent, WheelEvent
|
|
25
|
+
from .lifecycle import Ref, before_leave, inject, on_destroy, on_mount, provide, ref
|
|
26
|
+
from .pages import PageStack, Sections, navigation, pages, sections
|
|
27
|
+
from .storage import Persisted, persisted
|
|
28
|
+
from .styling.theme import theme
|
|
29
|
+
from .tasks import Task, background, spawn, task
|
|
30
|
+
from .timers import Timer, interval, timeout
|
|
31
|
+
from .windows import open_window
|
|
32
|
+
|
|
33
|
+
__version__ = "0.1.0"
|
|
34
|
+
|
|
35
|
+
# API pública: lo que se importa desde `janelkit` es estable dentro de una
|
|
36
|
+
# versión menor (ver docs/api.md). Cualquier otro módulo es interno.
|
|
37
|
+
__all__ = [
|
|
38
|
+
"Computed",
|
|
39
|
+
"Effect",
|
|
40
|
+
"DragEvent",
|
|
41
|
+
"Event",
|
|
42
|
+
"History",
|
|
43
|
+
"FocusEvent",
|
|
44
|
+
"Frames",
|
|
45
|
+
"KeyEvent",
|
|
46
|
+
"Prop",
|
|
47
|
+
"PageStack",
|
|
48
|
+
"Persisted",
|
|
49
|
+
"PointerEvent",
|
|
50
|
+
"PropError",
|
|
51
|
+
"Ref",
|
|
52
|
+
"Sections",
|
|
53
|
+
"ResizeEvent",
|
|
54
|
+
"State",
|
|
55
|
+
"Task",
|
|
56
|
+
"Timer",
|
|
57
|
+
"WheelEvent",
|
|
58
|
+
"__version__",
|
|
59
|
+
"background",
|
|
60
|
+
"batch",
|
|
61
|
+
"before_leave",
|
|
62
|
+
"computed",
|
|
63
|
+
"effect",
|
|
64
|
+
"event",
|
|
65
|
+
"inject",
|
|
66
|
+
"interval",
|
|
67
|
+
"locale",
|
|
68
|
+
"navigation",
|
|
69
|
+
"on_destroy",
|
|
70
|
+
"on_mount",
|
|
71
|
+
"pages",
|
|
72
|
+
"persisted",
|
|
73
|
+
"open_window",
|
|
74
|
+
"prop",
|
|
75
|
+
"provide",
|
|
76
|
+
"ref",
|
|
77
|
+
"run",
|
|
78
|
+
"sections",
|
|
79
|
+
"spawn",
|
|
80
|
+
"state",
|
|
81
|
+
"task",
|
|
82
|
+
"theme",
|
|
83
|
+
"timeout",
|
|
84
|
+
"untracked",
|
|
85
|
+
]
|
|
86
|
+
|
|
87
|
+
if TYPE_CHECKING:
|
|
88
|
+
from .qt_backend.application import run
|
|
89
|
+
from .video import Frames
|
|
90
|
+
else:
|
|
91
|
+
|
|
92
|
+
def run(entry: str | os.PathLike[str], argv: list[str] | None = None) -> int:
|
|
93
|
+
# Importación diferida: `from janelkit import state` no necesita cargar Qt.
|
|
94
|
+
from .qt_backend.application import run as _run
|
|
95
|
+
|
|
96
|
+
return _run(entry, argv)
|
|
97
|
+
|
|
98
|
+
run.__doc__ = "Compila el componente raíz `entry`, abre la ventana y ejecuta el ciclo de eventos de Qt."
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def __getattr__(name: str):
|
|
102
|
+
# Importación diferida: Frames carga QtMultimedia, que solo necesitan las apps con vídeo.
|
|
103
|
+
if name == "Frames":
|
|
104
|
+
from .video import Frames
|
|
105
|
+
|
|
106
|
+
return Frames
|
|
107
|
+
raise AttributeError(f"module 'janelkit' has no attribute {name!r}")
|
|
File without changes
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"""`janel build`: compila todos los componentes del proyecto y guarda el QML generado.
|
|
2
|
+
|
|
3
|
+
Sirve para validar el proyecto completo (también componentes que todavía no se
|
|
4
|
+
usan) y para inspeccionar el QML. **No genera un ejecutable**: empaquetar
|
|
5
|
+
aplicaciones para distribuirlas es un paso distinto, previsto para más adelante.
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from dataclasses import dataclass, field
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
from ..compiler import CompileSession, CompiledComponent
|
|
13
|
+
from ..diagnostics import Diagnostic, JanelError
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@dataclass
|
|
17
|
+
class BuildResult:
|
|
18
|
+
out_dir: Path
|
|
19
|
+
written: list[Path] = field(default_factory=list)
|
|
20
|
+
errors: list[Diagnostic] = field(default_factory=list)
|
|
21
|
+
warnings: list[Diagnostic] = field(default_factory=list)
|
|
22
|
+
|
|
23
|
+
@property
|
|
24
|
+
def ok(self) -> bool:
|
|
25
|
+
return not self.errors
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def find_source_dir(target: Path) -> Path:
|
|
29
|
+
target = target.resolve()
|
|
30
|
+
if target.is_file():
|
|
31
|
+
return target.parent
|
|
32
|
+
src = target / "src"
|
|
33
|
+
return src if (src / "App.janel").is_file() else target
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def build_project(target: Path, out_dir: Path | None = None) -> BuildResult:
|
|
37
|
+
src = find_source_dir(target)
|
|
38
|
+
project = src.parent if src.name == "src" else src
|
|
39
|
+
out = (out_dir or project / "build" / "qml").resolve()
|
|
40
|
+
result = BuildResult(out)
|
|
41
|
+
|
|
42
|
+
entry = src / "App.janel"
|
|
43
|
+
files = sorted(src.rglob("*.janel"))
|
|
44
|
+
if not files:
|
|
45
|
+
result.errors.append(Diagnostic(f"no hay archivos .janel en {src}"))
|
|
46
|
+
return result
|
|
47
|
+
|
|
48
|
+
session = CompileSession([src])
|
|
49
|
+
compiled: dict[str, CompiledComponent] = {}
|
|
50
|
+
|
|
51
|
+
def attempt(path: Path, as_window: bool) -> None:
|
|
52
|
+
try:
|
|
53
|
+
session.compile(path, as_window=as_window)
|
|
54
|
+
except JanelError as exc:
|
|
55
|
+
result.errors.extend(exc.diagnostics)
|
|
56
|
+
|
|
57
|
+
if entry.is_file():
|
|
58
|
+
attempt(entry, as_window=True)
|
|
59
|
+
for path in files:
|
|
60
|
+
if str(path.resolve()) not in session.registry and path != entry:
|
|
61
|
+
# Sin usar en ninguna plantilla: un componente, o una ventana para open_window.
|
|
62
|
+
attempt(path, as_window=_is_window(session, path))
|
|
63
|
+
compiled.update(session.registry)
|
|
64
|
+
# Un archivo con errores puede intentarse dos veces (como hijo y por sí mismo).
|
|
65
|
+
result.errors = list({(d.message, d.location): d for d in result.errors}.values())
|
|
66
|
+
|
|
67
|
+
for key, comp in compiled.items():
|
|
68
|
+
result.warnings.extend(comp.warnings)
|
|
69
|
+
rel = Path(key).relative_to(src) if Path(key).is_relative_to(src) else Path(Path(key).name)
|
|
70
|
+
target_file = out / rel.with_suffix(".qml")
|
|
71
|
+
target_file.parent.mkdir(parents=True, exist_ok=True)
|
|
72
|
+
target_file.write_text(comp.qml, encoding="utf-8")
|
|
73
|
+
result.written.append(target_file)
|
|
74
|
+
return result
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def _is_window(session: CompileSession, path: Path) -> bool:
|
|
78
|
+
"""El archivo tiene <Window> como raíz (se abrirá con open_window)."""
|
|
79
|
+
try:
|
|
80
|
+
sfc, _ = session.load(path)
|
|
81
|
+
except JanelError:
|
|
82
|
+
return False
|
|
83
|
+
roots = sfc.root_elements
|
|
84
|
+
return bool(roots) and getattr(roots[0], "tag", None) == "Window"
|