mirror of
https://github.com/SteamDeckHomebrew/decky-loader.git
synced 2026-07-11 19:02:03 +00:00
Plugin store button now uses built-in browser
This commit is contained in:
@@ -27,7 +27,6 @@ class PluginBrowser:
|
|||||||
server_instance.add_routes([
|
server_instance.add_routes([
|
||||||
web.post("/browser/install_plugin", self.install_plugin),
|
web.post("/browser/install_plugin", self.install_plugin),
|
||||||
web.get("/browser/redirect", self.redirect_to_store),
|
web.get("/browser/redirect", self.redirect_to_store),
|
||||||
web.post("/browser/close_store", self.close_store)
|
|
||||||
])
|
])
|
||||||
|
|
||||||
def _unzip_to_plugin_dir(self, zip, name, hash):
|
def _unzip_to_plugin_dir(self, zip, name, hash):
|
||||||
@@ -73,10 +72,6 @@ class PluginBrowser:
|
|||||||
async def redirect_to_store(self, request):
|
async def redirect_to_store(self, request):
|
||||||
return web.Response(status=302, headers={"Location": self.store_url})
|
return web.Response(status=302, headers={"Location": self.store_url})
|
||||||
|
|
||||||
async def close_store(self, request):
|
|
||||||
await inject_to_tab("SP", "window.PLUGIN_STORE_TAB_INSTANCE.SetVisible(false)")
|
|
||||||
await inject_to_tab("SP", "SteamClient.BrowserView.Destroy(window.PLUGIN_STORE_TAB_INSTANCE)")
|
|
||||||
|
|
||||||
async def install_plugin(self, request):
|
async def install_plugin(self, request):
|
||||||
data = await request.post()
|
data = await request.post()
|
||||||
get_event_loop().create_task(self.request_plugin_install(data["artifact"], data["version"], data["hash"]))
|
get_event_loop().create_task(self.request_plugin_install(data["artifact"], data["version"], data["hash"]))
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ class Loader:
|
|||||||
return await self.callsigns[callsign].execute_method(method_name, kwargs)
|
return await self.callsigns[callsign].execute_method(method_name, kwargs)
|
||||||
|
|
||||||
async def get_steam_resource(self, request):
|
async def get_steam_resource(self, request):
|
||||||
tab = (await get_tabs())[0]
|
tab = await get_tab("QuickAccess")
|
||||||
try:
|
try:
|
||||||
return web.Response(text=await tab.get_steam_resource(f"https://steamloopback.host/{request.match_info['path']}"), content_type="text/html")
|
return web.Response(text=await tab.get_steam_resource(f"https://steamloopback.host/{request.match_info['path']}"), content_type="text/html")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ CONFIG = {
|
|||||||
"server_port": int(getenv("SERVER_PORT", "1337")),
|
"server_port": int(getenv("SERVER_PORT", "1337")),
|
||||||
"live_reload": getenv("LIVE_RELOAD", "1") == "1",
|
"live_reload": getenv("LIVE_RELOAD", "1") == "1",
|
||||||
"log_level": {"CRITICAL": 50, "ERROR": 40, "WARNING":30, "INFO": 20, "DEBUG": 10}[getenv("LOG_LEVEL", "INFO")],
|
"log_level": {"CRITICAL": 50, "ERROR": 40, "WARNING":30, "INFO": 20, "DEBUG": 10}[getenv("LOG_LEVEL", "INFO")],
|
||||||
"store_url": getenv("STORE_URL", "https://plugins.deckbrew.xyz"),
|
"store_url": getenv("STORE_URL", "https://beta.deckbrew.xyz"),
|
||||||
"log_base_events": getenv("LOG_BASE_EVENTS", "0")=="1"
|
"log_base_events": getenv("LOG_BASE_EVENTS", "0")=="1"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ class PluginManager:
|
|||||||
"id": 1,
|
"id": 1,
|
||||||
"method": "Runtime.evaluate",
|
"method": "Runtime.evaluate",
|
||||||
"params": {
|
"params": {
|
||||||
"expression": f"resolveMethodCall({call_id}, {r})",
|
"expression": f"resolveMethodCall('{call_id}', {r})",
|
||||||
"userGesture": True
|
"userGesture": True
|
||||||
}
|
}
|
||||||
}, receive=False)
|
}, receive=False)
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ function addPluginInstallPrompt(artifact, version, request_id) {
|
|||||||
|
|
||||||
function createTitle(text) {
|
function createTitle(text) {
|
||||||
return `
|
return `
|
||||||
<div id="plugin_title" class="quickaccessmenu_Title_34nl5">${text}${SHOP_ICON}</div>
|
<div class="quickaccessmenu_Title_34nl5"><div id="plugin_title">${text}</div>${SHOP_ICON}</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,10 +93,10 @@ function addPluginInstallPrompt(artifact, version, request_id) {
|
|||||||
inject();
|
inject();
|
||||||
document.getElementById("plugin_title").onclick = function() {
|
document.getElementById("plugin_title").onclick = function() {
|
||||||
reloadIframe();
|
reloadIframe();
|
||||||
document.getElementById("plugin_title").innerHTML = `Plugins ${SHOP_ICON}`;
|
document.getElementById("plugin_title").innerText = `Plugins`;
|
||||||
|
document.getElementById("open_shop_button").style.display = 'block';
|
||||||
}
|
}
|
||||||
document.getElementById("open_shop_button").onclick = function(ev) {
|
document.getElementById("open_shop_button").onclick = function(ev) {
|
||||||
ev.stopPropagation();
|
|
||||||
console.debug(JSON.stringify({
|
console.debug(JSON.stringify({
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"method": "open_plugin_store",
|
"method": "open_plugin_store",
|
||||||
@@ -106,6 +106,7 @@ function addPluginInstallPrompt(artifact, version, request_id) {
|
|||||||
window.onmessage = function(ev) {
|
window.onmessage = function(ev) {
|
||||||
let title = ev.data;
|
let title = ev.data;
|
||||||
if (title.startsWith("PLUGIN_LOADER__")) {
|
if (title.startsWith("PLUGIN_LOADER__")) {
|
||||||
|
document.getElementById("open_shop_button").style.display = 'none';
|
||||||
document.getElementById("plugin_title").innerHTML = `
|
document.getElementById("plugin_title").innerHTML = `
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-left-square-fill" viewBox="0 0 16 16">
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-left-square-fill" viewBox="0 0 16 16">
|
||||||
<path d="M16 14a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v12zm-4.5-6.5H5.707l2.147-2.146a.5.5 0 1 0-.708-.708l-3 3a.5.5 0 0 0 0 .708l3 3a.5.5 0 0 0 .708-.708L5.707 8.5H11.5a.5.5 0 0 0 0-1z"/>
|
<path d="M16 14a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v12zm-4.5-6.5H5.707l2.147-2.146a.5.5 0 1 0-.708-.708l-3 3a.5.5 0 0 0 0 .708l3 3a.5.5 0 0 0 .708-.708L5.707 8.5H11.5a.5.5 0 0 0 0-1z"/>
|
||||||
|
|||||||
+10
-11
@@ -1,5 +1,5 @@
|
|||||||
from aiohttp import ClientSession
|
from aiohttp import ClientSession
|
||||||
from injector import get_tab, get_tabs, inject_to_tab
|
from injector import inject_to_tab
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
class Utilities:
|
class Utilities:
|
||||||
@@ -107,15 +107,14 @@ class Utilities:
|
|||||||
}
|
}
|
||||||
|
|
||||||
async def open_plugin_store(self):
|
async def open_plugin_store(self):
|
||||||
if self.context.plugin_browser.store_url in await get_tabs():
|
await inject_to_tab("SP", """
|
||||||
return
|
(function() {
|
||||||
res = await inject_to_tab("SP", """
|
wpRequire = webpackJsonp.push([[], { get_require: (mod, _exports, wpRequire) => mod.exports = wpRequire }, [["get_require"]]]);
|
||||||
window.PLUGIN_STORE_TAB_INSTANCE = (function() {
|
const all = () => Object.keys(wpRequire.c).map((x) => wpRequire.c[x].exports).filter((x) => x);
|
||||||
let i = SteamClient.BrowserView.Create()
|
router = all().map(m => {
|
||||||
i.SetBounds(0, 60, 1280, 800-59-60)
|
if (typeof m !== "object") return undefined;
|
||||||
i.LoadURL('http://127.0.0.1:1337/browser/redirect')
|
for (let prop in m) { if (m[prop]?.Navigate) return m[prop]}
|
||||||
i.SetVisible(true);
|
}).find(x => x)
|
||||||
return i;
|
router.NavigateToExternalWeb("http://127.0.0.1:1337/browser/redirect")
|
||||||
})();
|
})();
|
||||||
""")
|
""")
|
||||||
setattr(self, "store_is_open", True)
|
|
||||||
Reference in New Issue
Block a user