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"],
"unwantedRecommendations": []
"recommendations": ["astro-build.astro-vscode"],
"unwantedRecommendations": []
}

18
.vscode/launch.json vendored
View file

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

View file

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

View file

@ -1,32 +1,32 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.3/schema.json",
"files": {
"ignore": ["~/", "**/dist/**", ".github/**"],
"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
"$schema": "https://biomejs.dev/schemas/1.9.3/schema.json",
"files": {
"ignore": ["~/", "**/dist/**", ".github/**"],
"include": ["**/**", "server/**"]
},
"formatter": {
"indentStyle": "space",
"trailingCommas": "none"
"indentStyle": "space",
"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_psk": "CHANGE_THIS_THIS_IS_INSECURE",
"marketplace_level": "1"
"marketplace_enabled": true,
"marketplace_psk": "CHANGE_THIS_THIS_IS_INSECURE",
"marketplace_level": "1"
}

View file

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

View file

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

View file

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

View file

@ -1,30 +1,30 @@
self.__uv$config = {
prefix: "/~/uv/",
bare: "/bare/",
encodeUrl: function encode(str) {
if (!str) return str;
return encodeURIComponent(
str
.toString()
.split("")
.map((char, ind) => (ind % 2 ? String.fromCharCode(char.charCodeAt() ^ 3) : char))
.join("")
);
},
decodeUrl: function decode(str) {
if (!str) return str;
let [input, ...search] = str.split("?");
prefix: "/~/uv/",
bare: "/bare/",
encodeUrl: function encode(str) {
if (!str) return str;
return encodeURIComponent(
str
.toString()
.split("")
.map((char, ind) => (ind % 2 ? String.fromCharCode(char.charCodeAt() ^ 3) : char))
.join("")
);
},
decodeUrl: function decode(str) {
if (!str) return str;
let [input, ...search] = str.split("?");
return (
decodeURIComponent(input)
.split("")
.map((char, ind) => (ind % 2 ? String.fromCharCode(char.charCodeAt(0) ^ 3) : char))
.join("") + (search.length ? "?" + search.join("?") : "")
);
},
handler: "/uv/uv.handler.js",
client: "/uv/uv.client.js",
bundle: "/uv/uv.bundle.js",
config: "/uv/uv.config.js",
sw: "/uv/uv.sw.js"
return (
decodeURIComponent(input)
.split("")
.map((char, ind) => (ind % 2 ? String.fromCharCode(char.charCodeAt(0) ^ 3) : char))
.join("") + (search.length ? "?" + search.join("?") : "")
);
},
handler: "/uv/uv.handler.js",
client: "/uv/uv.client.js",
bundle: "/uv/uv.bundle.js",
config: "/uv/uv.config.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 { fileURLToPath } from "url";
import {
createRammerhead,
routeRhRequest,
routeRhUpgrade,
shouldRouteRh
createRammerhead,
routeRhRequest,
routeRhUpgrade,
shouldRouteRh
} from "@rubynetwork/rammerhead";
import express from "express";
import multer from "multer";
@ -19,71 +19,71 @@ const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
//create the rh server.
const rh = createRammerhead({
logLevel: "debug",
reverseProxy: true,
disableLocalStorageSync: false,
disableHttp2: false
logLevel: "debug",
reverseProxy: true,
disableLocalStorageSync: false,
disableHttp2: false
});
const app = express();
const publicPath = "dist/client";
const sequelize = new Sequelize("database", "user", "password", {
host: "localhost",
dialect: "sqlite",
logging: false,
// SQLite only
storage: "database.sqlite"
host: "localhost",
dialect: "sqlite",
logging: false,
// SQLite only
storage: "database.sqlite"
});
// Auth middleware
function auth_psk(req, res, next) {
if (!config.marketplace_enabled) {
let err = "Marketplace is disabled!";
return next(err);
}
if (!config.marketplace_enabled) {
let err = "Marketplace is disabled!";
return next(err);
}
if (req.headers.psk !== config.marketplace_psk) {
let err = "Bad PSK!";
console.log("Bad psk");
return next(err);
}
if (req.headers.psk !== config.marketplace_psk) {
let err = "Bad PSK!";
console.log("Bad psk");
return next(err);
}
return next();
return next();
}
var image_storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, "database_assets/image");
},
filename: function (req, file, cb) {
cb(null, file.originalname); //Appending extension
}
destination: function (req, file, cb) {
cb(null, "database_assets/image");
},
filename: function (req, file, cb) {
cb(null, file.originalname); //Appending extension
}
});
var video_storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, "database_assets/video");
},
filename: function (req, file, cb) {
cb(null, file.originalname); //Appending extension
}
destination: function (req, file, cb) {
cb(null, "database_assets/video");
},
filename: function (req, file, cb) {
cb(null, file.originalname); //Appending extension
}
});
var style_storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, "database_assets/styles");
},
filename: function (req, file, cb) {
cb(null, file.originalname); //Appending extension
}
destination: function (req, file, cb) {
cb(null, "database_assets/styles");
},
filename: function (req, file, cb) {
cb(null, file.originalname); //Appending extension
}
});
var script_storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, "database_assets/scripts");
},
filename: function (req, file, cb) {
cb(null, file.originalname); //Appending extension
}
destination: function (req, file, cb) {
cb(null, "database_assets/scripts");
},
filename: function (req, file, cb) {
cb(null, file.originalname); //Appending extension
}
});
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 });
const catalog_assets = sequelize.define("catalog_assets", {
package_name: {
type: DataTypes.TEXT,
unique: true
},
title: {
type: DataTypes.TEXT
},
description: {
type: DataTypes.TEXT
},
author: {
type: DataTypes.TEXT
},
image: {
type: DataTypes.TEXT
},
tags: {
type: DataTypes.JSON,
allowNull: true
},
version: {
type: DataTypes.TEXT
},
background_image: {
type: DataTypes.TEXT,
allowNull: true
},
background_video: {
type: DataTypes.TEXT,
allowNull: true
},
payload: {
type: DataTypes.TEXT
},
type: {
type: DataTypes.TEXT
}
package_name: {
type: DataTypes.TEXT,
unique: true
},
title: {
type: DataTypes.TEXT
},
description: {
type: DataTypes.TEXT
},
author: {
type: DataTypes.TEXT
},
image: {
type: DataTypes.TEXT
},
tags: {
type: DataTypes.JSON,
allowNull: true
},
version: {
type: DataTypes.TEXT
},
background_image: {
type: DataTypes.TEXT,
allowNull: true
},
background_video: {
type: DataTypes.TEXT,
allowNull: true
},
payload: {
type: DataTypes.TEXT
},
type: {
type: DataTypes.TEXT
}
});
app.use(express.json());
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).
// 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.
app.get("/api/catalog-assets", async (request, reply) => {
try {
const page = parseInt(request.query.page, 10) || 1; // default to page 1
try {
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) {
reply.status(400).send({ error: "Page must be a positive number!" });
return;
if (page < 1) {
reply.status(400).send({ error: "Page must be a positive number!" });
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.
app.get("/api/packages/:package", async (request, reply) => {
try {
console.log(request.params.package);
try {
console.log(request.params.package);
const package_row = await catalog_assets.findOne({
where: { package_name: request.params.package }
});
const package_row = await catalog_assets.findOne({
where: { package_name: request.params.package }
});
if (!package_row) {
return reply.status(404).send({ error: "Package not found!" });
if (!package_row) {
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
// PSK authentication required.
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) {
return res.status(400).json({ error: "No file uploaded" });
}
if (!req.file) {
return res.status(400).json({ error: "No file uploaded" });
}
console.log(req.file.originalname);
res.json({
message: "File uploaded successfully",
filename: req.file.originalname
});
console.log(req.file.originalname);
res.json({
message: "File uploaded successfully",
filename: req.file.originalname
});
});
// This API is responsible for video uploads
// PSK authentication required.
app.post("/api/upload-video", auth_psk, video_upload.single("file"), (req, res) => {
if (!req.file) {
return res.status(400).json({ error: "No file uploaded" });
}
if (!req.file) {
return res.status(400).json({ error: "No file uploaded" });
}
res.json({
message: "File uploaded successfully",
filename: req.file.originalname
});
res.json({
message: "File uploaded successfully",
filename: req.file.originalname
});
});
// This API is responsible for stylesheet uploads
// PSK authentication required.
app.post("/api/upload-style", auth_psk, style_upload.single("file"), (req, res) => {
if (!req.file) {
return res.status(400).json({ error: "No file uploaded" });
}
if (!req.file) {
return res.status(400).json({ error: "No file uploaded" });
}
res.json({
message: "File uploaded successfully",
filename: req.file.originalname
});
res.json({
message: "File uploaded successfully",
filename: req.file.originalname
});
});
// This API is responsible for script/plugin uploads
// PSK authentication required.
app.post("/api/upload-script", auth_psk, script_upload.single("file"), (req, res) => {
if (!req.file) {
return res.status(400).json({ error: "No file uploaded" });
}
if (!req.file) {
return res.status(400).json({ error: "No file uploaded" });
}
res.json({
message: "File uploaded successfully",
filename: req.file.originalname
});
res.json({
message: "File uploaded successfully",
filename: req.file.originalname
});
});
// This API is responsible for creating packages in the database.
// PSK authentication required.
app.post("/api/create-package", auth_psk, async function (req, res) {
console.log(req.body);
await catalog_assets.create({
package_name: req.body.uuid,
title: req.body.title,
image: req.body.image_path,
author: req.body.author,
version: req.body.version,
description: req.body.description,
tags: req.body.tags,
payload: req.body.payload,
background_video: req.body.background_video_path,
background_image: req.body.background_image_path,
type: req.body.type
});
res.send({ hello: "world" });
console.log(req.body);
await catalog_assets.create({
package_name: req.body.uuid,
title: req.body.title,
image: req.body.image_path,
author: req.body.author,
version: req.body.version,
description: req.body.description,
tags: req.body.tags,
payload: req.body.payload,
background_video: req.body.background_video_path,
background_image: req.body.background_image_path,
type: req.body.type
});
res.send({ hello: "world" });
});
app.use("/images/", express.static("./database_assets/image"));
@ -323,23 +323,23 @@ catalog_assets.sync();
const server = createServer();
server.on("request", (req, res) => {
res.setHeader("Cross-Origin-Opener-Policy", "same-origin");
res.setHeader("Cross-Origin-Embedder-Policy", "require-corp");
if (shouldRouteRh(req)) {
routeRhRequest(rh, req, res);
} else {
app(req, res);
}
res.setHeader("Cross-Origin-Opener-Policy", "same-origin");
res.setHeader("Cross-Origin-Embedder-Policy", "require-corp");
if (shouldRouteRh(req)) {
routeRhRequest(rh, req, res);
} else {
app(req, res);
}
});
server.on("upgrade", (req, socket, head) => {
if (shouldRouteRh(req)) {
routeRhUpgrade(rh, req, socket, head);
} else if (req.url.endsWith("/wisp/")) {
wisp.routeRequest(req, socket, head);
}
if (shouldRouteRh(req)) {
routeRhUpgrade(rh, req, socket, head);
} else if (req.url.endsWith("/wisp/")) {
wisp.routeRequest(req, socket, head);
}
});
server.listen({
port: 8080
port: 8080
});

View file

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

View file

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

View file

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

View file

@ -1,30 +1,30 @@
---
interface Inputs {
input: boolean;
required?: boolean;
placeholder?: string;
input: boolean;
required?: boolean;
placeholder?: string;
}
interface SelectOptions {
value: string;
name: string;
disabled: boolean;
value: string;
name: string;
disabled: boolean;
}
interface Selects {
select: boolean;
name: string;
multiple?: boolean;
options?: SelectOptions[];
select: boolean;
name: string;
multiple?: boolean;
options?: SelectOptions[];
}
interface Buttons {
name: string;
id: string;
name: string;
id: string;
}
interface Props {
title: string;
description: string;
input: Inputs;
select: Selects;
button: Buttons;
title: string;
description: string;
input: Inputs;
select: Selects;
button: Buttons;
}
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";
export let toastProp: Props;
function handleToast(toastProp: Props) {
switch (toastProp.toastType) {
case "success":
toast.success(toastProp.text, {
style: "background: var(--navbar-color); color: var(--input-text-color);",
icon: toastProp.emoji,
position: toastProp.position ?? "bottom-right",
duration: toastProp.duration
});
break;
case "error":
toast.error(toastProp.text, {
style: "background: var(--navbar-color); color: var(--input-text-color);",
icon: toastProp.emoji,
position: toastProp.position ?? "bottom-right",
duration: toastProp.duration
});
break;
case "promise":
throw new Error("Due to the way astro renders promise toasts are not available (ish)");
break;
case "multiline":
toast(toastProp.text, {
style: "background: var(--navbar-color); color: var(--input-text-color);",
icon: toastProp.emoji,
position: toastProp.position ?? "bottom-right",
duration: toastProp.duration
});
break;
default:
throw new Error("Something isn't right...");
break;
}
switch (toastProp.toastType) {
case "success":
toast.success(toastProp.text, {
style: "background: var(--navbar-color); color: var(--input-text-color);",
icon: toastProp.emoji,
position: toastProp.position ?? "bottom-right",
duration: toastProp.duration
});
break;
case "error":
toast.error(toastProp.text, {
style: "background: var(--navbar-color); color: var(--input-text-color);",
icon: toastProp.emoji,
position: toastProp.position ?? "bottom-right",
duration: toastProp.duration
});
break;
case "promise":
throw new Error("Due to the way astro renders promise toasts are not available (ish)");
break;
case "multiline":
toast(toastProp.text, {
style: "background: var(--navbar-color); color: var(--input-text-color);",
icon: toastProp.emoji,
position: toastProp.position ?? "bottom-right",
duration: toastProp.duration
});
break;
default:
throw new Error("Something isn't right...");
break;
}
}
</script>
<!-- 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.games": "Games",
"header.settings": "Settings",
"header.morelinks": "Want more links?",
"header.catalog": "Nebula Catalog",
"home.placeholder": "Search the web freely",
"settings.settings": "Settings",
"settings.appearance": "Appearance",
"settings.proxy": "Proxy",
"settings.tab": "Tab"
"header.home": "Home",
"header.games": "Games",
"header.settings": "Settings",
"header.morelinks": "Want more links?",
"header.catalog": "Nebula Catalog",
"home.placeholder": "Search the web freely",
"settings.settings": "Settings",
"settings.appearance": "Appearance",
"settings.proxy": "Proxy",
"settings.tab": "Tab"
}

View file

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

View file

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

View file

@ -3,13 +3,13 @@ import { defaultLang, ui } from "./ui";
export const STATIC_PATHS = [{ params: { lang: "en_US" } }, { params: { lang: "jp" } }];
export function getLangFromUrl(url: URL) {
const [, lang] = url.pathname.split("/");
if (lang in ui) return lang as keyof typeof ui;
return defaultLang;
const [, lang] = url.pathname.split("/");
if (lang in ui) return lang as keyof typeof ui;
return defaultLang;
}
export function useTranslations(lang: keyof typeof ui) {
return function t(key: keyof (typeof ui)[typeof defaultLang]) {
return ui[lang][key] || ui[defaultLang][key];
};
return function t(key: keyof (typeof ui)[typeof defaultLang]) {
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 SettingsLoader from "@components/settings/Loader.astro";
interface Props {
title: string;
noHeader?: string;
title: string;
noHeader?: string;
}
const { title, noHeader } = Astro.props;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,71 +1,71 @@
import { Settings, WispServerURLS } from "./settings/index";
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);
const uvBundle = document.createElement("script");
uvBundle.src = "/uv/uv.bundle.js";
uvBundle.defer = true;
document.body.appendChild(uvBundle);
const uvConfig = document.createElement("script");
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();
}
}, 100);
});
//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);
const uvBundle = document.createElement("script");
uvBundle.src = "/uv/uv.bundle.js";
uvBundle.defer = true;
document.body.appendChild(uvBundle);
const uvConfig = document.createElement("script");
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();
}
}, 100);
});
}
function setTransport(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
});
break;
case "libcurl":
BareMux.SetTransport("CurlMod.default", {
wisp: wispServer ? WispServerURLS[wispServer] : WispServerURLS.default
});
break;
}
resolve();
});
//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
});
break;
case "libcurl":
BareMux.SetTransport("CurlMod.default", {
wisp: wispServer ? WispServerURLS[wispServer] : WispServerURLS.default
});
break;
}
resolve();
});
}
function initSw() {
//this is wrapped in a promise to mostly solve the bare-mux v1 problems
return new Promise<void>((resolve) => {
if ("serviceWorker" in navigator) {
navigator.serviceWorker.ready.then(async () => {
console.debug("Service worker ready!");
await loadProxyScripts();
resolve();
});
navigator.serviceWorker.register("/sw.js", { scope: "/" });
}
});
//this is wrapped in a promise to mostly solve the bare-mux v1 problems
return new Promise<void>((resolve) => {
if ("serviceWorker" in navigator) {
navigator.serviceWorker.ready.then(async () => {
console.debug("Service worker ready!");
await loadProxyScripts();
resolve();
});
navigator.serviceWorker.register("/sw.js", { scope: "/" });
}
});
}
export { initSw, setTransport };

View file

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

View file

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

View file

@ -1,102 +1,102 @@
//marketplace code & handlers
import { type Package, type PackageType } from "./types";
const AppearanceSettings = {
themes: "nebula||themes",
stylePayload: "nebula||stylepayload",
video: "nebula||video",
image: "nebula||image"
themes: "nebula||themes",
stylePayload: "nebula||stylepayload",
video: "nebula||video",
image: "nebula||image"
};
const marketPlaceSettings = {
install: function (p: Package, packageName: string, payload?: any) {
return new Promise<void>((resolve) => {
if (p.theme) {
let themes = localStorage.getItem(AppearanceSettings.themes) as any;
themes ? (themes = JSON.parse(themes)) : (themes = []);
if (!themes.find((theme: any) => theme === packageName)) {
themes.push(packageName);
localStorage.setItem(AppearanceSettings.themes, JSON.stringify(themes));
this.changeTheme(false, payload, p.theme.video, p.theme.bgImage);
install: function (p: Package, packageName: string, payload?: any) {
return new Promise<void>((resolve) => {
if (p.theme) {
let themes = localStorage.getItem(AppearanceSettings.themes) as any;
themes ? (themes = JSON.parse(themes)) : (themes = []);
if (!themes.find((theme: any) => theme === packageName)) {
themes.push(packageName);
localStorage.setItem(AppearanceSettings.themes, JSON.stringify(themes));
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();
}
});
},
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);
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)}`;
}
}
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 };

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,21 +1,21 @@
/** @type {import('tailwindcss').Config} */
export default {
content: ["./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}"],
theme: {
colors: {
primary: "var(--background-primary)",
lighter: "var(--background-lighter)",
"navbar-text-color": "var(--navbar-text-color)",
"navbar-color": "var(--navbar-color)",
"text-color": "var(--navbar-link-color)",
"text-hover-color": "var(--navbar-link-hover-color)",
input: "var(--input-background-color)",
"input-text": "var(--input-text-color)",
"input-border-color": "var(--input-border-color)",
"dropdown-option-hover-color": "var(--dropdown-option-hover-color)",
"border-color": "var(--border-color)"
content: ["./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}"],
theme: {
colors: {
primary: "var(--background-primary)",
lighter: "var(--background-lighter)",
"navbar-text-color": "var(--navbar-text-color)",
"navbar-color": "var(--navbar-color)",
"text-color": "var(--navbar-link-color)",
"text-hover-color": "var(--navbar-link-hover-color)",
input: "var(--input-background-color)",
"input-text": "var(--input-text-color)",
"input-border-color": "var(--input-border-color)",
"dropdown-option-hover-color": "var(--dropdown-option-hover-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(form);
await fetch("http://localhost:8080/api/upload-image", {
headers: {
PSK: config.marketplace_psk
},
method: "post",
body: form
headers: {
PSK: config.marketplace_psk
},
method: "post",
body: form
});

View file

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