fastled 1.2.54__py3-none-any.whl → 1.2.55__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
@@ -13,7 +13,7 @@ from .types import BuildMode, CompileResult, CompileServerError
13
13
  # IMPORTANT! There's a bug in github which will REJECT any version update
14
14
  # that has any other change in the repo. Please bump the version as the
15
15
  # ONLY change in a commit, or else the pypi update and the release will fail.
16
- __version__ = "1.2.54"
16
+ __version__ = "1.2.55"
17
17
 
18
18
  DOCKER_FILE = (
19
19
  "https://raw.githubusercontent.com/zackees/fastled-wasm/refs/heads/main/Dockerfile"
fastled/client_server.py CHANGED
@@ -7,7 +7,7 @@ from pathlib import Path
7
7
 
8
8
  from fastled.compile_server import CompileServer
9
9
  from fastled.docker_manager import DockerManager
10
- from fastled.filewatcher import FileWatcherProcess
10
+ from fastled.filewatcher import DebouncedFileWatcherProcess, FileWatcherProcess
11
11
  from fastled.keyboard import SpaceBarWatcher
12
12
  from fastled.open_browser import open_browser_process
13
13
  from fastled.parse_args import Args
@@ -231,9 +231,8 @@ def run_client(
231
231
  return 1
232
232
 
233
233
  excluded_patterns = ["fastled_js"]
234
-
235
- sketch_filewatcher = FileWatcherProcess(
236
- directory, excluded_patterns=excluded_patterns
234
+ debounced_sketch_watcher = DebouncedFileWatcherProcess(
235
+ FileWatcherProcess(directory, excluded_patterns=excluded_patterns),
237
236
  )
238
237
 
239
238
  source_code_watcher: FileWatcherProcess | None = None
@@ -246,7 +245,7 @@ def run_client(
246
245
  def trigger_rebuild_if_sketch_changed(
247
246
  last_compiled_result: CompileResult,
248
247
  ) -> tuple[bool, CompileResult]:
249
- changed_files = sketch_filewatcher.get_all_changes()
248
+ changed_files = debounced_sketch_watcher.get_all_changes()
250
249
  if changed_files:
251
250
  print(f"\nChanges detected in {changed_files}")
252
251
  last_hash_value = last_compiled_result.hash_value
@@ -301,7 +300,9 @@ def run_client(
301
300
  timeout=1.0
302
301
  )
303
302
  file_changes = source_code_watcher.get_all_changes()
304
- sketch_files_changed = sketch_filewatcher.get_all_changes()
303
+ sketch_files_changed = (
304
+ debounced_sketch_watcher.get_all_changes()
305
+ )
305
306
 
306
307
  if file_changes:
307
308
  print(
@@ -331,7 +332,7 @@ def run_client(
331
332
  print(f"Error: {e}")
332
333
  return 1
333
334
  finally:
334
- sketch_filewatcher.stop()
335
+ debounced_sketch_watcher.stop()
335
336
  if compile_server:
336
337
  compile_server.stop()
337
338
  if browser_proc:
fastled/filewatcher.py CHANGED
@@ -208,6 +208,7 @@ class FileWatcherProcess:
208
208
  daemon=True,
209
209
  )
210
210
  self.process.start()
211
+ self.global_debounce = FILE_CHANGED_DEBOUNCE_SECONDS
211
212
 
212
213
  def stop(self):
213
214
  self.process.terminate()
@@ -226,3 +227,72 @@ class FileWatcherProcess:
226
227
  except Empty:
227
228
  break
228
229
  return changed_files
230
+
231
+
232
+ # DEBOUNCE_SECONDS = 4
233
+ # LAST_TIME = 0.0
234
+ # WATCHED_FILES: list[str] = []
235
+
236
+ # def debounced_sketch_filewatcher_get_all_changes() -> list[str]:
237
+ # nonlocal DEBOUNCE_SECONDS
238
+ # nonlocal LAST_TIME
239
+ # nonlocal WATCHED_FILES
240
+ # current_time = time.time()
241
+ # new_files = sketch_filewatcher.get_all_changes()
242
+ # if new_files:
243
+ # WATCHED_FILES.extend(new_files)
244
+ # print(f"Changes detected in {new_files}")
245
+ # LAST_TIME = current_time
246
+ # return []
247
+ # diff = current_time - LAST_TIME
248
+ # if diff > DEBOUNCE_SECONDS and len(WATCHED_FILES) > 0:
249
+ # LAST_TIME = current_time
250
+ # WATCHED_FILES, changed_files = [], WATCHED_FILES
251
+ # changed_files = sorted(list(set(changed_files)))
252
+ # return changed_files
253
+ # return []
254
+
255
+
256
+ class DebouncedFileWatcherProcess:
257
+ """
258
+ Wraps a FileWatcherProcess to batch rapid-fire change events
259
+ and only emit them once the debounce interval has passed.
260
+ """
261
+
262
+ def __init__(
263
+ self,
264
+ watcher: FileWatcherProcess,
265
+ debounce_seconds: float = FILE_CHANGED_DEBOUNCE_SECONDS,
266
+ ) -> None:
267
+ self.watcher = watcher
268
+ self.debounce_seconds = debounce_seconds
269
+ self._last_time = 0.0
270
+ self._watched_files: list[str] = []
271
+
272
+ def get_all_changes(self, timeout: float | None = None) -> list[str]:
273
+ """
274
+ Polls the underlying watcher for raw events, accumulates them,
275
+ and once no new events arrive for `debounce_seconds`, flushes
276
+ a sorted, unique list of paths.
277
+ """
278
+ now = time.time()
279
+ # pull in any new raw events
280
+ new = self.watcher.get_all_changes(timeout=timeout)
281
+ if new:
282
+ self._watched_files.extend(new)
283
+ # reset the window
284
+ self._last_time = now
285
+ return []
286
+
287
+ # if the window has elapsed, flush
288
+ if self._watched_files and (now - self._last_time) > self.debounce_seconds:
289
+ batch = sorted(set(self._watched_files))
290
+ self._watched_files.clear()
291
+ self._last_time = now
292
+ return batch
293
+
294
+ return []
295
+
296
+ def stop(self) -> None:
297
+ """Tear down the underlying watcher process."""
298
+ self.watcher.stop()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastled
3
- Version: 1.2.54
3
+ Version: 1.2.55
4
4
  Summary: FastLED Wasm Compiler
5
5
  Home-page: https://github.com/zackees/fastled-wasm
6
6
  Maintainer: Zachary Vorhies
@@ -1,12 +1,12 @@
1
- fastled/__init__.py,sha256=1tn764qvEIfcjOPi4adfxROxoe-vfxz8R8RB3jyxC78,6734
1
+ fastled/__init__.py,sha256=6kRImRI2Oc4dHucIY5jBajNGE5d3zpUrExS-ZTRUcow,6734
2
2
  fastled/app.py,sha256=Ozn7OJ0rz3CEHsJKMhFLxV7TisRKo4DuFpVhrf5FQNw,3944
3
3
  fastled/cli.py,sha256=FjVr31ht0UPlAcmX-84NwfAGMQHTkrCe4o744jCAxiw,375
4
4
  fastled/cli_test.py,sha256=qJB9yLRFR3OwOwdIWSQ0fQsWLnA37v5pDccufiP_hTs,512
5
- fastled/client_server.py,sha256=JSp2vNjkdvKnMrs-_ic4Qutw61uH1aa6pgXrVQ9BpM4,14792
5
+ fastled/client_server.py,sha256=Pr_b_406XpB6QLrlRMV3mwM82x25s1bIGFU0O0XA3yk,14931
6
6
  fastled/compile_server.py,sha256=ul3eiZNX2wwmInooo3PJC3_kNpdejYVDIo94G3sV9HQ,2941
7
7
  fastled/compile_server_impl.py,sha256=xhC7WBlIfvghgpxAP8VwBeM13NuTA99cI47prODW-IU,9927
8
8
  fastled/docker_manager.py,sha256=VVyfl4HNsSB95nlENuccZFR0qL3Y0ZJgPCFyHKa9A14,31459
9
- fastled/filewatcher.py,sha256=h7GKpJbXSd9XaCXmdqJ5cl_EWoAC7IBmJxlYswSm3cs,7534
9
+ fastled/filewatcher.py,sha256=40XZ2euBg5ZMHsjv8obxHApVAUE5ztUEd7FTGqtgsMc,9826
10
10
  fastled/interactive_srcs.py,sha256=F5nHdJc60xsnmOtnKhngE9JytqGn56PmYw_MVSIX1ac,138
11
11
  fastled/keyboard.py,sha256=UTAsqCn1UMYnB8YDzENiLTj4GeL45tYfEcO7_5fLFEg,3556
12
12
  fastled/live_client.py,sha256=MDauol0mxtXggV1Pv9ahC0Jjg_4wnnV6FjGEtdd9cxU,2763
@@ -28,9 +28,9 @@ fastled/site/build.py,sha256=pjsaeHQQh_Zdh1g5Q78lYlUT7UPDFuNgW5YZkpsPxWc,14436
28
28
  fastled/site/examples.py,sha256=s6vj2zJc6BfKlnbwXr1QWY1mzuDBMt6j5MEBOWjO_U8,155
29
29
  fastled/test/can_run_local_docker_tests.py,sha256=LEuUbHctRhNNFWcvnz2kEGmjDJeXO4c3kNpizm3yVJs,400
30
30
  fastled/test/examples.py,sha256=GfaHeY1E8izBl6ZqDVjz--RHLyVR4NRnQ5pBesCFJFY,1673
31
- fastled-1.2.54.dist-info/licenses/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
32
- fastled-1.2.54.dist-info/METADATA,sha256=O_S9Qgxlm_1ePE727EuyUmmUB0GzrvaIP4etAtHcjgY,21668
33
- fastled-1.2.54.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
34
- fastled-1.2.54.dist-info/entry_points.txt,sha256=RCwmzCSOS4-C2i9EziANq7Z2Zb4KFnEMR1FQC0bBwAw,101
35
- fastled-1.2.54.dist-info/top_level.txt,sha256=Bbv5kpJpZhWNCvDF4K0VcvtBSDMa8B7PTOrZa9CezHY,8
36
- fastled-1.2.54.dist-info/RECORD,,
31
+ fastled-1.2.55.dist-info/licenses/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
32
+ fastled-1.2.55.dist-info/METADATA,sha256=fLJj2AsQnGgflwpxrBCI-Ktt047LhKacc_1mc2Kr0sU,21668
33
+ fastled-1.2.55.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
34
+ fastled-1.2.55.dist-info/entry_points.txt,sha256=RCwmzCSOS4-C2i9EziANq7Z2Zb4KFnEMR1FQC0bBwAw,101
35
+ fastled-1.2.55.dist-info/top_level.txt,sha256=Bbv5kpJpZhWNCvDF4K0VcvtBSDMa8B7PTOrZa9CezHY,8
36
+ fastled-1.2.55.dist-info/RECORD,,