mirror of
https://github.com/SteamDeckHomebrew/decky-loader.git
synced 2026-06-15 18:13:40 +03:00
Plugin store button now uses built-in browser
This commit is contained in:
@@ -27,7 +27,6 @@ class PluginBrowser:
|
||||
server_instance.add_routes([
|
||||
web.post("/browser/install_plugin", self.install_plugin),
|
||||
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):
|
||||
@@ -73,10 +72,6 @@ class PluginBrowser:
|
||||
async def redirect_to_store(self, request):
|
||||
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):
|
||||
data = await request.post()
|
||||
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)
|
||||
|
||||
async def get_steam_resource(self, request):
|
||||
tab = (await get_tabs())[0]
|
||||
tab = await get_tab("QuickAccess")
|
||||
try:
|
||||
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:
|
||||
|
||||
@@ -7,7 +7,7 @@ CONFIG = {
|
||||
"server_port": int(getenv("SERVER_PORT", "1337")),
|
||||
"live_reload": getenv("LIVE_RELOAD", "1") == "1",
|
||||
"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"
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ class PluginManager:
|
||||
"id": 1,
|
||||
"method": "Runtime.evaluate",
|
||||
"params": {
|
||||
"expression": f"resolveMethodCall({call_id}, {r})",
|
||||
"expression": f"resolveMethodCall('{call_id}', {r})",
|
||||
"userGesture": True
|
||||
}
|
||||
}, receive=False)
|
||||
@@ -141,4 +141,4 @@ class PluginManager:
|
||||
return run_app(self.web_app, host=CONFIG["server_host"], port=CONFIG["server_port"], loop=self.loop, access_log=None)
|
||||
|
||||
if __name__ == "__main__":
|
||||
PluginManager().run()
|
||||
PluginManager().run()
|
||||
|
||||
@@ -67,7 +67,7 @@ function addPluginInstallPrompt(artifact, version, request_id) {
|
||||
|
||||
function createTitle(text) {
|
||||
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();
|
||||
document.getElementById("plugin_title").onclick = function() {
|
||||
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) {
|
||||
ev.stopPropagation();
|
||||
console.debug(JSON.stringify({
|
||||
"id": 1,
|
||||
"method": "open_plugin_store",
|
||||
@@ -106,6 +106,7 @@ function addPluginInstallPrompt(artifact, version, request_id) {
|
||||
window.onmessage = function(ev) {
|
||||
let title = ev.data;
|
||||
if (title.startsWith("PLUGIN_LOADER__")) {
|
||||
document.getElementById("open_shop_button").style.display = 'none';
|
||||
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">
|
||||
<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"/>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from aiohttp import ClientSession
|
||||
from injector import get_tab, get_tabs, inject_to_tab
|
||||
from injector import inject_to_tab
|
||||
import uuid
|
||||
|
||||
class Utilities:
|
||||
@@ -107,15 +107,14 @@ class Utilities:
|
||||
}
|
||||
|
||||
async def open_plugin_store(self):
|
||||
if self.context.plugin_browser.store_url in await get_tabs():
|
||||
return
|
||||
res = await inject_to_tab("SP", """
|
||||
window.PLUGIN_STORE_TAB_INSTANCE = (function() {
|
||||
let i = SteamClient.BrowserView.Create()
|
||||
i.SetBounds(0, 60, 1280, 800-59-60)
|
||||
i.LoadURL('http://127.0.0.1:1337/browser/redirect')
|
||||
i.SetVisible(true);
|
||||
return i;
|
||||
await inject_to_tab("SP", """
|
||||
(function() {
|
||||
wpRequire = webpackJsonp.push([[], { get_require: (mod, _exports, wpRequire) => mod.exports = wpRequire }, [["get_require"]]]);
|
||||
const all = () => Object.keys(wpRequire.c).map((x) => wpRequire.c[x].exports).filter((x) => x);
|
||||
router = all().map(m => {
|
||||
if (typeof m !== "object") return undefined;
|
||||
for (let prop in m) { if (m[prop]?.Navigate) return m[prop]}
|
||||
}).find(x => x)
|
||||
router.NavigateToExternalWeb("http://127.0.0.1:1337/browser/redirect")
|
||||
})();
|
||||
""")
|
||||
setattr(self, "store_is_open", True)
|
||||
""")
|
||||
Reference in New Issue
Block a user