fastled 1.4.29__py3-none-any.whl → 1.4.31__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/__version__.py CHANGED
@@ -1,6 +1,6 @@
1
1
  # IMPORTANT! There's a bug in github which will REJECT any version update
2
2
  # that has any other change in the repo. Please bump the version as the
3
3
  # ONLY change in a commit, or else the pypi update and the release will fail.
4
- __version__ = "1.4.29"
4
+ __version__ = "1.4.31"
5
5
 
6
6
  __version_url_latest__ = "https://raw.githubusercontent.com/zackees/fastled-wasm/refs/heads/main/src/fastled/__version__.py"
@@ -281,6 +281,33 @@ class PlaywrightBrowser:
281
281
  # Start polling loop that tracks browser window changes and adjusts viewport only
282
282
  asyncio.create_task(self._track_browser_adjust_viewport())
283
283
 
284
+ async def _get_window_info(self) -> dict[str, int] | None:
285
+ """Get browser window dimensions information.
286
+
287
+ Returns:
288
+ Dictionary containing window dimensions or None if unable to retrieve
289
+ """
290
+ if self.page is None:
291
+ return None
292
+
293
+ try:
294
+ return await self.page.evaluate(
295
+ """
296
+ () => {
297
+ return {
298
+ outerWidth: window.outerWidth,
299
+ outerHeight: window.outerHeight,
300
+ innerWidth: window.innerWidth,
301
+ innerHeight: window.innerHeight,
302
+ contentWidth: document.documentElement.clientWidth,
303
+ contentHeight: document.documentElement.clientHeight
304
+ };
305
+ }
306
+ """
307
+ )
308
+ except Exception:
309
+ return None
310
+
284
311
  async def _track_browser_adjust_viewport(self) -> None:
285
312
  """Track browser window changes and adjust viewport accordingly.
286
313
 
@@ -288,62 +315,85 @@ class PlaywrightBrowser:
288
315
  the viewport size to match, maintaining the browser window dimensions
289
316
  while ensuring the content area matches the sketch requirements.
290
317
  """
291
- last_viewport = None
292
- consecutive_same_count = 0
293
- max_consecutive_same = 5
318
+
319
+ last_outer_size = None
294
320
 
295
321
  while not self._should_exit.is_set():
296
322
  try:
297
- await asyncio.sleep(0.5) # Poll every 500ms
298
-
299
- if self.page is None:
300
- continue
323
+ # Wait 1 second between polls
324
+ await asyncio.sleep(0.25) # Poll every 500ms
301
325
 
302
- # Get current viewport size
303
- current_viewport = await self.page.evaluate(
304
- """
305
- () => ({
306
- width: window.innerWidth,
307
- height: window.innerHeight
308
- })
309
- """
310
- )
326
+ # Check if page is still alive
327
+ if self.page is None or self.page.is_closed():
328
+ print("[PYTHON] Page closed, signaling exit")
329
+ self._should_exit.set()
330
+ return
311
331
 
312
- # Check if viewport changed
313
- if current_viewport != last_viewport:
314
- last_viewport = current_viewport
315
- consecutive_same_count = 0
332
+ # Try to get window outer dimensions for context
333
+ try:
334
+ window_info = await self._get_window_info()
316
335
 
317
- print(
318
- f"[PYTHON] Viewport: {current_viewport['width']}x{current_viewport['height']}"
319
- )
336
+ if window_info:
320
337
 
321
- # Try to get window outer dimensions for context
322
- try:
323
- window_info = await self.page.evaluate(
324
- """
325
- () => ({
326
- outerWidth: window.outerWidth,
327
- outerHeight: window.outerHeight,
328
- screenX: window.screenX,
329
- screenY: window.screenY
330
- })
331
- """
338
+ current_outer = (
339
+ window_info["outerWidth"],
340
+ window_info["outerHeight"],
332
341
  )
333
342
 
334
- print(
335
- f"[PYTHON] Window: {window_info['outerWidth']}x{window_info['outerHeight']} at ({window_info['screenX']}, {window_info['screenY']})"
336
- )
343
+ # Print current state occasionally
344
+ if last_outer_size is None or current_outer != last_outer_size:
337
345
 
338
- except Exception:
339
- pass
346
+ if last_outer_size is not None:
347
+ print("[PYTHON] *** BROWSER WINDOW RESIZED ***")
348
+ print(
349
+ f"[PYTHON] Outer window changed from {last_outer_size[0]}x{last_outer_size[1]} to {current_outer[0]}x{current_outer[1]}"
350
+ )
340
351
 
341
- else:
342
- consecutive_same_count += 1
343
- if consecutive_same_count >= max_consecutive_same:
344
- # Viewport hasn't changed for a while, reduce polling frequency
345
- await asyncio.sleep(2.0)
346
- consecutive_same_count = 0
352
+ last_outer_size = current_outer
353
+
354
+ # Set viewport to match the outer window size
355
+ outer_width = int(window_info["outerWidth"])
356
+ outer_height = int(window_info["outerHeight"])
357
+
358
+ print(
359
+ f"[PYTHON] Setting viewport to match outer window size: {outer_width}x{outer_height}"
360
+ )
361
+
362
+ await self.page.set_viewport_size(
363
+ {"width": outer_width, "height": outer_height}
364
+ )
365
+ print("[PYTHON] Viewport set successfully")
366
+
367
+ # Wait briefly for browser to settle after viewport change
368
+ # await asyncio.sleep(2)
369
+
370
+ # Query the actual window dimensions after the viewport change
371
+ updated_window_info = await self._get_window_info()
372
+
373
+ if updated_window_info:
374
+ print(
375
+ f"[PYTHON] Updated window info: {updated_window_info}"
376
+ )
377
+
378
+ # Update our tracking with the actual final outer size
379
+ last_outer_size = (
380
+ updated_window_info["outerWidth"],
381
+ updated_window_info["outerHeight"],
382
+ )
383
+ print(
384
+ f"[PYTHON] Updated last_outer_size to actual final size: {last_outer_size}"
385
+ )
386
+ else:
387
+ print("[PYTHON] Could not get updated window info")
388
+
389
+ except Exception as e:
390
+ warnings.warn(
391
+ f"[PYTHON] Could not get browser window info: {e}. Assuming browser is not closed."
392
+ )
393
+ import traceback
394
+
395
+ traceback.print_exc()
396
+ pass
347
397
 
348
398
  # Get the browser window information periodically
349
399
  try:
@@ -370,6 +420,7 @@ class PlaywrightBrowser:
370
420
 
371
421
  except Exception as e:
372
422
  error_message = str(e)
423
+ warnings.warn(f"[PYTHON] Error in browser tracking: {error_message}")
373
424
  # Be EXTREMELY conservative about browser close detection
374
425
  # Only trigger shutdown on very specific errors that definitively indicate browser closure
375
426
  browser_definitely_closed = any(
@@ -394,6 +445,9 @@ class PlaywrightBrowser:
394
445
  browser_state_indicates_closed = self.context.closed
395
446
  except Exception:
396
447
  # If we can't check the state, don't assume it's closed
448
+ warnings.warn(
449
+ f"[PYTHON] Could not check browser state: {e}. Assuming browser is not closed."
450
+ )
397
451
  browser_state_indicates_closed = False
398
452
 
399
453
  if browser_definitely_closed or browser_state_indicates_closed:
@@ -413,6 +467,7 @@ class PlaywrightBrowser:
413
467
  # Add a small delay to prevent tight error loops
414
468
  await asyncio.sleep(1.0)
415
469
  continue
470
+ warnings.warn("[PYTHON] Browser tracking loop exited.")
416
471
 
417
472
  async def wait_for_close(self) -> None:
418
473
  """Wait for the browser to be closed."""
@@ -479,6 +534,7 @@ class PlaywrightBrowser:
479
534
  _thread.interrupt_main()
480
535
  except Exception as e:
481
536
  print(f"[PYTHON] Error closing Playwright browser: {e}")
537
+ self._should_exit.set()
482
538
 
483
539
 
484
540
  def run_playwright_browser(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastled
3
- Version: 1.4.29
3
+ Version: 1.4.31
4
4
  Summary: FastLED Wasm Compiler
5
5
  Home-page: https://github.com/zackees/fastled-wasm
6
6
  Maintainer: Zachary Vorhies
@@ -1,6 +1,6 @@
1
1
  fastled/__init__.py,sha256=dahiY41HLLotTjqmpVJmXSwUEp8NKqoZ57jt55hBLa4,7667
2
2
  fastled/__main__.py,sha256=OcKv2ER1_iQAsZzLIUb3C8hRC9L2clNOhCrjpshrlf4,336
3
- fastled/__version__.py,sha256=BhMJ4-HBEDFT1L33HMiHtXnXxXsyzCwgIwkSRBEmt2g,373
3
+ fastled/__version__.py,sha256=QbUGBqPvYjKxBz8WmNRAWARUDFJgLwViAnEWwQSxhko,373
4
4
  fastled/app.py,sha256=yZP_UbLLyteBkiYJQQLvqHmH14xwrayGKbL7jtjY6g4,6225
5
5
  fastled/args.py,sha256=uYNM4ALYaB6vj4q4ypfvrgK7tNCEgvC_MBAyGyIeEx8,3885
6
6
  fastled/cli.py,sha256=drgR2AOxVrj3QEz58iiKscYAumbbin2vIV-k91VCOAA,561
@@ -37,14 +37,14 @@ fastled/assets/example.txt,sha256=lTBovRjiz0_TgtAtbA1C5hNi2ffbqnNPqkKg6UiKCT8,54
37
37
  fastled/assets/localhost-key.pem,sha256=Q-CNO_UoOd8fFNN4ljcnqwUeCMhzTplRjLO2x0pYRlU,1704
38
38
  fastled/assets/localhost.pem,sha256=QTwUtTwjYWbm9m3pHW2IlK2nFZJ8b0pppxPjhgVZqQo,1619
39
39
  fastled/playwright/chrome_extension_downloader.py,sha256=48YyQrsuK1TVXPuAvRGzqkQJnx0991Ka6OVUo1A58zU,7079
40
- fastled/playwright/playwright_browser.py,sha256=XZsL66wZETiRAdRPpJQE29j2Awy1EReJCPoAy-8H4qs,30713
40
+ fastled/playwright/playwright_browser.py,sha256=lhoHG0NakpkqfO-EELhPKXFB9NcjssrqtGQdM8dHOgY,33385
41
41
  fastled/site/build.py,sha256=2YKU_UWKlJdGnjdbAbaL0co6kceFMSTVYwH1KCmgPZA,13987
42
42
  fastled/site/examples.py,sha256=s6vj2zJc6BfKlnbwXr1QWY1mzuDBMt6j5MEBOWjO_U8,155
43
43
  fastled/test/can_run_local_docker_tests.py,sha256=LEuUbHctRhNNFWcvnz2kEGmjDJeXO4c3kNpizm3yVJs,400
44
44
  fastled/test/examples.py,sha256=GfaHeY1E8izBl6ZqDVjz--RHLyVR4NRnQ5pBesCFJFY,1673
45
- fastled-1.4.29.dist-info/licenses/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
46
- fastled-1.4.29.dist-info/METADATA,sha256=tu9nTnfgfRUHAN7XM_mCtji7aMD2oX7Uuf8agWa03oI,32441
47
- fastled-1.4.29.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
48
- fastled-1.4.29.dist-info/entry_points.txt,sha256=RCwmzCSOS4-C2i9EziANq7Z2Zb4KFnEMR1FQC0bBwAw,101
49
- fastled-1.4.29.dist-info/top_level.txt,sha256=Bbv5kpJpZhWNCvDF4K0VcvtBSDMa8B7PTOrZa9CezHY,8
50
- fastled-1.4.29.dist-info/RECORD,,
45
+ fastled-1.4.31.dist-info/licenses/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
46
+ fastled-1.4.31.dist-info/METADATA,sha256=E2WfnzRWr27Ck28pbTZxhcsJ3i0_X9-Tg0DteCkUWsc,32441
47
+ fastled-1.4.31.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
48
+ fastled-1.4.31.dist-info/entry_points.txt,sha256=RCwmzCSOS4-C2i9EziANq7Z2Zb4KFnEMR1FQC0bBwAw,101
49
+ fastled-1.4.31.dist-info/top_level.txt,sha256=Bbv5kpJpZhWNCvDF4K0VcvtBSDMa8B7PTOrZa9CezHY,8
50
+ fastled-1.4.31.dist-info/RECORD,,