pyloid 0.20.1.dev2__tar.gz → 0.20.2.dev0__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (21) hide show
  1. {pyloid-0.20.1.dev2 → pyloid-0.20.2.dev0}/LICENSE +1 -1
  2. {pyloid-0.20.1.dev2 → pyloid-0.20.2.dev0}/PKG-INFO +4 -2
  3. {pyloid-0.20.1.dev2 → pyloid-0.20.2.dev0}/pyproject.toml +2 -1
  4. {pyloid-0.20.1.dev2 → pyloid-0.20.2.dev0}/src/pyloid/browser_window.py +62 -76
  5. {pyloid-0.20.1.dev2 → pyloid-0.20.2.dev0}/src/pyloid/builder/spec.py +2 -2
  6. {pyloid-0.20.1.dev2 → pyloid-0.20.2.dev0}/README.md +0 -0
  7. {pyloid-0.20.1.dev2 → pyloid-0.20.2.dev0}/src/pyloid/__init__.py +0 -0
  8. {pyloid-0.20.1.dev2 → pyloid-0.20.2.dev0}/src/pyloid/api.py +0 -0
  9. {pyloid-0.20.1.dev2 → pyloid-0.20.2.dev0}/src/pyloid/autostart.py +0 -0
  10. {pyloid-0.20.1.dev2 → pyloid-0.20.2.dev0}/src/pyloid/builder/__init__.py +0 -0
  11. {pyloid-0.20.1.dev2 → pyloid-0.20.2.dev0}/src/pyloid/builder/build_config.schema.json +0 -0
  12. {pyloid-0.20.1.dev2 → pyloid-0.20.2.dev0}/src/pyloid/custom/titlebar.py +0 -0
  13. {pyloid-0.20.1.dev2 → pyloid-0.20.2.dev0}/src/pyloid/filewatcher.py +0 -0
  14. {pyloid-0.20.1.dev2 → pyloid-0.20.2.dev0}/src/pyloid/js_api/event_api.py +0 -0
  15. {pyloid-0.20.1.dev2 → pyloid-0.20.2.dev0}/src/pyloid/js_api/window_api.py +0 -0
  16. {pyloid-0.20.1.dev2 → pyloid-0.20.2.dev0}/src/pyloid/monitor.py +0 -0
  17. {pyloid-0.20.1.dev2 → pyloid-0.20.2.dev0}/src/pyloid/pyloid.py +0 -0
  18. {pyloid-0.20.1.dev2 → pyloid-0.20.2.dev0}/src/pyloid/thread_pool.py +0 -0
  19. {pyloid-0.20.1.dev2 → pyloid-0.20.2.dev0}/src/pyloid/timer.py +0 -0
  20. {pyloid-0.20.1.dev2 → pyloid-0.20.2.dev0}/src/pyloid/tray.py +0 -0
  21. {pyloid-0.20.1.dev2 → pyloid-0.20.2.dev0}/src/pyloid/utils.py +0 -0
@@ -198,4 +198,4 @@ Apache License
198
198
  distributed under the License is distributed on an "AS IS" BASIS,
199
199
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
200
  See the License for the specific language governing permissions and
201
- limitations under the License.
201
+ limitations under the License.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: pyloid
3
- Version: 0.20.1.dev2
3
+ Version: 0.20.2.dev0
4
4
  Summary:
5
5
  Author: aesthetics-of-record
6
6
  Author-email: 111675679+aesthetics-of-record@users.noreply.github.com
@@ -10,6 +10,8 @@ Classifier: Programming Language :: Python :: 3.9
10
10
  Classifier: Programming Language :: Python :: 3.10
11
11
  Classifier: Programming Language :: Python :: 3.11
12
12
  Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Requires-Dist: pyinstaller (>=6.11.1,<7.0.0)
13
15
  Requires-Dist: pyside6 (>=6.8.1,<7.0.0)
14
16
  Description-Content-Type: text/markdown
15
17
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "pyloid"
3
- version = "0.20.1-dev2"
3
+ version = "0.20.2-dev"
4
4
  description = ""
5
5
  authors = ["aesthetics-of-record <111675679+aesthetics-of-record@users.noreply.github.com>"]
6
6
  readme = "README.md"
@@ -11,6 +11,7 @@ packages = [
11
11
  [tool.poetry.dependencies]
12
12
  python = ">=3.9,<3.14"
13
13
  pyside6 = "^6.8.1"
14
+ pyinstaller = "^6.11.1"
14
15
 
15
16
 
16
17
  [build-system]
@@ -11,7 +11,11 @@ from PySide6.QtGui import (
11
11
  QCursor,
12
12
  )
13
13
  from PySide6.QtCore import Qt, QPoint, QUrl, QEvent, QFile
14
- from PySide6.QtWebEngineCore import QWebEnginePage, QWebEngineSettings
14
+ from PySide6.QtWebEngineCore import (
15
+ QWebEnginePage,
16
+ QWebEngineSettings,
17
+ QWebEngineUrlRequestInterceptor,
18
+ )
15
19
  from .api import PyloidAPI
16
20
  import uuid
17
21
  from typing import List, Optional, Dict, Callable
@@ -26,8 +30,7 @@ from PySide6.QtGui import QPixmap, QMovie
26
30
  from PySide6.QtWidgets import QSplashScreen, QLabel
27
31
  from PySide6.QtCore import QSize
28
32
  from typing import TYPE_CHECKING
29
- from PySide6.QtWebEngineCore import QWebEngineSettings, QWebEngineUrlRequestInterceptor
30
- from .utils import get_production_path, is_production
33
+ from PySide6.QtWebEngineCore import QWebEngineSettings
31
34
 
32
35
  if TYPE_CHECKING:
33
36
  from ..pyloid import Pyloid
@@ -41,10 +44,15 @@ class CustomWebPage(QWebEnginePage):
41
44
  self.desktopMediaRequested.connect(self._handleDesktopMediaRequest)
42
45
  self._permission_handlers = {}
43
46
  self._desktop_media_handler = None
47
+ self._url_handlers = {} # URL 핸들러 저장을 위한 딕셔너리 추가
48
+
49
+ # interceptor ( all url request )
50
+ self.interceptor = CustomUrlInterceptor()
51
+ self.profile().setUrlRequestInterceptor(self.interceptor)
44
52
 
45
53
  def _handlePermissionRequest(self, origin: QUrl, feature: QWebEnginePage.Feature):
46
54
  print(origin, feature)
47
-
55
+
48
56
  """Default permission request handler"""
49
57
  if feature in self._permission_handlers:
50
58
  # Execute if a handler is registered
@@ -63,52 +71,41 @@ class CustomWebPage(QWebEnginePage):
63
71
  def _handleDesktopMediaRequest(self, *args, **kwargs):
64
72
  print("Desktop media request received:", args, kwargs)
65
73
 
66
- # def setDesktopMediaHandler(self, handler):
67
- # """desktop media handler"""
68
- # self._desktop_media_handler = handler
74
+ # interceptor ( navigation request )
75
+ def acceptNavigationRequest(self, url, navigation_type, is_main_frame):
76
+ """네비게이션 요청을 처리하는 메서드"""
77
+ print(f"Navigation Request - URL: {url.toString()}")
78
+ print(f"Navigation Type: {navigation_type}")
79
+ print(f"Is Main Frame: {is_main_frame}")
80
+
81
+ # # URL이 구글이 아닐 경우에만 구글로 리다이렉트
82
+ # if "example.com" not in url.toString():
83
+ # self.setUrl(QUrl("https://www.example.com"))
84
+ # return False
85
+
86
+ return True
87
+
88
+ def add_url_handler(self, pattern: str, handler):
89
+ """URL 패턴에 대한 핸들러 등록
90
+
91
+ Parameters:
92
+ -----------
93
+ pattern : str
94
+ 정규표현식 패턴
95
+ handler : callable
96
+ URL을 인자로 받고 bool을 반환해야 함
97
+ True를 반환하면 네비게이션을 허용, False를 반환하면 차단
98
+ """
99
+ import re
100
+
101
+ self._url_handlers[re.compile(pattern)] = handler
102
+
69
103
 
70
- class CustomInterceptor(QWebEngineUrlRequestInterceptor):
71
- def __init__(self, index_path=None):
72
- super().__init__()
73
- self.index_path = get_production_path()
74
- self.last_path = "/"
75
-
104
+ # interceptor ( all url request )
105
+ class CustomUrlInterceptor(QWebEngineUrlRequestInterceptor):
76
106
  def interceptRequest(self, info):
77
- url = info.requestUrl()
78
- navigation_type = info.navigationType()
79
-
80
- print("--------------------------------")
81
-
82
- if navigation_type == QWebEnginePage.NavigationType.NavigationTypeTyped:
83
- print("NavigationTypeTyped")
84
-
85
- if navigation_type == QWebEnginePage.NavigationType.NavigationTypeReload:
86
- print("NavigationTypeReload")
87
-
88
- if navigation_type == QWebEnginePage.NavigationType.NavigationTypeBackForward:
89
- print("NavigationTypeBackForward")
90
-
91
- if navigation_type == QWebEnginePage.NavigationType.NavigationTypeLinkClicked:
92
- print("NavigationTypeLinkClicked")
93
-
94
- if navigation_type == QWebEnginePage.NavigationType.NavigationTypeFormSubmitted:
95
- print("NavigationTypeFormSubmitted")
96
-
97
- if navigation_type == QWebEnginePage.NavigationType.NavigationTypeTyped:
98
- print("NavigationTypeTyped")
99
-
100
- if navigation_type == QWebEnginePage.NavigationType.NavigationTypeOther:
101
- print("NavigationTypeOther")
102
-
103
- print(navigation_type.value)
104
-
107
+ url = info.requestUrl().toString()
105
108
  print(url)
106
- print(url.scheme())
107
- print(url.host())
108
- print(url.url())
109
- print(self.last_path)
110
-
111
- self.last_path = url.path()
112
109
 
113
110
 
114
111
  class CustomWebEngineView(QWebEngineView):
@@ -125,15 +122,15 @@ class CustomWebEngineView(QWebEngineView):
125
122
  self.resize_direction = None
126
123
  self.screen_geometry = self.screen().virtualGeometry()
127
124
  self.is_resizing_enabled = True
128
-
125
+
129
126
  self.setAttribute(Qt.WA_SetCursor, False)
130
-
127
+
131
128
  self.is_in_resize_area = False
132
129
 
133
130
  def mouse_press_event(self, event):
134
131
  if self.parent.frame or not self.is_resizing_enabled:
135
132
  return
136
-
133
+
137
134
  if event.button() == Qt.LeftButton:
138
135
  self.resize_direction = self.get_resize_direction(event.pos())
139
136
  if self.resize_direction:
@@ -148,19 +145,19 @@ class CustomWebEngineView(QWebEngineView):
148
145
  def mouse_move_event(self, event):
149
146
  if self.parent.frame or not self.is_resizing_enabled:
150
147
  return
151
-
148
+
152
149
  # Check resize direction
153
150
  was_in_resize_area = self.is_in_resize_area
154
151
  resize_direction = self.get_resize_direction(event.pos())
155
152
  self.is_in_resize_area = bool(resize_direction)
156
-
153
+
157
154
  if resize_direction and not self.is_resizing:
158
155
  self.set_cursor_for_resize_direction(resize_direction)
159
-
156
+
160
157
  if self.is_resizing:
161
158
  self.resize_window(event.globalPos())
162
159
  return
163
-
160
+
164
161
  # Change cursor when entering/leaving resize area
165
162
  if self.is_in_resize_area != was_in_resize_area:
166
163
  if self.is_in_resize_area:
@@ -173,12 +170,12 @@ class CustomWebEngineView(QWebEngineView):
173
170
  def mouse_release_event(self, event):
174
171
  if self.parent.frame or not self.is_resizing_enabled:
175
172
  return
176
-
173
+
177
174
  if event.button() == Qt.LeftButton:
178
175
  self.is_resizing = False
179
-
176
+
180
177
  if self.resize_direction:
181
- self.unsetCursor()
178
+ self.unsetCursor()
182
179
  self.resize_direction = None
183
180
 
184
181
  self.setAttribute(Qt.WA_SetCursor, False)
@@ -225,7 +222,7 @@ class CustomWebEngineView(QWebEngineView):
225
222
  cursor = Qt.SizeFDiagCursor
226
223
  elif direction in ["right-top", "left-bottom"]:
227
224
  cursor = Qt.SizeBDiagCursor
228
-
225
+
229
226
  if cursor:
230
227
  self.setCursor(cursor)
231
228
  self.setAttribute(Qt.WA_SetCursor, True)
@@ -422,7 +419,7 @@ class BrowserWindow:
422
419
  js_api.window_id = self.id
423
420
  js_api.window = self
424
421
  js_api.app = self.app
425
-
422
+
426
423
  self.channel.registerObject(js_api.__class__.__name__, js_api)
427
424
 
428
425
  self.web_view.page().setWebChannel(self.channel)
@@ -435,17 +432,6 @@ class BrowserWindow:
435
432
 
436
433
  # Set F12 shortcut
437
434
  self.set_dev_tools(self.dev_tools)
438
-
439
- # 프로필 가져오기 및 인터셉터 설정
440
- profile = self.web_view.page().profile()
441
-
442
- # # 기존 인터셉터가 있다면 제거
443
- # if self.interceptor:
444
- # profile.setUrlRequestInterceptor(None)
445
-
446
- # 새 인터셉터 설정
447
- self.interceptor = CustomInterceptor()
448
- profile.setUrlRequestInterceptor(self.interceptor)
449
435
 
450
436
  def _on_load_finished(self, ok):
451
437
  """Handles the event when the web page finishes loading."""
@@ -1942,12 +1928,12 @@ class BrowserWindow:
1942
1928
  def set_desktop_media_handler(self, handler):
1943
1929
  """
1944
1930
  데스크톱 미디어(화면/윈도우) 선택 핸들러를 설정합니다.
1945
-
1931
+
1946
1932
  Parameters
1947
1933
  ----------
1948
1934
  handler : callable
1949
- 요청을 처리할 핸들러 함수. QWebEngineDesktopMediaRequest��� 인자로 받습니다.
1950
-
1935
+ 요청을 처리할 핸들러 함수. QWebEngineDesktopMediaRequest 인자로 받습니다.
1936
+
1951
1937
  Examples
1952
1938
  --------
1953
1939
  ```python
@@ -1955,15 +1941,15 @@ class BrowserWindow:
1955
1941
  # 사용 가능한 화면 목록 출력
1956
1942
  for screen in request.screenList():
1957
1943
  print(f"Screen: {screen.name}")
1958
-
1944
+
1959
1945
  # 사용 가능한 윈도우 목록 출력
1960
1946
  for window in request.windowList():
1961
1947
  print(f"Window: {window.name}")
1962
-
1948
+
1963
1949
  # 첫 번째 화면 선택
1964
1950
  if request.screenList():
1965
1951
  request.selectScreen(request.screenList()[0])
1966
-
1952
+
1967
1953
  window.set_desktop_media_handler(custom_media_handler)
1968
1954
  ```
1969
1955
  """
@@ -210,7 +210,7 @@ exe = EXE(
210
210
  target_arch=None,
211
211
  codesign_identity=None,
212
212
  entitlements_file=None,
213
- icon={config.get('icon', 'src-pyloid/icons/icon.png')}
213
+ icon='{config.get('icon', 'src-pyloid/icons/icon.png')}'
214
214
  )
215
215
  """
216
216
  else:
@@ -231,7 +231,7 @@ exe = EXE(
231
231
  target_arch=None,
232
232
  codesign_identity=None,
233
233
  entitlements_file=None,
234
- icon={config.get('icon', 'src-pyloid/icons/icon.png')}
234
+ icon='{config.get('icon', 'src-pyloid/icons/icon.png')}'
235
235
  )
236
236
 
237
237
  coll = COLLECT(
File without changes