fastled 1.4.4__py3-none-any.whl → 1.4.5__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 +89 -94
- {fastled-1.4.4.dist-info → fastled-1.4.5.dist-info}/METADATA +1 -1
- {fastled-1.4.4.dist-info → fastled-1.4.5.dist-info}/RECORD +8 -8
- {fastled-1.4.4.dist-info → fastled-1.4.5.dist-info}/WHEEL +0 -0
- {fastled-1.4.4.dist-info → fastled-1.4.5.dist-info}/entry_points.txt +0 -0
- {fastled-1.4.4.dist-info → fastled-1.4.5.dist-info}/licenses/LICENSE +0 -0
- {fastled-1.4.4.dist-info → fastled-1.4.5.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.5"
|
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
@@ -44,7 +44,7 @@ class PlaywrightBrowser:
|
|
44
44
|
Args:
|
45
45
|
headless: Whether to run the browser in headless mode
|
46
46
|
"""
|
47
|
-
if not
|
47
|
+
if not is_playwright_available():
|
48
48
|
raise ImportError(
|
49
49
|
"Playwright is not installed. Install with: pip install fastled[full]"
|
50
50
|
)
|
@@ -56,106 +56,92 @@ class PlaywrightBrowser:
|
|
56
56
|
self.playwright: Any = None
|
57
57
|
self._should_exit = asyncio.Event()
|
58
58
|
|
59
|
-
|
60
|
-
"""
|
61
|
-
|
62
|
-
|
59
|
+
def _detect_device_scale_factor(self) -> float | None:
|
60
|
+
"""Detect the system's device scale factor for natural browser behavior.
|
61
|
+
|
62
|
+
Returns:
|
63
|
+
The detected device scale factor, or None if detection fails or
|
64
|
+
the value is outside reasonable bounds (0.5-4.0).
|
65
|
+
"""
|
66
|
+
try:
|
67
|
+
import platform
|
68
|
+
|
69
|
+
if platform.system() == "Windows":
|
70
|
+
import winreg
|
63
71
|
|
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
72
|
try:
|
73
|
-
|
74
|
-
|
73
|
+
key = winreg.OpenKey(
|
74
|
+
winreg.HKEY_CURRENT_USER, r"Control Panel\Desktop\WindowMetrics"
|
75
75
|
)
|
76
|
-
|
77
|
-
|
78
|
-
|
76
|
+
dpi, _ = winreg.QueryValueEx(key, "AppliedDPI")
|
77
|
+
winreg.CloseKey(key)
|
78
|
+
device_scale_factor = dpi / 96.0
|
79
|
+
|
80
|
+
# Validate the scale factor is within reasonable bounds
|
81
|
+
if 0.5 <= device_scale_factor <= 4.0:
|
82
|
+
print(
|
83
|
+
f"[PYTHON] Detected Windows DPI scaling: {device_scale_factor:.2f}"
|
84
|
+
)
|
85
|
+
return device_scale_factor
|
86
|
+
else:
|
87
|
+
print(
|
88
|
+
f"[PYTHON] Detected scale factor {device_scale_factor:.2f} outside reasonable bounds"
|
89
|
+
)
|
90
|
+
return None
|
91
|
+
|
92
|
+
except (OSError, FileNotFoundError):
|
93
|
+
print(
|
94
|
+
"[PYTHON] Could not detect Windows DPI, using browser default"
|
79
95
|
)
|
96
|
+
return None
|
97
|
+
else:
|
98
|
+
# Future: Add support for other platforms (macOS, Linux) here
|
99
|
+
print(
|
100
|
+
f"[PYTHON] Device scale detection not implemented for {platform.system()}"
|
101
|
+
)
|
102
|
+
return None
|
80
103
|
|
81
|
-
|
82
|
-
|
83
|
-
|
104
|
+
except Exception as e:
|
105
|
+
print(f"[PYTHON] DPI detection failed: {e}")
|
106
|
+
return None
|
84
107
|
|
85
|
-
|
108
|
+
async def start(self) -> None:
|
109
|
+
"""Start the Playwright browser."""
|
110
|
+
if self.browser is None:
|
111
|
+
if is_playwright_available():
|
112
|
+
from playwright.async_api import async_playwright
|
86
113
|
|
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
|
114
|
+
self.playwright = async_playwright()
|
115
|
+
playwright = await self.playwright.start()
|
116
|
+
self.browser = await playwright.chromium.launch(
|
117
|
+
headless=self.headless,
|
118
|
+
args=[
|
119
|
+
"--disable-dev-shm-usage",
|
120
|
+
"--disable-web-security",
|
121
|
+
"--allow-running-insecure-content",
|
122
|
+
],
|
123
|
+
)
|
124
|
+
else:
|
125
|
+
raise RuntimeError("Playwright is not available")
|
147
126
|
|
148
|
-
|
149
|
-
|
127
|
+
if self.page is None and self.browser is not None:
|
128
|
+
# Detect system device scale factor for natural browser behavior
|
129
|
+
device_scale_factor = self._detect_device_scale_factor()
|
150
130
|
|
151
|
-
|
131
|
+
# Create browser context with detected or default device scale factor
|
132
|
+
if device_scale_factor:
|
133
|
+
context = await self.browser.new_context(
|
134
|
+
device_scale_factor=device_scale_factor
|
135
|
+
)
|
136
|
+
print(
|
137
|
+
f"[PYTHON] Created browser context with device scale factor: {device_scale_factor:.2f}"
|
138
|
+
)
|
139
|
+
else:
|
140
|
+
context = await self.browser.new_context()
|
141
|
+
print(
|
142
|
+
"[PYTHON] Created browser context with default device scale factor"
|
143
|
+
)
|
152
144
|
|
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
145
|
self.page = await context.new_page()
|
160
146
|
|
161
147
|
async def open_url(self, url: str) -> None:
|
@@ -174,6 +160,15 @@ class PlaywrightBrowser:
|
|
174
160
|
# Wait for the page to load
|
175
161
|
await self.page.wait_for_load_state("networkidle")
|
176
162
|
|
163
|
+
# Verify device scale factor is working correctly
|
164
|
+
try:
|
165
|
+
device_pixel_ratio = await self.page.evaluate("window.devicePixelRatio")
|
166
|
+
print(
|
167
|
+
f"[PYTHON] Verified browser device pixel ratio: {device_pixel_ratio}"
|
168
|
+
)
|
169
|
+
except Exception as e:
|
170
|
+
print(f"[PYTHON] Could not verify device pixel ratio: {e}")
|
171
|
+
|
177
172
|
# Set up auto-resizing functionality if enabled
|
178
173
|
if self.auto_resize:
|
179
174
|
await self._setup_auto_resize()
|
@@ -343,7 +338,7 @@ def run_playwright_browser(url: str, headless: bool = False) -> None:
|
|
343
338
|
url: The URL to open
|
344
339
|
headless: Whether to run in headless mode
|
345
340
|
"""
|
346
|
-
if not
|
341
|
+
if not is_playwright_available():
|
347
342
|
warnings.warn(
|
348
343
|
"Playwright is not installed. Install with: pip install fastled[full]. "
|
349
344
|
"Falling back to default browser."
|
@@ -417,7 +412,7 @@ class PlaywrightBrowserProxy:
|
|
417
412
|
url: The URL to open
|
418
413
|
headless: Whether to run in headless mode
|
419
414
|
"""
|
420
|
-
if not
|
415
|
+
if not is_playwright_available():
|
421
416
|
warnings.warn(
|
422
417
|
"Playwright is not installed. Install with: pip install fastled[full]. "
|
423
418
|
"Falling back to default browser."
|
@@ -505,7 +500,7 @@ def run_playwright_browser_persistent(url: str, headless: bool = False) -> None:
|
|
505
500
|
url: The URL to open
|
506
501
|
headless: Whether to run in headless mode
|
507
502
|
"""
|
508
|
-
if not
|
503
|
+
if not is_playwright_available():
|
509
504
|
return
|
510
505
|
|
511
506
|
async def main():
|
@@ -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=B4ZqzHwXA9uCBNwRrujcvuXXm2l56Enp2DP18gCaohg,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=acnp_mdADSlCmWJkvQJETHHRsajQjrdHuKiQGT_V6Mc,22868
|
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.5.dist-info/licenses/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
|
44
|
+
fastled-1.4.5.dist-info/METADATA,sha256=FTgtOasheiABxVui1GCO4MXKXxeEFmjh3XVfQ2ydrcQ,32369
|
45
|
+
fastled-1.4.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
46
|
+
fastled-1.4.5.dist-info/entry_points.txt,sha256=RCwmzCSOS4-C2i9EziANq7Z2Zb4KFnEMR1FQC0bBwAw,101
|
47
|
+
fastled-1.4.5.dist-info/top_level.txt,sha256=Bbv5kpJpZhWNCvDF4K0VcvtBSDMa8B7PTOrZa9CezHY,8
|
48
|
+
fastled-1.4.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|