pyloid 0.23.2__tar.gz → 0.23.4__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.2
3
+ Version: 0.23.4
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.2"
3
+ version = "0.23.4"
4
4
  description = ""
5
5
  authors = ["aesthetics-of-record <111675679+aesthetics-of-record@users.noreply.github.com>"]
6
6
  readme = "README.md"
@@ -5,4 +5,4 @@ from .tray import TrayEvent
5
5
  from .timer import PyloidTimer
6
6
  from .serve import pyloid_serve
7
7
 
8
- __all__ = ['Pyloid', 'PyloidAPI', 'Bridge', 'get_production_path', 'is_production', 'TrayEvent', 'PyloidTimer', 'serve']
8
+ __all__ = ['Pyloid']
@@ -43,7 +43,7 @@ from PySide6.QtWebEngineCore import (
43
43
  QWebEngineDesktopMediaRequest,
44
44
  )
45
45
 
46
- from .url_interceptor import CustomUrlInterceptor
46
+ # from .url_interceptor import CustomUrlInterceptor
47
47
  from .rpc import PyloidRPC
48
48
 
49
49
  if TYPE_CHECKING:
@@ -323,8 +323,8 @@ class _BrowserWindow:
323
323
  self.rpc_url = None
324
324
 
325
325
  # interceptor ( all url request )
326
- self.interceptor = CustomUrlInterceptor(rpc_url=self.rpc_url)
327
- self.web_view.page().setUrlRequestInterceptor(self.interceptor)
326
+ # self.interceptor = CustomUrlInterceptor(rpc_url=self.rpc_url)
327
+ # self.web_view.page().setUrlRequestInterceptor(self.interceptor)
328
328
 
329
329
  self._window.closeEvent = self.closeEvent # Override closeEvent method
330
330
  ###########################################################################################
@@ -338,7 +338,7 @@ class _BrowserWindow:
338
338
  self.context_menu = context_menu
339
339
  self.dev_tools = dev_tools
340
340
 
341
- self.js_apis = [BaseAPI(self.id, self.app.data, self.app)]
341
+ self.js_apis = [BaseAPI(self.id, self.app.data, self.app, self.rpc_url)]
342
342
 
343
343
  # for js_api in js_apis:
344
344
  # self.js_apis.append(js_api)
@@ -10,11 +10,12 @@ if TYPE_CHECKING:
10
10
 
11
11
 
12
12
  class BaseAPI(PyloidAPI):
13
- def __init__(self, window_id: str, data: dict, app: "Pyloid"):
13
+ def __init__(self, window_id: str, data: dict, app: "Pyloid", rpc_url: Optional[str] = None):
14
14
  super().__init__()
15
15
  self.window_id: str = window_id
16
16
  self.data: dict = data
17
17
  self.app: "Pyloid" = app
18
+ self.rpc_url: Optional[str] = rpc_url
18
19
 
19
20
  @Bridge(result=dict)
20
21
  def getData(self):
@@ -252,4 +253,9 @@ class BaseAPI(PyloidAPI):
252
253
  """Returns the production path of the application."""
253
254
  return get_production_path(path)
254
255
 
256
+ @Bridge(result=str)
257
+ def getRpcUrl(self):
258
+ """Returns the RPC URL of the application."""
259
+ return self.rpc_url
260
+
255
261
 
@@ -87,6 +87,18 @@ class PyloidRPC:
87
87
  def __init__(self):
88
88
  """
89
89
  Initialize the PyloidRPC server instance.
90
+
91
+ Examples
92
+ --------
93
+ ```python
94
+ from pyloid.rpc import PyloidRPC
95
+
96
+ rpc = PyloidRPC()
97
+
98
+ @rpc.method()
99
+ async def add(a: int, b: int) -> int:
100
+ return a + b
101
+ ```
90
102
  """
91
103
  self._host = "127.0.0.1"
92
104
  self._port = get_free_port()
@@ -115,7 +127,7 @@ class PyloidRPC:
115
127
  self._runner: Optional[web.AppRunner] = None
116
128
  self._site: Optional[web.TCPSite] = None
117
129
 
118
- def rpc(self, name: Optional[str] = None) -> Callable:
130
+ def method(self, name: Optional[str] = None) -> Callable:
119
131
  """
120
132
  Decorator to register an async function as an RPC method.
121
133
 
@@ -136,6 +148,18 @@ class PyloidRPC:
136
148
  If the decorated function is not an async function (`coroutinefunction`).
137
149
  ValueError
138
150
  If an RPC function with the specified name is already registered.
151
+
152
+ Examples
153
+ --------
154
+ ```python
155
+ from pyloid.rpc import PyloidRPC
156
+
157
+ rpc = PyloidRPC()
158
+
159
+ @rpc.method()
160
+ async def add(a: int, b: int) -> int:
161
+ return a + b
162
+ ```
139
163
  """
140
164
  def decorator(func: Callable[..., Coroutine[Any, Any, Any]]):
141
165
  rpc_name = name or func.__name__
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