@danhachuel/thunderbolt 0.7.18 → 0.7.20

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 (2) hide show
  1. package/app/main.py +44 -5
  2. package/package.json +1 -1
package/app/main.py CHANGED
@@ -35,6 +35,7 @@ from typing import Any
35
35
 
36
36
  import requests
37
37
  import streamlit as st
38
+ import streamlit.components.v1 as components
38
39
 
39
40
  ROOT = Path(__file__).resolve().parents[1]
40
41
  if str(ROOT) not in sys.path:
@@ -267,8 +268,8 @@ ensure_storage()
267
268
  st.set_page_config(page_title="Thunderbolt", page_icon="T", layout="wide", initial_sidebar_state="expanded")
268
269
 
269
270
  theme_base = (st.get_option("theme.base") or "dark").lower()
270
- st.iframe(
271
- srcdoc="""
271
+ components.html(
272
+ """
272
273
  <script>
273
274
  (() => {
274
275
  const STYLE_ID = "thunderbolt-light-theme-style";
@@ -697,6 +698,46 @@ def blueprint_for_channel(channel: dict) -> dict[str, Any]:
697
698
  return {"id": blueprint_id, "name": blueprint_id}
698
699
 
699
700
 
701
+ def _resolve_saved_script_blueprint(record: dict[str, Any], channel: dict[str, Any]) -> tuple[str, str]:
702
+ """Resolve legacy script Blueprint metadata from channel fields or its saved name."""
703
+ blueprint_id = str(
704
+ channel.get("default_blueprint_id")
705
+ or channel.get("blueprint_id")
706
+ or record.get("blueprint_id")
707
+ or ""
708
+ ).strip()
709
+ blueprint_name = str(
710
+ channel.get("default_blueprint_name")
711
+ or channel.get("blueprint_name")
712
+ or channel.get("blueprint")
713
+ or record.get("blueprint_name")
714
+ or record.get("blueprint")
715
+ or ""
716
+ ).strip()
717
+ resolved = blueprint_for_channel(channel) if blueprint_id else {}
718
+ resolved_name = str(resolved.get("name") or "").strip()
719
+ if resolved_name and (resolved_name.casefold() != blueprint_id.casefold() or not blueprint_name):
720
+ blueprint_name = resolved_name
721
+ wanted = {value.casefold() for value in (blueprint_id, blueprint_name) if value}
722
+ if wanted:
723
+ for path in list_blueprint_files():
724
+ try:
725
+ data = load_blueprint_file(path)
726
+ except (OSError, ValueError, json.JSONDecodeError):
727
+ continue
728
+ display_name = get_display_name("blueprints", path, str(data.get("name") or data.get("title") or path.stem)).strip()
729
+ identifiers = {
730
+ str(data.get("id") or "").strip(),
731
+ path.stem.strip(),
732
+ str(data.get("name") or "").strip(),
733
+ str(data.get("title") or "").strip(),
734
+ display_name,
735
+ }
736
+ if wanted.intersection({value.casefold() for value in identifiers if value}):
737
+ return str(data.get("id") or path.stem).strip(), display_name
738
+ return blueprint_id, blueprint_name or (blueprint_id if blueprint_id else "SEM BLUEPRINT CONFIGURADO")
739
+
740
+
700
741
  def _script_channel(record: dict[str, Any], channels: list[dict[str, Any]]) -> dict[str, Any]:
701
742
  channel_id = str(record.get("channel_id") or "").strip()
702
743
  channel_name = str(record.get("channel_name") or record.get("channel") or "").strip().casefold()
@@ -724,9 +765,7 @@ def _backfill_saved_script_blueprints(records: list[dict[str, Any]] | None = Non
724
765
  channel = _script_channel(record, channels)
725
766
  if not channel:
726
767
  continue
727
- blueprint_id = str(channel.get("default_blueprint_id") or channel.get("blueprint_id") or "").strip()
728
- blueprint = blueprint_for_channel(channel)
729
- blueprint_name = str(blueprint.get("name") or blueprint_id or "SEM BLUEPRINT CONFIGURADO").strip()
768
+ blueprint_id, blueprint_name = _resolve_saved_script_blueprint(record, channel)
730
769
  current_id = str(record.get("blueprint_id") or "").strip()
731
770
  current_name = str(record.get("blueprint_name") or record.get("blueprint") or "").strip()
732
771
  if current_id == blueprint_id and current_name == blueprint_name:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danhachuel/thunderbolt",
3
- "version": "0.7.18",
3
+ "version": "0.7.20",
4
4
  "description": "Thunderbolt — interface local para operação de canais faceless e motor MoneyPrinterTurbo",
5
5
  "license": "MIT",
6
6
  "main": "scripts/cli.mjs",