From 620e433547f9ca7686cc18475cb36ca34409b1fd Mon Sep 17 00:00:00 2001 From: paul2212 Date: Wed, 18 Mar 2026 18:05:26 +0100 Subject: [PATCH] v0.1.33: Fix scanForDevices is not defined error - Fixed JavaScript scope issue by injecting scan function into existing script section - Scan function now properly available when button is clicked - Improved JavaScript injection strategy to avoid separate script tag conflicts - Updated version to 0.1.33 in all files Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe --- fichero_printer/CHANGELOG.md | 10 ++++++++++ fichero_printer/config.yaml | 2 +- fichero_printer/fichero/api.py | 23 +++++++++++++++-------- pyproject.toml | 2 +- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/fichero_printer/CHANGELOG.md b/fichero_printer/CHANGELOG.md index ba31512..802dc9f 100644 --- a/fichero_printer/CHANGELOG.md +++ b/fichero_printer/CHANGELOG.md @@ -5,6 +5,16 @@ All notable changes to this project are documented in this file. The format is based on Keep a Changelog and this project uses Semantic Versioning. +## [0.1.33] - 2026-03-18 + +### Fixed +- **Web UI**: Fixed "scanForDevices is not defined" error by injecting scan function into existing script section instead of separate script tag. +- **Web UI**: Ensured scan JavaScript is properly scoped and available when button is clicked. + +### Changed +- **Web UI**: Improved JavaScript injection strategy to avoid scope issues. +- **Web UI**: Scan function now injected directly into main script section for proper global availability. + ## [0.1.32] - 2026-03-18 ### Fixed diff --git a/fichero_printer/config.yaml b/fichero_printer/config.yaml index 59ba6b0..04dd450 100644 --- a/fichero_printer/config.yaml +++ b/fichero_printer/config.yaml @@ -1,5 +1,5 @@ name: "Fichero Printer" -version: "0.1.32" +version: "0.1.33" slug: "fichero_printer" description: "REST API for the Fichero D11s (AiYin) thermal label printer over Bluetooth" url: "https://git.leuschner.dev/Tobias/Fichero" diff --git a/fichero_printer/fichero/api.py b/fichero_printer/fichero/api.py index 35ec923..1e52f5e 100644 --- a/fichero_printer/fichero/api.py +++ b/fichero_printer/fichero/api.py @@ -77,7 +77,7 @@ async def lifespan(app: FastAPI): # noqa: ARG001 app = FastAPI( title="Fichero Printer API", description="REST API for the Fichero D11s (AiYin) thermal label printer.", - version = "0.1.32", + version = "0.1.33", lifespan=lifespan, docs_url=None, redoc_url=None, @@ -134,7 +134,7 @@ def _ui_html() -> str: """ scan_script = r''' - - ''' - # Inject after the main content but before scripts +''' + # Inject scan HTML after main content if "" in template: parts = template.split("", 1) - template = parts[0] + "" + scan_html + scan_script + parts[1] + template = parts[0] + "" + scan_html + parts[1] elif "" in template: parts = template.split("", 1) - template = parts[0] + scan_html + scan_script + "" + parts[1] + template = parts[0] + scan_html + "" + parts[1] else: # Fallback if no main or body tag - template += scan_html + scan_script + template += scan_html + + # Inject scan script before the closing tag of the main script + if "" in template: + parts = template.rsplit("", 1) + template = parts[0] + scan_script + "" + parts[1] + else: + # Fallback if no script tag found + template += f"" return template diff --git a/pyproject.toml b/pyproject.toml index 9aecbb2..7c779c7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "fichero-printer" -version = "0.1.32" +version = "0.1.33" description = "Web GUI, Python CLI, and protocol documentation for the Fichero D11s thermal label printer." readme = "README.md" requires-python = ">=3.10"