Upgrade to astro 5, for some reason epoxy is broken now?
This commit is contained in:
parent
cef106b512
commit
58e7cb118e
12 changed files with 2427 additions and 2854 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import { defineConfig } from "astro/config";
|
||||
import node from "@astrojs/node";
|
||||
import sitemap from "@inox-tools/sitemap-ext";
|
||||
import dotenv from "dotenv-flow";
|
||||
import sitemap from '@astrojs/sitemap';
|
||||
dotenv.config();
|
||||
|
||||
// Check if node is running in production mode
|
||||
|
|
@ -14,7 +14,6 @@ export default defineConfig({
|
|||
site: site,
|
||||
integrations: [
|
||||
sitemap({
|
||||
includeByDefault: true,
|
||||
lastmod: new Date(),
|
||||
}),
|
||||
],
|
||||
|
|
|
|||
BIN
database.sqlite
BIN
database.sqlite
Binary file not shown.
26
index.js
26
index.js
|
|
@ -8,10 +8,8 @@ import { baremuxPath } from "@mercuryworkshop/bare-mux/node";
|
|||
import express from "express";
|
||||
import { createServer } from "http";
|
||||
import path from "node:path";
|
||||
import rammerhead from "@rubynetwork/rammerhead";
|
||||
import chalk from "chalk";
|
||||
import { server as wisp, logging } from "@mercuryworkshop/wisp-js/server";
|
||||
import router from "./middleware/ProxyExt/index.js";
|
||||
import { server as wisp, logging as wispLogging } from "@mercuryworkshop/wisp-js/server";
|
||||
import { handler as astroSSR } from "./dist/server/entry.mjs";
|
||||
import cookies from "cookie-parser";
|
||||
import { existsSync, readFileSync } from "fs";
|
||||
|
|
@ -30,19 +28,12 @@ if (existsSync("exempt_masqr.txt")) {
|
|||
|
||||
const LICENSE_SERVER_URL = "https://license.mercurywork.shop/validate?license=";
|
||||
const MASQR_ENABLED = process.env.MASQR_ENABLED;
|
||||
logging.set_level(logging.WARN);
|
||||
wispLogging.set_level(wispLogging.WARN);
|
||||
|
||||
const log = (message) => console.log(chalk.gray.bold("[Alu] " + message));
|
||||
const success = (message) => console.log(chalk.green.bold("[Alu] " + message));
|
||||
|
||||
const PORT = process.env.PORT;
|
||||
log("Starting Rammerhead...");
|
||||
const rh = rammerhead.createRammerhead({
|
||||
logLevel: "info",
|
||||
reverseProxy: false,
|
||||
disableLocalStorageSync: false,
|
||||
disableHttp2: false,
|
||||
});
|
||||
const app = express();
|
||||
|
||||
app.use(cookies());
|
||||
|
|
@ -56,9 +47,6 @@ if (MASQR_ENABLED == "true") {
|
|||
|
||||
app.use(astroSSR);
|
||||
|
||||
log("Starting Marketplace Provider...");
|
||||
app.use(router);
|
||||
|
||||
app.use(express.static(path.join(process.cwd(), "static")));
|
||||
app.use(express.static(path.join(process.cwd(), "build")));
|
||||
app.use("/uv/", express.static(uvPath));
|
||||
|
|
@ -131,17 +119,11 @@ app.get("*", (req, res) => {
|
|||
|
||||
const server = createServer();
|
||||
server.on("request", (req, res) => {
|
||||
if (rammerhead.shouldRouteRh(req)) {
|
||||
rammerhead.routeRhRequest(rh, req, res);
|
||||
} else {
|
||||
app(req, res);
|
||||
}
|
||||
app(req, res);
|
||||
});
|
||||
|
||||
server.on("upgrade", (req, socket, head) => {
|
||||
if (rammerhead.shouldRouteRh(req)) {
|
||||
rammerhead.routeRhUpgrade(rh, req, socket, head);
|
||||
} else if (req.url.endsWith("/wisp/")) {
|
||||
if (req.url.endsWith("/wisp/")) {
|
||||
wisp.routeRequest(req, socket, head);
|
||||
} else {
|
||||
socket.end();
|
||||
|
|
|
|||
|
|
@ -1,79 +0,0 @@
|
|||
import b from "express";
|
||||
import { DataTypes as t, Sequelize as k } from "sequelize";
|
||||
var A = new k("database", "user", "password", { host: "localhost", dialect: "sqlite", logging: !1, storage: "database.sqlite" }),
|
||||
n = A.define("catalog_assets", {
|
||||
package_name: { type: t.TEXT, unique: !0 },
|
||||
title: { type: t.TEXT },
|
||||
description: { type: t.TEXT },
|
||||
author: { type: t.TEXT },
|
||||
image: { type: t.TEXT },
|
||||
tags: { type: t.JSON, allowNull: !0 },
|
||||
version: { type: t.TEXT },
|
||||
background_image: { type: t.TEXT, allowNull: !0 },
|
||||
background_video: { type: t.TEXT, allowNull: !0 },
|
||||
payload: { type: t.TEXT },
|
||||
type: { type: t.TEXT },
|
||||
});
|
||||
n.sync();
|
||||
async function c(p, s) {
|
||||
try {
|
||||
let a = p.query,
|
||||
o = parseInt(a.page) || 1,
|
||||
r = parseInt(a.amount) || 20,
|
||||
u = await n.count(),
|
||||
m = Math.ceil(u / r),
|
||||
d = o < m;
|
||||
if (o < 1) {
|
||||
s.status(400).json({ error: "Invalid page number!" });
|
||||
return;
|
||||
}
|
||||
if (parseInt(a.amount) < 10) {
|
||||
s.status(400).json({ error: "Amount must be at least 10!" });
|
||||
return;
|
||||
}
|
||||
let y = (o - 1) * r,
|
||||
f = (await n.findAll({ offset: y, limit: 20 })).map((e) => e.get()),
|
||||
T = {
|
||||
assets: Object.fromEntries(
|
||||
f.map((e) => [
|
||||
e.package_name,
|
||||
{
|
||||
title: e.title,
|
||||
description: e.description,
|
||||
author: e.author,
|
||||
image: e.image,
|
||||
tags: e.tags,
|
||||
version: e.version,
|
||||
background_image: e.background_image,
|
||||
background_video: e.background_video,
|
||||
payload: e.payload,
|
||||
type: e.type,
|
||||
},
|
||||
])
|
||||
),
|
||||
page: o.toString(),
|
||||
nextPage: d,
|
||||
amount: u,
|
||||
};
|
||||
s.send(T);
|
||||
} catch (a) {
|
||||
s.status(500).json({ error: a });
|
||||
}
|
||||
}
|
||||
async function l(p, s) {
|
||||
try {
|
||||
let a = p.params.package,
|
||||
o = await n.findOne({ where: { package_name: a } });
|
||||
if (!o) return s.status(404).json({ error: "Package not found" });
|
||||
let r = o.toJSON();
|
||||
return delete r.id, delete r.createdAt, delete r.updatedAt, s.send(r);
|
||||
} catch (a) {
|
||||
return s.status(500).json({ error: a });
|
||||
}
|
||||
}
|
||||
var i = { getCatalogAssets: c, getPackage: l };
|
||||
var g = b.Router();
|
||||
g.get("/api/catalog_assets", i.getCatalogAssets);
|
||||
g.get("/api/packages/:package", i.getPackage);
|
||||
var N = g;
|
||||
export { N as default };
|
||||
30
package.json
30
package.json
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "alus-unblocker",
|
||||
"name": "alu",
|
||||
"type": "module",
|
||||
"version": "0.0.1",
|
||||
"scripts": {
|
||||
|
|
@ -13,18 +13,18 @@
|
|||
"lint:fix": "eslint --fix ."
|
||||
},
|
||||
"dependencies": {
|
||||
"@astrojs/node": "^8.3.4",
|
||||
"@inox-tools/sitemap-ext": "^0.3.5",
|
||||
"@astrojs/node": "^9.0.0",
|
||||
"@astrojs/sitemap": "^3.2.1",
|
||||
"@mercuryworkshop/bare-as-module3": "^2.2.5",
|
||||
"@mercuryworkshop/bare-mux": "^2.1.6",
|
||||
"@mercuryworkshop/epoxy-transport": "^2.1.13",
|
||||
"@mercuryworkshop/libcurl-transport": "^1.3.12",
|
||||
"@mercuryworkshop/bare-mux": "^2.1.5",
|
||||
"@mercuryworkshop/epoxy-transport": "^2.1.12",
|
||||
"@mercuryworkshop/libcurl-transport": "^1.3.14",
|
||||
"@mercuryworkshop/wisp-js": "^0.3.3",
|
||||
"@rubynetwork/rammerhead": "^1.3.5",
|
||||
"@titaniumnetwork-dev/ultraviolet": "^3.2.10",
|
||||
"@tomphttp/bare-server-node": "^2.0.4",
|
||||
"@types/node": "^20.17.1",
|
||||
"astro": "^4.16.7",
|
||||
"@tomphttp/bare-server-node": "^2.0.5",
|
||||
"@types/node": "^22.10.1",
|
||||
"astro": "^5.0.1",
|
||||
"chalk": "^5.3.0",
|
||||
"cookie-parser": "^1.4.7",
|
||||
"dotenv-flow": "^4.1.0",
|
||||
|
|
@ -34,12 +34,12 @@
|
|||
"sqlite3": "^5.1.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
||||
"@typescript-eslint/parser": "^7.18.0",
|
||||
"eslint": "^8.57.1",
|
||||
"eslint-plugin-astro": "^0.31.4",
|
||||
"prettier": "3.2.5",
|
||||
"prettier-plugin-astro": "^0.13.0"
|
||||
"@typescript-eslint/eslint-plugin": "^8.17.0",
|
||||
"@typescript-eslint/parser": "^8.17.0",
|
||||
"eslint": "^9.16.0",
|
||||
"eslint-plugin-astro": "^1.3.1",
|
||||
"prettier": "3.4.1",
|
||||
"prettier-plugin-astro": "^0.14.1"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"bufferutil": "^4.0.8"
|
||||
|
|
|
|||
4986
pnpm-lock.yaml
generated
4986
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
64
public/sw.js
64
public/sw.js
|
|
@ -11,42 +11,52 @@ function loadExtensionScripts() {
|
|||
try {
|
||||
let db = indexedDB.open("AluDB", 1);
|
||||
db.onsuccess = () => {
|
||||
let transaction = db.result.transaction("InstalledExtensions", "readonly");
|
||||
let store = transaction.objectStore("InstalledExtensions");
|
||||
let request = store.getAll();
|
||||
request.onsuccess = () => {
|
||||
let extensions = request.result.filter((extension) => extension.type == "serviceWorker");
|
||||
extensions.forEach((extension) => {
|
||||
const decoder = new TextDecoder();
|
||||
const contents = decoder.decode(extension.scriptCopy);
|
||||
try {
|
||||
let transaction = db.result.transaction("InstalledExtensions", "readonly");
|
||||
let store = transaction.objectStore("InstalledExtensions");
|
||||
let request = store.getAll();
|
||||
request.onsuccess = () => {
|
||||
let extensions = request.result.filter((extension) => extension.type == "serviceWorker");
|
||||
extensions.forEach((extension) => {
|
||||
const decoder = new TextDecoder();
|
||||
const contents = decoder.decode(extension.scriptCopy);
|
||||
|
||||
|
||||
eval(contents);
|
||||
const func = self[extension.entryNamespace][extension.entryFunc];
|
||||
switch (extension.type) {
|
||||
case "serviceWorker":
|
||||
// Loads the function to be added as a middleware into global scope.
|
||||
eval(contents);
|
||||
const func = self[extension.entryNamespace][extension.entryFunc];
|
||||
switch (extension.type) {
|
||||
case "serviceWorker":
|
||||
// Loads the function to be added as a middleware into global scope.
|
||||
|
||||
ww.use({
|
||||
function: self[extension.entryNamespace][extension.entryFunc],
|
||||
name: extension.title,
|
||||
events: ["fetch"],
|
||||
});
|
||||
break;
|
||||
case "page":
|
||||
console.log("Calling " + extension.entryFunc);
|
||||
func();
|
||||
break;
|
||||
ww.use({
|
||||
function: self[extension.entryNamespace][extension.entryFunc],
|
||||
name: extension.title,
|
||||
events: ["fetch"],
|
||||
});
|
||||
break;
|
||||
case "page":
|
||||
console.log("Calling " + extension.entryFunc);
|
||||
func();
|
||||
break;
|
||||
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
});
|
||||
};
|
||||
} catch {
|
||||
console.error("Failed to open IndexedDB");
|
||||
}
|
||||
};
|
||||
} catch (err) {
|
||||
console.error(`Failed load extension scripts: ${err}`);
|
||||
}
|
||||
}
|
||||
loadExtensionScripts();
|
||||
|
||||
try {
|
||||
loadExtensionScripts();
|
||||
} catch (err) {
|
||||
console.error(`Failed to load extension scripts: ${err}`);
|
||||
}
|
||||
|
||||
|
||||
self.addEventListener("fetch", async (event) => {
|
||||
event.respondWith(
|
||||
|
|
|
|||
|
|
@ -2,7 +2,15 @@
|
|||
import IDBManager from "@components/ts/IDBManager";
|
||||
const idb = IDBManager.loadIDB("AluDB", 1);
|
||||
|
||||
idb.onsuccess = () => {
|
||||
idb.onupgradeneeded = (event) => {
|
||||
const db = (event.target as IDBOpenDBRequest).result;
|
||||
db.createObjectStore("InstalledExtensions", { keyPath: "slug" });
|
||||
};
|
||||
|
||||
// Create a store for installed extensions
|
||||
|
||||
idb.onsuccess = (event) => {
|
||||
IDBManager.SetIDB((event.target as IDBOpenDBRequest).result);
|
||||
IDBManager.GetStore("InstalledExtensions", "readonly").getAll().onsuccess = (event) => {
|
||||
// TODO: Get rid of this ugly type assertion!!
|
||||
const result = (event.target as IDBRequest).result;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
<script>
|
||||
import IDBManager from "@components/ts/IDBManager";
|
||||
import instantiateAlu from "@components/ts/Alu";
|
||||
|
||||
await instantiateAlu();
|
||||
|
||||
function switchTheme() {
|
||||
const currentTheme = Alu.store.get("theme");
|
||||
|
|
|
|||
|
|
@ -1,15 +1,32 @@
|
|||
import AluStore from "./AluStore";
|
||||
import IDBManager from "./IDBManager";
|
||||
|
||||
function instantiateAlu() {
|
||||
if (globalThis.Alu) return;
|
||||
globalThis.Alu = {
|
||||
store: new AluStore(),
|
||||
eventList: {},
|
||||
settings: {
|
||||
loadedContentStorage: {},
|
||||
currentTab: "",
|
||||
},
|
||||
};
|
||||
async function instantiateAlu(): Promise<void> {
|
||||
return new Promise((resolve) => {
|
||||
if (globalThis.Alu) return;
|
||||
globalThis.Alu = {
|
||||
store: new AluStore(),
|
||||
eventList: {},
|
||||
settings: {
|
||||
loadedContentStorage: {},
|
||||
currentTab: "",
|
||||
},
|
||||
};
|
||||
|
||||
if (!window.idb) {
|
||||
const db = IDBManager.loadIDB("AluDB", 1);
|
||||
db.onupgradeneeded = () => {
|
||||
window.idb = db.result;
|
||||
IDBManager.SetIDB(window.idb);
|
||||
IDBManager.CreateStore("InstalledExtensions", { keyPath: "slug" });
|
||||
};
|
||||
db.onsuccess = () => {
|
||||
window.idb = db.result;
|
||||
IDBManager.SetIDB(window.idb);
|
||||
resolve();
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export default instantiateAlu;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
---
|
||||
|
||||
|
||||
import { ViewTransitions } from "astro:transitions";
|
||||
import Header from "@components/UI/Header.astro";
|
||||
import Footer from "@components/UI/Footer.astro";
|
||||
|
|
@ -44,7 +46,7 @@ const DESCRIPTION =
|
|||
<link rel="sitemap" href="/sitemap-index.xml" />
|
||||
<SchemaData />
|
||||
{
|
||||
optionalStylesheets?.map((item) => {
|
||||
optionalStylesheets?.map((item: string) => {
|
||||
return <link rel="stylesheet" class="style-load" href={item} />;
|
||||
})
|
||||
}
|
||||
|
|
@ -57,25 +59,6 @@ const DESCRIPTION =
|
|||
gtag("js", new Date());
|
||||
gtag("config", "G-P1JX4G9KSF");
|
||||
</script>
|
||||
<script>
|
||||
import instantiateAlu from "@components/ts/Alu";
|
||||
import IDBManager from "@components/ts/IDBManager";
|
||||
|
||||
instantiateAlu();
|
||||
|
||||
if (!window.idb) {
|
||||
const db = IDBManager.loadIDB("AluDB", 1);
|
||||
db.onupgradeneeded = () => {
|
||||
window.idb = db.result;
|
||||
IDBManager.SetIDB(window.idb);
|
||||
IDBManager.CreateStore("InstalledExtensions", { keyPath: "slug" });
|
||||
};
|
||||
db.onsuccess = () => {
|
||||
window.idb = db.result;
|
||||
IDBManager.SetIDB(window.idb);
|
||||
};
|
||||
}
|
||||
</script>
|
||||
<script src="@components/ts/AluStore.ts"></script>
|
||||
<meta name="generator" content={Astro.generator} />
|
||||
<title>{title}</title>
|
||||
|
|
|
|||
|
|
@ -3,22 +3,8 @@ export const prerender = false;
|
|||
import Layout from "../../layouts/Layout.astro";
|
||||
import games from "../../json/games.json";
|
||||
|
||||
import sitemap from "sitemap-ext:config";
|
||||
|
||||
const gamesList = games as GameList;
|
||||
|
||||
sitemap(async ({ setSitemap }) => {
|
||||
const gamesList = games as GameList;
|
||||
setSitemap(
|
||||
Object.keys(gamesList).map((game) => ({
|
||||
sitemap: true,
|
||||
params: {
|
||||
game: game,
|
||||
},
|
||||
}))
|
||||
);
|
||||
});
|
||||
|
||||
// get the current game based on the information in the url
|
||||
const game = Astro.params.game;
|
||||
if (!game) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue