fastled 1.1.30__py2.py3-none-any.whl → 1.1.32__py2.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.
fastled/open_browser.py CHANGED
@@ -13,11 +13,12 @@ def _open_browser_python(fastled_js: Path, port: int) -> Server:
13
13
  """Start livereload server in the fastled_js directory using API"""
14
14
  print(f"\nStarting livereload server in {fastled_js} on port {port}")
15
15
 
16
- server = Server()
17
- server.watch(str(fastled_js / "index.html"), delay=0.1)
18
- server.setHeader("Cache-Control", "no-cache")
19
- server.serve(root=str(fastled_js), port=port, open_url_delay=0.5)
20
- return server
16
+ # server = Server()
17
+ # server.watch(str(fastled_js / "index.html"), delay=0.1)
18
+ # server.setHeader("Cache-Control", "no-cache")
19
+ # server.serve(root=str(fastled_js), port=port, open_url_delay=0.5)
20
+ # return server
21
+ os.system(f"cd {fastled_js} && live-server")
21
22
 
22
23
 
23
24
  def _find_open_port(start_port: int) -> int:
fastled/parse_args.py ADDED
@@ -0,0 +1,164 @@
1
+ import argparse
2
+ import os
3
+ import sys
4
+ from pathlib import Path
5
+
6
+ from fastled import __version__
7
+ from fastled.docker_manager import DockerManager
8
+ from fastled.env import DEFAULT_URL
9
+ from fastled.project_init import project_init
10
+ from fastled.select_sketch_directory import select_sketch_directory
11
+ from fastled.sketch import (
12
+ find_sketch_directories,
13
+ looks_like_fastled_repo,
14
+ looks_like_sketch_directory,
15
+ )
16
+
17
+
18
+ def parse_args() -> argparse.Namespace:
19
+ """Parse command-line arguments."""
20
+ parser = argparse.ArgumentParser(description=f"FastLED WASM Compiler {__version__}")
21
+ parser.add_argument(
22
+ "--version", action="version", version=f"%(prog)s {__version__}"
23
+ )
24
+ parser.add_argument(
25
+ "directory",
26
+ type=str,
27
+ nargs="?",
28
+ default=None,
29
+ help="Directory containing the FastLED sketch to compile",
30
+ )
31
+ parser.add_argument(
32
+ "--init",
33
+ action="store_true",
34
+ help="Initialize the FastLED sketch in the current directory",
35
+ )
36
+ parser.add_argument(
37
+ "--just-compile",
38
+ action="store_true",
39
+ help="Just compile, skip opening the browser and watching for changes.",
40
+ )
41
+ parser.add_argument(
42
+ "--web",
43
+ "-w",
44
+ type=str,
45
+ nargs="?",
46
+ # const does not seem to be working as expected
47
+ const=DEFAULT_URL, # Default value when --web is specified without value
48
+ help="Use web compiler. Optional URL can be provided (default: https://fastled.onrender.com)",
49
+ )
50
+ parser.add_argument(
51
+ "-i",
52
+ "--interactive",
53
+ action="store_true",
54
+ help="Run in interactive mode (Not available with --web)",
55
+ )
56
+ parser.add_argument(
57
+ "--profile",
58
+ action="store_true",
59
+ help="Enable profiling for web compilation",
60
+ )
61
+ parser.add_argument(
62
+ "--force-compile",
63
+ action="store_true",
64
+ help="Skips the test to see if the current directory is a valid FastLED sketch directory",
65
+ )
66
+ parser.add_argument(
67
+ "--no-auto-updates",
68
+ action="store_true",
69
+ help="Disable automatic updates of the wasm compiler image when using docker.",
70
+ )
71
+ parser.add_argument(
72
+ "--update",
73
+ "--upgrade",
74
+ action="store_true",
75
+ help="Update the wasm compiler (if necessary) before running",
76
+ )
77
+ parser.add_argument(
78
+ "--localhost",
79
+ "--local",
80
+ "-l",
81
+ action="store_true",
82
+ help="Use localhost for web compilation from an instance of fastled --server, creating it if necessary",
83
+ )
84
+ parser.add_argument(
85
+ "--server",
86
+ "-s",
87
+ action="store_true",
88
+ help="Run the server in the current directory, volume mapping fastled if we are in the repo",
89
+ )
90
+
91
+ build_mode = parser.add_mutually_exclusive_group()
92
+ build_mode.add_argument("--debug", action="store_true", help="Build in debug mode")
93
+ build_mode.add_argument(
94
+ "--quick",
95
+ action="store_true",
96
+ default=True,
97
+ help="Build in quick mode (default)",
98
+ )
99
+ build_mode.add_argument(
100
+ "--release", action="store_true", help="Build in release mode"
101
+ )
102
+
103
+ cwd_is_fastled = looks_like_fastled_repo(Path(os.getcwd()))
104
+
105
+ args = parser.parse_args()
106
+
107
+ if args.init:
108
+ args.directory = project_init()
109
+ print("\nInitialized FastLED project in", args.directory)
110
+ print(f"Use 'fastled {args.directory}' to compile the project.")
111
+ sys.exit(0)
112
+
113
+ if not args.update:
114
+ if args.no_auto_updates:
115
+ args.auto_update = False
116
+ else:
117
+ args.auto_update = None
118
+
119
+ if (
120
+ not cwd_is_fastled
121
+ and not args.localhost
122
+ and not args.web
123
+ and not args.server
124
+ ):
125
+ # print(f"Using web compiler at {DEFAULT_URL}")
126
+ args.web = DEFAULT_URL
127
+ if DockerManager.is_docker_installed():
128
+ print("Docker is installed. Use --server to run the compiler locally.")
129
+ args.localhost = True
130
+ else:
131
+ print("Docker is not installed. Using web compiler.")
132
+ if cwd_is_fastled and not args.web and not args.server:
133
+ print("Forcing --local mode because we are in the FastLED repo")
134
+ args.localhost = True
135
+ if args.localhost:
136
+ args.web = "localhost"
137
+ if args.interactive and not args.server:
138
+ print("--interactive forces --server mode")
139
+ args.server = True
140
+ if args.directory is None and not args.server:
141
+ # does current directory look like a sketch?
142
+ maybe_sketch_dir = Path(os.getcwd())
143
+ if looks_like_sketch_directory(maybe_sketch_dir):
144
+ args.directory = str(maybe_sketch_dir)
145
+ else:
146
+ sketch_directories = find_sketch_directories(maybe_sketch_dir)
147
+ selected_dir = select_sketch_directory(
148
+ sketch_directories, cwd_is_fastled
149
+ )
150
+ if selected_dir:
151
+ print(f"Using sketch directory: {selected_dir}")
152
+ args.directory = selected_dir
153
+ else:
154
+ print(
155
+ "\nYou either need to specify a sketch directory or run in --server mode."
156
+ )
157
+ sys.exit(1)
158
+ elif args.directory is not None and os.path.isfile(args.directory):
159
+ dir_path = Path(args.directory).parent
160
+ if looks_like_sketch_directory(dir_path):
161
+ print(f"Using sketch directory: {dir_path}")
162
+ args.directory = str(dir_path)
163
+
164
+ return args
fastled/project_init.py CHANGED
@@ -5,28 +5,59 @@ import httpx
5
5
 
6
6
  from fastled.env import DEFAULT_URL
7
7
 
8
- ENDPOINT = f"{DEFAULT_URL}/project/init"
8
+ ENDPOINT_PROJECT_INIT = f"{DEFAULT_URL}/project/init"
9
+ ENDPOINT_INFO = f"{DEFAULT_URL}/info"
10
+ DEFAULT_EXAMPLE = "wasm"
9
11
 
10
12
 
11
- def project_init() -> Path:
13
+ def get_examples() -> list[str]:
14
+ response = httpx.get(ENDPOINT_INFO, timeout=4)
15
+ response.raise_for_status()
16
+ return response.json()["examples"]
17
+
18
+
19
+ def _prompt_for_example() -> str:
20
+ examples = get_examples()
21
+ while True:
22
+ print("Available examples:")
23
+ for i, example in enumerate(examples):
24
+ print(f" [{i+1}]: {example}")
25
+ answer = input("Enter the example number or name: ").strip()
26
+ if answer.isdigit():
27
+ example_num = int(answer) - 1
28
+ if example_num < 0 or example_num >= len(examples):
29
+ print("Invalid example number")
30
+ continue
31
+ return examples[example_num]
32
+ elif answer in examples:
33
+ return answer
34
+
35
+
36
+ def project_init(example: str | None = None, outputdir: Path | None = None) -> Path:
12
37
  """
13
38
  Initialize a new FastLED project.
14
39
  """
15
- response = httpx.get(ENDPOINT, timeout=20)
40
+
41
+ outputdir = outputdir or Path("fastled")
42
+ if example is None:
43
+ try:
44
+ example = _prompt_for_example()
45
+ except httpx.HTTPStatusError:
46
+ print(
47
+ f"Failed to fetch examples, using default example '{DEFAULT_EXAMPLE}'"
48
+ )
49
+ example = DEFAULT_EXAMPLE
50
+ assert example is not None
51
+ response = httpx.get(f"{ENDPOINT_PROJECT_INIT}/{example}", timeout=20)
16
52
  response.raise_for_status()
17
53
  content = response.content
18
- output = Path("fastled.zip")
19
- output.write_bytes(content)
20
- # unzip the content
21
- outdir = Path("fastled")
22
- if outdir.exists():
23
- print("Project already initialized.")
24
- return Path("fastled").iterdir().__next__()
25
- with zipfile.ZipFile(output, "r") as zip_ref:
26
- zip_ref.extractall(outdir)
27
- print(f"Project initialized successfully at {outdir}")
28
- output.unlink()
29
- return Path("fastled").iterdir().__next__()
54
+ tmpzip = outputdir / "fastled.zip"
55
+ outputdir.mkdir(exist_ok=True)
56
+ tmpzip.write_bytes(content)
57
+ with zipfile.ZipFile(tmpzip, "r") as zip_ref:
58
+ zip_ref.extractall(outputdir)
59
+ tmpzip.unlink()
60
+ return outputdir.iterdir().__next__()
30
61
 
31
62
 
32
63
  def unit_test() -> None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fastled
3
- Version: 1.1.30
3
+ Version: 1.1.32
4
4
  Summary: FastLED Wasm Compiler
5
5
  Home-page: https://github.com/zackees/fastled-wasm
6
6
  Maintainer: Zachary Vorhies
@@ -161,10 +161,10 @@ A: `delay()` will block `loop()` which blocks the main thread of the browser. Th
161
161
  Q: How can I get the compiled size of my FastLED sketch smaller?
162
162
  A: A big chunk of space is being used by unnecessary javascript `emscripten` is bundling. This can be tweeked by the wasm_compiler_settings.py file in the FastLED repo.
163
163
 
164
-
165
-
166
164
  # Revisions
167
165
 
166
+ * 1.1.32 - `--init` now asks for which example you want, then tells you where the example was downloaded to. No longer auto-compiles.
167
+ * 1.1.31 - `--local` is auto-enabled if docker is installed, use `--web` to force web compiler. Updating is much more pretty.
168
168
  * 1.1.30 - Added `--init` to initialize a demo project.
169
169
  * 1.1.29 - Remove annoying dbg messages i left in.
170
170
  * 1.1.28 - Adds cache control headers to the live server to disable all caching in the live browser.
@@ -1,16 +1,17 @@
1
- fastled/__init__.py,sha256=yLjBvriNeONWn5KKcX1r03E91NonWMYyWdtvyeeo7I8,61
2
- fastled/app.py,sha256=eKaY6sD8JQ0pz0CZ6rtmhx27xkv5-WteuMYd9HxSeYU,7245
1
+ fastled/__init__.py,sha256=h57bgf-pWUgIqNDTiwecNLHLOonvdSie9JE_H5qq-eo,61
2
+ fastled/app.py,sha256=Zw1RS72yyIZSDt1_08MDSzfY4YwLWzarwXM4nvy8GE4,1787
3
3
  fastled/build_mode.py,sha256=joMwsV4K1y_LijT4gEAcjx69RZBoe_KmFmHZdPYbL_4,631
4
4
  fastled/cli.py,sha256=CNR_pQR0sNVPNuv8e_nmm-0PI8sU-eUBUgnWgWkzW9c,237
5
5
  fastled/client_server.py,sha256=IK_u71XbmOAKBX1ovHATsCmfUON8VVJJu-XtObTuYJI,11448
6
6
  fastled/compile_server.py,sha256=Adb2lvJ_p6Ui7UMxijRtYJhbO4YPTERKVQeuoQgibSE,6724
7
- fastled/docker_manager.py,sha256=Ok8TC1JXMoNMWt4P9clFFEVE29Xd-4C_MvIMIfvNo78,22134
7
+ fastled/docker_manager.py,sha256=WVWg8ABWjdrX1P4vRRbW2z6yMOhhrHVtQ9H_cBBBAlI,23275
8
8
  fastled/env.py,sha256=8wctQwl5qE4CI8NBugHtgMmUfEfHZ869JX5lGdSOJxc,304
9
9
  fastled/filewatcher.py,sha256=5dVmjEG23kMeJa29tRVm5XKSr9sTD4ME2boo-CFDuUM,6910
10
10
  fastled/keyboard.py,sha256=Zz_ggxOUTX2XQEy6K6kAoorVlUev4wEk9Awpvv9aStA,3241
11
- fastled/open_browser.py,sha256=-2_vyf6dbi2xGex-CMZHVVcXvwXGJkLOwFcjHGxknUQ,1769
11
+ fastled/open_browser.py,sha256=ERDHvsJKl7yKHX7UJKm35eCeQ1fRXseWdZavV962O0A,1829
12
+ fastled/parse_args.py,sha256=PoFA9BVXexPf6g4tVIDigzCCOTHqV9aSbs71WqDhJZI,5696
12
13
  fastled/paths.py,sha256=VsPmgu0lNSCFOoEC0BsTYzDygXqy15AHUfN-tTuzDZA,99
13
- fastled/project_init.py,sha256=9GmyaRsXa1fNuzqpv0lcpkSFTOFszpEZ3jr788zZNp0,870
14
+ fastled/project_init.py,sha256=ndQICZ9rBtfEPOnucZ3cgRE67PUKc66CJYO4Tkwmt_M,1932
14
15
  fastled/select_sketch_directory.py,sha256=TZdCjl1D7YMKjodMTvDRurPcpAmN3x0TcJxffER2NfM,1314
15
16
  fastled/sketch.py,sha256=5nRjg281lMH8Bo9wKjbcpTQCfEP574ZCG-lukvFmyQ8,2656
16
17
  fastled/spinner.py,sha256=ZGFXona3SJxmuHIzMGa6tqB0IVDSRr8W_dju09Z1Hwg,901
@@ -19,9 +20,9 @@ fastled/types.py,sha256=dDIsGHJkHNJ7B61wNp6X0JSLs_nrHiq7RlNqNWbwFec,194
19
20
  fastled/util.py,sha256=t4M3NFMhnCzfYbLvIyJi0RdFssZqbTN_vVIaej1WV-U,265
20
21
  fastled/web_compile.py,sha256=KuvKGdX6SSUUqC7YgX4T9SMSP5wdcPUhpg9-K9zPoTI,10378
21
22
  fastled/assets/example.txt,sha256=lTBovRjiz0_TgtAtbA1C5hNi2ffbqnNPqkKg6UiKCT8,54
22
- fastled-1.1.30.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
23
- fastled-1.1.30.dist-info/METADATA,sha256=JdbFFpslqjqfeg9SLWlsL1TABA2pCk2pPJFHNIwtqYE,14541
24
- fastled-1.1.30.dist-info/WHEEL,sha256=0VNUDWQJzfRahYI3neAhz2UVbRCtztpN5dPHAGvmGXc,109
25
- fastled-1.1.30.dist-info/entry_points.txt,sha256=RCwmzCSOS4-C2i9EziANq7Z2Zb4KFnEMR1FQC0bBwAw,101
26
- fastled-1.1.30.dist-info/top_level.txt,sha256=xfG6Z_ol9V5YmBROkZq2QTRwjbS2ouCUxaTJsOwfkOo,14
27
- fastled-1.1.30.dist-info/RECORD,,
23
+ fastled-1.1.32.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
24
+ fastled-1.1.32.dist-info/METADATA,sha256=Ywsknp8GbAi4ExBaULxknlC7XEY7AfWTGFYxA6AUCIk,14803
25
+ fastled-1.1.32.dist-info/WHEEL,sha256=0VNUDWQJzfRahYI3neAhz2UVbRCtztpN5dPHAGvmGXc,109
26
+ fastled-1.1.32.dist-info/entry_points.txt,sha256=RCwmzCSOS4-C2i9EziANq7Z2Zb4KFnEMR1FQC0bBwAw,101
27
+ fastled-1.1.32.dist-info/top_level.txt,sha256=xfG6Z_ol9V5YmBROkZq2QTRwjbS2ouCUxaTJsOwfkOo,14
28
+ fastled-1.1.32.dist-info/RECORD,,