VertexEngine-WebEngine 1.0__py3-none-any.whl → 1.2.dev1__py3-none-any.whl
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.
- VertexEngine/BrowserTools/Tabs.py +80 -0
- VertexEngine/WebEngine/WebEngine.py +70 -18
- VertexEngine/WebView/WebPage.py +12 -27
- VertexEngine/WebView/bridge.py +13 -1
- VertexEngine/WebView/profile.py +11 -0
- VertexEngine/main.py +17 -0
- VertexEngine/test.py +61 -0
- {vertexengine_webengine-1.0.dist-info → vertexengine_webengine-1.2.dev1.dist-info}/METADATA +11 -5
- vertexengine_webengine-1.2.dev1.dist-info/RECORD +11 -0
- {vertexengine_webengine-1.0.dist-info → vertexengine_webengine-1.2.dev1.dist-info}/WHEEL +1 -1
- vertexengine_webengine-1.0.dist-info/RECORD +0 -8
- {vertexengine_webengine-1.0.dist-info → vertexengine_webengine-1.2.dev1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
from PyQt6.QtWidgets import QTabWidget, QToolButton
|
|
2
|
+
from PyQt6.QtCore import QUrl
|
|
3
|
+
from PyQt6.QtGui import QKeySequence, QShortcut
|
|
4
|
+
from PyQt6.QtCore import Qt
|
|
5
|
+
|
|
6
|
+
from WebEngine.WebEngine import WebEngine
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class BrowserTabs(QTabWidget):
|
|
10
|
+
def __init__(self, parent=None):
|
|
11
|
+
super().__init__(parent)
|
|
12
|
+
|
|
13
|
+
self.setTabsClosable(True)
|
|
14
|
+
self.setMovable(True)
|
|
15
|
+
|
|
16
|
+
self.tabCloseRequested.connect(self.close_tab)
|
|
17
|
+
self.currentChanged.connect(self.on_tab_changed)
|
|
18
|
+
|
|
19
|
+
# Keyboard shortcuts
|
|
20
|
+
QShortcut(QKeySequence("Ctrl+T"), self).activated.connect(self.new_tab)
|
|
21
|
+
QShortcut(QKeySequence("Ctrl+W"), self).activated.connect(self.close_current_tab)
|
|
22
|
+
# ➕ New Tab button
|
|
23
|
+
self.new_tab_btn = QToolButton(self)
|
|
24
|
+
self.new_tab_btn.setText("+")
|
|
25
|
+
self.new_tab_btn.setAutoRaise(True)
|
|
26
|
+
self.new_tab_btn.setToolTip("New Tab")
|
|
27
|
+
|
|
28
|
+
self.new_tab_btn.clicked.connect(self.new_tab)
|
|
29
|
+
|
|
30
|
+
self.setCornerWidget(
|
|
31
|
+
self.new_tab_btn,
|
|
32
|
+
Qt.Corner.TopRightCorner
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
self.new_tab("https://www.google.com")
|
|
36
|
+
|
|
37
|
+
# ➕ Create tab
|
|
38
|
+
def new_tab(self, url=None):
|
|
39
|
+
if not isinstance(url, str):
|
|
40
|
+
url = "https://www.google.com"
|
|
41
|
+
|
|
42
|
+
print("🆕 New tab:", url)
|
|
43
|
+
|
|
44
|
+
engine = WebEngine()
|
|
45
|
+
index = self.addTab(engine, "New Tab")
|
|
46
|
+
self.setCurrentIndex(index)
|
|
47
|
+
|
|
48
|
+
engine.load_url(url)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
# ❌ Close tab by index
|
|
52
|
+
def close_tab(self, index):
|
|
53
|
+
if self.count() <= 1:
|
|
54
|
+
return
|
|
55
|
+
|
|
56
|
+
widget = self.widget(index)
|
|
57
|
+
self.removeTab(index)
|
|
58
|
+
widget.deleteLater()
|
|
59
|
+
|
|
60
|
+
# ❌ Close current tab
|
|
61
|
+
def close_current_tab(self):
|
|
62
|
+
self.close_tab(self.currentIndex())
|
|
63
|
+
|
|
64
|
+
def safe_remove(self, index):
|
|
65
|
+
if 0 <= index < self.count():
|
|
66
|
+
self.removeTab(index)
|
|
67
|
+
|
|
68
|
+
def update_tab_title(self, engine, title):
|
|
69
|
+
index = self.indexOf(engine)
|
|
70
|
+
if index != -1:
|
|
71
|
+
self.setTabText(index, title[:24])
|
|
72
|
+
|
|
73
|
+
# 🔀 Tab switch handler
|
|
74
|
+
def on_tab_changed(self, index):
|
|
75
|
+
engine = self.widget(index)
|
|
76
|
+
if not engine:
|
|
77
|
+
return
|
|
78
|
+
|
|
79
|
+
url = engine.url().toString()
|
|
80
|
+
print("🔀 Switched to tab:", url)
|
|
@@ -1,32 +1,84 @@
|
|
|
1
1
|
from PyQt6.QtWebEngineWidgets import QWebEngineView
|
|
2
|
+
from PyQt6.QtGui import QKeySequence, QShortcut
|
|
2
3
|
from PyQt6.QtWebChannel import QWebChannel
|
|
3
4
|
from PyQt6.QtCore import QUrl
|
|
4
|
-
|
|
5
|
-
from
|
|
6
|
-
from
|
|
7
|
-
from VertexEngine.WebView.bridge import JSBridge
|
|
8
|
-
|
|
5
|
+
from WebView.profile import WebProfile
|
|
6
|
+
from WebView.WebPage import WebPage
|
|
7
|
+
from WebView.bridge import JSBridge
|
|
9
8
|
|
|
10
9
|
class WebEngine(QWebEngineView):
|
|
11
10
|
def __init__(self, parent=None):
|
|
12
11
|
super().__init__(parent)
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
self.
|
|
13
|
+
self.profile = WebProfile(parent=self)
|
|
14
|
+
self.webpage = WebPage(self.profile, self)
|
|
15
|
+
self.setPage(self.webpage)
|
|
16
16
|
|
|
17
|
-
#
|
|
18
|
-
self.
|
|
19
|
-
self.
|
|
17
|
+
# JS Bridge
|
|
18
|
+
self.channel = QWebChannel()
|
|
19
|
+
self.bridge = JSBridge(self.webpage)
|
|
20
|
+
self.channel.registerObject("bridge", self.bridge)
|
|
21
|
+
self.webpage.setWebChannel(self.channel)
|
|
20
22
|
|
|
21
|
-
#
|
|
22
|
-
self.
|
|
23
|
+
# DevTools
|
|
24
|
+
self._devtools = None
|
|
25
|
+
QShortcut(QKeySequence("Ctrl+Shift+I"), self).activated.connect(self.toggle_devtools)
|
|
23
26
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
self.load_home()
|
|
28
|
+
|
|
29
|
+
def toggle_devtools(self):
|
|
30
|
+
if self._devtools is None:
|
|
31
|
+
self._devtools = QWebEngineView()
|
|
32
|
+
self.webpage.setDevToolsPage(self._devtools.page())
|
|
33
|
+
self._devtools.resize(800, 600)
|
|
34
|
+
self._devtools.show()
|
|
35
|
+
else:
|
|
36
|
+
self._devtools.close()
|
|
37
|
+
self._devtools = None
|
|
38
|
+
|
|
39
|
+
def load_home(self):
|
|
40
|
+
html = """
|
|
41
|
+
<!DOCTYPE html>
|
|
42
|
+
<html>
|
|
43
|
+
<head>
|
|
44
|
+
<meta charset="utf-8">
|
|
45
|
+
<script src="qrc:///qtwebchannel/qwebchannel.js"></script>
|
|
46
|
+
<style>
|
|
47
|
+
body {
|
|
48
|
+
background:#0f0f14;
|
|
49
|
+
color:white;
|
|
50
|
+
font-family:monospace;
|
|
51
|
+
text-align:center;
|
|
52
|
+
margin-top:20vh;
|
|
53
|
+
}
|
|
54
|
+
button {
|
|
55
|
+
padding:10px 20px;
|
|
56
|
+
font-size:16px;
|
|
57
|
+
}
|
|
58
|
+
</style>
|
|
59
|
+
</head>
|
|
60
|
+
<body>
|
|
61
|
+
|
|
62
|
+
<h1>🔥 Vertex WebEngine</h1>
|
|
63
|
+
<button onclick="openSite()">Open example.com</button>
|
|
64
|
+
|
|
65
|
+
<script>
|
|
66
|
+
new QWebChannel(qt.webChannelTransport, channel => {
|
|
67
|
+
window.bridge = channel.objects.bridge;
|
|
68
|
+
bridge.log("Home loaded");
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
function openSite() {
|
|
72
|
+
bridge.emit("open_url", JSON.stringify({
|
|
73
|
+
url: "https://example.com"
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
</script>
|
|
27
77
|
|
|
28
|
-
|
|
29
|
-
|
|
78
|
+
</body>
|
|
79
|
+
</html>
|
|
80
|
+
"""
|
|
81
|
+
self.webpage.setHtml(html, QUrl("https://www.google.com"))
|
|
30
82
|
|
|
31
|
-
def load_url(self, url
|
|
83
|
+
def load_url(self, url):
|
|
32
84
|
self.load(QUrl(url))
|
VertexEngine/WebView/WebPage.py
CHANGED
|
@@ -1,37 +1,22 @@
|
|
|
1
1
|
from PyQt6.QtWebEngineCore import QWebEnginePage
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
class WebPage(QWebEnginePage):
|
|
5
|
-
def load_default_html(self):
|
|
6
|
-
html = """
|
|
7
|
-
<!DOCTYPE html>
|
|
8
|
-
<html>
|
|
9
|
-
<head>
|
|
10
|
-
<meta charset="utf-8">
|
|
11
|
-
<script src="qrc:///qtwebchannel/qwebchannel.js"></script>
|
|
12
|
-
</head>
|
|
13
|
-
<body>
|
|
14
|
-
<h1>Vertex WebEngine</h1>
|
|
15
|
-
|
|
16
|
-
<script>
|
|
17
|
-
new QWebChannel(qt.webChannelTransport, function (channel) {
|
|
18
|
-
window.bridge = channel.objects.bridge;
|
|
19
|
-
bridge.log("HELLO FROM INLINE HTML 🚀");
|
|
20
|
-
});
|
|
21
|
-
</script>
|
|
22
|
-
</body>
|
|
23
|
-
</html>
|
|
24
|
-
"""
|
|
25
4
|
|
|
26
|
-
|
|
5
|
+
BLOCKED = ["malware", "phishing"]
|
|
27
6
|
|
|
28
|
-
def
|
|
29
|
-
|
|
7
|
+
def __init__(self, profile, parent=None):
|
|
8
|
+
super().__init__(profile, parent)
|
|
30
9
|
|
|
31
10
|
def acceptNavigationRequest(self, url, nav_type, is_main_frame):
|
|
32
|
-
|
|
11
|
+
url_str = url.toString()
|
|
12
|
+
print("➡️ Navigating to:", url_str)
|
|
33
13
|
|
|
34
|
-
|
|
35
|
-
|
|
14
|
+
for bad in self.BLOCKED:
|
|
15
|
+
if bad in url_str:
|
|
16
|
+
print("🚫 Blocked URL")
|
|
17
|
+
return False
|
|
36
18
|
|
|
37
19
|
return True
|
|
20
|
+
|
|
21
|
+
def javaScriptConsoleMessage(self, level, message, line, source):
|
|
22
|
+
print(f"[JS:{level.name}] {message} ({source}:{line})")
|
VertexEngine/WebView/bridge.py
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
from PyQt6.QtWebChannel import QWebChannel
|
|
2
1
|
from PyQt6.QtCore import QObject, pyqtSlot
|
|
2
|
+
from PyQt6.QtCore import QUrl
|
|
3
|
+
import json
|
|
3
4
|
|
|
4
5
|
class JSBridge(QObject):
|
|
6
|
+
def __init__(self, page):
|
|
7
|
+
super().__init__()
|
|
8
|
+
self.page = page
|
|
9
|
+
|
|
5
10
|
@pyqtSlot(str)
|
|
6
11
|
def log(self, msg):
|
|
7
12
|
print("[JS → Python]", msg)
|
|
13
|
+
|
|
14
|
+
@pyqtSlot(str, str)
|
|
15
|
+
def emit(self, event, payload):
|
|
16
|
+
data = json.loads(payload)
|
|
17
|
+
|
|
18
|
+
if event == "open_url":
|
|
19
|
+
self.page.load(QUrl(data["url"]))
|
VertexEngine/WebView/profile.py
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
from PyQt6.QtWebEngineCore import QWebEngineProfile
|
|
2
|
+
import os
|
|
2
3
|
|
|
3
4
|
class WebProfile(QWebEngineProfile):
|
|
4
5
|
def __init__(self, name="CustomProfile", parent=None):
|
|
5
6
|
super().__init__(name, parent)
|
|
6
7
|
|
|
8
|
+
os.makedirs("downloads", exist_ok=True)
|
|
9
|
+
|
|
7
10
|
self.setHttpUserAgent(
|
|
8
11
|
"VertexWebEngine/1.0 (PyQt6)"
|
|
9
12
|
)
|
|
@@ -14,3 +17,11 @@ class WebProfile(QWebEngineProfile):
|
|
|
14
17
|
|
|
15
18
|
self.setCachePath("webcache")
|
|
16
19
|
self.setPersistentStoragePath("webstorage")
|
|
20
|
+
|
|
21
|
+
self.downloadRequested.connect(self.on_download)
|
|
22
|
+
|
|
23
|
+
def on_download(self, download):
|
|
24
|
+
path = f"downloads/{download.downloadFileName()}"
|
|
25
|
+
download.setPath(path)
|
|
26
|
+
download.accept()
|
|
27
|
+
print("⬇️ Downloading:", path)
|
VertexEngine/main.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from PyQt6.QtWidgets import QApplication, QMainWindow
|
|
3
|
+
|
|
4
|
+
from BrowserTools.Tabs import BrowserTabs
|
|
5
|
+
|
|
6
|
+
app = QApplication(sys.argv)
|
|
7
|
+
|
|
8
|
+
window = QMainWindow()
|
|
9
|
+
window.setWindowTitle("Vertex Browser")
|
|
10
|
+
|
|
11
|
+
tabs = BrowserTabs()
|
|
12
|
+
window.setCentralWidget(tabs)
|
|
13
|
+
|
|
14
|
+
window.resize(1280, 800)
|
|
15
|
+
window.show()
|
|
16
|
+
|
|
17
|
+
sys.exit(app.exec())
|
VertexEngine/test.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
from PyQt6.QtWidgets import (
|
|
2
|
+
QMainWindow, QWidget, QVBoxLayout,
|
|
3
|
+
QHBoxLayout, QPushButton, QLineEdit
|
|
4
|
+
)
|
|
5
|
+
from VertexEngine.WebEngine.WebEngine import WebEngine
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class MainWindow(QMainWindow):
|
|
9
|
+
def __init__(self):
|
|
10
|
+
super().__init__()
|
|
11
|
+
|
|
12
|
+
self.setWindowTitle("Vertex Browser")
|
|
13
|
+
self.resize(1100, 700)
|
|
14
|
+
|
|
15
|
+
# Central widget
|
|
16
|
+
central = QWidget()
|
|
17
|
+
self.setCentralWidget(central)
|
|
18
|
+
|
|
19
|
+
layout = QVBoxLayout(central)
|
|
20
|
+
|
|
21
|
+
# 🔧 Toolbar
|
|
22
|
+
toolbar = QHBoxLayout()
|
|
23
|
+
|
|
24
|
+
self.back_btn = QPushButton("←")
|
|
25
|
+
self.reload_btn = QPushButton("⟳")
|
|
26
|
+
self.home_btn = QPushButton("🏠")
|
|
27
|
+
self.url_bar = QLineEdit()
|
|
28
|
+
|
|
29
|
+
toolbar.addWidget(self.back_btn)
|
|
30
|
+
toolbar.addWidget(self.reload_btn)
|
|
31
|
+
toolbar.addWidget(self.home_btn)
|
|
32
|
+
toolbar.addWidget(self.url_bar)
|
|
33
|
+
|
|
34
|
+
layout.addLayout(toolbar)
|
|
35
|
+
|
|
36
|
+
# 🌐 WebEngine
|
|
37
|
+
self.web = WebEngine()
|
|
38
|
+
layout.addWidget(self.web)
|
|
39
|
+
|
|
40
|
+
# 🔗 Signals
|
|
41
|
+
self.back_btn.clicked.connect(self.web.back)
|
|
42
|
+
self.reload_btn.clicked.connect(self.web.reload)
|
|
43
|
+
self.home_btn.clicked.connect(self.go_home)
|
|
44
|
+
self.url_bar.returnPressed.connect(self.load_url)
|
|
45
|
+
|
|
46
|
+
self.web.urlChanged.connect(self.update_url)
|
|
47
|
+
|
|
48
|
+
# 🏠 Home
|
|
49
|
+
self.go_home()
|
|
50
|
+
|
|
51
|
+
def load_url(self):
|
|
52
|
+
url = self.url_bar.text()
|
|
53
|
+
if not url.startswith("http"):
|
|
54
|
+
url = "https://" + url
|
|
55
|
+
self.web.load_url(url)
|
|
56
|
+
|
|
57
|
+
def update_url(self, qurl):
|
|
58
|
+
self.url_bar.setText(qurl.toString())
|
|
59
|
+
|
|
60
|
+
def go_home(self):
|
|
61
|
+
self.web.load_url("https://example.com")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: VertexEngine-WebEngine
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.dev1
|
|
4
4
|
Author-email: Tyrel Miguel <annbasilan0828@gmail.com>
|
|
5
5
|
License: MIT
|
|
6
6
|
Project-URL: Documentation, https://vertexenginedocs.netlify.app/
|
|
@@ -8,10 +8,20 @@ Requires-Python: >=3.10
|
|
|
8
8
|
Description-Content-Type: text/markdown
|
|
9
9
|
Requires-Dist: pygame>=2.0
|
|
10
10
|
Requires-Dist: PyQt6>=6.7
|
|
11
|
+
Requires-Dist: VertexEngine>=1.0.1
|
|
11
12
|
|
|
12
13
|
# VertexEngine/Vertex-WebEngine
|
|
13
14
|
VertexEngine-WebEngine is a WebEngine built for the VertexEngine SDK. It's a seperate package.
|
|
14
15
|
|
|
16
|
+
## Help
|
|
17
|
+
The documentation is in the following link:
|
|
18
|
+
[Project Documentation](https://vertexenginedocs.netlify.app/) for help.
|
|
19
|
+
|
|
20
|
+
## Change Logs (1.1), NEW!
|
|
21
|
+
### Version 1.1
|
|
22
|
+
- Added 1 New Library!
|
|
23
|
+
~ BrowserTools.Tabs
|
|
24
|
+
|
|
15
25
|
## How to install Pyinstaller
|
|
16
26
|
Step 1. Type in:
|
|
17
27
|
pip install pyinstaller
|
|
@@ -35,10 +45,6 @@ pip install VertexEngine-WebEngine
|
|
|
35
45
|
|
|
36
46
|
Step 2: Wait a few min, don't worry if it takes 1 hr or more, it will finish
|
|
37
47
|
|
|
38
|
-
## Help
|
|
39
|
-
The documentation is in the following link:
|
|
40
|
-
[Project Documentation](https://vertexenginedocs.netlify.app/) for help.
|
|
41
|
-
|
|
42
48
|
## Dependencies
|
|
43
49
|
Vertex obviously has heavy dependencies since it's a game engine, the following requirements are:
|
|
44
50
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
VertexEngine/main.py,sha256=hutXWxm5qQv2x9eBdXyhD2ErKENzHb-aHSfuxWT-QoQ,333
|
|
2
|
+
VertexEngine/test.py,sha256=y2VWCtKSOmXNOD1qlitSF44a7q6qRmHS0q-o7_bG0k8,1696
|
|
3
|
+
VertexEngine/BrowserTools/Tabs.py,sha256=TOT0df5afpLHhvaUOA-xtUHFbGgvdo66peHaBvzVCrc,2301
|
|
4
|
+
VertexEngine/WebEngine/WebEngine.py,sha256=1kko_WabEyJEt8mPTMxg3lMB-QPYdflq8bpRYg_DNxQ,2189
|
|
5
|
+
VertexEngine/WebView/WebPage.py,sha256=Lav-uWvMhg3fIOhFxteujpx0YpyRNvWRD3C47sYK4N0,674
|
|
6
|
+
VertexEngine/WebView/bridge.py,sha256=iJuXC9g7OynrH-7Jsg2-OmwngY8-z3nGycaIQwooRLQ,469
|
|
7
|
+
VertexEngine/WebView/profile.py,sha256=g1KJRqYd2EHGJn1C-MyoPzk6Y6Awuuf9Tf5L9K9BGkI,832
|
|
8
|
+
vertexengine_webengine-1.2.dev1.dist-info/METADATA,sha256=OxHrojCCpxKPDgGonSxVgB7GJW8gXrFrTq24d8Q9fmI,2177
|
|
9
|
+
vertexengine_webengine-1.2.dev1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
10
|
+
vertexengine_webengine-1.2.dev1.dist-info/top_level.txt,sha256=ONNMJUQViY7bNuEYPB2TaUwj7Jo1Is2yuBY4KOv19wM,13
|
|
11
|
+
vertexengine_webengine-1.2.dev1.dist-info/RECORD,,
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
VertexEngine/WebEngine/WebEngine.py,sha256=JMcMDO7vwH9lN1eOycAlxhCLb6i-H1MULlQQzBILz-o,929
|
|
2
|
-
VertexEngine/WebView/WebPage.py,sha256=cQ1AeEWgLtsCCRF4SsKO_yWncaC_p5oDHyfO1G6gkEg,1093
|
|
3
|
-
VertexEngine/WebView/bridge.py,sha256=_4yP7knlHMmbqt4OQ6qaxyh44bY5Ot6g1jYSFNihNOs,200
|
|
4
|
-
VertexEngine/WebView/profile.py,sha256=Xj0fX8tUtwpVvIeo3c6xIStj1DD7fhZQHTag1NUmZLo,508
|
|
5
|
-
vertexengine_webengine-1.0.dist-info/METADATA,sha256=gCSeNCE5N0KO-JW3lg5u9vcQW4_fPIAiGO1VFA1FDEo,2038
|
|
6
|
-
vertexengine_webengine-1.0.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
|
|
7
|
-
vertexengine_webengine-1.0.dist-info/top_level.txt,sha256=ONNMJUQViY7bNuEYPB2TaUwj7Jo1Is2yuBY4KOv19wM,13
|
|
8
|
-
vertexengine_webengine-1.0.dist-info/RECORD,,
|
{vertexengine_webengine-1.0.dist-info → vertexengine_webengine-1.2.dev1.dist-info}/top_level.txt
RENAMED
|
File without changes
|