Clone widgets that import a sibling JS module
A cloned bar widget is copied out on its own, so a relative JS import lands in a directory without the file and the clone fails to load. Point those imports back at the bundled module, the same way Qt.resolvedUrl() references were already rewritten. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
c619865432
commit
cc4771fd91
@@ -98,6 +98,19 @@ def resolve_relative(match):
|
||||
|
||||
text = re.sub(r'Qt\.resolvedUrl\("([^"]+)"\)', resolve_relative, text)
|
||||
|
||||
|
||||
# A widget that imports a sibling JS module (the clock's Model.js) clones into
|
||||
# a directory that does not have it. Point the import back at the bundled file,
|
||||
# the same way Qt.resolvedUrl() references above are rewritten.
|
||||
def resolve_js_import(match):
|
||||
rel = match.group(1)
|
||||
if rel.startswith("/") or "://" in rel:
|
||||
return match.group(0)
|
||||
resolved = (source_path.parent / rel).resolve()
|
||||
return 'import "' + resolved.as_uri() + '"'
|
||||
|
||||
text = re.sub(r'import\s+"([^"]+\.js)"', resolve_js_import, text)
|
||||
|
||||
# Indicators dynamically loads sibling indicator components via string
|
||||
# concatenation, so the simple Qt.resolvedUrl("literal") rewrite above cannot
|
||||
# see it. Point the clone back at Omarchy's bundled indicator directory.
|
||||
|
||||
Reference in New Issue
Block a user