pyloid 0.23.10__tar.gz → 0.23.12__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.23.10 → pyloid-0.23.12}/PKG-INFO +1 -1
- {pyloid-0.23.10 → pyloid-0.23.12}/pyproject.toml +1 -1
- {pyloid-0.23.10 → pyloid-0.23.12}/src/pyloid/browser_window.py +11 -3
- {pyloid-0.23.10 → pyloid-0.23.12}/src/pyloid/pyloid.py +4 -1
- {pyloid-0.23.10 → pyloid-0.23.12}/src/pyloid/rpc.py +30 -10
- {pyloid-0.23.10 → pyloid-0.23.12}/LICENSE +0 -0
- {pyloid-0.23.10 → pyloid-0.23.12}/README.md +0 -0
- {pyloid-0.23.10 → pyloid-0.23.12}/src/pyloid/__init__.py +0 -0
- {pyloid-0.23.10 → pyloid-0.23.12}/src/pyloid/api.py +0 -0
- {pyloid-0.23.10 → pyloid-0.23.12}/src/pyloid/autostart.py +0 -0
- {pyloid-0.23.10 → pyloid-0.23.12}/src/pyloid/custom/titlebar.py +0 -0
- {pyloid-0.23.10 → pyloid-0.23.12}/src/pyloid/filewatcher.py +0 -0
- {pyloid-0.23.10 → pyloid-0.23.12}/src/pyloid/js_api/base.py +0 -0
- {pyloid-0.23.10 → pyloid-0.23.12}/src/pyloid/js_api/event_api.py +0 -0
- {pyloid-0.23.10 → pyloid-0.23.12}/src/pyloid/js_api/window_api.py +0 -0
- {pyloid-0.23.10 → pyloid-0.23.12}/src/pyloid/monitor.py +0 -0
- {pyloid-0.23.10 → pyloid-0.23.12}/src/pyloid/serve.py +0 -0
- {pyloid-0.23.10 → pyloid-0.23.12}/src/pyloid/store.py +0 -0
- {pyloid-0.23.10 → pyloid-0.23.12}/src/pyloid/thread_pool.py +0 -0
- {pyloid-0.23.10 → pyloid-0.23.12}/src/pyloid/timer.py +0 -0
- {pyloid-0.23.10 → pyloid-0.23.12}/src/pyloid/tray.py +0 -0
- {pyloid-0.23.10 → pyloid-0.23.12}/src/pyloid/url_interceptor.py +0 -0
- {pyloid-0.23.10 → pyloid-0.23.12}/src/pyloid/utils.py +0 -0
@@ -48,7 +48,7 @@ import threading
|
|
48
48
|
from .rpc import PyloidRPC
|
49
49
|
|
50
50
|
if TYPE_CHECKING:
|
51
|
-
from .pyloid import _Pyloid
|
51
|
+
from .pyloid import _Pyloid, Pyloid
|
52
52
|
|
53
53
|
|
54
54
|
class CustomWebPage(QWebEnginePage):
|
@@ -300,6 +300,7 @@ class _BrowserWindow:
|
|
300
300
|
def __init__(
|
301
301
|
self,
|
302
302
|
app: "_Pyloid",
|
303
|
+
window_wrapper: "BrowserWindow",
|
303
304
|
title: str = "pyloid app",
|
304
305
|
width: int = 800,
|
305
306
|
height: int = 600,
|
@@ -316,6 +317,7 @@ class _BrowserWindow:
|
|
316
317
|
self._window = QMainWindow()
|
317
318
|
self.web_view = CustomWebEngineView(self)
|
318
319
|
|
320
|
+
|
319
321
|
if rpc:
|
320
322
|
self.rpc = rpc
|
321
323
|
self.rpc_url = rpc.url
|
@@ -330,6 +332,7 @@ class _BrowserWindow:
|
|
330
332
|
self._window.closeEvent = self.closeEvent # Override closeEvent method
|
331
333
|
###########################################################################################
|
332
334
|
self.app = app
|
335
|
+
self.window_wrapper = window_wrapper
|
333
336
|
self.title = title
|
334
337
|
self.width = width
|
335
338
|
self.height = height
|
@@ -347,11 +350,14 @@ class _BrowserWindow:
|
|
347
350
|
self.shortcuts = {}
|
348
351
|
self.close_on_load = True
|
349
352
|
self.splash_screen = None
|
350
|
-
###########################################################################################
|
353
|
+
###########################################################################################
|
351
354
|
# RPC 서버가 없으면 추가하지 않음
|
352
355
|
if not self.rpc:
|
353
356
|
return;
|
354
357
|
|
358
|
+
self.rpc.pyloid = self.app.pyloid_wrapper
|
359
|
+
# self.rpc.window = self.window_wrapper
|
360
|
+
|
355
361
|
# RPC 서버 중복 방지
|
356
362
|
if self.rpc in self.app.rpc_servers:
|
357
363
|
return;
|
@@ -362,6 +368,8 @@ class _BrowserWindow:
|
|
362
368
|
# Start unique RPC servers
|
363
369
|
server_thread = threading.Thread(target=self.rpc.start, daemon=True)
|
364
370
|
server_thread.start()
|
371
|
+
###########################################################################################
|
372
|
+
|
365
373
|
|
366
374
|
def _set_custom_frame(
|
367
375
|
self,
|
@@ -2052,7 +2060,7 @@ class BrowserWindow(QObject):
|
|
2052
2060
|
):
|
2053
2061
|
super().__init__()
|
2054
2062
|
self._window = _BrowserWindow(
|
2055
|
-
app, title, width, height, x, y, frame, context_menu, dev_tools, rpc
|
2063
|
+
app, self, title, width, height, x, y, frame, context_menu, dev_tools, rpc
|
2056
2064
|
)
|
2057
2065
|
self.command_signal.connect(self._handle_command)
|
2058
2066
|
|
@@ -87,6 +87,7 @@ class _WindowController(QObject):
|
|
87
87
|
class _Pyloid(QApplication):
|
88
88
|
def __init__(
|
89
89
|
self,
|
90
|
+
pyloid_wrapper: "Pyloid",
|
90
91
|
app_name,
|
91
92
|
single_instance=True,
|
92
93
|
data=None,
|
@@ -115,6 +116,8 @@ class _Pyloid(QApplication):
|
|
115
116
|
```
|
116
117
|
"""
|
117
118
|
super().__init__(sys.argv)
|
119
|
+
|
120
|
+
self.pyloid_wrapper = pyloid_wrapper
|
118
121
|
|
119
122
|
self.data = data
|
120
123
|
|
@@ -1681,7 +1684,7 @@ class Pyloid(QObject):
|
|
1681
1684
|
|
1682
1685
|
self.data = None # 나중에 데이터 필요 시 수정
|
1683
1686
|
|
1684
|
-
self.app = _Pyloid(app_name, single_instance, self.data)
|
1687
|
+
self.app = _Pyloid(self, app_name, single_instance, self.data)
|
1685
1688
|
|
1686
1689
|
self.command_signal.connect(self._handle_command)
|
1687
1690
|
|
@@ -130,7 +130,7 @@ class PyloidRPC:
|
|
130
130
|
self._app = web.Application()
|
131
131
|
|
132
132
|
self.pyloid: Optional["Pyloid"] = None
|
133
|
-
self.window: Optional["BrowserWindow"] = None
|
133
|
+
# self.window: Optional["BrowserWindow"] = None
|
134
134
|
|
135
135
|
# CORS 설정 추가
|
136
136
|
cors = aiohttp_cors.setup(self._app, defaults={
|
@@ -177,12 +177,12 @@ class PyloidRPC:
|
|
177
177
|
Examples
|
178
178
|
--------
|
179
179
|
```python
|
180
|
-
from pyloid.rpc import PyloidRPC
|
180
|
+
from pyloid.rpc import PyloidRPC, RPCContext
|
181
181
|
|
182
182
|
rpc = PyloidRPC()
|
183
183
|
|
184
184
|
@rpc.method()
|
185
|
-
async def add(ctx, a: int, b: int) -> int:
|
185
|
+
async def add(ctx: RPCContext, a: int, b: int) -> int:
|
186
186
|
# Access the application and window through ctx.pyloid and ctx.window
|
187
187
|
if ctx.window:
|
188
188
|
print(f"Window title: {ctx.window.title}")
|
@@ -205,16 +205,13 @@ class PyloidRPC:
|
|
205
205
|
log.info(f"RPC function registered: {rpc_name}")
|
206
206
|
|
207
207
|
@wraps(func)
|
208
|
-
async def wrapper(*args, **kwargs):
|
209
|
-
# If the function has a 'ctx' parameter and it's not provided, inject the context object
|
208
|
+
async def wrapper(*args, _pyloid_window_id=None, **kwargs):
|
210
209
|
if has_ctx_param and 'ctx' not in kwargs:
|
211
210
|
ctx = RPCContext(
|
212
211
|
pyloid=self.pyloid,
|
213
|
-
window=self.
|
212
|
+
window=self.pyloid.get_window_by_id(_pyloid_window_id)
|
214
213
|
)
|
215
214
|
kwargs['ctx'] = ctx
|
216
|
-
|
217
|
-
# Call the original function
|
218
215
|
return await func(*args, **kwargs)
|
219
216
|
return wrapper
|
220
217
|
return decorator
|
@@ -316,10 +313,33 @@ class PyloidRPC:
|
|
316
313
|
|
317
314
|
try:
|
318
315
|
log.debug(f"Executing RPC method: {method_name}(params={params})")
|
316
|
+
|
317
|
+
# 함수의 서명 분석하여 ctx 매개변수 유무 확인
|
318
|
+
sig = inspect.signature(func)
|
319
|
+
has_ctx_param = 'ctx' in sig.parameters
|
320
|
+
|
321
|
+
# ctx 매개변수가 있으면 컨텍스트 객체 생성
|
322
|
+
if has_ctx_param and isinstance(params, dict) and 'ctx' not in params:
|
323
|
+
ctx = RPCContext(
|
324
|
+
pyloid=self.pyloid,
|
325
|
+
window=self.pyloid.get_window_by_id(request_id)
|
326
|
+
)
|
327
|
+
# 딕셔너리 형태로 params 사용할 때
|
328
|
+
params = params.copy() # 원본 params 복사
|
329
|
+
params['ctx'] = ctx
|
330
|
+
|
319
331
|
# Call the function with positional or keyword arguments
|
320
332
|
if isinstance(params, list):
|
321
|
-
|
322
|
-
|
333
|
+
# 리스트 형태로 params 사용할 때 처리 필요
|
334
|
+
if has_ctx_param:
|
335
|
+
ctx = RPCContext(pyloid=self.pyloid, window=self.pyloid.get_window_by_id(request_id))
|
336
|
+
result = await func(ctx, *params, request_id=request_id)
|
337
|
+
else:
|
338
|
+
result = await func(*params, request_id=request_id)
|
339
|
+
else: # isinstance(params, dict)
|
340
|
+
internal_window_id = request_id # 기존 request_id에서 이름만 변경
|
341
|
+
params = params.copy()
|
342
|
+
params['_pyloid_window_id'] = internal_window_id
|
323
343
|
result = await func(**params)
|
324
344
|
|
325
345
|
# 5. Format Success Response (only for non-notification requests)
|
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
|