Switch to bare mux v2, libcurl is now default
This commit is contained in:
parent
952337be6e
commit
aae0bd2420
12 changed files with 344 additions and 517 deletions
|
|
@ -1,11 +1,11 @@
|
|||
import node from "@astrojs/node";
|
||||
import svelte from "@astrojs/svelte";
|
||||
import tailwind from "@astrojs/tailwind";
|
||||
import { baremuxPath } from "@mercuryworkshop/bare-mux";
|
||||
import { baremuxPath } from "@mercuryworkshop/bare-mux/node";
|
||||
import { epoxyPath } from "@mercuryworkshop/epoxy-transport";
|
||||
import { libcurlPath } from "@mercuryworkshop/libcurl-transport";
|
||||
import playformCompress from "@playform/compress";
|
||||
import { uvPath } from "@rubynetwork/ultraviolet";
|
||||
import { uvPath } from "@titaniumnetwork-dev/ultraviolet";
|
||||
import icon from "astro-icon";
|
||||
import { defineConfig, envField } from "astro/config";
|
||||
import { viteStaticCopy } from "vite-plugin-static-copy";
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
const script = `
|
||||
console.error('GYATT')
|
||||
`
|
||||
|
||||
self.entryFunc = function(){
|
||||
async function loadVencord() {
|
||||
const loadCss = await fetch("https://raw.githubusercontent.com/Vencord/builds/main/browser.css");
|
||||
const css = await loadCss.text();
|
||||
return {
|
||||
host: 'example.com',
|
||||
html: `<script>${script}</script>`,
|
||||
injectTo: 'body'
|
||||
host: 'discord.com',
|
||||
html: `<style>${css}</script>`,
|
||||
injectTo: 'head'
|
||||
}
|
||||
}
|
||||
|
||||
self.entryFunc = loadVencord;
|
||||
|
|
|
|||
|
|
@ -27,13 +27,13 @@
|
|||
"@fastify/multipart": "^9.0.1",
|
||||
"@fastify/static": "^8.0.1",
|
||||
"@iconify-json/ph": "^1.2.1",
|
||||
"@mercuryworkshop/bare-mux": "1.1.1",
|
||||
"@mercuryworkshop/epoxy-transport": "github:motortruck1221/epoxytransport",
|
||||
"@mercuryworkshop/bare-mux": "^2.1.6",
|
||||
"@mercuryworkshop/epoxy-transport": "2.1.13",
|
||||
"@mercuryworkshop/libcurl-transport": "^1.3.10",
|
||||
"@playform/compress": "^0.1.4",
|
||||
"@rubynetwork/rammerhead": "^1.3.5",
|
||||
"@rubynetwork/rammerhead-browser": "^1.0.9",
|
||||
"@rubynetwork/ultraviolet": "3.2.7-ruby.1",
|
||||
"@titaniumnetwork-dev/ultraviolet": "^3.2.7",
|
||||
"@svelte-drama/suspense": "0.5.1",
|
||||
"@types/node": "^22.7.5",
|
||||
"@types/sequelize": "^4.28.20",
|
||||
|
|
|
|||
759
pnpm-lock.yaml
generated
759
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,5 +1,3 @@
|
|||
importScripts("/epoxy/index.js");
|
||||
importScripts("/libcurl/index.js");
|
||||
importScripts("/uv/uv.bundle.js");
|
||||
importScripts("/uv/uv.config.js");
|
||||
importScripts(__uv$config.sw || "/uv/uv.sw.js");
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ async function installItems(db: ModelStatic<CatalogModel>, items: Items[]) {
|
|||
background_video: item.background_video,
|
||||
background_image: item.background_image,
|
||||
type: item.type,
|
||||
entryFunc: item.entryFunc
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
settings.proxySettings.openIn(localStorage.getItem(Settings.ProxySettings.openIn) as string || "embed");
|
||||
settings.proxySettings.setSearchEngine(localStorage.getItem(Settings.ProxySettings.searchEngine) as string || "ddg");
|
||||
settings.proxySettings.setWispURL(localStorage.getItem(Settings.ProxySettings.wispServerURL) as string || "default");
|
||||
settings.proxySettings.setTransport(localStorage.getItem(Settings.ProxySettings.transport) as string || "epoxy");
|
||||
settings.proxySettings.setTransport(localStorage.getItem(Settings.ProxySettings.transport) as string || "libcurl");
|
||||
settings.marketPlaceSettings.changeTheme(false, undefined, localStorage.getItem(Settings.AppearanceSettings.video) as string, localStorage.getItem(Settings.AppearanceSettings.image) as string);
|
||||
document.addEventListener("astro:after-swap", function() {
|
||||
settings.tabSettings.cloakTab(localStorage.getItem(Settings.TabSettings.tabCloak) as string || "default");
|
||||
|
|
|
|||
4
src/env.d.ts
vendored
4
src/env.d.ts
vendored
|
|
@ -1,5 +1,3 @@
|
|||
/// <reference path="../.astro/types.d.ts" />
|
||||
/// <reference types="astro/client" />
|
||||
/// <reference types="@rubynetwork/ultraviolet/client" />
|
||||
declare var BareMux: any;
|
||||
declare var EpxMod: any;
|
||||
/// <reference types="@titaniumnetwork-dev/ultraviolet/client" />
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ const assetsJson = await response.json();
|
|||
installButton.addEventListener("click", () => {
|
||||
settings.marketPlaceSettings.install(
|
||||
payload.type === "theme" ? {theme: {payload: payload.payload, video: payload.background_video, bgImage: payload.background_image}} :
|
||||
{plugin: {name: packageName, src: payload.payload, type: "page", entryFunc: payload.entryFunc }},
|
||||
{plugin: {name: packageName, src: payload.payload, type: "page" }},
|
||||
packageName, payload.payload
|
||||
).then(() => {
|
||||
installButton.classList.add("hidden");
|
||||
|
|
|
|||
|
|
@ -82,9 +82,9 @@ import { VERSION } from "astro:env/client";
|
|||
}
|
||||
}
|
||||
function uv(iframe: HTMLIFrameElement, term: string) {
|
||||
initSw().then((reg) => {
|
||||
settings.marketPlaceSettings.handlePlugins(reg).then(() => {
|
||||
setTransport(localStorage.getItem(Settings.ProxySettings.transport) as string).then(async () => {
|
||||
initSw().then((init) => {
|
||||
settings.marketPlaceSettings.handlePlugins(init.sw).then(() => {
|
||||
setTransport(init.conn, localStorage.getItem(Settings.ProxySettings.transport) as string).then(async () => {
|
||||
iframe.classList.remove("hidden");
|
||||
const url = await proxy(term, false);
|
||||
if (url) {
|
||||
|
|
|
|||
|
|
@ -91,8 +91,8 @@ export const prerender = true;
|
|||
select: true,
|
||||
name: 'transport',
|
||||
options: [
|
||||
{name: 'Epoxy', value: 'epoxy', disabled: false},
|
||||
{name: 'Libcurl', value: 'libcurl', disabled: false}
|
||||
{name: 'Libcurl', value: 'libcurl', disabled: false},
|
||||
{name: 'Epoxy', value: 'epoxy', disabled: false}
|
||||
]
|
||||
}}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -1,16 +1,9 @@
|
|||
import { Settings, WispServerURLS } from "./settings/index";
|
||||
import { BareMuxConnection } from "@mercuryworkshop/bare-mux";
|
||||
function loadProxyScripts() {
|
||||
//wrap everything in a promise to avoid race conditions
|
||||
return new Promise<void>((resolve) => {
|
||||
//create and append then scripts tags to the body (this is how we lazy load things)
|
||||
const epoxyScript = document.createElement("script");
|
||||
epoxyScript.src = "/epoxy/index.js";
|
||||
epoxyScript.defer = true;
|
||||
document.body.appendChild(epoxyScript);
|
||||
const libCurlScript = document.createElement("script");
|
||||
libCurlScript.src = "/libcurl/index.js";
|
||||
libCurlScript.defer = true;
|
||||
document.body.appendChild(libCurlScript);
|
||||
return new Promise<BareMuxConnection>((resolve) => {
|
||||
const conn = new BareMuxConnection("/baremux/worker.js");
|
||||
const uvBundle = document.createElement("script");
|
||||
uvBundle.src = "/uv/uv.bundle.js";
|
||||
uvBundle.defer = true;
|
||||
|
|
@ -19,49 +12,51 @@ function loadProxyScripts() {
|
|||
uvConfig.src = "/uv/uv.config.js";
|
||||
uvConfig.defer = true;
|
||||
document.body.appendChild(uvConfig);
|
||||
const bareMux = document.createElement("script");
|
||||
bareMux.src = "/baremux/bare.cjs";
|
||||
bareMux.defer = true;
|
||||
document.body.appendChild(bareMux);
|
||||
const checkScripts = setInterval(() => {
|
||||
//If both of these aren't defined this will repeat until they are
|
||||
//this allows use to wait for all of the scripts to be ready *before* we setup the serviceworker
|
||||
if (typeof EpxMod !== "undefined" && typeof BareMux !== "undefined") {
|
||||
clearInterval(checkScripts);
|
||||
resolve();
|
||||
const checkScript = setInterval(() => {
|
||||
if (typeof __uv$config !== 'undefined') {
|
||||
clearInterval(checkScript);
|
||||
resolve(conn);
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
|
||||
function setTransport(transport?: string) {
|
||||
function setTransport(conn: BareMuxConnection, transport?: string) {
|
||||
//wrap in a promise so we don't register sw until a transport is set.
|
||||
const wispServer = localStorage.getItem(Settings.ProxySettings.wispServerURL);
|
||||
return new Promise<void>((resolve) => {
|
||||
switch (transport) {
|
||||
case "epoxy":
|
||||
BareMux.SetTransport("EpxMod.default", {
|
||||
wisp: wispServer ? WispServerURLS[wispServer] : WispServerURLS.default
|
||||
});
|
||||
conn.setTransport("/epoxy/index.mjs", [
|
||||
{wisp: wispServer ? WispServerURLS[wispServer] : WispServerURLS.default}
|
||||
]);
|
||||
break;
|
||||
case "libcurl":
|
||||
BareMux.SetTransport("CurlMod.default", {
|
||||
wisp: wispServer ? WispServerURLS[wispServer] : WispServerURLS.default
|
||||
});
|
||||
conn.setTransport("/libcurl/index.mjs", [
|
||||
{wisp: wispServer ? WispServerURLS[wispServer]: WispServerURLS.default}
|
||||
]);
|
||||
break;
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
|
||||
type SWInitResolve = {
|
||||
sw: ServiceWorkerRegistration,
|
||||
conn: BareMuxConnection
|
||||
}
|
||||
function initSw() {
|
||||
//this is wrapped in a promise to mostly solve the bare-mux v1 problems
|
||||
return new Promise<ServiceWorkerRegistration>((resolve) => {
|
||||
return new Promise<SWInitResolve>((resolve) => {
|
||||
if ("serviceWorker" in navigator) {
|
||||
navigator.serviceWorker.ready.then(async (reg) => {
|
||||
console.debug("Service worker ready!");
|
||||
await loadProxyScripts();
|
||||
resolve(reg);
|
||||
const conn = await loadProxyScripts();
|
||||
const resolveVal: SWInitResolve = {
|
||||
sw: reg,
|
||||
conn: conn
|
||||
}
|
||||
resolve(resolveVal);
|
||||
});
|
||||
navigator.serviceWorker.register("/sw.js", { scope: "/" });
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue