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.
- {htag-2.0.6 → htag-2.0.7}/PKG-INFO +1 -1
- {htag-2.0.6 → htag-2.0.7}/htag/client_js.py +35 -3
- {htag-2.0.6 → htag-2.0.7}/htag.egg-info/PKG-INFO +1 -1
- {htag-2.0.6 → htag-2.0.7}/pyproject.toml +1 -1
- {htag-2.0.6 → htag-2.0.7}/README.md +0 -0
- {htag-2.0.6 → htag-2.0.7}/htag/__init__.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/htag/cli.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/htag/context.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/htag/core.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/htag/css.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/htag/exceptions.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/htag/logo.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/htag/runner.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/htag/runners/__init__.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/htag/runners/chromeapp.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/htag/runners/pyscript.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/htag/server.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/htag/tag.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/htag/utils.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/htag/web.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/htag.egg-info/SOURCES.txt +0 -0
- {htag-2.0.6 → htag-2.0.7}/htag.egg-info/dependency_links.txt +0 -0
- {htag-2.0.6 → htag-2.0.7}/htag.egg-info/entry_points.txt +0 -0
- {htag-2.0.6 → htag-2.0.7}/htag.egg-info/requires.txt +0 -0
- {htag-2.0.6 → htag-2.0.7}/htag.egg-info/top_level.txt +0 -0
- {htag-2.0.6 → htag-2.0.7}/setup.cfg +0 -0
- {htag-2.0.6 → htag-2.0.7}/tests/test_cmd.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/tests/test_core.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/tests/test_deprecation_warnings.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/tests/test_fallback.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/tests/test_interacting_robustness.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/tests/test_lifecycle.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/tests/test_memory.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/tests/test_parano.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/tests/test_reactivity_edge_cases.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/tests/test_runner_pyscript.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/tests/test_runners_reload.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/tests/test_server.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/tests/test_simple_events.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/tests/test_state_advanced.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/tests/test_state_features.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/tests/test_state_proxy.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/tests/test_state_reactivity.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/tests/test_statics_deduplication.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/tests/test_tag_names.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/tests/test_web_sessions.py +0 -0
- {htag-2.0.6 → htag-2.0.7}/tests/test_webapp_run.py +0 -0
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
|
|
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)
|
|
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
|
+
|
|
@@ -9,7 +9,7 @@ include-package-data = true
|
|
|
9
9
|
|
|
10
10
|
[project]
|
|
11
11
|
name = "htag"
|
|
12
|
-
version = "2.0.
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|