pyloid 0.23.11__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pyloid
3
- Version: 0.23.11
3
+ Version: 0.23.12
4
4
  Summary:
5
5
  Author: aesthetics-of-record
6
6
  Author-email: 111675679+aesthetics-of-record@users.noreply.github.com
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "pyloid"
3
- version = "0.23.11"
3
+ version = "0.23.12"
4
4
  description = ""
5
5
  authors = ["aesthetics-of-record <111675679+aesthetics-of-record@users.noreply.github.com>"]
6
6
  readme = "README.md"
@@ -356,7 +356,7 @@ class _BrowserWindow:
356
356
  return;
357
357
 
358
358
  self.rpc.pyloid = self.app.pyloid_wrapper
359
- self.rpc.window = self.window_wrapper
359
+ # self.rpc.window = self.window_wrapper
360
360
 
361
361
  # RPC 서버 중복 방지
362
362
  if self.rpc in self.app.rpc_servers:
@@ -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.window
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
@@ -325,7 +322,7 @@ class PyloidRPC:
325
322
  if has_ctx_param and isinstance(params, dict) and 'ctx' not in params:
326
323
  ctx = RPCContext(
327
324
  pyloid=self.pyloid,
328
- window=self.window
325
+ window=self.pyloid.get_window_by_id(request_id)
329
326
  )
330
327
  # 딕셔너리 형태로 params 사용할 때
331
328
  params = params.copy() # 원본 params 복사
@@ -335,11 +332,14 @@ class PyloidRPC:
335
332
  if isinstance(params, list):
336
333
  # 리스트 형태로 params 사용할 때 처리 필요
337
334
  if has_ctx_param:
338
- ctx = RPCContext(pyloid=self.pyloid, window=self.window)
339
- result = await func(ctx, *params)
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)
340
337
  else:
341
- result = await func(*params)
338
+ result = await func(*params, request_id=request_id)
342
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
343
343
  result = await func(**params)
344
344
 
345
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