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 node from "@astrojs/node";
|
||||||
import svelte from "@astrojs/svelte";
|
import svelte from "@astrojs/svelte";
|
||||||
import tailwind from "@astrojs/tailwind";
|
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 { epoxyPath } from "@mercuryworkshop/epoxy-transport";
|
||||||
import { libcurlPath } from "@mercuryworkshop/libcurl-transport";
|
import { libcurlPath } from "@mercuryworkshop/libcurl-transport";
|
||||||
import playformCompress from "@playform/compress";
|
import playformCompress from "@playform/compress";
|
||||||
import { uvPath } from "@rubynetwork/ultraviolet";
|
import { uvPath } from "@titaniumnetwork-dev/ultraviolet";
|
||||||
import icon from "astro-icon";
|
import icon from "astro-icon";
|
||||||
import { defineConfig, envField } from "astro/config";
|
import { defineConfig, envField } from "astro/config";
|
||||||
import { viteStaticCopy } from "vite-plugin-static-copy";
|
import { viteStaticCopy } from "vite-plugin-static-copy";
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
const script = `
|
async function loadVencord() {
|
||||||
console.error('GYATT')
|
const loadCss = await fetch("https://raw.githubusercontent.com/Vencord/builds/main/browser.css");
|
||||||
`
|
const css = await loadCss.text();
|
||||||
|
|
||||||
self.entryFunc = function(){
|
|
||||||
return {
|
return {
|
||||||
host: 'example.com',
|
host: 'discord.com',
|
||||||
html: `<script>${script}</script>`,
|
html: `<style>${css}</script>`,
|
||||||
injectTo: 'body'
|
injectTo: 'head'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.entryFunc = loadVencord;
|
||||||
|
|
|
||||||
|
|
@ -27,13 +27,13 @@
|
||||||
"@fastify/multipart": "^9.0.1",
|
"@fastify/multipart": "^9.0.1",
|
||||||
"@fastify/static": "^8.0.1",
|
"@fastify/static": "^8.0.1",
|
||||||
"@iconify-json/ph": "^1.2.1",
|
"@iconify-json/ph": "^1.2.1",
|
||||||
"@mercuryworkshop/bare-mux": "1.1.1",
|
"@mercuryworkshop/bare-mux": "^2.1.6",
|
||||||
"@mercuryworkshop/epoxy-transport": "github:motortruck1221/epoxytransport",
|
"@mercuryworkshop/epoxy-transport": "2.1.13",
|
||||||
"@mercuryworkshop/libcurl-transport": "^1.3.10",
|
"@mercuryworkshop/libcurl-transport": "^1.3.10",
|
||||||
"@playform/compress": "^0.1.4",
|
"@playform/compress": "^0.1.4",
|
||||||
"@rubynetwork/rammerhead": "^1.3.5",
|
"@rubynetwork/rammerhead": "^1.3.5",
|
||||||
"@rubynetwork/rammerhead-browser": "^1.0.9",
|
"@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",
|
"@svelte-drama/suspense": "0.5.1",
|
||||||
"@types/node": "^22.7.5",
|
"@types/node": "^22.7.5",
|
||||||
"@types/sequelize": "^4.28.20",
|
"@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.bundle.js");
|
||||||
importScripts("/uv/uv.config.js");
|
importScripts("/uv/uv.config.js");
|
||||||
importScripts(__uv$config.sw || "/uv/uv.sw.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_video: item.background_video,
|
||||||
background_image: item.background_image,
|
background_image: item.background_image,
|
||||||
type: item.type,
|
type: item.type,
|
||||||
entryFunc: item.entryFunc
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
settings.proxySettings.openIn(localStorage.getItem(Settings.ProxySettings.openIn) as string || "embed");
|
settings.proxySettings.openIn(localStorage.getItem(Settings.ProxySettings.openIn) as string || "embed");
|
||||||
settings.proxySettings.setSearchEngine(localStorage.getItem(Settings.ProxySettings.searchEngine) as string || "ddg");
|
settings.proxySettings.setSearchEngine(localStorage.getItem(Settings.ProxySettings.searchEngine) as string || "ddg");
|
||||||
settings.proxySettings.setWispURL(localStorage.getItem(Settings.ProxySettings.wispServerURL) as string || "default");
|
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);
|
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() {
|
document.addEventListener("astro:after-swap", function() {
|
||||||
settings.tabSettings.cloakTab(localStorage.getItem(Settings.TabSettings.tabCloak) as string || "default");
|
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 path="../.astro/types.d.ts" />
|
||||||
/// <reference types="astro/client" />
|
/// <reference types="astro/client" />
|
||||||
/// <reference types="@rubynetwork/ultraviolet/client" />
|
/// <reference types="@titaniumnetwork-dev/ultraviolet/client" />
|
||||||
declare var BareMux: any;
|
|
||||||
declare var EpxMod: any;
|
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ const assetsJson = await response.json();
|
||||||
installButton.addEventListener("click", () => {
|
installButton.addEventListener("click", () => {
|
||||||
settings.marketPlaceSettings.install(
|
settings.marketPlaceSettings.install(
|
||||||
payload.type === "theme" ? {theme: {payload: payload.payload, video: payload.background_video, bgImage: payload.background_image}} :
|
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
|
packageName, payload.payload
|
||||||
).then(() => {
|
).then(() => {
|
||||||
installButton.classList.add("hidden");
|
installButton.classList.add("hidden");
|
||||||
|
|
|
||||||
|
|
@ -82,9 +82,9 @@ import { VERSION } from "astro:env/client";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function uv(iframe: HTMLIFrameElement, term: string) {
|
function uv(iframe: HTMLIFrameElement, term: string) {
|
||||||
initSw().then((reg) => {
|
initSw().then((init) => {
|
||||||
settings.marketPlaceSettings.handlePlugins(reg).then(() => {
|
settings.marketPlaceSettings.handlePlugins(init.sw).then(() => {
|
||||||
setTransport(localStorage.getItem(Settings.ProxySettings.transport) as string).then(async () => {
|
setTransport(init.conn, localStorage.getItem(Settings.ProxySettings.transport) as string).then(async () => {
|
||||||
iframe.classList.remove("hidden");
|
iframe.classList.remove("hidden");
|
||||||
const url = await proxy(term, false);
|
const url = await proxy(term, false);
|
||||||
if (url) {
|
if (url) {
|
||||||
|
|
|
||||||
|
|
@ -91,8 +91,8 @@ export const prerender = true;
|
||||||
select: true,
|
select: true,
|
||||||
name: 'transport',
|
name: 'transport',
|
||||||
options: [
|
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 { Settings, WispServerURLS } from "./settings/index";
|
||||||
|
import { BareMuxConnection } from "@mercuryworkshop/bare-mux";
|
||||||
function loadProxyScripts() {
|
function loadProxyScripts() {
|
||||||
//wrap everything in a promise to avoid race conditions
|
//wrap everything in a promise to avoid race conditions
|
||||||
return new Promise<void>((resolve) => {
|
return new Promise<BareMuxConnection>((resolve) => {
|
||||||
//create and append then scripts tags to the body (this is how we lazy load things)
|
const conn = new BareMuxConnection("/baremux/worker.js");
|
||||||
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);
|
|
||||||
const uvBundle = document.createElement("script");
|
const uvBundle = document.createElement("script");
|
||||||
uvBundle.src = "/uv/uv.bundle.js";
|
uvBundle.src = "/uv/uv.bundle.js";
|
||||||
uvBundle.defer = true;
|
uvBundle.defer = true;
|
||||||
|
|
@ -19,49 +12,51 @@ function loadProxyScripts() {
|
||||||
uvConfig.src = "/uv/uv.config.js";
|
uvConfig.src = "/uv/uv.config.js";
|
||||||
uvConfig.defer = true;
|
uvConfig.defer = true;
|
||||||
document.body.appendChild(uvConfig);
|
document.body.appendChild(uvConfig);
|
||||||
const bareMux = document.createElement("script");
|
const checkScript = setInterval(() => {
|
||||||
bareMux.src = "/baremux/bare.cjs";
|
if (typeof __uv$config !== 'undefined') {
|
||||||
bareMux.defer = true;
|
clearInterval(checkScript);
|
||||||
document.body.appendChild(bareMux);
|
resolve(conn);
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
}, 100);
|
}, 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.
|
//wrap in a promise so we don't register sw until a transport is set.
|
||||||
const wispServer = localStorage.getItem(Settings.ProxySettings.wispServerURL);
|
const wispServer = localStorage.getItem(Settings.ProxySettings.wispServerURL);
|
||||||
return new Promise<void>((resolve) => {
|
return new Promise<void>((resolve) => {
|
||||||
switch (transport) {
|
switch (transport) {
|
||||||
case "epoxy":
|
case "epoxy":
|
||||||
BareMux.SetTransport("EpxMod.default", {
|
conn.setTransport("/epoxy/index.mjs", [
|
||||||
wisp: wispServer ? WispServerURLS[wispServer] : WispServerURLS.default
|
{wisp: wispServer ? WispServerURLS[wispServer] : WispServerURLS.default}
|
||||||
});
|
]);
|
||||||
break;
|
break;
|
||||||
case "libcurl":
|
case "libcurl":
|
||||||
BareMux.SetTransport("CurlMod.default", {
|
conn.setTransport("/libcurl/index.mjs", [
|
||||||
wisp: wispServer ? WispServerURLS[wispServer] : WispServerURLS.default
|
{wisp: wispServer ? WispServerURLS[wispServer]: WispServerURLS.default}
|
||||||
});
|
]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SWInitResolve = {
|
||||||
|
sw: ServiceWorkerRegistration,
|
||||||
|
conn: BareMuxConnection
|
||||||
|
}
|
||||||
function initSw() {
|
function initSw() {
|
||||||
//this is wrapped in a promise to mostly solve the bare-mux v1 problems
|
//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) {
|
if ("serviceWorker" in navigator) {
|
||||||
navigator.serviceWorker.ready.then(async (reg) => {
|
navigator.serviceWorker.ready.then(async (reg) => {
|
||||||
console.debug("Service worker ready!");
|
console.debug("Service worker ready!");
|
||||||
await loadProxyScripts();
|
const conn = await loadProxyScripts();
|
||||||
resolve(reg);
|
const resolveVal: SWInitResolve = {
|
||||||
|
sw: reg,
|
||||||
|
conn: conn
|
||||||
|
}
|
||||||
|
resolve(resolveVal);
|
||||||
});
|
});
|
||||||
navigator.serviceWorker.register("/sw.js", { scope: "/" });
|
navigator.serviceWorker.register("/sw.js", { scope: "/" });
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue