pyloid 0.24.9__tar.gz → 0.25.0__tar.gz
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.
- {pyloid-0.24.9 → pyloid-0.25.0}/PKG-INFO +1 -1
- {pyloid-0.24.9 → pyloid-0.25.0}/pyproject.toml +1 -1
- {pyloid-0.24.9 → pyloid-0.25.0}/src/pyloid/browser_window.py +2 -31
- {pyloid-0.24.9 → pyloid-0.25.0}/src/pyloid/pyloid.py +20 -28
- {pyloid-0.24.9 → pyloid-0.25.0}/src/pyloid/rpc.py +29 -1
- {pyloid-0.24.9 → pyloid-0.25.0}/LICENSE +0 -0
- {pyloid-0.24.9 → pyloid-0.25.0}/README.md +0 -0
- {pyloid-0.24.9 → pyloid-0.25.0}/src/pyloid/__init__.py +0 -0
- {pyloid-0.24.9 → pyloid-0.25.0}/src/pyloid/api.py +0 -0
- {pyloid-0.24.9 → pyloid-0.25.0}/src/pyloid/autostart.py +0 -0
- {pyloid-0.24.9 → pyloid-0.25.0}/src/pyloid/custom/titlebar.py +0 -0
- {pyloid-0.24.9 → pyloid-0.25.0}/src/pyloid/filewatcher.py +0 -0
- {pyloid-0.24.9 → pyloid-0.25.0}/src/pyloid/js_api/base.py +0 -0
- {pyloid-0.24.9 → pyloid-0.25.0}/src/pyloid/js_api/event_api.py +0 -0
- {pyloid-0.24.9 → pyloid-0.25.0}/src/pyloid/js_api/window_api.py +0 -0
- {pyloid-0.24.9 → pyloid-0.25.0}/src/pyloid/monitor.py +0 -0
- {pyloid-0.24.9 → pyloid-0.25.0}/src/pyloid/serve.py +0 -0
- {pyloid-0.24.9 → pyloid-0.25.0}/src/pyloid/store.py +0 -0
- {pyloid-0.24.9 → pyloid-0.25.0}/src/pyloid/thread_pool.py +0 -0
- {pyloid-0.24.9 → pyloid-0.25.0}/src/pyloid/timer.py +0 -0
- {pyloid-0.24.9 → pyloid-0.25.0}/src/pyloid/tray.py +0 -0
- {pyloid-0.24.9 → pyloid-0.25.0}/src/pyloid/url_interceptor.py +0 -0
- {pyloid-0.24.9 → pyloid-0.25.0}/src/pyloid/utils.py +0 -0
|
@@ -45,7 +45,6 @@ from PySide6.QtWebEngineCore import (
|
|
|
45
45
|
import threading
|
|
46
46
|
|
|
47
47
|
# from .url_interceptor import CustomUrlInterceptor
|
|
48
|
-
from .rpc import PyloidRPC
|
|
49
48
|
|
|
50
49
|
if TYPE_CHECKING:
|
|
51
50
|
from .pyloid import _Pyloid, Pyloid
|
|
@@ -316,7 +315,6 @@ class _BrowserWindow:
|
|
|
316
315
|
context_menu: bool = False,
|
|
317
316
|
dev_tools: bool = False,
|
|
318
317
|
# js_apis: List[PyloidAPI] = [],
|
|
319
|
-
rpc: Optional[PyloidRPC] = None,
|
|
320
318
|
transparent: bool = False,
|
|
321
319
|
):
|
|
322
320
|
###########################################################################################
|
|
@@ -324,15 +322,9 @@ class _BrowserWindow:
|
|
|
324
322
|
self._window = QMainWindow()
|
|
325
323
|
self.web_view = CustomWebEngineView(self)
|
|
326
324
|
|
|
327
|
-
|
|
328
|
-
self.rpc = rpc
|
|
329
|
-
self.rpc_url = rpc.url
|
|
330
|
-
else:
|
|
331
|
-
self.rpc = None
|
|
332
|
-
self.rpc_url = None
|
|
325
|
+
|
|
333
326
|
|
|
334
327
|
# interceptor ( all url request )
|
|
335
|
-
# self.interceptor = CustomUrlInterceptor(rpc_url=self.rpc_url)
|
|
336
328
|
# self.web_view.page().setUrlRequestInterceptor(self.interceptor)
|
|
337
329
|
|
|
338
330
|
self._window.closeEvent = self.closeEvent # Override closeEvent method
|
|
@@ -349,7 +341,7 @@ class _BrowserWindow:
|
|
|
349
341
|
self.context_menu = context_menu
|
|
350
342
|
self.dev_tools = dev_tools
|
|
351
343
|
|
|
352
|
-
self.js_apis = [BaseAPI(self.id, self.app.data, self.app, self.
|
|
344
|
+
self.js_apis = [BaseAPI(self.id, self.app.data, self.app, self.app.server.url)]
|
|
353
345
|
|
|
354
346
|
# for js_api in js_apis:
|
|
355
347
|
# self.js_apis.append(js_api)
|
|
@@ -357,25 +349,6 @@ class _BrowserWindow:
|
|
|
357
349
|
self.shortcuts = {}
|
|
358
350
|
self.close_on_load = True
|
|
359
351
|
self.splash_screen = None
|
|
360
|
-
###########################################################################################
|
|
361
|
-
# if the RPC server is not present, do not add it
|
|
362
|
-
if not self.rpc:
|
|
363
|
-
return
|
|
364
|
-
|
|
365
|
-
self.rpc.pyloid = self.app.pyloid_wrapper
|
|
366
|
-
# self.rpc.window = self.window_wrapper
|
|
367
|
-
|
|
368
|
-
# prevent duplicate RPC servers
|
|
369
|
-
if self.rpc in self.app.rpc_servers:
|
|
370
|
-
return
|
|
371
|
-
|
|
372
|
-
# add the RPC server
|
|
373
|
-
self.app.rpc_servers.add(self.rpc)
|
|
374
|
-
|
|
375
|
-
# Start unique RPC servers
|
|
376
|
-
server_thread = threading.Thread(target=self.rpc.start, daemon=True)
|
|
377
|
-
server_thread.start()
|
|
378
|
-
###########################################################################################
|
|
379
352
|
|
|
380
353
|
def _set_custom_frame(
|
|
381
354
|
self,
|
|
@@ -2125,7 +2098,6 @@ class BrowserWindow(QObject):
|
|
|
2125
2098
|
frame: bool = True,
|
|
2126
2099
|
context_menu: bool = False,
|
|
2127
2100
|
dev_tools: bool = False,
|
|
2128
|
-
rpc: Optional[PyloidRPC] = None,
|
|
2129
2101
|
transparent: bool = False,
|
|
2130
2102
|
):
|
|
2131
2103
|
super().__init__()
|
|
@@ -2140,7 +2112,6 @@ class BrowserWindow(QObject):
|
|
|
2140
2112
|
frame,
|
|
2141
2113
|
context_menu,
|
|
2142
2114
|
dev_tools,
|
|
2143
|
-
rpc,
|
|
2144
2115
|
transparent,
|
|
2145
2116
|
)
|
|
2146
2117
|
self.command_signal.connect(self._handle_command)
|
|
@@ -32,7 +32,6 @@ from PySide6.QtCore import QEventLoop
|
|
|
32
32
|
from typing import Any, Set
|
|
33
33
|
from platformdirs import PlatformDirs
|
|
34
34
|
from .store import Store
|
|
35
|
-
from .rpc import PyloidRPC
|
|
36
35
|
import threading
|
|
37
36
|
import signal
|
|
38
37
|
|
|
@@ -100,6 +99,7 @@ class _Pyloid(QApplication):
|
|
|
100
99
|
pyloid_wrapper: "Pyloid",
|
|
101
100
|
app_name,
|
|
102
101
|
single_instance=True,
|
|
102
|
+
server=None,
|
|
103
103
|
data=None,
|
|
104
104
|
):
|
|
105
105
|
"""
|
|
@@ -132,7 +132,6 @@ class _Pyloid(QApplication):
|
|
|
132
132
|
self.data = data
|
|
133
133
|
|
|
134
134
|
self.windows_dict: Dict[str, BrowserWindow] = {} # 윈도우 ID를 키로 사용하는 딕셔너리
|
|
135
|
-
self.server = None
|
|
136
135
|
|
|
137
136
|
self.app_name = app_name
|
|
138
137
|
self.icon = None
|
|
@@ -171,7 +170,14 @@ class _Pyloid(QApplication):
|
|
|
171
170
|
|
|
172
171
|
self.dirs = PlatformDirs(self.app_name, appauthor=False)
|
|
173
172
|
|
|
174
|
-
|
|
173
|
+
|
|
174
|
+
###################################################
|
|
175
|
+
# Pyloid Server Integration
|
|
176
|
+
if server:
|
|
177
|
+
self.server = server
|
|
178
|
+
else:
|
|
179
|
+
self.server = None
|
|
180
|
+
###################################################
|
|
175
181
|
|
|
176
182
|
# def set_theme(self, theme: Literal["system", "dark", "light"]):
|
|
177
183
|
# """
|
|
@@ -242,7 +248,6 @@ class _Pyloid(QApplication):
|
|
|
242
248
|
frame: bool = True,
|
|
243
249
|
context_menu: bool = False,
|
|
244
250
|
dev_tools: bool = False,
|
|
245
|
-
rpc: Optional[PyloidRPC] = None,
|
|
246
251
|
transparent: bool = False,
|
|
247
252
|
) -> BrowserWindow:
|
|
248
253
|
"""
|
|
@@ -266,8 +271,6 @@ class _Pyloid(QApplication):
|
|
|
266
271
|
Whether to use the context menu (default is False)
|
|
267
272
|
dev_tools : bool, optional
|
|
268
273
|
Whether to use developer tools (default is False)
|
|
269
|
-
rpc : PyloidRPC, optional
|
|
270
|
-
The RPC server instance to be used in the window
|
|
271
274
|
transparent : bool, optional
|
|
272
275
|
Whether the window is transparent (default is False)
|
|
273
276
|
|
|
@@ -292,7 +295,6 @@ class _Pyloid(QApplication):
|
|
|
292
295
|
frame,
|
|
293
296
|
context_menu,
|
|
294
297
|
dev_tools,
|
|
295
|
-
rpc,
|
|
296
298
|
transparent,
|
|
297
299
|
)
|
|
298
300
|
self.windows_dict[window._window.id] = window
|
|
@@ -315,17 +317,9 @@ class _Pyloid(QApplication):
|
|
|
315
317
|
```
|
|
316
318
|
"""
|
|
317
319
|
|
|
318
|
-
#
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
# if window._window.rpc is not None:
|
|
322
|
-
# rpc_servers.add(window._window.rpc)
|
|
323
|
-
|
|
324
|
-
# # Start unique RPC servers
|
|
325
|
-
# for rpc in rpc_servers:
|
|
326
|
-
# server_thread = threading.Thread(target=rpc.start, daemon=True)
|
|
327
|
-
# server_thread.start()
|
|
328
|
-
|
|
320
|
+
# Start Pyloid Integrated Server
|
|
321
|
+
if self.server:
|
|
322
|
+
self.server.run()
|
|
329
323
|
|
|
330
324
|
if is_production():
|
|
331
325
|
sys.exit(self.exec())
|
|
@@ -341,10 +335,10 @@ class _Pyloid(QApplication):
|
|
|
341
335
|
# Another instance is already running
|
|
342
336
|
sys.exit(1)
|
|
343
337
|
|
|
344
|
-
# Create a new server
|
|
345
|
-
self.
|
|
346
|
-
self.
|
|
347
|
-
self.
|
|
338
|
+
# Create a new Single Instance server
|
|
339
|
+
self.single_instance_server = QLocalServer()
|
|
340
|
+
self.single_instance_server.listen(self.app_name)
|
|
341
|
+
self.single_instance_server.newConnection.connect(self._handle_new_connection)
|
|
348
342
|
|
|
349
343
|
def _handle_new_connection(self):
|
|
350
344
|
"""Handles new connections for the single instance server."""
|
|
@@ -1616,6 +1610,7 @@ class Pyloid(QObject):
|
|
|
1616
1610
|
self,
|
|
1617
1611
|
app_name: str,
|
|
1618
1612
|
single_instance: bool = True,
|
|
1613
|
+
server = None,
|
|
1619
1614
|
# data: Optional[Dict[str, Any]] = None,
|
|
1620
1615
|
):
|
|
1621
1616
|
"""
|
|
@@ -1631,12 +1626,14 @@ class Pyloid(QObject):
|
|
|
1631
1626
|
The name of the application.
|
|
1632
1627
|
single_instance : bool, optional
|
|
1633
1628
|
Determines whether to run as a single instance. (Default is True)
|
|
1629
|
+
server : optional
|
|
1630
|
+
The pyloid server instance to be used in the application
|
|
1634
1631
|
"""
|
|
1635
1632
|
super().__init__()
|
|
1636
1633
|
|
|
1637
1634
|
self.data = None # 나중에 데이터 필요 시 수정
|
|
1638
1635
|
|
|
1639
|
-
self.app = _Pyloid(self, app_name, single_instance, self.data)
|
|
1636
|
+
self.app = _Pyloid(self, app_name, single_instance, server, self.data)
|
|
1640
1637
|
|
|
1641
1638
|
self.command_signal.connect(self._handle_command)
|
|
1642
1639
|
|
|
@@ -1657,7 +1654,6 @@ class Pyloid(QObject):
|
|
|
1657
1654
|
frame=params.get("frame", True),
|
|
1658
1655
|
context_menu=params.get("context_menu", False),
|
|
1659
1656
|
dev_tools=params.get("dev_tools", False),
|
|
1660
|
-
rpc=params.get("rpc", None),
|
|
1661
1657
|
transparent=params.get("transparent", False),
|
|
1662
1658
|
)
|
|
1663
1659
|
result = window
|
|
@@ -1833,7 +1829,6 @@ class Pyloid(QObject):
|
|
|
1833
1829
|
frame: bool = True,
|
|
1834
1830
|
context_menu: bool = False,
|
|
1835
1831
|
dev_tools: bool = False,
|
|
1836
|
-
rpc: Optional[PyloidRPC] = None,
|
|
1837
1832
|
transparent: bool = False,
|
|
1838
1833
|
) -> BrowserWindow:
|
|
1839
1834
|
"""
|
|
@@ -1857,8 +1852,6 @@ class Pyloid(QObject):
|
|
|
1857
1852
|
Whether to use the context menu (default is False)
|
|
1858
1853
|
dev_tools : bool, optional
|
|
1859
1854
|
Whether to use developer tools (default is False)
|
|
1860
|
-
rpc : PyloidRPC, optional
|
|
1861
|
-
The RPC server instance to be used in the window
|
|
1862
1855
|
transparent : bool, optional
|
|
1863
1856
|
Whether the window is transparent (default is False)
|
|
1864
1857
|
|
|
@@ -1881,7 +1874,6 @@ class Pyloid(QObject):
|
|
|
1881
1874
|
"frame": frame,
|
|
1882
1875
|
"context_menu": context_menu,
|
|
1883
1876
|
"dev_tools": dev_tools,
|
|
1884
|
-
"rpc": rpc,
|
|
1885
1877
|
"transparent": transparent,
|
|
1886
1878
|
}
|
|
1887
1879
|
return self.execute_command("create_window", params)
|
|
@@ -220,7 +220,7 @@ class PyloidRPC:
|
|
|
220
220
|
|
|
221
221
|
# Store the original function
|
|
222
222
|
self._functions[rpc_name] = func
|
|
223
|
-
log.info(f"RPC function registered: {rpc_name}")
|
|
223
|
+
# log.info(f"RPC function registered: {rpc_name}")
|
|
224
224
|
|
|
225
225
|
@wraps(func)
|
|
226
226
|
async def wrapper(*args, _pyloid_window_id=None, **kwargs):
|
|
@@ -518,3 +518,31 @@ class PyloidRPC:
|
|
|
518
518
|
except Exception as e:
|
|
519
519
|
log.exception(f"Failed to start or run the server: {e}")
|
|
520
520
|
raise
|
|
521
|
+
|
|
522
|
+
def run(self):
|
|
523
|
+
"""
|
|
524
|
+
Runs start_async in a separate thread.
|
|
525
|
+
|
|
526
|
+
This method is useful when you want to start the aiohttp server in the background
|
|
527
|
+
without blocking the main thread. It creates a new thread, sets up a new asyncio event loop
|
|
528
|
+
in that thread, and starts the asynchronous server. The thread is marked as daemon so that
|
|
529
|
+
it will not prevent the program from exiting if only daemon threads remain.
|
|
530
|
+
"""
|
|
531
|
+
import asyncio
|
|
532
|
+
|
|
533
|
+
def _run_asyncio():
|
|
534
|
+
# Create a new event loop for this thread.
|
|
535
|
+
loop = asyncio.new_event_loop()
|
|
536
|
+
# Set the newly created event loop as the current event loop for this thread.
|
|
537
|
+
asyncio.set_event_loop(loop)
|
|
538
|
+
# Start the asynchronous server; this coroutine will set up the server.
|
|
539
|
+
loop.run_until_complete(self.start_async())
|
|
540
|
+
# Keep the event loop running forever to handle incoming requests.
|
|
541
|
+
loop.run_forever()
|
|
542
|
+
|
|
543
|
+
# Create a new thread to run the event loop and server in the background.
|
|
544
|
+
# The thread is set as a daemon so it will not block program exit.
|
|
545
|
+
server_thread = threading.Thread(target=_run_asyncio, daemon=True)
|
|
546
|
+
# Start the background server thread.
|
|
547
|
+
server_thread.start()
|
|
548
|
+
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|