urirun-widgets 0.1.1__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.
Files changed (37) hide show
  1. urirun_widgets-0.1.1/LICENSE +201 -0
  2. urirun_widgets-0.1.1/PKG-INFO +150 -0
  3. urirun_widgets-0.1.1/README.md +127 -0
  4. urirun_widgets-0.1.1/pyproject.toml +72 -0
  5. urirun_widgets-0.1.1/setup.cfg +4 -0
  6. urirun_widgets-0.1.1/tests/test_render_single_source.py +91 -0
  7. urirun_widgets-0.1.1/tests/test_widgets_core.py +448 -0
  8. urirun_widgets-0.1.1/urirun_widgets/__init__.py +10 -0
  9. urirun_widgets-0.1.1/urirun_widgets/assets/dashboard-render.js +28 -0
  10. urirun_widgets-0.1.1/urirun_widgets/assets/render-helpers.js +100 -0
  11. urirun_widgets-0.1.1/urirun_widgets/assets/render.js +47 -0
  12. urirun_widgets-0.1.1/urirun_widgets/assets/widgets/artifact-grid.js +102 -0
  13. urirun_widgets-0.1.1/urirun_widgets/assets/widgets/attachment.js +66 -0
  14. urirun_widgets-0.1.1/urirun_widgets/assets/widgets/chat-message.js +78 -0
  15. urirun_widgets-0.1.1/urirun_widgets/assets/widgets/dashboard.js +82 -0
  16. urirun_widgets-0.1.1/urirun_widgets/assets/widgets/form.js +32 -0
  17. urirun_widgets-0.1.1/urirun_widgets/assets/widgets/generic.js +18 -0
  18. urirun_widgets-0.1.1/urirun_widgets/assets/widgets/graph.js +14 -0
  19. urirun_widgets-0.1.1/urirun_widgets/assets/widgets/iframe.js +12 -0
  20. urirun_widgets-0.1.1/urirun_widgets/assets/widgets/image.js +18 -0
  21. urirun_widgets-0.1.1/urirun_widgets/assets/widgets/scanner-status.js +40 -0
  22. urirun_widgets-0.1.1/urirun_widgets/assets/widgets/scanner-stream.js +34 -0
  23. urirun_widgets-0.1.1/urirun_widgets/assets/widgets/table.js +19 -0
  24. urirun_widgets-0.1.1/urirun_widgets/assets/widgets/twin.js +98 -0
  25. urirun_widgets-0.1.1/urirun_widgets/assets/widgets/video.js +12 -0
  26. urirun_widgets-0.1.1/urirun_widgets/assets/widgets/widget-card.js +46 -0
  27. urirun_widgets-0.1.1/urirun_widgets/assets/widgets.css +352 -0
  28. urirun_widgets-0.1.1/urirun_widgets/catalog.py +211 -0
  29. urirun_widgets-0.1.1/urirun_widgets/connector.manifest.json +54 -0
  30. urirun_widgets-0.1.1/urirun_widgets/core.py +185 -0
  31. urirun_widgets-0.1.1/urirun_widgets/render.py +911 -0
  32. urirun_widgets-0.1.1/urirun_widgets.egg-info/PKG-INFO +150 -0
  33. urirun_widgets-0.1.1/urirun_widgets.egg-info/SOURCES.txt +35 -0
  34. urirun_widgets-0.1.1/urirun_widgets.egg-info/dependency_links.txt +1 -0
  35. urirun_widgets-0.1.1/urirun_widgets.egg-info/entry_points.txt +5 -0
  36. urirun_widgets-0.1.1/urirun_widgets.egg-info/requires.txt +4 -0
  37. urirun_widgets-0.1.1/urirun_widgets.egg-info/top_level.txt +1 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Tom Sapletta — ifURI
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,150 @@
1
+ Metadata-Version: 2.4
2
+ Name: urirun-widgets
3
+ Version: 0.1.1
4
+ Summary: Chat-stream HTML widgets for ifuri and urirun (widget://)
5
+ Author-email: Tom Sapletta <info@softreck.dev>, Tom Sapletta <tom@sapletta.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://connect.ifuri.com/connectors/widget
8
+ Project-URL: Repository, https://github.com/if-uri/urirun-widgets
9
+ Keywords: urirun,widget,render,dashboard,html,svg,ui
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Topic :: Software Development :: User Interfaces
15
+ Classifier: Topic :: Text Processing :: Markup :: HTML
16
+ Requires-Python: >=3.10
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: urirun>=0.4.190
20
+ Provides-Extra: test
21
+ Requires-Dist: pytest>=8; extra == "test"
22
+ Dynamic: license-file
23
+
24
+ # urirun-widgets
25
+
26
+
27
+ ## AI Cost Tracking
28
+
29
+ ![PyPI](https://img.shields.io/badge/pypi-costs-blue) ![Version](https://img.shields.io/badge/version-0.1.1-blue) ![Python](https://img.shields.io/badge/python-3.9+-blue) ![License](https://img.shields.io/badge/license-Apache--2.0-green)
30
+ ![AI Cost](https://img.shields.io/badge/AI%20Cost-$0.11-orange) ![Human Time](https://img.shields.io/badge/Human%20Time-17.9h-blue) ![Model](https://img.shields.io/badge/Model-openrouter%2Fqwen%2Fqwen3--coder--next-lightgrey)
31
+
32
+ - 🤖 **LLM usage:** $0.1050 (6 commits)
33
+ - 👤 **Human dev:** ~$1795 (17.9h @ $100/h, 30min dedup)
34
+
35
+ Generated on 2026-07-05 using [openrouter/qwen/qwen3-coder-next](https://openrouter.ai/qwen/qwen3-coder-next)
36
+
37
+ ---
38
+
39
+
40
+
41
+ **Chat-stream HTML widgets** — connector ekosystemu [ifURI / urirun](https://github.com/if-uri/urirun).
42
+ Schemat URI: `widget://`
43
+
44
+ Widoki HTML, które okno czatu (`chat-main`) renderuje w `chatStreamList` podczas skanowania — teraz jako wspólny, adresowany przez URI katalog, zamiast funkcji wklejonych w dashboard hosta. Źródłem prawdy dla przeglądarki są samodzielne moduły ES w `assets/widgets/`. Connector listuje katalog, serwuje JS pojedynczego widgetu, serwuje cały katalog jako jeden import (`bundle`) oraz renderuje widok po stronie serwera (mirror w Pythonie) dla powierzchni bez DOM.
45
+
46
+ The HTML views chatStreamList renders in chat-main when scanning, collected into one URI-addressable catalogue.
47
+
48
+ ## Widgety
49
+
50
+ | id | obsługuje `view` | plik |
51
+ |----|------------------|------|
52
+ | `scanner-stream` | `scanner-stream` | `assets/widgets/scanner-stream.js` |
53
+ | `scanner-status` | `scanner-status` | `assets/widgets/scanner-status.js` |
54
+ | `table` | `table` | `assets/widgets/table.js` |
55
+ | `image` | `image`, `image-list` | `assets/widgets/image.js` |
56
+ | `video` | `video` | `assets/widgets/video.js` |
57
+ | `iframe` | `iframe`, `page`, `web` | `assets/widgets/iframe.js` |
58
+ | `form` | `form` | `assets/widgets/form.js` |
59
+ | `graph` | `graph` | `assets/widgets/graph.js` |
60
+ | `generic` | *(fallback)* | `assets/widgets/generic.js` |
61
+
62
+ Wspólne helpery: `assets/render-helpers.js` · Dyspozytor `renderServiceView`: `assets/render.js` · Style: `assets/widgets.css`.
63
+
64
+ Widgety dashboardowe są renderowane jawnie po nazwie, a nie po polu `view`:
65
+
66
+ | id | użycie | plik |
67
+ |----|--------|------|
68
+ | `attachment` | pojedynczy załącznik czatu | `assets/widgets/attachment.js` |
69
+ | `chat-message` | wiadomość czatu z timeline URI i załącznikami | `assets/widgets/chat-message.js` |
70
+ | `artifact-grid` | tabela/grid artefaktów z preview, metadata i akcjami | `assets/widgets/artifact-grid.js` |
71
+ | `widget-card` | karta usługi z live view | `assets/widgets/widget-card.js` |
72
+ | `metrics`, `task-table`, `nodes`, `routes`, `contacts` | panele dashboardu | `assets/widgets/dashboard.js` |
73
+
74
+ Dyspozytor dashboardowy: `assets/dashboard-render.js` (`renderDashboardWidget(name, data)`).
75
+
76
+ ## Trasy
77
+
78
+ - `widget://host/registry/query/list` — katalog widgetów (id, obsługiwane `view`, kształt `data`).
79
+ - `widget://host/widget/query/get?name=table` — metadane + źródło ES jednego widgetu (`name` może być też kluczem `view`, np. `page` → `iframe`).
80
+ - `widget://host/bundle/query/js` — helpery + wszystkie widgety + dyspozytory `renderServiceView(view)` i `renderDashboardWidget(name, data)` sklejone w **jeden moduł ES**.
81
+ - `widget://host/bundle/query/css` — wspólny arkusz stylów (samowystarczalny; zmienne motywu host może nadpisać).
82
+ - `widget://host/widget/query/render?view=table` — render widoku do HTML **po stronie serwera** (mirror w Pythonie) dla e-maila/SVG/testów. Podaj `view` + `data` (JSON) albo pełny obiekt widoku w `data`.
83
+
84
+ ### Użycie w chacie
85
+
86
+ ```js
87
+ // załaduj cały katalog widgetów z connectora
88
+ import { renderServiceView } from 'widget://host/bundle/query/js';
89
+ chatStreamList.innerHTML = views.map(renderServiceView).join('');
90
+ ```
91
+
92
+ ```js
93
+ // dashboard: artefakty albo wiadomości czatu po nazwie widgetu
94
+ import { renderDashboardWidget } from 'widget://host/bundle/query/js';
95
+ artifactFileGrid.innerHTML = renderDashboardWidget('artifact-grid', { items, selectedIds });
96
+ ```
97
+
98
+ ```bash
99
+ # render po stronie serwera (headless)
100
+ urirun-widget render --view table --data '{"rows":[{"nip":"7781422455","gross":1230.0}]}'
101
+ urirun-widget render --widget artifact-grid --data '{"items":[{"id":"a1","path":"/tmp/FV.pdf"}]}'
102
+ ```
103
+
104
+ ## Źródło prawdy a render serwerowy
105
+
106
+ Moduły JS (`assets/`) to źródło prawdy dla przeglądarki. `render.py` to ich wierny odpowiednik w Pythonie używany przez `widget/query/render` — przy zmianie widgetu aktualizuj oba. Testy pilnują osobno pokrycia `view` (`RENDERERS`) i dashboard widgets (`DASHBOARD_RENDERERS`).
107
+
108
+ ### Trzecia kopia: host (do skasowania)
109
+
110
+ Host (`urirun/host/`) wciąż **wendoruje** te renderery — niewidoczna trzecia kopia, która z umowy
111
+ „aktualizuj oba" wypada:
112
+
113
+ - `dashboard.js` — rodzina `render*ServiceView` / `renderWidget*` (fallback inline; konsumpcja bundla
114
+ `widget://host/bundle/query/js` jest już wpięta przez `loadWidgetBundleViaUri`)
115
+ - `widgets.py` — `select_service_view`, `service_widget_summary`
116
+ - `html_templates.py` — `service_widget_html`, `service_widget_svg`
117
+
118
+ **Burn-down (ratchet):** `ci/check_render_single_source.py <host-dir> --baseline ci/render_baseline.json`
119
+ liczy te kopie i blokuje NOWE; cel = `--strict` zielony, gdy bundle jest jedynym źródłem. Plan:
120
+ (1) `dashboard.js` ładuje bundle i NIC nie renderuje inline; (2) serwer woła `urirun-widgets` `render.py`
121
+ zamiast `html_templates.service_widget_*`; (3) skasuj inline'owe renderery hosta; (4) zaciśnij baseline → 0.
122
+
123
+ **NIE migruje do widgetów:** kontroler dashboardu (`renderNodeCard`, `renderChatHistory`, `renderUrlState`,
124
+ formularze CRUD node'ów, submit czatu, polling, wybór targetów) — to app operatora (`urirun-service-chat`),
125
+ nie katalog widgetów. Widget renderuje *widok*, nie *prowadzi dashboard*.
126
+
127
+ ## Wymagania
128
+
129
+ - **python:** `urirun`
130
+
131
+ ## Instalacja (dev)
132
+
133
+ ```bash
134
+ pip install -e .
135
+ pytest -q
136
+ ```
137
+
138
+ ## Powiązane
139
+
140
+ - Rdzeń: [if-uri/urirun](https://github.com/if-uri/urirun)
141
+ - Modele danych: [if-uri/urirun-artifacts](https://github.com/if-uri/urirun-artifacts)
142
+ - Hub connectorów: [connect.ifuri.com](https://connect.ifuri.com)
143
+
144
+ ---
145
+ Kategoria: UI · Słowa kluczowe: widget, html, chat, chatstreamlist, scanner, view, dashboard, ui · Wydawca: if-uri
146
+
147
+
148
+ ## License
149
+
150
+ Licensed under Apache-2.0.
@@ -0,0 +1,127 @@
1
+ # urirun-widgets
2
+
3
+
4
+ ## AI Cost Tracking
5
+
6
+ ![PyPI](https://img.shields.io/badge/pypi-costs-blue) ![Version](https://img.shields.io/badge/version-0.1.1-blue) ![Python](https://img.shields.io/badge/python-3.9+-blue) ![License](https://img.shields.io/badge/license-Apache--2.0-green)
7
+ ![AI Cost](https://img.shields.io/badge/AI%20Cost-$0.11-orange) ![Human Time](https://img.shields.io/badge/Human%20Time-17.9h-blue) ![Model](https://img.shields.io/badge/Model-openrouter%2Fqwen%2Fqwen3--coder--next-lightgrey)
8
+
9
+ - 🤖 **LLM usage:** $0.1050 (6 commits)
10
+ - 👤 **Human dev:** ~$1795 (17.9h @ $100/h, 30min dedup)
11
+
12
+ Generated on 2026-07-05 using [openrouter/qwen/qwen3-coder-next](https://openrouter.ai/qwen/qwen3-coder-next)
13
+
14
+ ---
15
+
16
+
17
+
18
+ **Chat-stream HTML widgets** — connector ekosystemu [ifURI / urirun](https://github.com/if-uri/urirun).
19
+ Schemat URI: `widget://`
20
+
21
+ Widoki HTML, które okno czatu (`chat-main`) renderuje w `chatStreamList` podczas skanowania — teraz jako wspólny, adresowany przez URI katalog, zamiast funkcji wklejonych w dashboard hosta. Źródłem prawdy dla przeglądarki są samodzielne moduły ES w `assets/widgets/`. Connector listuje katalog, serwuje JS pojedynczego widgetu, serwuje cały katalog jako jeden import (`bundle`) oraz renderuje widok po stronie serwera (mirror w Pythonie) dla powierzchni bez DOM.
22
+
23
+ The HTML views chatStreamList renders in chat-main when scanning, collected into one URI-addressable catalogue.
24
+
25
+ ## Widgety
26
+
27
+ | id | obsługuje `view` | plik |
28
+ |----|------------------|------|
29
+ | `scanner-stream` | `scanner-stream` | `assets/widgets/scanner-stream.js` |
30
+ | `scanner-status` | `scanner-status` | `assets/widgets/scanner-status.js` |
31
+ | `table` | `table` | `assets/widgets/table.js` |
32
+ | `image` | `image`, `image-list` | `assets/widgets/image.js` |
33
+ | `video` | `video` | `assets/widgets/video.js` |
34
+ | `iframe` | `iframe`, `page`, `web` | `assets/widgets/iframe.js` |
35
+ | `form` | `form` | `assets/widgets/form.js` |
36
+ | `graph` | `graph` | `assets/widgets/graph.js` |
37
+ | `generic` | *(fallback)* | `assets/widgets/generic.js` |
38
+
39
+ Wspólne helpery: `assets/render-helpers.js` · Dyspozytor `renderServiceView`: `assets/render.js` · Style: `assets/widgets.css`.
40
+
41
+ Widgety dashboardowe są renderowane jawnie po nazwie, a nie po polu `view`:
42
+
43
+ | id | użycie | plik |
44
+ |----|--------|------|
45
+ | `attachment` | pojedynczy załącznik czatu | `assets/widgets/attachment.js` |
46
+ | `chat-message` | wiadomość czatu z timeline URI i załącznikami | `assets/widgets/chat-message.js` |
47
+ | `artifact-grid` | tabela/grid artefaktów z preview, metadata i akcjami | `assets/widgets/artifact-grid.js` |
48
+ | `widget-card` | karta usługi z live view | `assets/widgets/widget-card.js` |
49
+ | `metrics`, `task-table`, `nodes`, `routes`, `contacts` | panele dashboardu | `assets/widgets/dashboard.js` |
50
+
51
+ Dyspozytor dashboardowy: `assets/dashboard-render.js` (`renderDashboardWidget(name, data)`).
52
+
53
+ ## Trasy
54
+
55
+ - `widget://host/registry/query/list` — katalog widgetów (id, obsługiwane `view`, kształt `data`).
56
+ - `widget://host/widget/query/get?name=table` — metadane + źródło ES jednego widgetu (`name` może być też kluczem `view`, np. `page` → `iframe`).
57
+ - `widget://host/bundle/query/js` — helpery + wszystkie widgety + dyspozytory `renderServiceView(view)` i `renderDashboardWidget(name, data)` sklejone w **jeden moduł ES**.
58
+ - `widget://host/bundle/query/css` — wspólny arkusz stylów (samowystarczalny; zmienne motywu host może nadpisać).
59
+ - `widget://host/widget/query/render?view=table` — render widoku do HTML **po stronie serwera** (mirror w Pythonie) dla e-maila/SVG/testów. Podaj `view` + `data` (JSON) albo pełny obiekt widoku w `data`.
60
+
61
+ ### Użycie w chacie
62
+
63
+ ```js
64
+ // załaduj cały katalog widgetów z connectora
65
+ import { renderServiceView } from 'widget://host/bundle/query/js';
66
+ chatStreamList.innerHTML = views.map(renderServiceView).join('');
67
+ ```
68
+
69
+ ```js
70
+ // dashboard: artefakty albo wiadomości czatu po nazwie widgetu
71
+ import { renderDashboardWidget } from 'widget://host/bundle/query/js';
72
+ artifactFileGrid.innerHTML = renderDashboardWidget('artifact-grid', { items, selectedIds });
73
+ ```
74
+
75
+ ```bash
76
+ # render po stronie serwera (headless)
77
+ urirun-widget render --view table --data '{"rows":[{"nip":"7781422455","gross":1230.0}]}'
78
+ urirun-widget render --widget artifact-grid --data '{"items":[{"id":"a1","path":"/tmp/FV.pdf"}]}'
79
+ ```
80
+
81
+ ## Źródło prawdy a render serwerowy
82
+
83
+ Moduły JS (`assets/`) to źródło prawdy dla przeglądarki. `render.py` to ich wierny odpowiednik w Pythonie używany przez `widget/query/render` — przy zmianie widgetu aktualizuj oba. Testy pilnują osobno pokrycia `view` (`RENDERERS`) i dashboard widgets (`DASHBOARD_RENDERERS`).
84
+
85
+ ### Trzecia kopia: host (do skasowania)
86
+
87
+ Host (`urirun/host/`) wciąż **wendoruje** te renderery — niewidoczna trzecia kopia, która z umowy
88
+ „aktualizuj oba" wypada:
89
+
90
+ - `dashboard.js` — rodzina `render*ServiceView` / `renderWidget*` (fallback inline; konsumpcja bundla
91
+ `widget://host/bundle/query/js` jest już wpięta przez `loadWidgetBundleViaUri`)
92
+ - `widgets.py` — `select_service_view`, `service_widget_summary`
93
+ - `html_templates.py` — `service_widget_html`, `service_widget_svg`
94
+
95
+ **Burn-down (ratchet):** `ci/check_render_single_source.py <host-dir> --baseline ci/render_baseline.json`
96
+ liczy te kopie i blokuje NOWE; cel = `--strict` zielony, gdy bundle jest jedynym źródłem. Plan:
97
+ (1) `dashboard.js` ładuje bundle i NIC nie renderuje inline; (2) serwer woła `urirun-widgets` `render.py`
98
+ zamiast `html_templates.service_widget_*`; (3) skasuj inline'owe renderery hosta; (4) zaciśnij baseline → 0.
99
+
100
+ **NIE migruje do widgetów:** kontroler dashboardu (`renderNodeCard`, `renderChatHistory`, `renderUrlState`,
101
+ formularze CRUD node'ów, submit czatu, polling, wybór targetów) — to app operatora (`urirun-service-chat`),
102
+ nie katalog widgetów. Widget renderuje *widok*, nie *prowadzi dashboard*.
103
+
104
+ ## Wymagania
105
+
106
+ - **python:** `urirun`
107
+
108
+ ## Instalacja (dev)
109
+
110
+ ```bash
111
+ pip install -e .
112
+ pytest -q
113
+ ```
114
+
115
+ ## Powiązane
116
+
117
+ - Rdzeń: [if-uri/urirun](https://github.com/if-uri/urirun)
118
+ - Modele danych: [if-uri/urirun-artifacts](https://github.com/if-uri/urirun-artifacts)
119
+ - Hub connectorów: [connect.ifuri.com](https://connect.ifuri.com)
120
+
121
+ ---
122
+ Kategoria: UI · Słowa kluczowe: widget, html, chat, chatstreamlist, scanner, view, dashboard, ui · Wydawca: if-uri
123
+
124
+
125
+ ## License
126
+
127
+ Licensed under Apache-2.0.
@@ -0,0 +1,72 @@
1
+ [build-system]
2
+ requires = ["setuptools>=69", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "urirun-widgets"
7
+ version = "0.1.1"
8
+ description = "Chat-stream HTML widgets for ifuri and urirun (widget://)"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "Apache-2.0"
12
+ license-files = ["LICENSE"]
13
+ authors = [{ name = "Tom Sapletta", email = "info@softreck.dev" }, {name = "Tom Sapletta",email = "tom@sapletta.com"}]
14
+ keywords = ["urirun", "widget", "render", "dashboard", "html", "svg", "ui"]
15
+ classifiers = [
16
+ "Development Status :: 4 - Beta",
17
+ "Intended Audience :: Developers",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3 :: Only",
20
+ "Topic :: Software Development :: User Interfaces",
21
+ "Topic :: Text Processing :: Markup :: HTML",
22
+ ]
23
+ dependencies = ["urirun>=0.4.190"]
24
+
25
+ [project.optional-dependencies]
26
+ test = ["pytest>=8"]
27
+
28
+ [project.urls]
29
+ Homepage = "https://connect.ifuri.com/connectors/widget"
30
+ Repository = "https://github.com/if-uri/urirun-widgets"
31
+
32
+ [project.scripts]
33
+ urirun-widget = "urirun_widgets.core:main"
34
+
35
+ [project.entry-points."urirun.bindings"]
36
+ widget = "urirun_widgets.core:urirun_bindings"
37
+
38
+ [tool.setuptools.packages.find]
39
+ where = ["."]
40
+ include = ["urirun_widgets*"]
41
+
42
+ [tool.setuptools.package-data]
43
+ urirun_widgets = ["connector.manifest.json", "assets/*.js", "assets/*.css", "assets/widgets/*.js"]
44
+
45
+ [tool.pfix]
46
+ # Self-healing Python configuration
47
+ model = "openrouter/qwen/qwen3-coder-next"
48
+ auto_apply = true
49
+ auto_install_deps = true
50
+ auto_restart = false
51
+ max_retries = 3
52
+ create_backups = false
53
+ git_auto_commit = false
54
+
55
+ [tool.pfix.runtime_todo]
56
+ enabled = true
57
+ todo_file = "TODO.md"
58
+ min_severity = "low"
59
+ deduplicate = true
60
+
61
+ [tool.costs]
62
+ # AI Cost tracking configuration
63
+ badge = true
64
+ update_readme = true
65
+ readme_path = "README.md"
66
+ default_model = "openrouter/qwen/qwen3-coder-next"
67
+ analysis_mode = "byok"
68
+ full_history = true
69
+ max_commits = 500
70
+
71
+ # Cost thresholds for badge colors (USD)
72
+ badge_color_thresholds = { low = 1.0, medium = 5.0, high = 10.0, critical = 50.0 }
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,91 @@
1
+ # Author: Tom Sapletta · https://tom.sapletta.com
2
+ # Part of the ifURI solution.
3
+ """The widget-render single-source gate: host vendored renderers are tracked + ratcheted.
4
+
5
+ urirun-widgets is the source of truth for service-view rendering; the host's `render*ServiceView`
6
+ (JS) and `service_widget_*` (Python) are a vendored third copy to burn down. The gate flags ONLY
7
+ view renderers — never the dashboard controller (node CRUD, chat, polling)."""
8
+ import os
9
+ import sys
10
+ from pathlib import Path
11
+
12
+ import pytest
13
+
14
+ sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "ci"))
15
+ import check_render_single_source as g # noqa: E402
16
+
17
+
18
+ def _host(tmp_path, js="", widgets_py="", html_py="", controller_js=""):
19
+ h = tmp_path / "host"
20
+ h.mkdir()
21
+ (h / "dashboard.js").write_text(js + "\n" + controller_js)
22
+ (h / "widgets.py").write_text(widgets_py)
23
+ (h / "html_templates.py").write_text(html_py)
24
+ return str(h)
25
+
26
+
27
+ def test_detects_vendored_view_renderers(tmp_path):
28
+ host = _host(tmp_path,
29
+ js="function renderTableServiceView(v){}\nfunction renderWidgetCard(w){}\n",
30
+ widgets_py="def select_service_view(x):\n ...\n",
31
+ html_py="def service_widget_html(v):\n return ''\n")
32
+ found = g.vendored_renderers(host)
33
+ names = {n for v in found.values() for n in v}
34
+ assert names == {"renderTableServiceView", "renderWidgetCard",
35
+ "select_service_view", "service_widget_html"}
36
+
37
+
38
+ def test_ignores_dashboard_controller_renderers(tmp_path):
39
+ """renderNodeCard / renderChatHistory / renderUrlState are operator-app, NOT widget views."""
40
+ host = _host(tmp_path, controller_js=(
41
+ "function renderNodeCard(n){}\nfunction renderChatHistory(){}\n"
42
+ "function renderUrlState(){}\nfunction renderHostConfigRow(){}\n"))
43
+ assert g.vendored_renderers(host) == {}
44
+
45
+
46
+ def test_strict_fails_while_host_still_vendors(tmp_path):
47
+ host = _host(tmp_path, js="function renderServiceView(v){}\n")
48
+ assert g.main([host, "--strict"]) == 1
49
+
50
+
51
+ def test_ratchet_passes_when_no_new_copy(tmp_path, monkeypatch):
52
+ host = _host(tmp_path, js="function renderServiceView(v){}\n")
53
+ bl = tmp_path / "baseline.json"
54
+ bl.write_text('{"known_vendored": ["renderServiceView"]}')
55
+ assert g.main([host, "--baseline", str(bl)]) == 0
56
+
57
+
58
+ def test_ratchet_fails_on_new_copy(tmp_path):
59
+ host = _host(tmp_path, js="function renderServiceView(v){}\nfunction renderGraphServiceView(v){}\n")
60
+ bl = tmp_path / "baseline.json"
61
+ bl.write_text('{"known_vendored": ["renderServiceView"]}') # the new graph renderer is not allowed
62
+ assert g.main([host, "--baseline", str(bl)]) == 1
63
+
64
+
65
+ def test_neutral_named_delegate_is_not_flagged(tmp_path):
66
+ """The correct host pattern: delegate through a NEUTRAL name (`_standalone_service_html`) that
67
+ calls urirun_widgets — not a render-owned name. Neutral names are not flagged."""
68
+ host = _host(tmp_path, html_py=(
69
+ "def _standalone_service_html(project, query):\n"
70
+ " from urirun_widgets.render import service_widget_html\n"
71
+ " return service_widget_html(view_from(project, query))\n"))
72
+ assert g.vendored_renderers(host) == {}
73
+
74
+
75
+ def test_render_owned_name_is_flagged_even_when_delegating(tmp_path):
76
+ """Policy (docs/ARCHITECTURE.md + hub AST gate): host must not DEFINE a render-owned name, even
77
+ one that delegates — reusing the catalogue's name in host is the third copy's seed. Use a neutral
78
+ wrapper name instead."""
79
+ host = _host(tmp_path, html_py=(
80
+ "def _service_widget_html(project, query):\n"
81
+ " from urirun_widgets.render import service_widget_html as impl\n"
82
+ " return impl(view_from(project, query))\n"))
83
+ found = g.vendored_renderers(host)
84
+ assert any("_service_widget_html" in names for names in found.values())
85
+
86
+
87
+ def test_ifuri_host_has_no_vendored_widget_renderers_when_sibling_exists():
88
+ host = Path(__file__).resolve().parents[2] / "urirun" / "adapters" / "python" / "urirun" / "host"
89
+ if not host.exists():
90
+ pytest.skip("if-uri monorepo sibling not present")
91
+ assert g.main([str(host), "--strict"]) == 0