Chore: format... 2!

This commit is contained in:
MotorTruck1221 2024-10-12 02:20:39 -06:00
parent 8cb2513610
commit fd8aaf543e
No known key found for this signature in database
GPG key ID: 08F417E2B8B61EA4
38 changed files with 854 additions and 854 deletions

View file

@ -1,4 +1,4 @@
{ {
"recommendations": ["astro-build.astro-vscode"], "recommendations": ["astro-build.astro-vscode"],
"unwantedRecommendations": [] "unwantedRecommendations": []
} }

18
.vscode/launch.json vendored
View file

@ -1,11 +1,11 @@
{ {
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"command": "./node_modules/.bin/astro dev", "command": "./node_modules/.bin/astro dev",
"name": "Development server", "name": "Development server",
"request": "launch", "request": "launch",
"type": "node-terminal" "type": "node-terminal"
} }
] ]
} }

View file

@ -9,72 +9,72 @@ import icon from "astro-icon";
import { defineConfig } from "astro/config"; import { defineConfig } from "astro/config";
import { viteStaticCopy } from "vite-plugin-static-copy"; import { viteStaticCopy } from "vite-plugin-static-copy";
export default defineConfig({ export default defineConfig({
integrations: [tailwind(), icon(), svelte()], integrations: [tailwind(), icon(), svelte()],
vite: { vite: {
plugins: [ plugins: [
viteStaticCopy({ viteStaticCopy({
targets: [ targets: [
{ {
src: `${uvPath}/**/*`.replace(/\\/g, "/"), src: `${uvPath}/**/*`.replace(/\\/g, "/"),
dest: "uv", dest: "uv",
overwrite: false overwrite: false
}, },
{ {
src: `${epoxyPath}/**/*`.replace(/\\/g, "/"), src: `${epoxyPath}/**/*`.replace(/\\/g, "/"),
dest: "epoxy", dest: "epoxy",
overwrite: false overwrite: false
}, },
{ {
src: `${libcurlPath}/**/*`.replace(/\\/g, "/"), src: `${libcurlPath}/**/*`.replace(/\\/g, "/"),
dest: "libcurl", dest: "libcurl",
overwrite: false overwrite: false
}, },
{ {
src: `${baremuxPath}/**/*`.replace(/\\/g, "/"), src: `${baremuxPath}/**/*`.replace(/\\/g, "/"),
dest: "baremux", dest: "baremux",
overwrite: false overwrite: false
} }
] ]
}) })
], ],
server: { server: {
proxy: { proxy: {
"/api/catalog-assets": { "/api/catalog-assets": {
target: "http://localhost:8080/api/catalog-assets", target: "http://localhost:8080/api/catalog-assets",
changeOrigin: true, changeOrigin: true,
rewrite: (path) => path.replace(/^\/api\/catalog-assets/, "") rewrite: (path) => path.replace(/^\/api\/catalog-assets/, "")
}, },
"/images": { "/images": {
target: "http://localhost:8080", target: "http://localhost:8080",
changeOrigin: true changeOrigin: true
}, },
"/videos": { "/videos": {
target: "http://localhost:8080", target: "http://localhost:8080",
changeOrigin: true changeOrigin: true
}, },
"/wisp/": { "/wisp/": {
target: "ws://localhost:8080/wisp/", target: "ws://localhost:8080/wisp/",
changeOrigin: true, changeOrigin: true,
ws: true, ws: true,
rewrite: (path) => path.replace(/^\/wisp\//, "") rewrite: (path) => path.replace(/^\/wisp\//, "")
}, },
"/styles": { "/styles": {
target: "http://localhost:8080", target: "http://localhost:8080",
changeOrigin: true changeOrigin: true
}, },
"/api/packages": { "/api/packages": {
target: "http://localhost:8080", target: "http://localhost:8080",
changeOrigin: true changeOrigin: true
}, },
"/api/catalog-pages": { "/api/catalog-pages": {
target: "http://localhost:8080", target: "http://localhost:8080",
changeOrigin: true changeOrigin: true
}
}
} }
} },
} output: "server",
}, adapter: node({
output: "server", mode: "hybrid"
adapter: node({ })
mode: "hybrid"
})
}); });

View file

@ -1,32 +1,32 @@
{ {
"$schema": "https://biomejs.dev/schemas/1.9.3/schema.json", "$schema": "https://biomejs.dev/schemas/1.9.3/schema.json",
"files": { "files": {
"ignore": ["~/", "**/dist/**", ".github/**"], "ignore": ["~/", "**/dist/**", ".github/**"],
"include": ["**/**", "server/**"] "include": ["**/**", "server/**"]
},
"formatter": {
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 100,
"ignore": ["pnpm-lock.yaml", "package.json"]
},
"organizeImports": { "enabled": true },
"linter": { "enabled": false },
"javascript": {
"formatter": {
"trailingCommas": "none",
"quoteStyle": "double",
"semicolons": "always"
}
},
"json": {
"parser": {
"allowComments": true,
"allowTrailingCommas": true
}, },
"formatter": { "formatter": {
"indentStyle": "space", "indentStyle": "space",
"trailingCommas": "none" "indentWidth": 4,
"lineWidth": 100,
"ignore": ["pnpm-lock.yaml", "package.json"]
},
"organizeImports": { "enabled": true },
"linter": { "enabled": false },
"javascript": {
"formatter": {
"trailingCommas": "none",
"quoteStyle": "double",
"semicolons": "always"
}
},
"json": {
"parser": {
"allowComments": true,
"allowTrailingCommas": true
},
"formatter": {
"indentStyle": "space",
"trailingCommas": "none"
}
} }
}
} }

View file

@ -1,5 +1,5 @@
{ {
"marketplace_enabled": true, "marketplace_enabled": true,
"marketplace_psk": "CHANGE_THIS_THIS_IS_INSECURE", "marketplace_psk": "CHANGE_THIS_THIS_IS_INSECURE",
"marketplace_level": "1" "marketplace_level": "1"
} }

View file

@ -1,19 +1,19 @@
:root { :root {
--background-primary: rgba(0, 0, 0, 0); --background-primary: rgba(0, 0, 0, 0);
--background-lighter: #000; --background-lighter: #000;
--navbar-color: #000; --navbar-color: #000;
--navbar-height: 60px; --navbar-height: 60px;
--navbar-text-color: greenyellow; --navbar-text-color: greenyellow;
--navbar-link-color: greenyellow; --navbar-link-color: greenyellow;
--navbar-link-hover-color: green; --navbar-link-hover-color: green;
--navbar-font: "Roboto"; --navbar-font: "Roboto";
--input-text-color: greenyellow; --input-text-color: greenyellow;
--input-placeholder-color: white; --input-placeholder-color: white;
--input-background-color: #000; --input-background-color: #000;
--input-border-color: greenyellow; --input-border-color: greenyellow;
--input-border-size: 1.3px; --input-border-size: 1.3px;
--navbar-logo-filter: none; --navbar-logo-filter: none;
--dropdown-option-hover-color: #312a49; --dropdown-option-hover-color: #312a49;
--tab-color: var(--black); --tab-color: var(--black);
--border-color: greenyellow; --border-color: greenyellow;
} }

View file

@ -1,19 +1,19 @@
:root { :root {
--background-primary: #191724; --background-primary: #191724;
--background-lighter: #16121f; --background-lighter: #16121f;
--navbar-color: #26233a; --navbar-color: #26233a;
--navbar-height: 60px; --navbar-height: 60px;
--navbar-text-color: #7967dd; --navbar-text-color: #7967dd;
--navbar-link-color: #e0def4; --navbar-link-color: #e0def4;
--navbar-link-hover-color: gray; --navbar-link-hover-color: gray;
--navbar-font: "Roboto"; --navbar-font: "Roboto";
--input-text-color: #e0def4; --input-text-color: #e0def4;
--input-placeholder-color: white; --input-placeholder-color: white;
--input-background-color: #1f1d2e; --input-background-color: #1f1d2e;
--input-border-color: #eb6f92; --input-border-color: #eb6f92;
--input-border-size: 1.3px; --input-border-size: 1.3px;
--navbar-logo-filter: none; --navbar-logo-filter: none;
--dropdown-option-hover-color: #312a49; --dropdown-option-hover-color: #312a49;
--tab-color: var(--black); --tab-color: var(--black);
--border-color: #16121f; --border-color: #16121f;
} }

View file

@ -5,17 +5,17 @@ importScripts("/uv/uv.config.js");
importScripts(__uv$config.sw || "/uv/uv.sw.js"); importScripts(__uv$config.sw || "/uv/uv.sw.js");
const uv = new UVServiceWorker(); const uv = new UVServiceWorker();
self.addEventListener("fetch", function (event) { self.addEventListener("fetch", function (event) {
if (event.request.url.startsWith(location.origin + __uv$config.prefix)) { if (event.request.url.startsWith(location.origin + __uv$config.prefix)) {
event.respondWith( event.respondWith(
(async function () { (async function () {
return await uv.fetch(event); return await uv.fetch(event);
})() })()
); );
} else { } else {
event.respondWith( event.respondWith(
(async function () { (async function () {
return await fetch(event.request); return await fetch(event.request);
})() })()
); );
} }
}); });

View file

@ -1,30 +1,30 @@
self.__uv$config = { self.__uv$config = {
prefix: "/~/uv/", prefix: "/~/uv/",
bare: "/bare/", bare: "/bare/",
encodeUrl: function encode(str) { encodeUrl: function encode(str) {
if (!str) return str; if (!str) return str;
return encodeURIComponent( return encodeURIComponent(
str str
.toString() .toString()
.split("") .split("")
.map((char, ind) => (ind % 2 ? String.fromCharCode(char.charCodeAt() ^ 3) : char)) .map((char, ind) => (ind % 2 ? String.fromCharCode(char.charCodeAt() ^ 3) : char))
.join("") .join("")
); );
}, },
decodeUrl: function decode(str) { decodeUrl: function decode(str) {
if (!str) return str; if (!str) return str;
let [input, ...search] = str.split("?"); let [input, ...search] = str.split("?");
return ( return (
decodeURIComponent(input) decodeURIComponent(input)
.split("") .split("")
.map((char, ind) => (ind % 2 ? String.fromCharCode(char.charCodeAt(0) ^ 3) : char)) .map((char, ind) => (ind % 2 ? String.fromCharCode(char.charCodeAt(0) ^ 3) : char))
.join("") + (search.length ? "?" + search.join("?") : "") .join("") + (search.length ? "?" + search.join("?") : "")
); );
}, },
handler: "/uv/uv.handler.js", handler: "/uv/uv.handler.js",
client: "/uv/uv.client.js", client: "/uv/uv.client.js",
bundle: "/uv/uv.bundle.js", bundle: "/uv/uv.bundle.js",
config: "/uv/uv.config.js", config: "/uv/uv.config.js",
sw: "/uv/uv.sw.js" sw: "/uv/uv.sw.js"
}; };

402
server.js
View file

@ -3,10 +3,10 @@ import { createServer } from "node:http";
import path from "path"; import path from "path";
import { fileURLToPath } from "url"; import { fileURLToPath } from "url";
import { import {
createRammerhead, createRammerhead,
routeRhRequest, routeRhRequest,
routeRhUpgrade, routeRhUpgrade,
shouldRouteRh shouldRouteRh
} from "@rubynetwork/rammerhead"; } from "@rubynetwork/rammerhead";
import express from "express"; import express from "express";
import multer from "multer"; import multer from "multer";
@ -19,71 +19,71 @@ const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename); const __dirname = path.dirname(__filename);
//create the rh server. //create the rh server.
const rh = createRammerhead({ const rh = createRammerhead({
logLevel: "debug", logLevel: "debug",
reverseProxy: true, reverseProxy: true,
disableLocalStorageSync: false, disableLocalStorageSync: false,
disableHttp2: false disableHttp2: false
}); });
const app = express(); const app = express();
const publicPath = "dist/client"; const publicPath = "dist/client";
const sequelize = new Sequelize("database", "user", "password", { const sequelize = new Sequelize("database", "user", "password", {
host: "localhost", host: "localhost",
dialect: "sqlite", dialect: "sqlite",
logging: false, logging: false,
// SQLite only // SQLite only
storage: "database.sqlite" storage: "database.sqlite"
}); });
// Auth middleware // Auth middleware
function auth_psk(req, res, next) { function auth_psk(req, res, next) {
if (!config.marketplace_enabled) { if (!config.marketplace_enabled) {
let err = "Marketplace is disabled!"; let err = "Marketplace is disabled!";
return next(err); return next(err);
} }
if (req.headers.psk !== config.marketplace_psk) { if (req.headers.psk !== config.marketplace_psk) {
let err = "Bad PSK!"; let err = "Bad PSK!";
console.log("Bad psk"); console.log("Bad psk");
return next(err); return next(err);
} }
return next(); return next();
} }
var image_storage = multer.diskStorage({ var image_storage = multer.diskStorage({
destination: function (req, file, cb) { destination: function (req, file, cb) {
cb(null, "database_assets/image"); cb(null, "database_assets/image");
}, },
filename: function (req, file, cb) { filename: function (req, file, cb) {
cb(null, file.originalname); //Appending extension cb(null, file.originalname); //Appending extension
} }
}); });
var video_storage = multer.diskStorage({ var video_storage = multer.diskStorage({
destination: function (req, file, cb) { destination: function (req, file, cb) {
cb(null, "database_assets/video"); cb(null, "database_assets/video");
}, },
filename: function (req, file, cb) { filename: function (req, file, cb) {
cb(null, file.originalname); //Appending extension cb(null, file.originalname); //Appending extension
} }
}); });
var style_storage = multer.diskStorage({ var style_storage = multer.diskStorage({
destination: function (req, file, cb) { destination: function (req, file, cb) {
cb(null, "database_assets/styles"); cb(null, "database_assets/styles");
}, },
filename: function (req, file, cb) { filename: function (req, file, cb) {
cb(null, file.originalname); //Appending extension cb(null, file.originalname); //Appending extension
} }
}); });
var script_storage = multer.diskStorage({ var script_storage = multer.diskStorage({
destination: function (req, file, cb) { destination: function (req, file, cb) {
cb(null, "database_assets/scripts"); cb(null, "database_assets/scripts");
}, },
filename: function (req, file, cb) { filename: function (req, file, cb) {
cb(null, file.originalname); //Appending extension cb(null, file.originalname); //Appending extension
} }
}); });
var image_upload = multer({ storage: image_storage }); var image_upload = multer({ storage: image_storage });
@ -92,198 +92,198 @@ var style_upload = multer({ storage: style_storage });
var script_upload = multer({ storage: script_storage }); var script_upload = multer({ storage: script_storage });
const catalog_assets = sequelize.define("catalog_assets", { const catalog_assets = sequelize.define("catalog_assets", {
package_name: { package_name: {
type: DataTypes.TEXT, type: DataTypes.TEXT,
unique: true unique: true
}, },
title: { title: {
type: DataTypes.TEXT type: DataTypes.TEXT
}, },
description: { description: {
type: DataTypes.TEXT type: DataTypes.TEXT
}, },
author: { author: {
type: DataTypes.TEXT type: DataTypes.TEXT
}, },
image: { image: {
type: DataTypes.TEXT type: DataTypes.TEXT
}, },
tags: { tags: {
type: DataTypes.JSON, type: DataTypes.JSON,
allowNull: true allowNull: true
}, },
version: { version: {
type: DataTypes.TEXT type: DataTypes.TEXT
}, },
background_image: { background_image: {
type: DataTypes.TEXT, type: DataTypes.TEXT,
allowNull: true allowNull: true
}, },
background_video: { background_video: {
type: DataTypes.TEXT, type: DataTypes.TEXT,
allowNull: true allowNull: true
}, },
payload: { payload: {
type: DataTypes.TEXT type: DataTypes.TEXT
}, },
type: { type: {
type: DataTypes.TEXT type: DataTypes.TEXT
} }
}); });
app.use(express.json()); app.use(express.json());
app.get("/api", function (request, reply) { app.get("/api", function (request, reply) {
reply.send({ hello: "world" }); reply.send({ hello: "world" });
}); });
// This API returns a list of the assets in the database (SW plugins and themes). // This API returns a list of the assets in the database (SW plugins and themes).
// It also returns the number of pages in the database. // It also returns the number of pages in the database.
// It can take a `?page=x` argument to display a different page, with a limit of 20 assets per page. // It can take a `?page=x` argument to display a different page, with a limit of 20 assets per page.
app.get("/api/catalog-assets", async (request, reply) => { app.get("/api/catalog-assets", async (request, reply) => {
try { try {
const page = parseInt(request.query.page, 10) || 1; // default to page 1 const page = parseInt(request.query.page, 10) || 1; // default to page 1
const totalItems = await catalog_assets.count(); const totalItems = await catalog_assets.count();
if (page < 1) { if (page < 1) {
reply.status(400).send({ error: "Page must be a positive number!" }); reply.status(400).send({ error: "Page must be a positive number!" });
return; return;
}
const offset = (page - 1) * 20;
const db_assets = await catalog_assets.findAll({
offset: offset,
limit: 20
});
const assets = db_assets.reduce((acc, asset) => {
acc[asset.package_name] = {
title: asset.title,
description: asset.description,
author: asset.author,
image: asset.image,
tags: asset.tags,
version: asset.version,
background_image: asset.background_image,
background_video: asset.background_video,
payload: asset.payload,
type: asset.type
};
return acc;
}, {});
reply.send({ assets, pages: Math.ceil(totalItems / 20) });
} catch (error) {
reply.status(500).send({ error: "There was an error" });
} }
const offset = (page - 1) * 20;
const db_assets = await catalog_assets.findAll({
offset: offset,
limit: 20
});
const assets = db_assets.reduce((acc, asset) => {
acc[asset.package_name] = {
title: asset.title,
description: asset.description,
author: asset.author,
image: asset.image,
tags: asset.tags,
version: asset.version,
background_image: asset.background_image,
background_video: asset.background_video,
payload: asset.payload,
type: asset.type
};
return acc;
}, {});
reply.send({ assets, pages: Math.ceil(totalItems / 20) });
} catch (error) {
reply.status(500).send({ error: "There was an error" });
}
}); });
// This API returns data about a single package. // This API returns data about a single package.
app.get("/api/packages/:package", async (request, reply) => { app.get("/api/packages/:package", async (request, reply) => {
try { try {
console.log(request.params.package); console.log(request.params.package);
const package_row = await catalog_assets.findOne({ const package_row = await catalog_assets.findOne({
where: { package_name: request.params.package } where: { package_name: request.params.package }
}); });
if (!package_row) { if (!package_row) {
return reply.status(404).send({ error: "Package not found!" }); return reply.status(404).send({ error: "Package not found!" });
}
const details = {
title: package_row.get("title"),
description: package_row.get("description"),
image: package_row.get("image"),
author: package_row.get("author"),
tags: package_row.get("tags"),
version: package_row.get("version"),
background_image: package_row.get("background_image"),
background_video: package_row.get("background_video"),
payload: package_row.get("payload"),
type: package_row.get("type")
};
reply.send(details);
} catch (error) {
reply.status(500).send({ error: "There was an error" });
} }
const details = {
title: package_row.get("title"),
description: package_row.get("description"),
image: package_row.get("image"),
author: package_row.get("author"),
tags: package_row.get("tags"),
version: package_row.get("version"),
background_image: package_row.get("background_image"),
background_video: package_row.get("background_video"),
payload: package_row.get("payload"),
type: package_row.get("type")
};
reply.send(details);
} catch (error) {
reply.status(500).send({ error: "There was an error" });
}
}); });
// This API is responsible for image uploads // This API is responsible for image uploads
// PSK authentication required. // PSK authentication required.
app.post("/api/upload-image", auth_psk, image_upload.single("file"), (req, res) => { app.post("/api/upload-image", auth_psk, image_upload.single("file"), (req, res) => {
console.log("Request file:", req.file); console.log("Request file:", req.file);
if (!req.file) { if (!req.file) {
return res.status(400).json({ error: "No file uploaded" }); return res.status(400).json({ error: "No file uploaded" });
} }
console.log(req.file.originalname); console.log(req.file.originalname);
res.json({ res.json({
message: "File uploaded successfully", message: "File uploaded successfully",
filename: req.file.originalname filename: req.file.originalname
}); });
}); });
// This API is responsible for video uploads // This API is responsible for video uploads
// PSK authentication required. // PSK authentication required.
app.post("/api/upload-video", auth_psk, video_upload.single("file"), (req, res) => { app.post("/api/upload-video", auth_psk, video_upload.single("file"), (req, res) => {
if (!req.file) { if (!req.file) {
return res.status(400).json({ error: "No file uploaded" }); return res.status(400).json({ error: "No file uploaded" });
} }
res.json({ res.json({
message: "File uploaded successfully", message: "File uploaded successfully",
filename: req.file.originalname filename: req.file.originalname
}); });
}); });
// This API is responsible for stylesheet uploads // This API is responsible for stylesheet uploads
// PSK authentication required. // PSK authentication required.
app.post("/api/upload-style", auth_psk, style_upload.single("file"), (req, res) => { app.post("/api/upload-style", auth_psk, style_upload.single("file"), (req, res) => {
if (!req.file) { if (!req.file) {
return res.status(400).json({ error: "No file uploaded" }); return res.status(400).json({ error: "No file uploaded" });
} }
res.json({ res.json({
message: "File uploaded successfully", message: "File uploaded successfully",
filename: req.file.originalname filename: req.file.originalname
}); });
}); });
// This API is responsible for script/plugin uploads // This API is responsible for script/plugin uploads
// PSK authentication required. // PSK authentication required.
app.post("/api/upload-script", auth_psk, script_upload.single("file"), (req, res) => { app.post("/api/upload-script", auth_psk, script_upload.single("file"), (req, res) => {
if (!req.file) { if (!req.file) {
return res.status(400).json({ error: "No file uploaded" }); return res.status(400).json({ error: "No file uploaded" });
} }
res.json({ res.json({
message: "File uploaded successfully", message: "File uploaded successfully",
filename: req.file.originalname filename: req.file.originalname
}); });
}); });
// This API is responsible for creating packages in the database. // This API is responsible for creating packages in the database.
// PSK authentication required. // PSK authentication required.
app.post("/api/create-package", auth_psk, async function (req, res) { app.post("/api/create-package", auth_psk, async function (req, res) {
console.log(req.body); console.log(req.body);
await catalog_assets.create({ await catalog_assets.create({
package_name: req.body.uuid, package_name: req.body.uuid,
title: req.body.title, title: req.body.title,
image: req.body.image_path, image: req.body.image_path,
author: req.body.author, author: req.body.author,
version: req.body.version, version: req.body.version,
description: req.body.description, description: req.body.description,
tags: req.body.tags, tags: req.body.tags,
payload: req.body.payload, payload: req.body.payload,
background_video: req.body.background_video_path, background_video: req.body.background_video_path,
background_image: req.body.background_image_path, background_image: req.body.background_image_path,
type: req.body.type type: req.body.type
}); });
res.send({ hello: "world" }); res.send({ hello: "world" });
}); });
app.use("/images/", express.static("./database_assets/image")); app.use("/images/", express.static("./database_assets/image"));
@ -323,23 +323,23 @@ catalog_assets.sync();
const server = createServer(); const server = createServer();
server.on("request", (req, res) => { server.on("request", (req, res) => {
res.setHeader("Cross-Origin-Opener-Policy", "same-origin"); res.setHeader("Cross-Origin-Opener-Policy", "same-origin");
res.setHeader("Cross-Origin-Embedder-Policy", "require-corp"); res.setHeader("Cross-Origin-Embedder-Policy", "require-corp");
if (shouldRouteRh(req)) { if (shouldRouteRh(req)) {
routeRhRequest(rh, req, res); routeRhRequest(rh, req, res);
} else { } else {
app(req, res); app(req, res);
} }
}); });
server.on("upgrade", (req, socket, head) => { server.on("upgrade", (req, socket, head) => {
if (shouldRouteRh(req)) { if (shouldRouteRh(req)) {
routeRhUpgrade(rh, req, socket, head); routeRhUpgrade(rh, req, socket, head);
} else if (req.url.endsWith("/wisp/")) { } else if (req.url.endsWith("/wisp/")) {
wisp.routeRequest(req, socket, head); wisp.routeRequest(req, socket, head);
} }
}); });
server.listen({ server.listen({
port: 8080 port: 8080
}); });

View file

@ -1,8 +1,8 @@
--- ---
interface Props { interface Props {
title: string; title: string;
body: string; body: string;
href: string; href: string;
} }
const { href, title, body } = Astro.props; const { href, title, body } = Astro.props;

View file

@ -3,9 +3,9 @@ import { Suspense } from "@svelte-drama/suspense";
import { Settings } from "@utils/settings/index"; import { Settings } from "@utils/settings/index";
export let page; export let page;
async function getAssets() { async function getAssets() {
const response = await fetch("/api/catalog-assets?page=" + page); const response = await fetch("/api/catalog-assets?page=" + page);
const data = await response.json(); const data = await response.json();
return data.assets; return data.assets;
} }
const assets = getAssets(); const assets = getAssets();
</script> </script>

View file

@ -3,25 +3,25 @@ import { Suspense } from "@svelte-drama/suspense";
import { Settings, settings } from "@utils/settings/index"; import { Settings, settings } from "@utils/settings/index";
import Parent from "./Parent.svelte"; import Parent from "./Parent.svelte";
async function getItem(item) { async function getItem(item) {
try { try {
const response = await fetch(`/api/packages/${item}`); const response = await fetch(`/api/packages/${item}`);
const data = await response.json(); const data = await response.json();
return { return {
...data, ...data,
package_name: item package_name: item
}; };
} catch (error) { } catch (error) {
console.error("error: failed to fetch", error); console.error("error: failed to fetch", error);
return null; return null;
} }
} }
async function getAssets() { async function getAssets() {
const items = JSON.parse(localStorage.getItem(Settings.AppearanceSettings.themes)) || []; const items = JSON.parse(localStorage.getItem(Settings.AppearanceSettings.themes)) || [];
const promises = items.map(getItem); const promises = items.map(getItem);
const dataArray = await Promise.all(promises); const dataArray = await Promise.all(promises);
const accumulatedData = dataArray.filter((data) => data !== null); const accumulatedData = dataArray.filter((data) => data !== null);
console.log(JSON.stringify(accumulatedData)); console.log(JSON.stringify(accumulatedData));
return accumulatedData; return accumulatedData;
} }
let assets = getAssets(); let assets = getAssets();
let compRef = []; let compRef = [];

View file

@ -1,30 +1,30 @@
--- ---
interface Inputs { interface Inputs {
input: boolean; input: boolean;
required?: boolean; required?: boolean;
placeholder?: string; placeholder?: string;
} }
interface SelectOptions { interface SelectOptions {
value: string; value: string;
name: string; name: string;
disabled: boolean; disabled: boolean;
} }
interface Selects { interface Selects {
select: boolean; select: boolean;
name: string; name: string;
multiple?: boolean; multiple?: boolean;
options?: SelectOptions[]; options?: SelectOptions[];
} }
interface Buttons { interface Buttons {
name: string; name: string;
id: string; id: string;
} }
interface Props { interface Props {
title: string; title: string;
description: string; description: string;
input: Inputs; input: Inputs;
select: Selects; select: Selects;
button: Buttons; button: Buttons;
} }
const { title, description, input, select, button } = Astro.props; const { title, description, input, select, button } = Astro.props;

View file

@ -3,38 +3,38 @@ import { type Position, type Props, type ToastType } from "@utils/toast.ts";
import toast from "svelte-french-toast"; import toast from "svelte-french-toast";
export let toastProp: Props; export let toastProp: Props;
function handleToast(toastProp: Props) { function handleToast(toastProp: Props) {
switch (toastProp.toastType) { switch (toastProp.toastType) {
case "success": case "success":
toast.success(toastProp.text, { toast.success(toastProp.text, {
style: "background: var(--navbar-color); color: var(--input-text-color);", style: "background: var(--navbar-color); color: var(--input-text-color);",
icon: toastProp.emoji, icon: toastProp.emoji,
position: toastProp.position ?? "bottom-right", position: toastProp.position ?? "bottom-right",
duration: toastProp.duration duration: toastProp.duration
}); });
break; break;
case "error": case "error":
toast.error(toastProp.text, { toast.error(toastProp.text, {
style: "background: var(--navbar-color); color: var(--input-text-color);", style: "background: var(--navbar-color); color: var(--input-text-color);",
icon: toastProp.emoji, icon: toastProp.emoji,
position: toastProp.position ?? "bottom-right", position: toastProp.position ?? "bottom-right",
duration: toastProp.duration duration: toastProp.duration
}); });
break; break;
case "promise": case "promise":
throw new Error("Due to the way astro renders promise toasts are not available (ish)"); throw new Error("Due to the way astro renders promise toasts are not available (ish)");
break; break;
case "multiline": case "multiline":
toast(toastProp.text, { toast(toastProp.text, {
style: "background: var(--navbar-color); color: var(--input-text-color);", style: "background: var(--navbar-color); color: var(--input-text-color);",
icon: toastProp.emoji, icon: toastProp.emoji,
position: toastProp.position ?? "bottom-right", position: toastProp.position ?? "bottom-right",
duration: toastProp.duration duration: toastProp.duration
}); });
break; break;
default: default:
throw new Error("Something isn't right..."); throw new Error("Something isn't right...");
break; break;
} }
} }
</script> </script>
<!-- A hacky way to get this to be called. Just click this button (preferably via an EVENT) (see ../../utils/toast.ts) --> <!-- A hacky way to get this to be called. Just click this button (preferably via an EVENT) (see ../../utils/toast.ts) -->

View file

@ -1,12 +1,12 @@
{ {
"header.home": "Home", "header.home": "Home",
"header.games": "Games", "header.games": "Games",
"header.settings": "Settings", "header.settings": "Settings",
"header.morelinks": "Want more links?", "header.morelinks": "Want more links?",
"header.catalog": "Nebula Catalog", "header.catalog": "Nebula Catalog",
"home.placeholder": "Search the web freely", "home.placeholder": "Search the web freely",
"settings.settings": "Settings", "settings.settings": "Settings",
"settings.appearance": "Appearance", "settings.appearance": "Appearance",
"settings.proxy": "Proxy", "settings.proxy": "Proxy",
"settings.tab": "Tab" "settings.tab": "Tab"
} }

View file

@ -1,12 +1,12 @@
{ {
"header.home": "ホーム", "header.home": "ホーム",
"header.games": "ゲーム", "header.games": "ゲーム",
"header.settings": "設定", "header.settings": "設定",
"header.morelinks": "リンク一覧", "header.morelinks": "リンク一覧",
"header.catalog": "Nebula Catalog", "header.catalog": "Nebula Catalog",
"home.placeholder": "検索欄", "home.placeholder": "検索欄",
"settings.settings": "Settings", "settings.settings": "Settings",
"settings.appearance": "Appearance", "settings.appearance": "Appearance",
"settings.proxy": "Proxy", "settings.proxy": "Proxy",
"settings.tab": "Tab" "settings.tab": "Tab"
} }

View file

@ -4,6 +4,6 @@ import jp from "./jp.json";
export const defaultLang = "en_US"; export const defaultLang = "en_US";
export const ui = { export const ui = {
en_US, en_US,
jp jp
}; };

View file

@ -3,13 +3,13 @@ import { defaultLang, ui } from "./ui";
export const STATIC_PATHS = [{ params: { lang: "en_US" } }, { params: { lang: "jp" } }]; export const STATIC_PATHS = [{ params: { lang: "en_US" } }, { params: { lang: "jp" } }];
export function getLangFromUrl(url: URL) { export function getLangFromUrl(url: URL) {
const [, lang] = url.pathname.split("/"); const [, lang] = url.pathname.split("/");
if (lang in ui) return lang as keyof typeof ui; if (lang in ui) return lang as keyof typeof ui;
return defaultLang; return defaultLang;
} }
export function useTranslations(lang: keyof typeof ui) { export function useTranslations(lang: keyof typeof ui) {
return function t(key: keyof (typeof ui)[typeof defaultLang]) { return function t(key: keyof (typeof ui)[typeof defaultLang]) {
return ui[lang][key] || ui[defaultLang][key]; return ui[lang][key] || ui[defaultLang][key];
}; };
} }

View file

@ -4,8 +4,8 @@ import Header from "@components/Header.astro";
import MobileNavigation from "@components/MobileNavigation.astro"; import MobileNavigation from "@components/MobileNavigation.astro";
import SettingsLoader from "@components/settings/Loader.astro"; import SettingsLoader from "@components/settings/Loader.astro";
interface Props { interface Props {
title: string; title: string;
noHeader?: string; noHeader?: string;
} }
const { title, noHeader } = Astro.props; const { title, noHeader } = Astro.props;

View file

@ -1,8 +1,8 @@
--- ---
import Layout from "@layouts/Layout.astro"; import Layout from "@layouts/Layout.astro";
export function getStaticPaths() { export function getStaticPaths() {
const STATIC_PATHS = [{ params: { lang: "en_US" } }, { params: { lang: "jp" } }]; const STATIC_PATHS = [{ params: { lang: "en_US" } }, { params: { lang: "jp" } }];
return STATIC_PATHS; return STATIC_PATHS;
} }
export const prerender = true; export const prerender = true;
--- ---

View file

@ -3,8 +3,8 @@ import Logo from "@components/Logo.astro";
import Layout from "@layouts/Layout.astro"; import Layout from "@layouts/Layout.astro";
import { getLangFromUrl, useTranslations } from "../../i18n/utils"; import { getLangFromUrl, useTranslations } from "../../i18n/utils";
export function getStaticPaths() { export function getStaticPaths() {
const STATIC_PATHS = [{ params: { lang: "en_US" } }, { params: { lang: "jp" } }]; const STATIC_PATHS = [{ params: { lang: "en_US" } }, { params: { lang: "jp" } }];
return STATIC_PATHS; return STATIC_PATHS;
} }
export const prerender = true; export const prerender = true;
const lang = getLangFromUrl(Astro.url); const lang = getLangFromUrl(Astro.url);

View file

@ -8,8 +8,8 @@ import { getLangFromUrl, useTranslations } from "../../../i18n/utils";
const lang = getLangFromUrl(Astro.url); const lang = getLangFromUrl(Astro.url);
const t = useTranslations(lang); const t = useTranslations(lang);
export function getStaticPaths() { export function getStaticPaths() {
const STATIC_PATHS = [{ params: { lang: "en_US" } }, { params: { lang: "jp" } }]; const STATIC_PATHS = [{ params: { lang: "en_US" } }, { params: { lang: "jp" } }];
return STATIC_PATHS; return STATIC_PATHS;
} }
export const prerender = true; export const prerender = true;
--- ---

View file

@ -10,8 +10,8 @@ import { getLangFromUrl, useTranslations } from "../../../i18n/utils";
const lang = getLangFromUrl(Astro.url); const lang = getLangFromUrl(Astro.url);
const t = useTranslations(lang); const t = useTranslations(lang);
export function getStaticPaths() { export function getStaticPaths() {
const STATIC_PATHS = [{ params: { lang: "en_US" } }, { params: { lang: "jp" } }]; const STATIC_PATHS = [{ params: { lang: "en_US" } }, { params: { lang: "jp" } }];
return STATIC_PATHS; return STATIC_PATHS;
} }
export const prerender = true; export const prerender = true;
--- ---

View file

@ -9,8 +9,8 @@ import { getLangFromUrl, useTranslations } from "../../../i18n/utils";
const lang = getLangFromUrl(Astro.url); const lang = getLangFromUrl(Astro.url);
const t = useTranslations(lang); const t = useTranslations(lang);
export function getStaticPaths() { export function getStaticPaths() {
const STATIC_PATHS = [{ params: { lang: "en_US" } }, { params: { lang: "jp" } }]; const STATIC_PATHS = [{ params: { lang: "en_US" } }, { params: { lang: "jp" } }];
return STATIC_PATHS; return STATIC_PATHS;
} }
export const prerender = true; export const prerender = true;
--- ---

View file

@ -1,71 +1,71 @@
import { Settings, WispServerURLS } from "./settings/index"; import { Settings, WispServerURLS } from "./settings/index";
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<void>((resolve) => {
//create and append then scripts tags to the body (this is how we lazy load things) //create and append then scripts tags to the body (this is how we lazy load things)
const epoxyScript = document.createElement("script"); const epoxyScript = document.createElement("script");
epoxyScript.src = "/epoxy/index.js"; epoxyScript.src = "/epoxy/index.js";
epoxyScript.defer = true; epoxyScript.defer = true;
document.body.appendChild(epoxyScript); document.body.appendChild(epoxyScript);
const libCurlScript = document.createElement("script"); const libCurlScript = document.createElement("script");
libCurlScript.src = "/libcurl/index.js"; libCurlScript.src = "/libcurl/index.js";
libCurlScript.defer = true; libCurlScript.defer = true;
document.body.appendChild(libCurlScript); 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;
document.body.appendChild(uvBundle); document.body.appendChild(uvBundle);
const uvConfig = document.createElement("script"); const uvConfig = document.createElement("script");
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 bareMux = document.createElement("script");
bareMux.src = "/baremux/bare.cjs"; bareMux.src = "/baremux/bare.cjs";
bareMux.defer = true; bareMux.defer = true;
document.body.appendChild(bareMux); document.body.appendChild(bareMux);
const checkScripts = setInterval(() => { const checkScripts = setInterval(() => {
//If both of these aren't defined this will repeat until they are //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 //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") { if (typeof EpxMod !== "undefined" && typeof BareMux !== "undefined") {
clearInterval(checkScripts); clearInterval(checkScripts);
resolve(); resolve();
} }
}, 100); }, 100);
}); });
} }
function setTransport(transport?: string) { function setTransport(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", { BareMux.SetTransport("EpxMod.default", {
wisp: wispServer ? WispServerURLS[wispServer] : WispServerURLS.default wisp: wispServer ? WispServerURLS[wispServer] : WispServerURLS.default
}); });
break; break;
case "libcurl": case "libcurl":
BareMux.SetTransport("CurlMod.default", { BareMux.SetTransport("CurlMod.default", {
wisp: wispServer ? WispServerURLS[wispServer] : WispServerURLS.default wisp: wispServer ? WispServerURLS[wispServer] : WispServerURLS.default
}); });
break; break;
} }
resolve(); resolve();
}); });
} }
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<void>((resolve) => { return new Promise<void>((resolve) => {
if ("serviceWorker" in navigator) { if ("serviceWorker" in navigator) {
navigator.serviceWorker.ready.then(async () => { navigator.serviceWorker.ready.then(async () => {
console.debug("Service worker ready!"); console.debug("Service worker ready!");
await loadProxyScripts(); await loadProxyScripts();
resolve(); resolve();
}); });
navigator.serviceWorker.register("/sw.js", { scope: "/" }); navigator.serviceWorker.register("/sw.js", { scope: "/" });
} }
}); });
} }
export { initSw, setTransport }; export { initSw, setTransport };

View file

@ -1,27 +1,27 @@
function search(input: string, template: string) { function search(input: string, template: string) {
try { try {
// input is a valid URL: // input is a valid URL:
// eg: https://example.com, https://example.com/test?q=param // eg: https://example.com, https://example.com/test?q=param
return new URL(input).toString(); return new URL(input).toString();
} catch (err) { } catch (err) {
// input was not a valid URL // input was not a valid URL
} }
try { try {
// input is a valid URL when http:// is added to the start: // input is a valid URL when http:// is added to the start:
// eg: example.com, https://example.com/test?q=param // eg: example.com, https://example.com/test?q=param
const url = new URL(`http://${input}`); const url = new URL(`http://${input}`);
// only if the hostname has a TLD/subdomain // only if the hostname has a TLD/subdomain
if (url.hostname.includes(".")) return url.toString(); if (url.hostname.includes(".")) return url.toString();
} catch (err) { } catch (err) {
// input was not valid URL // input was not valid URL
} }
// input may have been a valid URL, however the hostname was invalid // input may have been a valid URL, however the hostname was invalid
// Attempts to convert the input to a fully qualified URL have failed // Attempts to convert the input to a fully qualified URL have failed
// Treat the input as a search query // Treat the input as a search query
return template.replace("%s", encodeURIComponent(input)); return template.replace("%s", encodeURIComponent(input));
} }
export { search }; export { search };

View file

@ -3,45 +3,45 @@ import { AppearanceSettings, marketPlaceSettings } from "./marketplace";
import { ProxySettings, proxySettings } from "./proxy"; import { ProxySettings, proxySettings } from "./proxy";
import { TabSettings, cloak, tabSettings } from "./tab"; import { TabSettings, cloak, tabSettings } from "./tab";
import { import {
type AbCloaks, type AbCloaks,
type OpenIn, type OpenIn,
type Package, type Package,
type PackageType, type PackageType,
type Proxy, type Proxy,
type SearchEngine, type SearchEngine,
SearchEngines, SearchEngines,
type TabCloaks, type TabCloaks,
type Transport, type Transport,
WispServerURLS, WispServerURLS,
wispUrl wispUrl
} from "./types"; } from "./types";
const Settings = { const Settings = {
AppearanceSettings, AppearanceSettings,
TabSettings, TabSettings,
ProxySettings ProxySettings
}; };
const settings = { const settings = {
marketPlaceSettings, marketPlaceSettings,
tabSettings, tabSettings,
proxySettings proxySettings
}; };
//export all of the stuffs //export all of the stuffs
export { export {
Settings, Settings,
settings, settings,
SearchEngines, SearchEngines,
WispServerURLS, WispServerURLS,
wispUrl, wispUrl,
cloak, cloak,
type TabCloaks, type TabCloaks,
type AbCloaks, type AbCloaks,
type OpenIn, type OpenIn,
type Proxy, type Proxy,
type Transport, type Transport,
type PackageType, type PackageType,
type Package, type Package,
type SearchEngine type SearchEngine
}; };

View file

@ -1,102 +1,102 @@
//marketplace code & handlers //marketplace code & handlers
import { type Package, type PackageType } from "./types"; import { type Package, type PackageType } from "./types";
const AppearanceSettings = { const AppearanceSettings = {
themes: "nebula||themes", themes: "nebula||themes",
stylePayload: "nebula||stylepayload", stylePayload: "nebula||stylepayload",
video: "nebula||video", video: "nebula||video",
image: "nebula||image" image: "nebula||image"
}; };
const marketPlaceSettings = { const marketPlaceSettings = {
install: function (p: Package, packageName: string, payload?: any) { install: function (p: Package, packageName: string, payload?: any) {
return new Promise<void>((resolve) => { return new Promise<void>((resolve) => {
if (p.theme) { if (p.theme) {
let themes = localStorage.getItem(AppearanceSettings.themes) as any; let themes = localStorage.getItem(AppearanceSettings.themes) as any;
themes ? (themes = JSON.parse(themes)) : (themes = []); themes ? (themes = JSON.parse(themes)) : (themes = []);
if (!themes.find((theme: any) => theme === packageName)) { if (!themes.find((theme: any) => theme === packageName)) {
themes.push(packageName); themes.push(packageName);
localStorage.setItem(AppearanceSettings.themes, JSON.stringify(themes)); localStorage.setItem(AppearanceSettings.themes, JSON.stringify(themes));
this.changeTheme(false, payload, p.theme.video, p.theme.bgImage); this.changeTheme(false, payload, p.theme.video, p.theme.bgImage);
}
resolve();
}
});
},
uninstall: function (p: PackageType, packageName: string) {
return new Promise<void>((resolve) => {
if (p === "theme") {
let items = localStorage.getItem(AppearanceSettings.themes) as any;
items ? (items = JSON.parse(items)) : (items = []);
if (items.find((theme: any) => theme === packageName)) {
const idx = items.indexOf(packageName);
items.splice(idx, 1);
localStorage.setItem(AppearanceSettings.themes, JSON.stringify(items));
this.changeTheme(true);
}
resolve();
}
});
},
changeTheme: async function (
reset: Boolean,
payload?: any,
videoSource?: string,
bgSource?: string
) {
async function resetCSS() {
const stylesheet = document.getElementById("stylesheet")! as HTMLLinkElement;
localStorage.removeItem(AppearanceSettings.stylePayload);
stylesheet.href = "/nebula.css";
} }
resolve(); function resetVideo() {
} localStorage.removeItem(AppearanceSettings.video);
}); const source = document.getElementById("nebulaVideo")! as HTMLVideoElement;
}, source.src = "";
uninstall: function (p: PackageType, packageName: string) { }
return new Promise<void>((resolve) => { function resetBGImage() {
if (p === "theme") { localStorage.removeItem(AppearanceSettings.image);
let items = localStorage.getItem(AppearanceSettings.themes) as any; const image = document.getElementById("nebulaImage")! as HTMLImageElement;
items ? (items = JSON.parse(items)) : (items = []); image.style.display = "none";
if (items.find((theme: any) => theme === packageName)) { image.src = "";
const idx = items.indexOf(packageName); }
items.splice(idx, 1); if (reset === true) {
localStorage.setItem(AppearanceSettings.themes, JSON.stringify(items)); await resetCSS();
this.changeTheme(true); await resetCSS();
resetBGImage();
resetVideo();
}
if (videoSource || localStorage.getItem(AppearanceSettings.video)) {
resetBGImage();
resetVideo();
const source = document.getElementById("nebulaVideo")! as HTMLVideoElement;
if (!localStorage.getItem(AppearanceSettings.video)) {
localStorage.setItem(AppearanceSettings.video, videoSource as string);
}
source.src = `/videos/${videoSource ? videoSource : localStorage.getItem(AppearanceSettings.video)}`;
}
if (bgSource || localStorage.getItem(AppearanceSettings.image)) {
resetVideo();
resetBGImage();
const image = document.getElementById("nebulaImage")! as HTMLImageElement;
if (!localStorage.getItem(AppearanceSettings.image)) {
localStorage.setItem(AppearanceSettings.image, bgSource as string);
}
image.style.display = "block";
image.src = `/images/${bgSource ? bgSource : localStorage.getItem(AppearanceSettings.image)}`;
}
if (payload) {
const stylesheet = document.getElementById("stylesheet")! as HTMLLinkElement;
if (localStorage.getItem(AppearanceSettings.stylePayload) !== payload) {
localStorage.setItem(AppearanceSettings.stylePayload, payload);
}
stylesheet.href = `/styles/${localStorage.getItem(AppearanceSettings.stylePayload)}`;
} else {
if (localStorage.getItem(AppearanceSettings.stylePayload)) {
const stylesheet = document.getElementById("stylesheet")! as HTMLLinkElement;
stylesheet.href = `/styles/${localStorage.getItem(AppearanceSettings.stylePayload)}`;
}
} }
resolve();
}
});
},
changeTheme: async function (
reset: Boolean,
payload?: any,
videoSource?: string,
bgSource?: string
) {
async function resetCSS() {
const stylesheet = document.getElementById("stylesheet")! as HTMLLinkElement;
localStorage.removeItem(AppearanceSettings.stylePayload);
stylesheet.href = "/nebula.css";
} }
function resetVideo() {
localStorage.removeItem(AppearanceSettings.video);
const source = document.getElementById("nebulaVideo")! as HTMLVideoElement;
source.src = "";
}
function resetBGImage() {
localStorage.removeItem(AppearanceSettings.image);
const image = document.getElementById("nebulaImage")! as HTMLImageElement;
image.style.display = "none";
image.src = "";
}
if (reset === true) {
await resetCSS();
await resetCSS();
resetBGImage();
resetVideo();
}
if (videoSource || localStorage.getItem(AppearanceSettings.video)) {
resetBGImage();
resetVideo();
const source = document.getElementById("nebulaVideo")! as HTMLVideoElement;
if (!localStorage.getItem(AppearanceSettings.video)) {
localStorage.setItem(AppearanceSettings.video, videoSource as string);
}
source.src = `/videos/${videoSource ? videoSource : localStorage.getItem(AppearanceSettings.video)}`;
}
if (bgSource || localStorage.getItem(AppearanceSettings.image)) {
resetVideo();
resetBGImage();
const image = document.getElementById("nebulaImage")! as HTMLImageElement;
if (!localStorage.getItem(AppearanceSettings.image)) {
localStorage.setItem(AppearanceSettings.image, bgSource as string);
}
image.style.display = "block";
image.src = `/images/${bgSource ? bgSource : localStorage.getItem(AppearanceSettings.image)}`;
}
if (payload) {
const stylesheet = document.getElementById("stylesheet")! as HTMLLinkElement;
if (localStorage.getItem(AppearanceSettings.stylePayload) !== payload) {
localStorage.setItem(AppearanceSettings.stylePayload, payload);
}
stylesheet.href = `/styles/${localStorage.getItem(AppearanceSettings.stylePayload)}`;
} else {
if (localStorage.getItem(AppearanceSettings.stylePayload)) {
const stylesheet = document.getElementById("stylesheet")! as HTMLLinkElement;
stylesheet.href = `/styles/${localStorage.getItem(AppearanceSettings.stylePayload)}`;
}
}
}
}; };
export { AppearanceSettings, marketPlaceSettings }; export { AppearanceSettings, marketPlaceSettings };

View file

@ -1,29 +1,29 @@
//Proxy specific settings. //Proxy specific settings.
import { type OpenIn, type Proxy, type SearchEngine, type Transport } from "./types"; import { type OpenIn, type Proxy, type SearchEngine, type Transport } from "./types";
const ProxySettings = { const ProxySettings = {
proxy: "nebula||proxy", proxy: "nebula||proxy",
openIn: "nebula||open", openIn: "nebula||open",
searchEngine: "nebula||searchEngine", searchEngine: "nebula||searchEngine",
wispServerURL: "nebula||wisp", wispServerURL: "nebula||wisp",
transport: "nebula||transport" transport: "nebula||transport"
}; };
const proxySettings = { const proxySettings = {
changeProxy: function (proxy: Proxy | string) { changeProxy: function (proxy: Proxy | string) {
localStorage.setItem(ProxySettings.proxy, proxy); localStorage.setItem(ProxySettings.proxy, proxy);
}, },
openIn: function (type: OpenIn | string) { openIn: function (type: OpenIn | string) {
localStorage.setItem(ProxySettings.openIn, type); localStorage.setItem(ProxySettings.openIn, type);
}, },
setSearchEngine: function (searchEngine: SearchEngine | string) { setSearchEngine: function (searchEngine: SearchEngine | string) {
localStorage.setItem(ProxySettings.searchEngine, searchEngine); localStorage.setItem(ProxySettings.searchEngine, searchEngine);
}, },
setWispURL: function (server: string) { setWispURL: function (server: string) {
localStorage.setItem(ProxySettings.wispServerURL, server); localStorage.setItem(ProxySettings.wispServerURL, server);
}, },
setTransport: function (transport: Transport | string) { setTransport: function (transport: Transport | string) {
localStorage.setItem(ProxySettings.transport, transport); localStorage.setItem(ProxySettings.transport, transport);
} }
}; };
export { ProxySettings, proxySettings }; export { ProxySettings, proxySettings };

View file

@ -1,27 +1,27 @@
//Tab specific settings. //Tab specific settings.
import { type AbCloaks, type TabCloaks } from "./types"; import { type AbCloaks, type TabCloaks } from "./types";
const TabSettings = { const TabSettings = {
tabCloak: "nebula||tabCloak", tabCloak: "nebula||tabCloak",
abblob: "nebula||abBlob" abblob: "nebula||abBlob"
}; };
function cloak(cloak: AbCloaks | string, redirect: string, url: string) { function cloak(cloak: AbCloaks | string, redirect: string, url: string) {
switch (cloak) { switch (cloak) {
case "a:b": case "a:b":
window.location.replace(redirect); window.location.replace(redirect);
const win = window.open(); const win = window.open();
win!.document.body.style.margin = "0"; win!.document.body.style.margin = "0";
win!.document.body.style.height = "100vh"; win!.document.body.style.height = "100vh";
const iframe = win!.document.createElement("iframe"); const iframe = win!.document.createElement("iframe");
iframe.style.border = "none"; iframe.style.border = "none";
iframe.style.width = "100%"; iframe.style.width = "100%";
iframe.style.height = "100%"; iframe.style.height = "100%";
iframe.style.margin = "0"; iframe.style.margin = "0";
iframe.src = url; iframe.src = url;
win!.document.body.appendChild(iframe); win!.document.body.appendChild(iframe);
break; break;
case "blob": case "blob":
const htmlContent = ` const htmlContent = `
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
@ -34,50 +34,50 @@ function cloak(cloak: AbCloaks | string, redirect: string, url: string) {
</body> </body>
</html> </html>
`; `;
window.location.replace("https://google.com"); window.location.replace("https://google.com");
const blob = new Blob([htmlContent], { type: "text/html" }); const blob = new Blob([htmlContent], { type: "text/html" });
const blobURL = URL.createObjectURL(blob); const blobURL = URL.createObjectURL(blob);
window.open(blobURL, "_blank"); window.open(blobURL, "_blank");
break; break;
} }
} }
const tabSettings = { const tabSettings = {
cloakTab: function (cloak: TabCloaks | string) { cloakTab: function (cloak: TabCloaks | string) {
const faviconElement = document.getElementById("favicon") as HTMLLinkElement; const faviconElement = document.getElementById("favicon") as HTMLLinkElement;
localStorage.setItem(TabSettings.tabCloak, cloak); localStorage.setItem(TabSettings.tabCloak, cloak);
switch (cloak) { switch (cloak) {
case "google": case "google":
document.title = "Google"; document.title = "Google";
faviconElement.href = "/cloaks/google.png"; faviconElement.href = "/cloaks/google.png";
break; break;
case "wikipedia": case "wikipedia":
document.title = "Wikipedia"; document.title = "Wikipedia";
faviconElement.href = "/cloaks/wikipedia.ico"; faviconElement.href = "/cloaks/wikipedia.ico";
break; break;
case "canvas": case "canvas":
document.title = "Dashboard"; document.title = "Dashboard";
faviconElement.href = "/cloaks/canvas.ico"; faviconElement.href = "/cloaks/canvas.ico";
break; break;
case "classroom": case "classroom":
document.title = "Home"; document.title = "Home";
faviconElement.href = "/cloaks/classroom.png"; faviconElement.href = "/cloaks/classroom.png";
break; break;
case "powerschool": case "powerschool":
document.title = "PowerSchool"; document.title = "PowerSchool";
faviconElement.href = "/cloaks/ps.ico"; faviconElement.href = "/cloaks/ps.ico";
break; break;
case "reset": case "reset":
//force a reset of favicon & title //force a reset of favicon & title
localStorage.setItem("nebula||tabCloak", "default"); localStorage.setItem("nebula||tabCloak", "default");
window.location.reload(); window.location.reload();
default: default:
return; return;
}
},
abCloak: function (type: AbCloaks | string) {
localStorage.setItem(TabSettings.abblob, type);
cloak(type as AbCloaks, "https://google.com", window.location.href);
} }
},
abCloak: function (type: AbCloaks | string) {
localStorage.setItem(TabSettings.abblob, type);
cloak(type as AbCloaks, "https://google.com", window.location.href);
}
}; };
export { tabSettings, TabSettings, cloak }; export { tabSettings, TabSettings, cloak };

View file

@ -6,34 +6,34 @@ type Proxy = "automatic" | "uv" | "rh";
type Transport = "epoxy" | "libcurl"; type Transport = "epoxy" | "libcurl";
type PackageType = "theme" | "plugin"; type PackageType = "theme" | "plugin";
interface Package { interface Package {
theme?: { theme?: {
payload: string; payload: string;
video?: string; video?: string;
bgImage?: string; bgImage?: string;
}; };
plugin?: {}; plugin?: {};
} }
const SearchEngines: Record<string, string> = { const SearchEngines: Record<string, string> = {
ddg: "https://duckduckgo.com/?q=%s", ddg: "https://duckduckgo.com/?q=%s",
google: "https://google.com/search?q=%s", google: "https://google.com/search?q=%s",
bing: "https://bing.com/search?q=%s" bing: "https://bing.com/search?q=%s"
}; };
type SearchEngine = "ddg" | "google" | "bing"; type SearchEngine = "ddg" | "google" | "bing";
const WispServerURLS: Record<string, string> = { const WispServerURLS: Record<string, string> = {
default: wispUrl, default: wispUrl,
ruby: "wss://ruby.rubynetwork.co/wisp/" ruby: "wss://ruby.rubynetwork.co/wisp/"
}; };
export { export {
type TabCloaks, type TabCloaks,
type AbCloaks, type AbCloaks,
type OpenIn, type OpenIn,
type Proxy, type Proxy,
type Transport, type Transport,
type PackageType, type PackageType,
type Package, type Package,
SearchEngines, SearchEngines,
type SearchEngine, type SearchEngine,
WispServerURLS, WispServerURLS,
wispUrl wispUrl
}; };

View file

@ -2,12 +2,12 @@ import type { Proxy } from "./settings";
type ProxyChoices = Exclude<Proxy, "automatic">; type ProxyChoices = Exclude<Proxy, "automatic">;
const SupportedSites: Record<string, ProxyChoices> = { const SupportedSites: Record<string, ProxyChoices> = {
"discord.gg": "uv", "discord.gg": "uv",
"discord.com": "uv", "discord.com": "uv",
"spotify.com": "rh", "spotify.com": "rh",
"spotify.link": "rh", "spotify.link": "rh",
"youtube.com": "uv", "youtube.com": "uv",
"youtu.be": "uv" "youtu.be": "uv"
}; };
export { SupportedSites }; export { SupportedSites };

View file

@ -1,28 +1,28 @@
type ToastType = "success" | "error" | "multiline"; type ToastType = "success" | "error" | "multiline";
type Position = type Position =
| "top-left" | "top-left"
| "top-middle" | "top-middle"
| "top-right" | "top-right"
| "bottom-left" | "bottom-left"
| "bottom-right" | "bottom-right"
| "bottom-center"; | "bottom-center";
interface Props { interface Props {
toastType: ToastType; toastType: ToastType;
text: string; text: string;
class: string; class: string;
id?: string; id?: string;
duration?: number; duration?: number;
emoji?: any; emoji?: any;
position?: Position; position?: Position;
} }
function toast(query: string) { function toast(query: string) {
const wrapper = document.getElementById("toastwrapper") as HTMLDivElement; const wrapper = document.getElementById("toastwrapper") as HTMLDivElement;
wrapper.classList.remove("hidden"); wrapper.classList.remove("hidden");
//this is a really hacky solution for toast notifications LOL //this is a really hacky solution for toast notifications LOL
const element = document.querySelector(query) as HTMLElement; const element = document.querySelector(query) as HTMLElement;
//click the element //click the element
element.click(); element.click();
} }
export { type ToastType, type Position, type Props, toast }; export { type ToastType, type Position, type Props, toast };

View file

@ -1,5 +1,5 @@
import { vitePreprocess } from "@astrojs/svelte"; import { vitePreprocess } from "@astrojs/svelte";
export default { export default {
preprocess: vitePreprocess() preprocess: vitePreprocess()
}; };

View file

@ -1,21 +1,21 @@
/** @type {import('tailwindcss').Config} */ /** @type {import('tailwindcss').Config} */
export default { export default {
content: ["./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}"], content: ["./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}"],
theme: { theme: {
colors: { colors: {
primary: "var(--background-primary)", primary: "var(--background-primary)",
lighter: "var(--background-lighter)", lighter: "var(--background-lighter)",
"navbar-text-color": "var(--navbar-text-color)", "navbar-text-color": "var(--navbar-text-color)",
"navbar-color": "var(--navbar-color)", "navbar-color": "var(--navbar-color)",
"text-color": "var(--navbar-link-color)", "text-color": "var(--navbar-link-color)",
"text-hover-color": "var(--navbar-link-hover-color)", "text-hover-color": "var(--navbar-link-hover-color)",
input: "var(--input-background-color)", input: "var(--input-background-color)",
"input-text": "var(--input-text-color)", "input-text": "var(--input-text-color)",
"input-border-color": "var(--input-border-color)", "input-border-color": "var(--input-border-color)",
"dropdown-option-hover-color": "var(--dropdown-option-hover-color)", "dropdown-option-hover-color": "var(--dropdown-option-hover-color)",
"border-color": "var(--border-color)" "border-color": "var(--border-color)"
},
extend: {}
}, },
extend: {} plugins: []
},
plugins: []
}; };

View file

@ -12,9 +12,9 @@ form.set("file", await fileFromPath("asgard.png"));
console.log(config.marketplace_psk); console.log(config.marketplace_psk);
console.log(form); console.log(form);
await fetch("http://localhost:8080/api/upload-image", { await fetch("http://localhost:8080/api/upload-image", {
headers: { headers: {
PSK: config.marketplace_psk PSK: config.marketplace_psk
}, },
method: "post", method: "post",
body: form body: form
}); });

View file

@ -1,12 +1,12 @@
{ {
"extends": "astro/tsconfigs/strict", "extends": "astro/tsconfigs/strict",
"include": ["src"], "include": ["src"],
"compilerOptions": { "compilerOptions": {
"baseUrl": ".", "baseUrl": ".",
"paths": { "paths": {
"@components/*": ["src/components/*"], "@components/*": ["src/components/*"],
"@layouts/*": ["src/layouts/*"], "@layouts/*": ["src/layouts/*"],
"@utils/*": ["src/utils/*"] "@utils/*": ["src/utils/*"]
}
} }
}
} }