fastled 1.3.30__py3-none-any.whl → 1.4.50__py3-none-any.whl

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. fastled/__init__.py +30 -2
  2. fastled/__main__.py +14 -0
  3. fastled/__version__.py +1 -1
  4. fastled/app.py +51 -2
  5. fastled/args.py +33 -0
  6. fastled/client_server.py +188 -40
  7. fastled/compile_server.py +10 -0
  8. fastled/compile_server_impl.py +34 -1
  9. fastled/docker_manager.py +56 -14
  10. fastled/emoji_util.py +27 -0
  11. fastled/filewatcher.py +6 -3
  12. fastled/find_good_connection.py +105 -0
  13. fastled/header_dump.py +63 -0
  14. fastled/install/__init__.py +1 -0
  15. fastled/install/examples_manager.py +62 -0
  16. fastled/install/extension_manager.py +113 -0
  17. fastled/install/main.py +156 -0
  18. fastled/install/project_detection.py +167 -0
  19. fastled/install/test_install.py +373 -0
  20. fastled/install/vscode_config.py +344 -0
  21. fastled/interruptible_http.py +148 -0
  22. fastled/live_client.py +21 -1
  23. fastled/open_browser.py +84 -16
  24. fastled/parse_args.py +110 -9
  25. fastled/playwright/chrome_extension_downloader.py +207 -0
  26. fastled/playwright/playwright_browser.py +773 -0
  27. fastled/playwright/resize_tracking.py +127 -0
  28. fastled/print_filter.py +52 -52
  29. fastled/project_init.py +20 -13
  30. fastled/select_sketch_directory.py +142 -19
  31. fastled/server_flask.py +37 -1
  32. fastled/settings.py +47 -3
  33. fastled/sketch.py +121 -4
  34. fastled/string_diff.py +162 -26
  35. fastled/test/examples.py +7 -5
  36. fastled/types.py +4 -0
  37. fastled/util.py +34 -0
  38. fastled/version.py +41 -41
  39. fastled/web_compile.py +379 -236
  40. fastled/zip_files.py +76 -0
  41. {fastled-1.3.30.dist-info → fastled-1.4.50.dist-info}/METADATA +533 -508
  42. fastled-1.4.50.dist-info/RECORD +60 -0
  43. fastled-1.3.30.dist-info/RECORD +0 -44
  44. {fastled-1.3.30.dist-info → fastled-1.4.50.dist-info}/WHEEL +0 -0
  45. {fastled-1.3.30.dist-info → fastled-1.4.50.dist-info}/entry_points.txt +0 -0
  46. {fastled-1.3.30.dist-info → fastled-1.4.50.dist-info}/licenses/LICENSE +0 -0
  47. {fastled-1.3.30.dist-info → fastled-1.4.50.dist-info}/top_level.txt +0 -0
fastled/filewatcher.py CHANGED
@@ -22,8 +22,8 @@ _WATCHER_TIMEOUT = 0.1
22
22
 
23
23
 
24
24
  def file_watcher_enabled() -> bool:
25
- """Check if watchdog is disabled"""
26
- return os.getenv("NO_FILE_WATCHING", "0") == "1"
25
+ """Check if watchdog is enabled"""
26
+ return os.getenv("NO_FILE_WATCHING", "0") != "1"
27
27
 
28
28
 
29
29
  def file_watcher_set(enabled: bool) -> None:
@@ -122,6 +122,9 @@ class FileChangedNotifier(threading.Thread):
122
122
  time.sleep(0.1)
123
123
  except KeyboardInterrupt:
124
124
  print("File watcher stopped by user.")
125
+ import _thread
126
+
127
+ _thread.interrupt_main()
125
128
  finally:
126
129
  self.stop()
127
130
 
@@ -134,7 +137,7 @@ class FileChangedNotifier(threading.Thread):
134
137
  Returns:
135
138
  Changed filepath or None if no change within timeout
136
139
  """
137
- if file_watcher_enabled():
140
+ if not file_watcher_enabled():
138
141
  time.sleep(timeout)
139
142
  return None
140
143
  try:
@@ -0,0 +1,105 @@
1
+ import _thread
2
+ import time
3
+ from concurrent.futures import Future, ThreadPoolExecutor, as_completed
4
+ from dataclasses import dataclass
5
+ from typing import Dict, Tuple
6
+
7
+ import httpx
8
+
9
+ _TIMEOUT = 30.0
10
+
11
+ _EXECUTOR = ThreadPoolExecutor(max_workers=8)
12
+
13
+ # In-memory cache for connection results
14
+ # Key: (tuple of urls, filter_out_bad, use_ipv6)
15
+ # Value: (ConnectionResult | None, timestamp)
16
+ _CONNECTION_CACHE: Dict[
17
+ Tuple[tuple, bool, bool], Tuple["ConnectionResult | None", float]
18
+ ] = {}
19
+ _CACHE_TTL = 60.0 * 60.0 # Cache results for 1 hour
20
+
21
+
22
+ @dataclass
23
+ class ConnectionResult:
24
+ host: str
25
+ success: bool
26
+ ipv4: bool
27
+
28
+
29
+ def _sanitize_host(host: str) -> str:
30
+ if host.startswith("http"):
31
+ return host
32
+ is_local_host = "localhost" in host or "127.0.0.1" in host or "0.0.0.0" in host
33
+ use_https = not is_local_host
34
+ if use_https:
35
+ return host if host.startswith("https://") else f"https://{host}"
36
+ return host if host.startswith("http://") else f"http://{host}"
37
+
38
+
39
+ def _test_connection(host: str, use_ipv4: bool) -> ConnectionResult:
40
+ # Function static cache
41
+ host = _sanitize_host(host)
42
+ transport = httpx.HTTPTransport(local_address="0.0.0.0") if use_ipv4 else None
43
+ result: ConnectionResult | None = None
44
+ try:
45
+ with httpx.Client(
46
+ timeout=_TIMEOUT,
47
+ transport=transport,
48
+ ) as test_client:
49
+ test_response = test_client.get(
50
+ f"{host}/healthz", timeout=3, follow_redirects=True
51
+ )
52
+ result = ConnectionResult(host, test_response.status_code == 200, use_ipv4)
53
+ except KeyboardInterrupt:
54
+ _thread.interrupt_main()
55
+ result = ConnectionResult(host, False, use_ipv4)
56
+ except TimeoutError:
57
+ result = ConnectionResult(host, False, use_ipv4)
58
+ except Exception:
59
+ result = ConnectionResult(host, False, use_ipv4)
60
+ return result
61
+
62
+
63
+ def find_good_connection(
64
+ urls: list[str], filter_out_bad=True, use_ipv6: bool = True
65
+ ) -> ConnectionResult | None:
66
+ # Create cache key from parameters
67
+ cache_key = (tuple(sorted(urls)), filter_out_bad, use_ipv6)
68
+ current_time = time.time()
69
+
70
+ # Check if we have a cached result
71
+ if cache_key in _CONNECTION_CACHE:
72
+ cached_result, cached_time = _CONNECTION_CACHE[cache_key]
73
+ if current_time - cached_time < _CACHE_TTL:
74
+ return cached_result
75
+ else:
76
+ # Remove expired cache entry
77
+ del _CONNECTION_CACHE[cache_key]
78
+
79
+ # No valid cache entry, perform the actual connection test
80
+ futures: list[Future] = []
81
+ for url in urls:
82
+
83
+ f = _EXECUTOR.submit(_test_connection, url, use_ipv4=True)
84
+ futures.append(f)
85
+ if use_ipv6 and "localhost" not in url:
86
+ f_v6 = _EXECUTOR.submit(_test_connection, url, use_ipv4=False)
87
+ futures.append(f_v6)
88
+
89
+ result = None
90
+ try:
91
+ # Return first successful result
92
+ for future in as_completed(futures):
93
+ connection_result: ConnectionResult = future.result()
94
+ if connection_result.success or not filter_out_bad:
95
+ result = connection_result
96
+ break
97
+ finally:
98
+ # Cancel any remaining futures
99
+ for future in futures:
100
+ future.cancel()
101
+
102
+ # Cache the result (even if None)
103
+ _CONNECTION_CACHE[cache_key] = (result, current_time)
104
+
105
+ return result
fastled/header_dump.py ADDED
@@ -0,0 +1,63 @@
1
+ """Header dump functionality for EMSDK headers export."""
2
+
3
+ import sys
4
+ from pathlib import Path
5
+
6
+
7
+ def dump_emsdk_headers(output_path: Path | str, server_url: str | None = None) -> None:
8
+ """
9
+ Dump EMSDK headers to a specified path.
10
+
11
+ Args:
12
+ output_path: Path where to save the headers ZIP file
13
+ server_url: URL of the server. If None, tries to create local server first,
14
+ then falls back to remote server if local fails.
15
+ """
16
+ from fastled import Api
17
+ from fastled.settings import DEFAULT_URL
18
+ from fastled.util import download_emsdk_headers
19
+
20
+ # Convert to Path if string
21
+ if isinstance(output_path, str):
22
+ output_path = Path(output_path)
23
+
24
+ ends_with_zip = output_path.suffix == ".zip"
25
+ if not ends_with_zip:
26
+ raise ValueError(f"{output_path} must end with .zip")
27
+
28
+ try:
29
+ if server_url is not None:
30
+ # Use the provided server URL
31
+ download_emsdk_headers(server_url, output_path)
32
+ print(f"SUCCESS: EMSDK headers exported to {output_path}")
33
+ else:
34
+ # Try to create local server first
35
+ try:
36
+ with Api.server() as server:
37
+ base_url = server.url()
38
+ download_emsdk_headers(base_url, output_path)
39
+ print(
40
+ f"SUCCESS: EMSDK headers exported to {output_path} (using local server)"
41
+ )
42
+ except Exception as local_error:
43
+ print(
44
+ f"WARNING: Local server failed ({local_error}), falling back to remote server"
45
+ )
46
+ # Fall back to remote server
47
+ download_emsdk_headers(DEFAULT_URL, output_path)
48
+ print(
49
+ f"SUCCESS: EMSDK headers exported to {output_path} (using remote server)"
50
+ )
51
+
52
+ except Exception as e:
53
+ print(f"ERROR: Exception during header dump: {e}")
54
+ sys.exit(1)
55
+
56
+
57
+ if __name__ == "__main__":
58
+ if len(sys.argv) != 2:
59
+ print("Usage: python -m fastled.header_dump <output_path>")
60
+ sys.exit(1)
61
+
62
+ output_path = sys.argv[1]
63
+ dump_emsdk_headers(output_path)
@@ -0,0 +1 @@
1
+ """FastLED install module."""
@@ -0,0 +1,62 @@
1
+ """Examples installation manager using FastLED's built-in --project-init command."""
2
+
3
+ import subprocess
4
+
5
+
6
+ def install_fastled_examples_via_project_init(
7
+ force: bool = False, no_interactive: bool = False
8
+ ) -> bool:
9
+ """
10
+ Install FastLED examples using built-in --project-init command.
11
+
12
+ Args:
13
+ force: If True, install without prompting
14
+ no_interactive: If True, skip prompting and return False
15
+
16
+ Returns:
17
+ True if installation successful, False otherwise
18
+ """
19
+ if not force:
20
+ if no_interactive:
21
+ print("⚠️ No existing Arduino content found.")
22
+ print(" In non-interactive mode, skipping examples installation.")
23
+ print(" Run 'fastled --project-init' manually to install examples.")
24
+ return False
25
+
26
+ print("No existing Arduino content found.")
27
+ answer = (
28
+ input("Would you like to install FastLED examples? [y/n] ").strip().lower()
29
+ )
30
+ if answer not in ["y", "yes"]:
31
+ print("Skipping FastLED examples installation.")
32
+ return False
33
+
34
+ print("📦 Installing FastLED examples using project initialization...")
35
+
36
+ try:
37
+ # Use FastLED's built-in project initialization
38
+ subprocess.run(
39
+ ["fastled", "--project-init"],
40
+ check=True,
41
+ capture_output=True,
42
+ text=True,
43
+ cwd=".",
44
+ )
45
+
46
+ print("✅ FastLED project initialized successfully!")
47
+ print("📁 Examples and project structure created")
48
+ print("🚀 Quick start: Check for generated .ino files and press F5 to debug")
49
+
50
+ return True
51
+
52
+ except subprocess.CalledProcessError as e:
53
+ print(f"⚠️ Warning: Failed to initialize FastLED project: {e}")
54
+ if e.stderr:
55
+ print(f"Error details: {e.stderr}")
56
+ print("You can manually run: fastled --project-init")
57
+ return False
58
+ except FileNotFoundError:
59
+ print("⚠️ Warning: FastLED package not found. Please install it first:")
60
+ print(" pip install fastled")
61
+ print("Then run: fastled --project-init")
62
+ return False
@@ -0,0 +1,113 @@
1
+ """Auto Debug extension installation manager."""
2
+
3
+ import shutil
4
+ import subprocess
5
+ import tempfile
6
+ from pathlib import Path
7
+ from urllib.request import urlretrieve
8
+
9
+
10
+ def download_auto_debug_extension() -> Path | None:
11
+ """
12
+ Download the Auto Debug extension .vsix file from GitHub.
13
+
14
+ Returns:
15
+ Path to downloaded .vsix file, or None if download fails
16
+ """
17
+ # URL for the Auto Debug extension
18
+ extension_url = "https://github.com/zackees/vscode-auto-debug/releases/latest/download/auto-debug.vsix"
19
+
20
+ try:
21
+ # Create temporary directory
22
+ temp_dir = Path(tempfile.mkdtemp())
23
+ vsix_path = temp_dir / "auto-debug.vsix"
24
+
25
+ print("📥 Downloading Auto Debug extension...")
26
+
27
+ # Download the file
28
+ urlretrieve(extension_url, vsix_path)
29
+
30
+ if vsix_path.exists() and vsix_path.stat().st_size > 0:
31
+ print("✅ Extension downloaded successfully")
32
+ return vsix_path
33
+ else:
34
+ print("❌ Failed to download extension")
35
+ return None
36
+
37
+ except Exception as e:
38
+ print(f"❌ Error downloading extension: {e}")
39
+ return None
40
+
41
+
42
+ def install_vscode_extensions(extension_path: Path) -> bool:
43
+ """
44
+ Install extension in VSCode or Cursor.
45
+
46
+ Args:
47
+ extension_path: Path to .vsix file
48
+
49
+ Returns:
50
+ True if installation successful, False otherwise
51
+ """
52
+ # Try VSCode first
53
+ if shutil.which("code"):
54
+ ide_command = "code"
55
+ ide_name = "VSCode"
56
+ elif shutil.which("cursor"):
57
+ ide_command = "cursor"
58
+ ide_name = "Cursor"
59
+ else:
60
+ print("❌ No supported IDE found (VSCode or Cursor)")
61
+ return False
62
+
63
+ try:
64
+ print(f"📦 Installing extension in {ide_name}...")
65
+
66
+ # Install the extension
67
+ subprocess.run(
68
+ [ide_command, "--install-extension", str(extension_path)],
69
+ capture_output=True,
70
+ text=True,
71
+ check=True,
72
+ )
73
+
74
+ print(f"✅ Auto Debug extension installed in {ide_name}")
75
+ return True
76
+
77
+ except subprocess.CalledProcessError as e:
78
+ print(f"❌ Failed to install extension: {e}")
79
+ if e.stderr:
80
+ print(f"Error details: {e.stderr}")
81
+ return False
82
+ finally:
83
+ # Clean up temporary file
84
+ if extension_path.exists():
85
+ try:
86
+ extension_path.unlink()
87
+ extension_path.parent.rmdir()
88
+ except Exception:
89
+ pass
90
+
91
+
92
+ def install_auto_debug_extension(dry_run: bool = False) -> bool:
93
+ """
94
+ Main function to download and install Auto Debug extension.
95
+
96
+ Args:
97
+ dry_run: If True, simulate installation without actually installing
98
+
99
+ Returns:
100
+ True if installation successful, False otherwise
101
+ """
102
+ if dry_run:
103
+ print("[DRY-RUN]: Would download and install Auto Debug extension")
104
+ print("[DRY-RUN]: NO PLUGIN INSTALLED")
105
+ return True
106
+
107
+ # Download extension
108
+ vsix_path = download_auto_debug_extension()
109
+ if not vsix_path:
110
+ return False
111
+
112
+ # Install extension
113
+ return install_vscode_extensions(vsix_path)
@@ -0,0 +1,156 @@
1
+ """Main installation orchestrator for FastLED --install feature."""
2
+
3
+ import sys
4
+
5
+ from .examples_manager import install_fastled_examples_via_project_init
6
+ from .extension_manager import install_auto_debug_extension
7
+ from .project_detection import (
8
+ check_existing_arduino_content,
9
+ detect_fastled_project,
10
+ is_fastled_repository,
11
+ validate_vscode_project,
12
+ )
13
+ from .vscode_config import (
14
+ generate_fastled_tasks,
15
+ update_launch_json_for_arduino,
16
+ update_vscode_settings_for_fastled,
17
+ )
18
+
19
+
20
+ def fastled_install(dry_run: bool = False, no_interactive: bool = False) -> bool:
21
+ """
22
+ Main installation function with dry-run support.
23
+
24
+ Args:
25
+ dry_run: If True, simulate installation without making changes
26
+ no_interactive: If True, fail instead of prompting for input
27
+
28
+ Returns:
29
+ True if installation successful, False otherwise
30
+ """
31
+ try:
32
+ print("🚀 Starting FastLED installation...")
33
+
34
+ # 1. Validate VSCode project or offer alternatives
35
+ if not validate_vscode_project(no_interactive):
36
+ return False
37
+
38
+ # 2. Detect project type
39
+ is_fastled_project = detect_fastled_project()
40
+ is_repository = is_fastled_repository()
41
+
42
+ if is_fastled_project:
43
+ if is_repository:
44
+ print(
45
+ "✅ Detected FastLED repository - will configure full development environment"
46
+ )
47
+ else:
48
+ print(
49
+ "✅ Detected external FastLED project - will configure Arduino environment"
50
+ )
51
+ else:
52
+ print(
53
+ "✅ Detected standard project - will configure basic Arduino environment"
54
+ )
55
+
56
+ # 3. Auto Debug extension (with prompt)
57
+ if not dry_run and not no_interactive:
58
+ answer = (
59
+ input(
60
+ "\nWould you like to install the plugin for FastLED (auto-debug)? [y/n] "
61
+ )
62
+ .strip()
63
+ .lower()
64
+ )
65
+ elif no_interactive:
66
+ print(
67
+ "\n⚠️ Skipping Auto Debug extension installation in non-interactive mode"
68
+ )
69
+ answer = "no"
70
+ else:
71
+ answer = "yes"
72
+ print("\n[DRY-RUN]: Simulating Auto Debug extension installation...")
73
+
74
+ if answer in ["y", "yes"]:
75
+ if not install_auto_debug_extension(dry_run):
76
+ print(
77
+ "⚠️ Warning: Auto Debug extension installation failed, continuing..."
78
+ )
79
+
80
+ # 4. Configure VSCode files
81
+ print("\n📝 Configuring VSCode files...")
82
+ update_launch_json_for_arduino()
83
+ generate_fastled_tasks()
84
+
85
+ # 5. Examples installation (conditional)
86
+ if not check_existing_arduino_content():
87
+ if no_interactive:
88
+ print(
89
+ "⚠️ No Arduino content found. In non-interactive mode, skipping examples installation."
90
+ )
91
+ print(" Run 'fastled --project-init' manually to install examples.")
92
+ else:
93
+ install_fastled_examples_via_project_init(no_interactive=no_interactive)
94
+ else:
95
+ print(
96
+ "✅ Existing Arduino content detected, skipping examples installation"
97
+ )
98
+
99
+ # 6. Full development setup (repository only)
100
+ if is_fastled_project:
101
+ if is_repository:
102
+ print("\n🔧 Setting up FastLED development environment...")
103
+ update_vscode_settings_for_fastled()
104
+ else:
105
+ print(
106
+ "\n⚠️ Skipping clangd settings - not in FastLED repository (protects your environment)"
107
+ )
108
+
109
+ # 7. Post-installation auto-execution
110
+ if not dry_run:
111
+ auto_execute_fastled()
112
+ else:
113
+ print("\n[DRY-RUN]: Skipping auto-execution")
114
+
115
+ print("\n✅ FastLED installation completed successfully!")
116
+ return True
117
+
118
+ except Exception as e:
119
+ print(f"\n❌ Installation failed: {e}")
120
+ import traceback
121
+
122
+ traceback.print_exc()
123
+ return False
124
+
125
+
126
+ def auto_execute_fastled() -> None:
127
+ """Auto-launch fastled after successful installation."""
128
+ if check_existing_arduino_content():
129
+ print("\n🚀 Auto-launching FastLED...")
130
+
131
+ # Import the main function to avoid circular imports
132
+ from fastled.app import main
133
+
134
+ # Filter out --install and --dry-run from sys.argv
135
+ original_argv = sys.argv.copy()
136
+ filtered_argv = [
137
+ arg for arg in sys.argv if arg not in ["--install", "--dry-run"]
138
+ ]
139
+
140
+ # If no directory specified, add current directory
141
+ if len(filtered_argv) == 1: # Only the command name
142
+ filtered_argv.append(".")
143
+
144
+ # Replace sys.argv temporarily
145
+ sys.argv = filtered_argv
146
+
147
+ try:
148
+ # Call main directly
149
+ main()
150
+ finally:
151
+ # Restore original argv
152
+ sys.argv = original_argv
153
+ else:
154
+ print(
155
+ "\n💡 No Arduino content found. Create some .ino files and run 'fastled' to compile!"
156
+ )
@@ -0,0 +1,167 @@
1
+ """Project detection logic for FastLED installation."""
2
+
3
+ import json
4
+ import shutil
5
+ from pathlib import Path
6
+
7
+
8
+ def validate_vscode_project(no_interactive: bool = False) -> bool:
9
+ """
10
+ Validate if current directory has a VSCode project.
11
+ If not found, search parent directories, offer alternatives.
12
+ Returns True if a VSCode project is found or created.
13
+
14
+ Args:
15
+ no_interactive: If True, fail instead of prompting for input
16
+ """
17
+ current_dir = Path.cwd()
18
+
19
+ # Check current directory
20
+ if (current_dir / ".vscode").exists():
21
+ return True
22
+
23
+ # Search parent directories
24
+ parent_path = find_vscode_project_upward()
25
+ if parent_path:
26
+ if no_interactive:
27
+ print("❌ No .vscode directory found in current directory.")
28
+ print(f" Found .vscode in parent: {parent_path}")
29
+ print(" In non-interactive mode, cannot change directory.")
30
+ print(f" Please cd to {parent_path} and run the command again.")
31
+ return False
32
+ answer = (
33
+ input(f"Found a .vscode project in {parent_path}/\nInstall there? [y/n] ")
34
+ .strip()
35
+ .lower()
36
+ )
37
+ if answer in ["y", "yes"]:
38
+ import os
39
+
40
+ os.chdir(parent_path)
41
+ return True
42
+
43
+ # Check if IDE is available
44
+ if not (shutil.which("code") or shutil.which("cursor")):
45
+ print(
46
+ "No supported IDE found (VSCode or Cursor). Please install VSCode or Cursor first."
47
+ )
48
+ return False
49
+
50
+ # Offer to create new project
51
+ if no_interactive:
52
+ print(
53
+ "❌ No .vscode directory found in current directory or parent directories."
54
+ )
55
+ print(" In non-interactive mode, cannot create new project.")
56
+ print(" Please create a .vscode directory or run without --no-interactive.")
57
+ return False
58
+
59
+ print("No .vscode directory found in current directory or parent directories.")
60
+ answer = (
61
+ input(
62
+ "Would you like to generate a VSCode project with FastLED configuration? [y/n] "
63
+ )
64
+ .strip()
65
+ .lower()
66
+ )
67
+ if answer in ["y", "yes"]:
68
+ return generate_vscode_project()
69
+
70
+ return False
71
+
72
+
73
+ def find_vscode_project_upward(max_levels: int = 5) -> Path | None:
74
+ """Search parent directories for .vscode folder."""
75
+ current = Path.cwd()
76
+
77
+ for _ in range(max_levels):
78
+ parent = current.parent
79
+ if parent == current: # Reached root
80
+ break
81
+ current = parent
82
+ if (current / ".vscode").exists():
83
+ return current
84
+
85
+ return None
86
+
87
+
88
+ def generate_vscode_project() -> bool:
89
+ """Create a new .vscode directory structure."""
90
+ vscode_dir = Path.cwd() / ".vscode"
91
+ vscode_dir.mkdir(exist_ok=True)
92
+ print(f"✅ Created .vscode directory at {vscode_dir}")
93
+ return True
94
+
95
+
96
+ def detect_fastled_project() -> bool:
97
+ """Check if library.json contains FastLED."""
98
+ library_json = Path.cwd() / "library.json"
99
+ if not library_json.exists():
100
+ return False
101
+
102
+ try:
103
+ with open(library_json, "r") as f:
104
+ data = json.load(f)
105
+ return data.get("name") == "FastLED"
106
+ except (json.JSONDecodeError, KeyError):
107
+ return False
108
+
109
+
110
+ def is_fastled_repository() -> bool:
111
+ """
112
+ 🚨 CRITICAL: Detect actual FastLED repository.
113
+ Strict verification of multiple markers.
114
+ """
115
+ cwd = Path.cwd()
116
+
117
+ # Required files and directories for FastLED repository
118
+ required_markers = [
119
+ cwd / "src" / "FastLED.h",
120
+ cwd / "examples" / "Blink" / "Blink.ino",
121
+ cwd / "ci" / "ci-compile.py",
122
+ cwd / "src" / "platforms",
123
+ cwd / "library.json",
124
+ ]
125
+
126
+ # Check all markers exist
127
+ if not all(marker.exists() for marker in required_markers):
128
+ return False
129
+
130
+ # Verify library.json has correct content
131
+ try:
132
+ with open(cwd / "library.json", "r") as f:
133
+ data = json.load(f)
134
+ if data.get("name") != "FastLED":
135
+ return False
136
+ repo_url = data.get("repository", {}).get("url", "")
137
+ if "FastLED/FastLED" not in repo_url:
138
+ return False
139
+ except (json.JSONDecodeError, KeyError, FileNotFoundError):
140
+ return False
141
+
142
+ # Check for test files pattern
143
+ test_dir = cwd / "tests"
144
+ if test_dir.exists() and test_dir.is_dir():
145
+ test_files = list(test_dir.glob("test_*.cpp"))
146
+ if not test_files:
147
+ return False
148
+ else:
149
+ return False
150
+
151
+ return True
152
+
153
+
154
+ def check_existing_arduino_content() -> bool:
155
+ """Check for .ino files OR examples/ folder."""
156
+ cwd = Path.cwd()
157
+
158
+ # Check for any .ino files
159
+ ino_files = list(cwd.rglob("*.ino"))
160
+ if ino_files:
161
+ return True
162
+
163
+ # Check for examples folder
164
+ if (cwd / "examples").exists():
165
+ return True
166
+
167
+ return False