fastled 1.4.4__py3-none-any.whl → 1.4.6__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 +1 -1
- fastled/playwright_browser.py +95 -97
- {fastled-1.4.4.dist-info → fastled-1.4.6.dist-info}/METADATA +1 -1
- {fastled-1.4.4.dist-info → fastled-1.4.6.dist-info}/RECORD +8 -8
- {fastled-1.4.4.dist-info → fastled-1.4.6.dist-info}/WHEEL +0 -0
- {fastled-1.4.4.dist-info → fastled-1.4.6.dist-info}/entry_points.txt +0 -0
- {fastled-1.4.4.dist-info → fastled-1.4.6.dist-info}/licenses/LICENSE +0 -0
- {fastled-1.4.4.dist-info → fastled-1.4.6.dist-info}/top_level.txt +0 -0
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.
|
4
|
+
__version__ = "1.4.6"
|
5
5
|
|
6
6
|
__version_url_latest__ = "https://raw.githubusercontent.com/zackees/fastled-wasm/refs/heads/main/src/fastled/__version__.py"
|
fastled/playwright_browser.py
CHANGED
@@ -17,7 +17,8 @@ from typing import Any
|
|
17
17
|
# Set custom Playwright browser installation path
|
18
18
|
PLAYWRIGHT_DIR = Path.home() / ".fastled" / "playwright"
|
19
19
|
PLAYWRIGHT_DIR.mkdir(parents=True, exist_ok=True)
|
20
|
-
|
20
|
+
# Use absolute path and normalize for Windows compatibility
|
21
|
+
os.environ["PLAYWRIGHT_BROWSERS_PATH"] = str(PLAYWRIGHT_DIR.resolve())
|
21
22
|
|
22
23
|
try:
|
23
24
|
from playwright.async_api import Browser, Page, async_playwright
|
@@ -44,7 +45,7 @@ class PlaywrightBrowser:
|
|
44
45
|
Args:
|
45
46
|
headless: Whether to run the browser in headless mode
|
46
47
|
"""
|
47
|
-
if not
|
48
|
+
if not is_playwright_available():
|
48
49
|
raise ImportError(
|
49
50
|
"Playwright is not installed. Install with: pip install fastled[full]"
|
50
51
|
)
|
@@ -56,106 +57,92 @@ class PlaywrightBrowser:
|
|
56
57
|
self.playwright: Any = None
|
57
58
|
self._should_exit = asyncio.Event()
|
58
59
|
|
59
|
-
|
60
|
-
"""
|
61
|
-
|
62
|
-
|
60
|
+
def _detect_device_scale_factor(self) -> float | None:
|
61
|
+
"""Detect the system's device scale factor for natural browser behavior.
|
62
|
+
|
63
|
+
Returns:
|
64
|
+
The detected device scale factor, or None if detection fails or
|
65
|
+
the value is outside reasonable bounds (0.5-4.0).
|
66
|
+
"""
|
67
|
+
try:
|
68
|
+
import platform
|
69
|
+
|
70
|
+
if platform.system() == "Windows":
|
71
|
+
import winreg
|
63
72
|
|
64
|
-
if self.browser is None and self.playwright is not None:
|
65
|
-
# Try Chrome first, then Firefox, then WebKit
|
66
|
-
try:
|
67
|
-
self.browser = await self.playwright.chromium.launch(
|
68
|
-
headless=self.headless,
|
69
|
-
args=["--disable-web-security", "--allow-running-insecure-content"],
|
70
|
-
)
|
71
|
-
except Exception:
|
72
73
|
try:
|
73
|
-
|
74
|
-
|
74
|
+
key = winreg.OpenKey(
|
75
|
+
winreg.HKEY_CURRENT_USER, r"Control Panel\Desktop\WindowMetrics"
|
75
76
|
)
|
76
|
-
|
77
|
-
|
78
|
-
|
77
|
+
dpi, _ = winreg.QueryValueEx(key, "AppliedDPI")
|
78
|
+
winreg.CloseKey(key)
|
79
|
+
device_scale_factor = dpi / 96.0
|
80
|
+
|
81
|
+
# Validate the scale factor is within reasonable bounds
|
82
|
+
if 0.5 <= device_scale_factor <= 4.0:
|
83
|
+
print(
|
84
|
+
f"[PYTHON] Detected Windows DPI scaling: {device_scale_factor:.2f}"
|
85
|
+
)
|
86
|
+
return device_scale_factor
|
87
|
+
else:
|
88
|
+
print(
|
89
|
+
f"[PYTHON] Detected scale factor {device_scale_factor:.2f} outside reasonable bounds"
|
90
|
+
)
|
91
|
+
return None
|
92
|
+
|
93
|
+
except (OSError, FileNotFoundError):
|
94
|
+
print(
|
95
|
+
"[PYTHON] Could not detect Windows DPI, using browser default"
|
79
96
|
)
|
97
|
+
return None
|
98
|
+
else:
|
99
|
+
# Future: Add support for other platforms (macOS, Linux) here
|
100
|
+
print(
|
101
|
+
f"[PYTHON] Device scale detection not implemented for {platform.system()}"
|
102
|
+
)
|
103
|
+
return None
|
80
104
|
|
81
|
-
|
82
|
-
|
83
|
-
|
105
|
+
except Exception as e:
|
106
|
+
print(f"[PYTHON] DPI detection failed: {e}")
|
107
|
+
return None
|
84
108
|
|
85
|
-
|
109
|
+
async def start(self) -> None:
|
110
|
+
"""Start the Playwright browser."""
|
111
|
+
if self.browser is None:
|
112
|
+
if is_playwright_available():
|
113
|
+
from playwright.async_api import async_playwright
|
86
114
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
user32.ReleaseDC(0, dc)
|
100
|
-
device_scale_factor = dpi / 96.0 # 96 DPI is 100% scaling
|
101
|
-
except Exception:
|
102
|
-
# Fallback: try alternative method
|
103
|
-
try:
|
104
|
-
import tkinter as tk
|
105
|
-
|
106
|
-
root = tk.Tk()
|
107
|
-
device_scale_factor = root.winfo_fpixels("1i") / 96.0
|
108
|
-
root.destroy()
|
109
|
-
except Exception:
|
110
|
-
pass
|
111
|
-
elif platform.system() == "Darwin": # macOS
|
112
|
-
# On macOS, try to get the display scaling
|
113
|
-
try:
|
114
|
-
import subprocess
|
115
|
-
|
116
|
-
result = subprocess.run(
|
117
|
-
["system_profiler", "SPDisplaysDataType"],
|
118
|
-
capture_output=True,
|
119
|
-
text=True,
|
120
|
-
timeout=5,
|
121
|
-
)
|
122
|
-
if "Retina" in result.stdout or "2x" in result.stdout:
|
123
|
-
device_scale_factor = 2.0
|
124
|
-
elif "3x" in result.stdout:
|
125
|
-
device_scale_factor = 3.0
|
126
|
-
except Exception:
|
127
|
-
pass
|
128
|
-
elif platform.system() == "Linux":
|
129
|
-
# On Linux, try to get display scaling from environment or system
|
130
|
-
try:
|
131
|
-
import os
|
132
|
-
|
133
|
-
# Try GDK scaling first
|
134
|
-
gdk_scale = os.environ.get("GDK_SCALE")
|
135
|
-
if gdk_scale:
|
136
|
-
device_scale_factor = float(gdk_scale)
|
137
|
-
else:
|
138
|
-
# Try QT scaling
|
139
|
-
qt_scale = os.environ.get("QT_SCALE_FACTOR")
|
140
|
-
if qt_scale:
|
141
|
-
device_scale_factor = float(qt_scale)
|
142
|
-
except Exception:
|
143
|
-
pass
|
144
|
-
except Exception:
|
145
|
-
# If all detection methods fail, default to 1.0
|
146
|
-
device_scale_factor = 1.0
|
115
|
+
self.playwright = async_playwright()
|
116
|
+
playwright = await self.playwright.start()
|
117
|
+
self.browser = await playwright.chromium.launch(
|
118
|
+
headless=self.headless,
|
119
|
+
args=[
|
120
|
+
"--disable-dev-shm-usage",
|
121
|
+
"--disable-web-security",
|
122
|
+
"--allow-running-insecure-content",
|
123
|
+
],
|
124
|
+
)
|
125
|
+
else:
|
126
|
+
raise RuntimeError("Playwright is not available")
|
147
127
|
|
148
|
-
|
149
|
-
|
128
|
+
if self.page is None and self.browser is not None:
|
129
|
+
# Detect system device scale factor for natural browser behavior
|
130
|
+
device_scale_factor = self._detect_device_scale_factor()
|
150
131
|
|
151
|
-
|
132
|
+
# Create browser context with detected or default device scale factor
|
133
|
+
if device_scale_factor:
|
134
|
+
context = await self.browser.new_context(
|
135
|
+
device_scale_factor=device_scale_factor
|
136
|
+
)
|
137
|
+
print(
|
138
|
+
f"[PYTHON] Created browser context with device scale factor: {device_scale_factor:.2f}"
|
139
|
+
)
|
140
|
+
else:
|
141
|
+
context = await self.browser.new_context()
|
142
|
+
print(
|
143
|
+
"[PYTHON] Created browser context with default device scale factor"
|
144
|
+
)
|
152
145
|
|
153
|
-
# Create a new browser context with proper device scale factor
|
154
|
-
context = await self.browser.new_context(
|
155
|
-
device_scale_factor=device_scale_factor,
|
156
|
-
# Also ensure viewport scaling is handled properly
|
157
|
-
viewport={"width": 1280, "height": 720} if not self.headless else None,
|
158
|
-
)
|
159
146
|
self.page = await context.new_page()
|
160
147
|
|
161
148
|
async def open_url(self, url: str) -> None:
|
@@ -174,6 +161,15 @@ class PlaywrightBrowser:
|
|
174
161
|
# Wait for the page to load
|
175
162
|
await self.page.wait_for_load_state("networkidle")
|
176
163
|
|
164
|
+
# Verify device scale factor is working correctly
|
165
|
+
try:
|
166
|
+
device_pixel_ratio = await self.page.evaluate("window.devicePixelRatio")
|
167
|
+
print(
|
168
|
+
f"[PYTHON] Verified browser device pixel ratio: {device_pixel_ratio}"
|
169
|
+
)
|
170
|
+
except Exception as e:
|
171
|
+
print(f"[PYTHON] Could not verify device pixel ratio: {e}")
|
172
|
+
|
177
173
|
# Set up auto-resizing functionality if enabled
|
178
174
|
if self.auto_resize:
|
179
175
|
await self._setup_auto_resize()
|
@@ -343,7 +339,7 @@ def run_playwright_browser(url: str, headless: bool = False) -> None:
|
|
343
339
|
url: The URL to open
|
344
340
|
headless: Whether to run in headless mode
|
345
341
|
"""
|
346
|
-
if not
|
342
|
+
if not is_playwright_available():
|
347
343
|
warnings.warn(
|
348
344
|
"Playwright is not installed. Install with: pip install fastled[full]. "
|
349
345
|
"Falling back to default browser."
|
@@ -417,7 +413,7 @@ class PlaywrightBrowserProxy:
|
|
417
413
|
url: The URL to open
|
418
414
|
headless: Whether to run in headless mode
|
419
415
|
"""
|
420
|
-
if not
|
416
|
+
if not is_playwright_available():
|
421
417
|
warnings.warn(
|
422
418
|
"Playwright is not installed. Install with: pip install fastled[full]. "
|
423
419
|
"Falling back to default browser."
|
@@ -505,7 +501,7 @@ def run_playwright_browser_persistent(url: str, headless: bool = False) -> None:
|
|
505
501
|
url: The URL to open
|
506
502
|
headless: Whether to run in headless mode
|
507
503
|
"""
|
508
|
-
if not
|
504
|
+
if not is_playwright_available():
|
509
505
|
return
|
510
506
|
|
511
507
|
async def main():
|
@@ -600,7 +596,7 @@ def install_playwright_browsers() -> bool:
|
|
600
596
|
playwright_dir.mkdir(parents=True, exist_ok=True)
|
601
597
|
|
602
598
|
# Set environment variable for Playwright browser path
|
603
|
-
os.environ["PLAYWRIGHT_BROWSERS_PATH"] = str(playwright_dir)
|
599
|
+
os.environ["PLAYWRIGHT_BROWSERS_PATH"] = str(playwright_dir.resolve())
|
604
600
|
|
605
601
|
from playwright.sync_api import sync_playwright
|
606
602
|
|
@@ -622,7 +618,9 @@ def install_playwright_browsers() -> bool:
|
|
622
618
|
[sys.executable, "-m", "playwright", "install", "chromium"],
|
623
619
|
capture_output=True,
|
624
620
|
text=True,
|
625
|
-
env=dict(
|
621
|
+
env=dict(
|
622
|
+
os.environ, PLAYWRIGHT_BROWSERS_PATH=str(playwright_dir.resolve())
|
623
|
+
),
|
626
624
|
)
|
627
625
|
|
628
626
|
if result.returncode == 0:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
fastled/__init__.py,sha256=l4uDkh_YOd24okNfn6eWjtTYaZ0woeYC7khv-vHMmTM,7775
|
2
2
|
fastled/__main__.py,sha256=OcKv2ER1_iQAsZzLIUb3C8hRC9L2clNOhCrjpshrlf4,336
|
3
|
-
fastled/__version__.py,sha256=
|
3
|
+
fastled/__version__.py,sha256=0BVsV5LOWU3x9pRRh1qJu2YXi4h8zBPbXLYqavV1nu4,372
|
4
4
|
fastled/app.py,sha256=6XOuObi72AUnZXASDOVbcSflr4He0xnIDk5P8nVmVus,6131
|
5
5
|
fastled/args.py,sha256=uCMyRIYM8gFE52O12YKUfA-rwJL8Zxwk_hsH3cusSac,3669
|
6
6
|
fastled/cli.py,sha256=drgR2AOxVrj3QEz58iiKscYAumbbin2vIV-k91VCOAA,561
|
@@ -18,7 +18,7 @@ fastled/live_client.py,sha256=aDZqSWDMpqNaEsT3u1nrBcdeIOItv-L0Gk2A10difLA,3209
|
|
18
18
|
fastled/open_browser.py,sha256=mwjm65p2ydwmsaar7ooH4mhT5_qH_LZvXUpkRPPJ9eA,4881
|
19
19
|
fastled/parse_args.py,sha256=htjap9tWZDJXnJ5upDwcy8EhecJD1uLZwacHR_T5ySs,11518
|
20
20
|
fastled/paths.py,sha256=VsPmgu0lNSCFOoEC0BsTYzDygXqy15AHUfN-tTuzDZA,99
|
21
|
-
fastled/playwright_browser.py,sha256=
|
21
|
+
fastled/playwright_browser.py,sha256=JSR11iGbtAZ-u0GkpUn3_MSuRnvtwmAGgMAOXtu1RNY,22988
|
22
22
|
fastled/print_filter.py,sha256=nc_rqYYdCUPinFycaK7fiQF5PG1up51pmJptR__QyAs,1499
|
23
23
|
fastled/project_init.py,sha256=bBt4DwmW5hZkm9ICt9Qk-0Nr_0JQM7icCgH5Iv-bCQs,3984
|
24
24
|
fastled/select_sketch_directory.py,sha256=-eudwCns3AKj4HuHtSkZAFwbnf005SNL07pOzs9VxnE,1383
|
@@ -40,9 +40,9 @@ fastled/site/build.py,sha256=2YKU_UWKlJdGnjdbAbaL0co6kceFMSTVYwH1KCmgPZA,13987
|
|
40
40
|
fastled/site/examples.py,sha256=s6vj2zJc6BfKlnbwXr1QWY1mzuDBMt6j5MEBOWjO_U8,155
|
41
41
|
fastled/test/can_run_local_docker_tests.py,sha256=LEuUbHctRhNNFWcvnz2kEGmjDJeXO4c3kNpizm3yVJs,400
|
42
42
|
fastled/test/examples.py,sha256=GfaHeY1E8izBl6ZqDVjz--RHLyVR4NRnQ5pBesCFJFY,1673
|
43
|
-
fastled-1.4.
|
44
|
-
fastled-1.4.
|
45
|
-
fastled-1.4.
|
46
|
-
fastled-1.4.
|
47
|
-
fastled-1.4.
|
48
|
-
fastled-1.4.
|
43
|
+
fastled-1.4.6.dist-info/licenses/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
|
44
|
+
fastled-1.4.6.dist-info/METADATA,sha256=yOZDCOkINTohP4m91EUSuO_DGT8UNClV2Z-ySIGH19w,32369
|
45
|
+
fastled-1.4.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
46
|
+
fastled-1.4.6.dist-info/entry_points.txt,sha256=RCwmzCSOS4-C2i9EziANq7Z2Zb4KFnEMR1FQC0bBwAw,101
|
47
|
+
fastled-1.4.6.dist-info/top_level.txt,sha256=Bbv5kpJpZhWNCvDF4K0VcvtBSDMa8B7PTOrZa9CezHY,8
|
48
|
+
fastled-1.4.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|