htag 2.0.6__tar.gz → 2.0.7__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 (47) hide show
  1. {htag-2.0.6 → htag-2.0.7}/PKG-INFO +1 -1
  2. {htag-2.0.6 → htag-2.0.7}/htag/client_js.py +35 -3
  3. {htag-2.0.6 → htag-2.0.7}/htag.egg-info/PKG-INFO +1 -1
  4. {htag-2.0.6 → htag-2.0.7}/pyproject.toml +1 -1
  5. {htag-2.0.6 → htag-2.0.7}/README.md +0 -0
  6. {htag-2.0.6 → htag-2.0.7}/htag/__init__.py +0 -0
  7. {htag-2.0.6 → htag-2.0.7}/htag/cli.py +0 -0
  8. {htag-2.0.6 → htag-2.0.7}/htag/context.py +0 -0
  9. {htag-2.0.6 → htag-2.0.7}/htag/core.py +0 -0
  10. {htag-2.0.6 → htag-2.0.7}/htag/css.py +0 -0
  11. {htag-2.0.6 → htag-2.0.7}/htag/exceptions.py +0 -0
  12. {htag-2.0.6 → htag-2.0.7}/htag/logo.py +0 -0
  13. {htag-2.0.6 → htag-2.0.7}/htag/runner.py +0 -0
  14. {htag-2.0.6 → htag-2.0.7}/htag/runners/__init__.py +0 -0
  15. {htag-2.0.6 → htag-2.0.7}/htag/runners/chromeapp.py +0 -0
  16. {htag-2.0.6 → htag-2.0.7}/htag/runners/pyscript.py +0 -0
  17. {htag-2.0.6 → htag-2.0.7}/htag/server.py +0 -0
  18. {htag-2.0.6 → htag-2.0.7}/htag/tag.py +0 -0
  19. {htag-2.0.6 → htag-2.0.7}/htag/utils.py +0 -0
  20. {htag-2.0.6 → htag-2.0.7}/htag/web.py +0 -0
  21. {htag-2.0.6 → htag-2.0.7}/htag.egg-info/SOURCES.txt +0 -0
  22. {htag-2.0.6 → htag-2.0.7}/htag.egg-info/dependency_links.txt +0 -0
  23. {htag-2.0.6 → htag-2.0.7}/htag.egg-info/entry_points.txt +0 -0
  24. {htag-2.0.6 → htag-2.0.7}/htag.egg-info/requires.txt +0 -0
  25. {htag-2.0.6 → htag-2.0.7}/htag.egg-info/top_level.txt +0 -0
  26. {htag-2.0.6 → htag-2.0.7}/setup.cfg +0 -0
  27. {htag-2.0.6 → htag-2.0.7}/tests/test_cmd.py +0 -0
  28. {htag-2.0.6 → htag-2.0.7}/tests/test_core.py +0 -0
  29. {htag-2.0.6 → htag-2.0.7}/tests/test_deprecation_warnings.py +0 -0
  30. {htag-2.0.6 → htag-2.0.7}/tests/test_fallback.py +0 -0
  31. {htag-2.0.6 → htag-2.0.7}/tests/test_interacting_robustness.py +0 -0
  32. {htag-2.0.6 → htag-2.0.7}/tests/test_lifecycle.py +0 -0
  33. {htag-2.0.6 → htag-2.0.7}/tests/test_memory.py +0 -0
  34. {htag-2.0.6 → htag-2.0.7}/tests/test_parano.py +0 -0
  35. {htag-2.0.6 → htag-2.0.7}/tests/test_reactivity_edge_cases.py +0 -0
  36. {htag-2.0.6 → htag-2.0.7}/tests/test_runner_pyscript.py +0 -0
  37. {htag-2.0.6 → htag-2.0.7}/tests/test_runners_reload.py +0 -0
  38. {htag-2.0.6 → htag-2.0.7}/tests/test_server.py +0 -0
  39. {htag-2.0.6 → htag-2.0.7}/tests/test_simple_events.py +0 -0
  40. {htag-2.0.6 → htag-2.0.7}/tests/test_state_advanced.py +0 -0
  41. {htag-2.0.6 → htag-2.0.7}/tests/test_state_features.py +0 -0
  42. {htag-2.0.6 → htag-2.0.7}/tests/test_state_proxy.py +0 -0
  43. {htag-2.0.6 → htag-2.0.7}/tests/test_state_reactivity.py +0 -0
  44. {htag-2.0.6 → htag-2.0.7}/tests/test_statics_deduplication.py +0 -0
  45. {htag-2.0.6 → htag-2.0.7}/tests/test_tag_names.py +0 -0
  46. {htag-2.0.6 → htag-2.0.7}/tests/test_web_sessions.py +0 -0
  47. {htag-2.0.6 → htag-2.0.7}/tests/test_webapp_run.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: htag
3
- Version: 2.0.6
3
+ Version: 2.0.7
4
4
  Summary: Python3 GUI toolkit for building 'beautiful' applications for mobile, web, and desktop from a single codebase
5
5
  Author: manatlan
6
6
  License: MIT
@@ -1,4 +1,12 @@
1
- CLIENT_JS = """
1
+ def __minify_js(js_code: str) -> str:
2
+ import re
3
+ # Remove single line comments (but not URL schemes like http://)
4
+ js = re.sub(r'(?<!:)//.*', '', js_code)
5
+ # Remove newlines and tabs
6
+ js = re.sub(r'\s+', ' ', js).strip()
7
+ return js
8
+
9
+ CLIENT_JS = __minify_js("""
2
10
  // The client-side bridge that connects the browser to the Python server.
3
11
  var ws;
4
12
  var use_fallback = false;
@@ -158,7 +166,30 @@ function handle_payload(data) {
158
166
  // Apply partial DOM updates received from the server
159
167
  for(var id in data.updates) {
160
168
  var el = document.getElementById(id) || document.querySelector('[data-htag-id="' + id + '"]');
161
- if(el) el.outerHTML = data.updates[id];
169
+ if(el) {
170
+ if(el.tagName === 'BODY') {
171
+ var doc = new DOMParser().parseFromString(data.updates[id], 'text/html');
172
+
173
+ // Sync attributes properly
174
+ var newAttrNames = new Set();
175
+ for(var i = 0; i < doc.body.attributes.length; i++) {
176
+ var attr = doc.body.attributes[i];
177
+ el.setAttribute(attr.name, attr.value);
178
+ newAttrNames.add(attr.name);
179
+ }
180
+ // Remove old attributes that are not in the new body
181
+ for(var i = el.attributes.length - 1; i >= 0; i--) {
182
+ var attrName = el.attributes[i].name;
183
+ if(!newAttrNames.has(attrName)) {
184
+ el.removeAttribute(attrName);
185
+ }
186
+ }
187
+
188
+ el.innerHTML = doc.body.innerHTML;
189
+ } else {
190
+ el.outerHTML = data.updates[id];
191
+ }
192
+ }
162
193
  }
163
194
 
164
195
  // Ensure overlays are still in the DOM (in case the body was replaced)
@@ -349,4 +380,5 @@ function htag_event(id, event_name, event) {
349
380
  window.htag_transport(payload);
350
381
  });
351
382
  }
352
- """
383
+ """)
384
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: htag
3
- Version: 2.0.6
3
+ Version: 2.0.7
4
4
  Summary: Python3 GUI toolkit for building 'beautiful' applications for mobile, web, and desktop from a single codebase
5
5
  Author: manatlan
6
6
  License: MIT
@@ -9,7 +9,7 @@ include-package-data = true
9
9
 
10
10
  [project]
11
11
  name = "htag"
12
- version = "2.0.6"
12
+ version = "2.0.7"
13
13
  description = "Python3 GUI toolkit for building 'beautiful' applications for mobile, web, and desktop from a single codebase"
14
14
  readme = "README.md"
15
15
  requires-python = ">=3.10"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes