fastled 1.1.37__py2.py3-none-any.whl → 1.1.38__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/__init__.py CHANGED
@@ -3,11 +3,12 @@
3
3
  # context
4
4
  from contextlib import contextmanager
5
5
  from pathlib import Path
6
+ from typing import Generator
6
7
 
7
8
  from .compile_server import CompileServer
8
- from .types import WebCompileResult
9
+ from .types import BuildMode, CompileResult, CompileServerError
9
10
 
10
- __version__ = "1.1.37"
11
+ __version__ = "1.1.38"
11
12
 
12
13
 
13
14
  class Api:
@@ -29,15 +30,20 @@ class Api:
29
30
 
30
31
  @staticmethod
31
32
  def web_compile(
32
- directory: Path | str, host: str | CompileServer | None = None
33
- ) -> WebCompileResult:
33
+ directory: Path | str,
34
+ host: str | CompileServer | None = None,
35
+ build_mode: BuildMode = BuildMode.QUICK,
36
+ profile: bool = False, # When true then profile information will be enabled and included in the zip.
37
+ ) -> CompileResult:
34
38
  from fastled.web_compile import web_compile
35
39
 
36
40
  if isinstance(host, CompileServer):
37
41
  host = host.url()
38
42
  if isinstance(directory, str):
39
43
  directory = Path(directory)
40
- out: WebCompileResult = web_compile(directory, host)
44
+ out: CompileResult = web_compile(
45
+ directory, host, build_mode=build_mode, profile=profile
46
+ )
41
47
  return out
42
48
 
43
49
  @staticmethod
@@ -47,7 +53,7 @@ class Api:
47
53
  auto_updates=None,
48
54
  auto_start=True,
49
55
  container_name: str | None = None,
50
- ):
56
+ ) -> CompileServer:
51
57
  from fastled.compile_server import CompileServer
52
58
 
53
59
  out = CompileServer(
@@ -67,7 +73,7 @@ class Api:
67
73
  auto_updates=None,
68
74
  auto_start=True,
69
75
  container_name: str | None = None,
70
- ):
76
+ ) -> Generator[CompileServer, None, None]:
71
77
  server = Api.spawn_server(
72
78
  sketch_directory=sketch_directory,
73
79
  interactive=interactive,
@@ -92,3 +98,13 @@ class Test:
92
98
  host = host.url()
93
99
 
94
100
  return test_examples(examples=examples, host=host)
101
+
102
+
103
+ __all__ = [
104
+ "Api",
105
+ "Test",
106
+ "CompileServer",
107
+ "CompileResult",
108
+ "CompileServerError",
109
+ "BuildMode",
110
+ ]
fastled/client_server.py CHANGED
@@ -5,7 +5,6 @@ import time
5
5
  from multiprocessing import Process
6
6
  from pathlib import Path
7
7
 
8
- from fastled.build_mode import BuildMode, get_build_mode
9
8
  from fastled.compile_server import CompileServer
10
9
  from fastled.docker_manager import DockerManager
11
10
  from fastled.filewatcher import FileWatcherProcess
@@ -13,9 +12,7 @@ from fastled.keyboard import SpaceBarWatcher
13
12
  from fastled.open_browser import open_browser_process
14
13
  from fastled.settings import DEFAULT_URL
15
14
  from fastled.sketch import looks_like_sketch_directory
16
-
17
- # CompiledResult
18
- from fastled.types import CompiledResult
15
+ from fastled.types import BuildMode, CompileResult
19
16
  from fastled.web_compile import (
20
17
  SERVER_PORT,
21
18
  ConnectionResult,
@@ -30,7 +27,7 @@ def _run_web_compiler(
30
27
  build_mode: BuildMode,
31
28
  profile: bool,
32
29
  last_hash_value: str | None,
33
- ) -> CompiledResult:
30
+ ) -> CompileResult:
34
31
  input_dir = Path(directory)
35
32
  output_dir = input_dir / "fastled_js"
36
33
  start = time.time()
@@ -42,7 +39,7 @@ def _run_web_compiler(
42
39
  print("\nWeb compilation failed:")
43
40
  print(f"Time taken: {diff:.2f} seconds")
44
41
  print(web_result.stdout)
45
- return CompiledResult(success=False, fastled_js="", hash_value=None)
42
+ return web_result
46
43
 
47
44
  def print_results() -> None:
48
45
  hash_value = (
@@ -58,9 +55,7 @@ def _run_web_compiler(
58
55
  if last_hash_value is not None and last_hash_value == web_result.hash_value:
59
56
  print("\nSkipping redeploy: No significant changes found.")
60
57
  print_results()
61
- return CompiledResult(
62
- success=True, fastled_js=str(output_dir), hash_value=web_result.hash_value
63
- )
58
+ return web_result
64
59
 
65
60
  # Extract zip contents to fastled_js directory
66
61
  output_dir.mkdir(exist_ok=True)
@@ -78,18 +73,20 @@ def _run_web_compiler(
78
73
 
79
74
  print(web_result.stdout)
80
75
  print_results()
81
- return CompiledResult(
82
- success=True, fastled_js=str(output_dir), hash_value=web_result.hash_value
83
- )
76
+ return web_result
84
77
 
85
78
 
86
- def _try_start_server_or_get_url(args: argparse.Namespace) -> str | CompileServer:
87
- auto_update = args.auto_update
88
- is_local_host = "localhost" in args.web or "127.0.0.1" in args.web or args.localhost
79
+ def _try_start_server_or_get_url(
80
+ auto_update: bool, args_web: str | bool, localhost: bool
81
+ ) -> str | CompileServer:
82
+ is_local_host = localhost or (
83
+ isinstance(args_web, str)
84
+ and ("localhost" in args_web or "127.0.0.1" in args_web)
85
+ )
89
86
  # test to see if there is already a local host server
90
87
  local_host_needs_server = False
91
88
  if is_local_host:
92
- addr = "localhost" if args.localhost else args.web
89
+ addr = "localhost" if localhost or not isinstance(args_web, str) else args_web
93
90
  urls = [addr]
94
91
  if ":" not in addr:
95
92
  urls.append(f"{addr}:{SERVER_PORT}")
@@ -101,12 +98,12 @@ def _try_start_server_or_get_url(args: argparse.Namespace) -> str | CompileServe
101
98
  else:
102
99
  local_host_needs_server = True
103
100
 
104
- if not local_host_needs_server and args.web:
105
- if isinstance(args.web, str):
106
- return args.web
107
- if isinstance(args.web, bool):
101
+ if not local_host_needs_server and args_web:
102
+ if isinstance(args_web, str):
103
+ return args_web
104
+ if isinstance(args_web, bool):
108
105
  return DEFAULT_URL
109
- return args.web
106
+ return args_web
110
107
  else:
111
108
  try:
112
109
  print("No local server found, starting one...")
@@ -125,25 +122,36 @@ def _try_start_server_or_get_url(args: argparse.Namespace) -> str | CompileServe
125
122
 
126
123
  def run_client_server(args: argparse.Namespace) -> int:
127
124
  compile_server: CompileServer | None = None
128
- open_web_browser = not args.just_compile and not args.interactive
129
- profile = args.profile
130
- if not args.force_compile and not looks_like_sketch_directory(Path(args.directory)):
125
+
126
+ profile = bool(args.profile)
127
+ web: str | bool = args.web if isinstance(args.web, str) else bool(args.web)
128
+ auto_update = bool(args.auto_update)
129
+ localhost = bool(args.localhost)
130
+ directory = Path(args.directory)
131
+ just_compile = bool(args.just_compile)
132
+ interactive = bool(args.interactive)
133
+ force_compile = bool(args.force_compile)
134
+ open_web_browser = not just_compile and not interactive
135
+
136
+ if not force_compile and not looks_like_sketch_directory(directory):
131
137
  print(
132
138
  "Error: Not a valid FastLED sketch directory, if you are sure it is, use --force-compile"
133
139
  )
134
140
  return 1
135
141
 
136
142
  # If not explicitly using web compiler, check Docker installation
137
- if not args.web and not DockerManager.is_docker_installed():
143
+ if not web and not DockerManager.is_docker_installed():
138
144
  print(
139
145
  "\nDocker is not installed on this system - switching to web compiler instead."
140
146
  )
141
- args.web = True
147
+ web = True
142
148
 
143
149
  url: str
144
150
  try:
145
151
  try:
146
- url_or_server: str | CompileServer = _try_start_server_or_get_url(args)
152
+ url_or_server: str | CompileServer = _try_start_server_or_get_url(
153
+ auto_update, web, localhost
154
+ )
147
155
  if isinstance(url_or_server, str):
148
156
  print(f"Found URL: {url_or_server}")
149
157
  url = url_or_server
@@ -159,31 +167,31 @@ def run_client_server(args: argparse.Namespace) -> int:
159
167
  except Exception as e:
160
168
  print(f"Error: {e}")
161
169
  return 1
162
- build_mode: BuildMode = get_build_mode(args)
170
+ build_mode: BuildMode = BuildMode.from_args(args)
163
171
 
164
172
  def compile_function(
165
173
  url: str = url,
166
174
  build_mode: BuildMode = build_mode,
167
175
  profile: bool = profile,
168
176
  last_hash_value: str | None = None,
169
- ) -> CompiledResult:
177
+ ) -> CompileResult:
170
178
  return _run_web_compiler(
171
- args.directory,
179
+ directory,
172
180
  host=url,
173
181
  build_mode=build_mode,
174
182
  profile=profile,
175
183
  last_hash_value=last_hash_value,
176
184
  )
177
185
 
178
- result: CompiledResult = compile_function(last_hash_value=None)
179
- last_compiled_result: CompiledResult = result
186
+ result: CompileResult = compile_function(last_hash_value=None)
187
+ last_compiled_result: CompileResult = result
180
188
 
181
189
  if not result.success:
182
190
  print("\nCompilation failed.")
183
191
 
184
192
  browser_proc: Process | None = None
185
193
  if open_web_browser:
186
- browser_proc = open_browser_process(Path(args.directory) / "fastled_js")
194
+ browser_proc = open_browser_process(directory / "fastled_js")
187
195
  else:
188
196
  print("\nCompilation successful.")
189
197
  if compile_server:
@@ -191,7 +199,7 @@ def run_client_server(args: argparse.Namespace) -> int:
191
199
  compile_server.stop()
192
200
  return 0
193
201
 
194
- if args.just_compile:
202
+ if just_compile:
195
203
  if compile_server:
196
204
  compile_server.stop()
197
205
  if browser_proc:
@@ -203,9 +211,7 @@ def run_client_server(args: argparse.Namespace) -> int:
203
211
  compile_server.stop()
204
212
  return 1
205
213
 
206
- sketch_filewatcher = FileWatcherProcess(
207
- args.directory, excluded_patterns=["fastled_js"]
208
- )
214
+ sketch_filewatcher = FileWatcherProcess(directory, excluded_patterns=["fastled_js"])
209
215
 
210
216
  source_code_watcher: FileWatcherProcess | None = None
211
217
  if compile_server and compile_server.using_fastled_src_dir_volume():
@@ -215,8 +221,8 @@ def run_client_server(args: argparse.Namespace) -> int:
215
221
  )
216
222
 
217
223
  def trigger_rebuild_if_sketch_changed(
218
- last_compiled_result: CompiledResult,
219
- ) -> tuple[bool, CompiledResult]:
224
+ last_compiled_result: CompileResult,
225
+ ) -> tuple[bool, CompileResult]:
220
226
  changed_files = sketch_filewatcher.get_all_changes()
221
227
  if changed_files:
222
228
  print(f"\nChanges detected in {changed_files}")
fastled/compile_server.py CHANGED
@@ -1,10 +1,11 @@
1
1
  from pathlib import Path
2
2
 
3
- from fastled.build_mode import BuildMode
4
- from fastled.types import WebCompileResult
3
+ from fastled.types import BuildMode, CompileResult
5
4
 
6
5
 
7
6
  class CompileServer:
7
+
8
+ # May throw CompileServerError if auto_start is True.
8
9
  def __init__(
9
10
  self,
10
11
  interactive: bool = False,
@@ -25,6 +26,7 @@ class CompileServer:
25
26
  auto_start=auto_start,
26
27
  )
27
28
 
29
+ # May throw CompileServerError if server could not be started.
28
30
  def start(self, wait_for_startup=True) -> None:
29
31
  # from fastled.compile_server_impl import CompileServerImpl # avoid circular import
30
32
  self.impl.start(wait_for_startup=wait_for_startup)
@@ -34,7 +36,7 @@ class CompileServer:
34
36
  directory: Path | str,
35
37
  build_mode: BuildMode = BuildMode.QUICK,
36
38
  profile: bool = False,
37
- ) -> WebCompileResult:
39
+ ) -> CompileResult:
38
40
  return self.impl.web_compile(
39
41
  directory=directory, build_mode=build_mode, profile=profile
40
42
  )
@@ -6,7 +6,6 @@ from pathlib import Path
6
6
 
7
7
  import httpx
8
8
 
9
- from fastled.build_mode import BuildMode
10
9
  from fastled.docker_manager import (
11
10
  DISK_CACHE,
12
11
  Container,
@@ -15,13 +14,27 @@ from fastled.docker_manager import (
15
14
  )
16
15
  from fastled.settings import SERVER_PORT
17
16
  from fastled.sketch import looks_like_fastled_repo
18
- from fastled.types import WebCompileResult
17
+ from fastled.types import BuildMode, CompileResult, CompileServerError
19
18
 
20
19
  _IMAGE_NAME = "niteris/fastled-wasm"
21
20
  _DEFAULT_CONTAINER_NAME = "fastled-wasm-compiler"
22
21
 
23
22
 
24
- SERVER_OPTIONS = ["--allow-shutdown", "--no-auto-update"]
23
+ SERVER_OPTIONS = [
24
+ "--allow-shutdown", # Allow the server to be shut down without a force kill.
25
+ "--no-auto-update", # Don't auto live updates from the git repo.
26
+ ]
27
+
28
+
29
+ def _try_get_fastled_src(path: Path) -> Path | None:
30
+ fastled_src_dir: Path | None = None
31
+ if looks_like_fastled_repo(path):
32
+ print(
33
+ "Looks like a FastLED repo, using it as the source directory and mapping it into the server."
34
+ )
35
+ fastled_src_dir = path / "src"
36
+ return fastled_src_dir
37
+ return None
25
38
 
26
39
 
27
40
  class CompileServerImpl:
@@ -40,52 +53,46 @@ class CompileServerImpl:
40
53
  )
41
54
  if not interactive and mapped_dir:
42
55
  raise ValueError("Mapped directory is only used in interactive mode")
43
- cwd = Path(".").resolve()
44
- fastled_src_dir: Path | None = None
45
- if looks_like_fastled_repo(cwd):
46
- print(
47
- "Looks like a FastLED repo, using it as the source directory and mapping it into the server."
48
- )
49
- fastled_src_dir = cwd / "src"
50
-
51
56
  self.container_name = container_name
52
57
  self.mapped_dir = mapped_dir
53
58
  self.docker = DockerManager()
54
- self.fastled_src_dir: Path | None = fastled_src_dir
59
+ self.fastled_src_dir: Path | None = _try_get_fastled_src(Path(".").resolve())
55
60
  self.interactive = interactive
56
61
  self.running_container: RunningContainer | None = None
57
62
  self.auto_updates = auto_updates
58
- # self._port = self._start()
59
63
  self._port = 0 # 0 until compile server is started
60
- # fancy print
61
- if not interactive:
62
- msg = f"# FastLED Compile Server started at {self.url()} #"
63
- print("\n" + "#" * len(msg))
64
- print(msg)
65
- print("#" * len(msg) + "\n")
66
64
  if auto_start:
67
65
  self.start()
68
66
 
69
67
  def start(self, wait_for_startup=True) -> None:
68
+ if not DockerManager.is_docker_installed():
69
+ raise CompileServerError("Docker is not installed")
70
70
  if self._port != 0:
71
71
  warnings.warn("Server has already been started")
72
72
  self._port = self._start()
73
73
  if wait_for_startup:
74
- self.wait_for_startup()
74
+ ok = self.wait_for_startup()
75
+ if not ok:
76
+ raise CompileServerError("Server did not start")
77
+ if not self.interactive:
78
+ msg = f"# FastLED Compile Server started at {self.url()} #"
79
+ print("\n" + "#" * len(msg))
80
+ print(msg)
81
+ print("#" * len(msg) + "\n")
75
82
 
76
83
  def web_compile(
77
84
  self,
78
85
  directory: Path | str,
79
86
  build_mode: BuildMode = BuildMode.QUICK,
80
87
  profile: bool = False,
81
- ) -> WebCompileResult:
88
+ ) -> CompileResult:
82
89
  from fastled.web_compile import web_compile # avoid circular import
83
90
 
84
91
  if not self._port:
85
92
  raise RuntimeError("Server has not been started yet")
86
93
  if not self.ping():
87
94
  raise RuntimeError("Server is not running")
88
- out: WebCompileResult = web_compile(
95
+ out: CompileResult = web_compile(
89
96
  directory, host=self.url(), build_mode=build_mode, profile=profile
90
97
  )
91
98
  return out
fastled/types.py CHANGED
@@ -1,18 +1,11 @@
1
+ import argparse
1
2
  from dataclasses import dataclass
3
+ from enum import Enum
2
4
  from typing import Any
3
5
 
4
6
 
5
7
  @dataclass
6
- class CompiledResult:
7
- """Dataclass to hold the result of the compilation."""
8
-
9
- success: bool
10
- fastled_js: str
11
- hash_value: str | None
12
-
13
-
14
- @dataclass
15
- class WebCompileResult:
8
+ class CompileResult:
16
9
  success: bool
17
10
  stdout: str
18
11
  hash_value: str | None
@@ -23,3 +16,32 @@ class WebCompileResult:
23
16
 
24
17
  def to_dict(self) -> dict[str, Any]:
25
18
  return self.__dict__.copy()
19
+
20
+
21
+ class CompileServerError(Exception):
22
+ """Error class for failing to instantiate CompileServer."""
23
+
24
+ pass
25
+
26
+
27
+ class BuildMode(Enum):
28
+ DEBUG = "DEBUG"
29
+ QUICK = "QUICK"
30
+ RELEASE = "RELEASE"
31
+
32
+ @classmethod
33
+ def from_string(cls, mode_str: str) -> "BuildMode":
34
+ try:
35
+ return cls[mode_str.upper()]
36
+ except KeyError:
37
+ valid_modes = [mode.name for mode in cls]
38
+ raise ValueError(f"BUILD_MODE must be one of {valid_modes}, got {mode_str}")
39
+
40
+ @staticmethod
41
+ def from_args(args: argparse.Namespace) -> "BuildMode":
42
+ if args.debug:
43
+ return BuildMode.DEBUG
44
+ elif args.release:
45
+ return BuildMode.RELEASE
46
+ else:
47
+ return BuildMode.QUICK
fastled/web_compile.py CHANGED
@@ -11,10 +11,9 @@ from pathlib import Path
11
11
 
12
12
  import httpx
13
13
 
14
- from fastled.build_mode import BuildMode
15
14
  from fastled.settings import SERVER_PORT
16
15
  from fastled.sketch import get_sketch_files
17
- from fastled.types import WebCompileResult
16
+ from fastled.types import BuildMode, CompileResult
18
17
  from fastled.util import hash_file
19
18
 
20
19
  DEFAULT_HOST = "https://fastled.onrender.com"
@@ -160,7 +159,7 @@ def web_compile(
160
159
  auth_token: str | None = None,
161
160
  build_mode: BuildMode | None = None,
162
161
  profile: bool = False,
163
- ) -> WebCompileResult:
162
+ ) -> CompileResult:
164
163
  if isinstance(directory, str):
165
164
  directory = Path(directory)
166
165
  host = _sanitize_host(host or DEFAULT_HOST)
@@ -171,7 +170,7 @@ def web_compile(
171
170
  raise FileNotFoundError(f"Directory not found: {directory}")
172
171
  zip_result = zip_files(directory, build_mode=build_mode)
173
172
  if isinstance(zip_result, Exception):
174
- return WebCompileResult(
173
+ return CompileResult(
175
174
  success=False, stdout=str(zip_result), hash_value=None, zip_bytes=b""
176
175
  )
177
176
  zip_bytes = zip_result.zip_bytes
@@ -187,7 +186,7 @@ def web_compile(
187
186
  connection_result = find_good_connection(urls)
188
187
  if connection_result is None:
189
188
  print("Connection failed to all endpoints")
190
- return WebCompileResult(
189
+ return CompileResult(
191
190
  success=False,
192
191
  stdout="Connection failed",
193
192
  hash_value=None,
@@ -229,7 +228,7 @@ def web_compile(
229
228
  if response.status_code != 200:
230
229
  json_response = response.json()
231
230
  detail = json_response.get("detail", "Could not compile")
232
- return WebCompileResult(
231
+ return CompileResult(
233
232
  success=False, stdout=detail, hash_value=None, zip_bytes=b""
234
233
  )
235
234
 
@@ -270,7 +269,7 @@ def web_compile(
270
269
  relative_path = file_path.relative_to(extract_path)
271
270
  out_zip.write(file_path, relative_path)
272
271
 
273
- return WebCompileResult(
272
+ return CompileResult(
274
273
  success=True,
275
274
  stdout=stdout,
276
275
  hash_value=hash_value,
@@ -281,6 +280,6 @@ def web_compile(
281
280
  raise
282
281
  except httpx.HTTPError as e:
283
282
  print(f"Error: {e}")
284
- return WebCompileResult(
283
+ return CompileResult(
285
284
  success=False, stdout=str(e), hash_value=None, zip_bytes=b""
286
285
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fastled
3
- Version: 1.1.37
3
+ Version: 1.1.38
4
4
  Summary: FastLED Wasm Compiler
5
5
  Home-page: https://github.com/zackees/fastled-wasm
6
6
  Maintainer: Zachary Vorhies
@@ -61,47 +61,109 @@ pip install fastled
61
61
 
62
62
  **Note that you may need to install x86 docker emulation on Mac-m1 and later, as this is an x86 only image at the prsent.**
63
63
 
64
- # Use
64
+ # Command Line Use
65
65
 
66
66
  Change to the directory where the sketch lives and run, will run the compilation
67
67
  on the web compiler.
68
68
 
69
69
  ```bash
70
+ # This will use the web-compiler, unless you have docker installed in which case a local
71
+ # server will be instantiated automatically.
70
72
  cd <SKETCH-DIRECTORY>
71
73
  fastled
72
74
  ```
73
75
 
74
- Or if you have docker you can run a server automatically.
76
+ Forces the local server to to spawn in order to run to do the compile.
75
77
 
76
78
  ```bash
77
79
  cd <SKETCH-DIRECTORY>
78
- fastled --local
80
+ fastled --local # if server doesn't already exist, one is created.
79
81
  ```
80
82
 
81
83
  You can also spawn a server in one process and then access it in another, like this:
82
84
 
83
85
  ```bash
84
- fastled --server
86
+ fastled --server # server will now run in the background.
85
87
  # now launch the client
86
- fastled examples/wasm --local
88
+ fastled examples/wasm --local # local will find the local server use it do the compile.
87
89
  ```
88
90
 
89
91
  After compilation a web browser windows will pop up. Changes to the sketch will automatically trigger a recompilation.
90
92
 
91
- # Hot reload by default
93
+ # Python Api
94
+
95
+ **Compiling through the api**
96
+ ```python
97
+
98
+ from fastapi import Api, CompileResult
99
+
100
+ out: CompileResult = Api.web_compile("path/to/sketch")
101
+ print(out.success)
102
+ print(out.stdout)
103
+
104
+ ```
105
+
106
+ **Launching a compile server**
107
+ ```python
108
+
109
+ from fastapi import Api, CompileServer
110
+
111
+ server: CompileServer = Api.spawn_server()
112
+ print(f"Local server running at {server.url()}")
113
+ server.web_compile("path/to/sketch") # output will be "path/to/sketch/fastled_js"
114
+ server.stop()
115
+ ```
116
+
117
+ **Launching a server in a scope**
118
+ ```python
119
+
120
+ from fastapi import Api
121
+
122
+ # Launching a server in a scope
123
+ with Api.server() as server:
124
+ server.web_compile("path/to/sketch")
125
+
126
+ ```
127
+
128
+ **Initializing a project example from the web compiler**
129
+ ```python
130
+
131
+ from fastapi import Api
132
+
133
+ examples = Api.get_examples()
134
+ print(f"Print available examples: {examples}")
135
+ Api.project_init(examples[0])
136
+
137
+
138
+ ```
139
+
140
+ **Initializing a project example from the CompileServer**
141
+ ```python
142
+
143
+ from fastapi import Api
144
+
145
+ with Api.server() as server:
146
+ examples = server.get_examples()
147
+ server.project_init(examples[0])
148
+
149
+ ```
150
+
151
+ # Features
152
+
153
+ ## Hot reload by default
92
154
 
93
155
  Once launched, the compiler will remain open, listening to changes and recompiling as necessary and hot-reloading the sketch into the current browser.
94
156
 
95
157
  This style of development should be familiar to those doing web development.
96
158
 
97
- # Hot Reload for working with the FastLED repo
159
+ ## Hot Reload fastled/src when working in the FastLED repo
98
160
 
99
161
  If you launch `fastled` in the FastLED repo then this tool will automatically detect this and map the src directory into the
100
162
  host container. Whenever there are changes in the source code from the mapped directory, then these will be re-compiled
101
163
  on the next change or if you hit the space bar when prompted. Unlike a sketch folder, a re-compile on the FastLED src
102
164
  can be much longer, for example if you modify a header file.
103
165
 
104
- # Data
166
+ ## Big Data in `/data` directory won't be round-tripped
105
167
 
106
168
  Huge blobs of data like video will absolutely kill the compile performance as these blobs would normally have to be shuffled
107
169
  back and forth. Therefore a special directory `data/` is implicitly used to hold this blob data. Any data in this directory
@@ -114,7 +176,7 @@ files will be asynchroniously streamed into the running sketch instance during r
114
176
 
115
177
  For an example of how to use this see `examples/SdCard` which is fully wasm compatible.
116
178
 
117
- # Compile Speed
179
+ ## Compile Speed
118
180
 
119
181
  The compile speeds for this compiler have been optimized pretty much to the max. There are three compile settings available to the user. The default is `--quick`. Aggressive optimizations are done with `--release` which will aggressively optimize for size. The speed difference between `--release` and `--quick` seems negligable. But `--release` will produce a ~1/3 smaller binary. There is also `--debug`, which will include symbols necessary for debugging and getting the C++ function symbols working correctly in the browser during step through debugging. It works better than expected, but don't expect to have gdb or msvc debugger level of debugging experience.
120
182
 
@@ -124,22 +186,22 @@ The compilation to wasm will happen under a lock. Removing this lock requires re
124
186
 
125
187
  Simple syntax errors will be caught by the pre-processing step. This happens without a lock to reduce the single lock bottleneck.
126
188
 
127
- # Sketch Cache
189
+ ## Sketch Cache
128
190
 
129
191
  Sketchs are aggresively finger-printed and stored in a cache. White space, comments, and other superficial data will be stripped out during pre-processing and minimization for fingerprinting. This source file decimation is only used for finger
130
192
  printing while the actual source files are sent to compiler to preserve line numbers and file names.
131
193
 
132
194
  This pre-processing done is done via gcc and special regex's and will happen without a lock. This will allow you to have extremely quick recompiles for whitespace and changes in comments even if the compiler is executing under it's lock.
133
195
 
134
- # Local compiles
196
+ ## Local compiles
135
197
 
136
198
  If the web-compiler get's congested then it's recommend that you run the compiler locally. This requires docker and will be invoked whenever you pass in `--local`. This will first pull the most recent Docker image of the Fastled compiler, launching a webserver and then connecting to it with the client once it's been up.
137
199
 
138
- # Auto updates
200
+ ## Auto updates
139
201
 
140
202
  In server mode the git repository will be cloned as a side repo and then periodically updated and rsync'd to the src directory. This allows a long running instance to stay updated.
141
203
 
142
- ### Wasm compatibility with Arduino sketchs
204
+ ## Compatibility with Arduino sketchs
143
205
 
144
206
  The compatibility is actually pretty good. Most simple sketchs should compile out of the box. Even some of the avr platform includes are stubbed out to make it work. The familiar `digitalWrite()`, `Serial.println()` and other common functions work. Although `digitalRead()` will always return 0 and `analogRead()` will return random numbers.
145
207
 
@@ -163,6 +225,7 @@ A: A big chunk of space is being used by unnecessary javascript `emscripten` is
163
225
 
164
226
  # Revisions
165
227
 
228
+ * 1.1.38 - Cleanup the `fastled.Api` object and streamline for general use.
166
229
  * 1.1.37 - `Test.test_examples()` is now unit tested to work correctly.
167
230
  * 1.1.36 - We now have an api. `from fastled import Api` and `from fastled import Test` for testing.
168
231
  * 1.1.35 - When searching for files cap the limit at a high amount to prevent hang.
@@ -1,10 +1,9 @@
1
- fastled/__init__.py,sha256=PWN2ftSaLElmfJkYyv0gmGKZgBTljVv8D58Di0JGmeY,2539
1
+ fastled/__init__.py,sha256=P9XIl4QcR1-RO-RBTPitME_vHzDDq4qFwkZDyEKvE0k,3001
2
2
  fastled/app.py,sha256=3xg7oVD-UYnKPU8SAY-Cs5UnAYdwpdpuEFRR2N8P1Tg,1787
3
- fastled/build_mode.py,sha256=joMwsV4K1y_LijT4gEAcjx69RZBoe_KmFmHZdPYbL_4,631
4
3
  fastled/cli.py,sha256=CNR_pQR0sNVPNuv8e_nmm-0PI8sU-eUBUgnWgWkzW9c,237
5
- fastled/client_server.py,sha256=rre250O1uCx6JFi_nn6fhKUncgKOw3F7BgN9O9wbCEM,11440
6
- fastled/compile_server.py,sha256=QxkXLpj9q7BWhPbS2NPeFF4WRne-358o-8fg4VEDH1o,2427
7
- fastled/compile_server_impl.py,sha256=cB5WZ9znNhCFe2HKl-p1ZonfYKeaJOUyV3uHfkQtTZk,8481
4
+ fastled/client_server.py,sha256=p9mbhgwA3UERrH-Hig0dLzpOpL3Y3xzIBCw3UMpoxPo,11518
5
+ fastled/compile_server.py,sha256=g95J9ZtNG-GiBLIO_qyg8f5FJfnrUJxjxZY-cb3d9lY,2517
6
+ fastled/compile_server_impl.py,sha256=ClBLtFHB0ucaT8tAJfI6o3bJ-LRnXc4Pxy7bVKnFiww,8803
8
7
  fastled/docker_manager.py,sha256=zBCFGk2P3_bS7_SUQ5j2lpsOS3RvIzXYkrJXC6xP69k,25383
9
8
  fastled/filewatcher.py,sha256=LwEQJkqADsArZyY499RLAer6JjJyDwaQBcAvT7xmp3c,6708
10
9
  fastled/keyboard.py,sha256=Zz_ggxOUTX2XQEy6K6kAoorVlUev4wEk9Awpvv9aStA,3241
@@ -17,14 +16,14 @@ fastled/settings.py,sha256=3eMKv0tLXgIQ0CFDboIp_l5_71rzIIyWg353YjnYJnc,323
17
16
  fastled/sketch.py,sha256=483TrrIdZJfo1MIu5FkD-V5OGmOfHmsZ2f6VvNsJBJM,3299
18
17
  fastled/spinner.py,sha256=VHxmvB92P0Z_zYxRajb5HiNmkHHvZ5dG7hKtZltzpcs,867
19
18
  fastled/string_diff.py,sha256=UR1oRhg9lsPzAG4bn_MwJMCn0evP5AigkBiwLiI9fgA,1354
20
- fastled/types.py,sha256=4uSSuOUhZptTreor6CXXGSk-FIMOdwHfdvFI-4Yx6AY,475
19
+ fastled/types.py,sha256=brmCvXeGBYcw0Sket_5I1XGOvrLMfKnhm7ZVbi0oDnI,1098
21
20
  fastled/util.py,sha256=t4M3NFMhnCzfYbLvIyJi0RdFssZqbTN_vVIaej1WV-U,265
22
- fastled/web_compile.py,sha256=0jXFeej-YhOxcjIau8Ru8qEu-ULlsFjaufbqKYUUXjQ,10312
21
+ fastled/web_compile.py,sha256=05PeLJ77QQC6PUKjDhsntBmyBola6QQIfF2k-zjYNE4,10261
23
22
  fastled/assets/example.txt,sha256=lTBovRjiz0_TgtAtbA1C5hNi2ffbqnNPqkKg6UiKCT8,54
24
23
  fastled/test/examples.py,sha256=EDXb6KastKOOWzew99zrpmcNcXTcAtYi8eud6F1pnWA,980
25
- fastled-1.1.37.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
26
- fastled-1.1.37.dist-info/METADATA,sha256=2_Eusq7JNju_ZOcwRSWmACJv6vY69A48T2hFs3kbSLE,15329
27
- fastled-1.1.37.dist-info/WHEEL,sha256=0VNUDWQJzfRahYI3neAhz2UVbRCtztpN5dPHAGvmGXc,109
28
- fastled-1.1.37.dist-info/entry_points.txt,sha256=RCwmzCSOS4-C2i9EziANq7Z2Zb4KFnEMR1FQC0bBwAw,101
29
- fastled-1.1.37.dist-info/top_level.txt,sha256=Bbv5kpJpZhWNCvDF4K0VcvtBSDMa8B7PTOrZa9CezHY,8
30
- fastled-1.1.37.dist-info/RECORD,,
24
+ fastled-1.1.38.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
25
+ fastled-1.1.38.dist-info/METADATA,sha256=hbt9CNXAOkHvxi7MasDzU9-RXBWab-mYTvoSItJWNJw,16912
26
+ fastled-1.1.38.dist-info/WHEEL,sha256=0VNUDWQJzfRahYI3neAhz2UVbRCtztpN5dPHAGvmGXc,109
27
+ fastled-1.1.38.dist-info/entry_points.txt,sha256=RCwmzCSOS4-C2i9EziANq7Z2Zb4KFnEMR1FQC0bBwAw,101
28
+ fastled-1.1.38.dist-info/top_level.txt,sha256=Bbv5kpJpZhWNCvDF4K0VcvtBSDMa8B7PTOrZa9CezHY,8
29
+ fastled-1.1.38.dist-info/RECORD,,
fastled/build_mode.py DELETED
@@ -1,25 +0,0 @@
1
- import argparse
2
- from enum import Enum
3
-
4
-
5
- class BuildMode(Enum):
6
- DEBUG = "DEBUG"
7
- QUICK = "QUICK"
8
- RELEASE = "RELEASE"
9
-
10
- @classmethod
11
- def from_string(cls, mode_str: str) -> "BuildMode":
12
- try:
13
- return cls[mode_str.upper()]
14
- except KeyError:
15
- valid_modes = [mode.name for mode in cls]
16
- raise ValueError(f"BUILD_MODE must be one of {valid_modes}, got {mode_str}")
17
-
18
-
19
- def get_build_mode(args: argparse.Namespace) -> BuildMode:
20
- if args.debug:
21
- return BuildMode.DEBUG
22
- elif args.release:
23
- return BuildMode.RELEASE
24
- else:
25
- return BuildMode.QUICK