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/zip_files.py ADDED
@@ -0,0 +1,76 @@
1
+ import io
2
+ import json
3
+ import zipfile
4
+ from dataclasses import dataclass
5
+ from pathlib import Path
6
+
7
+ from fastled.sketch import get_sketch_files
8
+ from fastled.types import BuildMode
9
+ from fastled.util import hash_file
10
+
11
+
12
+ def _file_info(file_path: Path) -> str:
13
+ hash_txt = hash_file(file_path)
14
+ file_size = file_path.stat().st_size
15
+ json_str = json.dumps({"hash": hash_txt, "size": file_size})
16
+ return json_str
17
+
18
+
19
+ @dataclass
20
+ class ZipResult:
21
+ zip_bytes: bytes
22
+ zip_embedded_bytes: bytes | None
23
+ success: bool
24
+ error: str | None
25
+
26
+
27
+ def zip_files(directory: Path, build_mode: BuildMode) -> ZipResult | Exception:
28
+ print("Zipping files...")
29
+ try:
30
+ files = get_sketch_files(directory)
31
+ if not files:
32
+ raise FileNotFoundError(f"No files found in {directory}")
33
+ for f in files:
34
+ print(f"Adding file: {f}")
35
+ # Create in-memory zip file
36
+ has_embedded_zip = False
37
+ zip_embedded_buffer = io.BytesIO()
38
+ zip_buffer = io.BytesIO()
39
+ with zipfile.ZipFile(
40
+ zip_embedded_buffer, "w", zipfile.ZIP_DEFLATED, compresslevel=9
41
+ ) as emebedded_zip_file:
42
+ with zipfile.ZipFile(
43
+ zip_buffer, "w", zipfile.ZIP_DEFLATED, compresslevel=9
44
+ ) as zip_file:
45
+ for file_path in files:
46
+ if "fastled_js" in str(file_path):
47
+ # These can be huge, don't send the output files back to the server!
48
+ continue
49
+ relative_path = file_path.relative_to(directory)
50
+ achive_path = str(Path("wasm") / relative_path)
51
+ if str(relative_path).startswith("data"):
52
+ _file_info_str = _file_info(file_path)
53
+ zip_file.writestr(
54
+ achive_path + ".embedded.json", _file_info_str
55
+ )
56
+ emebedded_zip_file.write(file_path, relative_path)
57
+ has_embedded_zip = True
58
+ else:
59
+ zip_file.write(file_path, achive_path)
60
+ # write build mode into the file as build.txt so that sketches are fingerprinted
61
+ # based on the build mode. Otherwise the same sketch with different build modes
62
+ # will have the same fingerprint.
63
+ zip_file.writestr(
64
+ str(Path("wasm") / "build_mode.txt"), build_mode.value
65
+ )
66
+ result = ZipResult(
67
+ zip_bytes=zip_buffer.getvalue(),
68
+ zip_embedded_bytes=(
69
+ zip_embedded_buffer.getvalue() if has_embedded_zip else None
70
+ ),
71
+ success=True,
72
+ error=None,
73
+ )
74
+ return result
75
+ except Exception as e:
76
+ return e