Run a format

This commit is contained in:
MotorTruck1221 2024-10-04 00:49:10 -06:00
parent 8d726133bc
commit 8f1feb8cff
No known key found for this signature in database
GPG key ID: 08F417E2B8B61EA4
36 changed files with 565 additions and 592 deletions

View file

@ -1,80 +1,80 @@
import { defineConfig } from "astro/config";
import tailwind from "@astrojs/tailwind";
import icon from "astro-icon";
import svelte from "@astrojs/svelte";
import node from "@astrojs/node";
import svelte from "@astrojs/svelte";
import tailwind from "@astrojs/tailwind";
import { baremuxPath } from "@mercuryworkshop/bare-mux";
import { epoxyPath } from "@mercuryworkshop/epoxy-transport";
import { libcurlPath } from "@mercuryworkshop/libcurl-transport";
import { uvPath } from "@titaniumnetwork-dev/ultraviolet";
import icon from "astro-icon";
import { defineConfig } from "astro/config";
import { viteStaticCopy } from "vite-plugin-static-copy";
import { baremuxPath } from '@mercuryworkshop/bare-mux';
import { epoxyPath } from '@mercuryworkshop/epoxy-transport';
import { libcurlPath } from '@mercuryworkshop/libcurl-transport';
import { uvPath } from '@titaniumnetwork-dev/ultraviolet';
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
}
]
})
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/, ""),
rewrite: (path) => path.replace(/^\/api\/catalog-assets/, "")
},
"/images": {
target: "http://localhost:8080",
changeOrigin: true,
changeOrigin: true
},
"/videos": {
target: "http://localhost:8080",
changeOrigin: true,
changeOrigin: true
},
"/wisp/" : {
target: "ws://localhost:8080/wisp/",
changeOrigin: true,
ws: true,
rewrite: (path) => path.replace(/^\/wisp\//, '')
"/wisp/": {
target: "ws://localhost:8080/wisp/",
changeOrigin: true,
ws: true,
rewrite: (path) => path.replace(/^\/wisp\//, "")
},
"/styles": {
target: "http://localhost:8080",
changeOrigin: true,
changeOrigin: true
},
"/api/packages": {
target: "http://localhost:8080",
changeOrigin: true,
changeOrigin: true
},
"/api/catalog-pages": {
target: "http://localhost:8080",
changeOrigin: true,
},
},
},
changeOrigin: true
}
}
}
},
output: "server",
adapter: node({
mode: "hybrid",
}),
mode: "hybrid"
})
});

View file

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

@ -4,11 +4,14 @@
"version": "0.0.1",
"scripts": {
"dev": "concurrently \"astro dev\" \"node server.js\"",
"start": "astro dev",
"start": "node server.js",
"build": "astro check && astro build",
"bstart": "astro build && node server.js",
"preview": "astro preview",
"astro": "astro"
"astro": "astro",
"format:code": "biome format . --write",
"format:imports": "biome check . --write",
"format": "concurrently -m 1 \"npm:format:code\" \"npm:format:imports\""
},
"dependencies": {
"@astrojs/check": "^0.8.3",

View file

@ -1,21 +1,21 @@
importScripts('/epoxy/index.js');
importScripts('/libcurl/index.js');
importScripts('/uv/uv.bundle.js');
importScripts('/uv/uv.config.js');
importScripts(__uv$config.sw || '/uv/uv.sw.js');
importScripts("/epoxy/index.js");
importScripts("/libcurl/index.js");
importScripts("/uv/uv.bundle.js");
importScripts("/uv/uv.config.js");
importScripts(__uv$config.sw || "/uv/uv.sw.js");
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);
})()
);
}
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);
})()
);
}
});

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"
};

152
server.js
View file

@ -1,12 +1,12 @@
import express from "express";
import fs from "fs";
import { createServer } from "node:http";
import path from "path";
import wisp from "wisp-server-node";
import { Sequelize, DataTypes } from "sequelize";
import { fileURLToPath } from "url";
import { handler as ssrHandler } from "./dist/server/entry.mjs";
import express from "express";
import multer from "multer";
import fs from "fs";
import { DataTypes, Sequelize } from "sequelize";
import wisp from "wisp-server-node";
import { handler as ssrHandler } from "./dist/server/entry.mjs";
const config = JSON.parse(fs.readFileSync("config.json", "utf8"));
const __filename = fileURLToPath(import.meta.url);
@ -18,7 +18,7 @@ const sequelize = new Sequelize("database", "user", "password", {
dialect: "sqlite",
logging: false,
// SQLite only
storage: "database.sqlite",
storage: "database.sqlite"
});
// Auth middleware
@ -43,7 +43,7 @@ var image_storage = multer.diskStorage({
},
filename: function (req, file, cb) {
cb(null, file.originalname); //Appending extension
},
}
});
var video_storage = multer.diskStorage({
@ -52,7 +52,7 @@ var video_storage = multer.diskStorage({
},
filename: function (req, file, cb) {
cb(null, file.originalname); //Appending extension
},
}
});
var style_storage = multer.diskStorage({
@ -61,7 +61,7 @@ var style_storage = multer.diskStorage({
},
filename: function (req, file, cb) {
cb(null, file.originalname); //Appending extension
},
}
});
var script_storage = multer.diskStorage({
@ -70,7 +70,7 @@ var script_storage = multer.diskStorage({
},
filename: function (req, file, cb) {
cb(null, file.originalname); //Appending extension
},
}
});
var image_upload = multer({ storage: image_storage });
@ -81,41 +81,41 @@ var script_upload = multer({ storage: script_storage });
const catalog_assets = sequelize.define("catalog_assets", {
package_name: {
type: DataTypes.TEXT,
unique: true,
unique: true
},
title: {
type: DataTypes.TEXT,
type: DataTypes.TEXT
},
description: {
type: DataTypes.TEXT,
type: DataTypes.TEXT
},
author: {
type: DataTypes.TEXT,
type: DataTypes.TEXT
},
image: {
type: DataTypes.TEXT,
type: DataTypes.TEXT
},
tags: {
type: DataTypes.JSON,
allowNull: true,
allowNull: true
},
version: {
type: DataTypes.TEXT,
type: DataTypes.TEXT
},
background_image: {
type: DataTypes.TEXT,
allowNull: true,
allowNull: true
},
background_video: {
type: DataTypes.TEXT,
allowNull: true,
allowNull: true
},
payload: {
type: DataTypes.TEXT,
type: DataTypes.TEXT
},
type: {
type: DataTypes.TEXT,
},
type: DataTypes.TEXT
}
});
app.use(express.json());
@ -142,7 +142,7 @@ app.get("/api/catalog-assets", async (request, reply) => {
const db_assets = await catalog_assets.findAll({
offset: offset,
limit: 20,
limit: 20
});
const assets = db_assets.reduce((acc, asset) => {
@ -156,7 +156,7 @@ app.get("/api/catalog-assets", async (request, reply) => {
background_image: asset.background_image,
background_video: asset.background_video,
payload: asset.payload,
type: asset.type,
type: asset.type
};
return acc;
}, {});
@ -173,7 +173,7 @@ app.get("/api/packages/:package", async (request, reply) => {
console.log(request.params.package);
const package_row = await catalog_assets.findOne({
where: { package_name: request.params.package },
where: { package_name: request.params.package }
});
if (!package_row) {
@ -190,7 +190,7 @@ app.get("/api/packages/:package", async (request, reply) => {
background_image: package_row.get("background_image"),
background_video: package_row.get("background_video"),
payload: package_row.get("payload"),
type: package_row.get("type"),
type: package_row.get("type")
};
reply.send(details);
} catch (error) {
@ -200,78 +200,58 @@ app.get("/api/packages/:package", async (request, reply) => {
// 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);
app.post("/api/upload-image", auth_psk, image_upload.single("file"), (req, res) => {
console.log("Request file:", req.file);
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,
});
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
});
});
// 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" });
}
res.json({
message: "File uploaded successfully",
filename: req.file.originalname,
});
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" });
}
);
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" });
}
res.json({
message: "File uploaded successfully",
filename: req.file.originalname,
});
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" });
}
);
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" });
}
res.json({
message: "File uploaded successfully",
filename: req.file.originalname,
});
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" });
}
);
res.json({
message: "File uploaded successfully",
filename: req.file.originalname
});
});
// This API is responsible for creating packages in the database.
// PSK authentication required.
@ -288,7 +268,7 @@ app.post("/api/create-package", auth_psk, async function (req, res) {
payload: req.body.payload,
background_video: req.body.background_video_path,
background_image: req.body.background_image_path,
type: req.body.type,
type: req.body.type
});
res.send({ hello: "world" });
});
@ -342,5 +322,5 @@ server.on("upgrade", (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

@ -1,9 +1,9 @@
---
import { Icon } from "astro-icon/components";
import { getLangFromUrl, useTranslations } from "../i18n/utils";
import { isMobileNavOpen } from "../store.js";
import Logo from "./Logo.astro";
import HeaderButton from "./HeaderButton.astro";
import { Icon } from "astro-icon/components";
import Logo from "./Logo.astro";
const lang = getLangFromUrl(Astro.url);
const t = useTranslations(lang);

View file

@ -1,7 +1,7 @@
---
import { Icon } from "astro-icon/components";
import { getLangFromUrl, useTranslations } from "../i18n/utils";
import HeaderButton from "./HeaderButton.astro";
import { Icon } from "astro-icon/components";
const lang = getLangFromUrl(Astro.url);
const t = useTranslations(lang);
---

View file

@ -1,11 +1,11 @@
<script>
export let page;
let assetPromise = get_assets();
async function get_assets() {
const response = await fetch("/api/catalog-assets?page=" + page);
const data = await response.json();
return data.assets;
}
export let page;
let assetPromise = get_assets();
async function get_assets() {
const response = await fetch("/api/catalog-assets?page=" + page);
const data = await response.json();
return data.assets;
}
</script>
<div class="text-3xl roboto font-bold text-text-color p-10">

View file

@ -1,66 +1,66 @@
<script>
let assetPromise = get_all_assets();
async function logItem(item) {
// hell
try {
const response = await fetch(`/api/packages/${item}`);
const data = await response.json();
let assetPromise = get_all_assets();
async function logItem(item) {
// hell
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;
}
return {
...data,
package_name: item
};
} catch (error) {
console.error("error: failed to fetch", error);
return null;
}
}
async function get_all_assets() {
let items = JSON.parse(localStorage.getItem("installed_themes")) || [];
const promises = items.map(logItem);
const dataArray = await Promise.all(promises);
async function get_all_assets() {
let items = JSON.parse(localStorage.getItem("installed_themes")) || [];
const promises = items.map(logItem);
const dataArray = await Promise.all(promises);
const accumulatedData = dataArray.filter((data) => data !== null);
console.log(JSON.stringify(accumulatedData));
return accumulatedData;
const accumulatedData = dataArray.filter((data) => data !== null);
console.log(JSON.stringify(accumulatedData));
return accumulatedData;
}
function install(assets_json, package_name) {
if (assets_json.background_video) {
localStorage.setItem("background_video", assets_json.background_video);
} else {
localStorage.removeItem("video");
}
function install(assets_json, package_name) {
if (assets_json.background_video) {
localStorage.setItem("background_video", assets_json.background_video);
} else {
localStorage.removeItem("video");
}
if (assets_json.background_image) {
localStorage.setItem("background_image", assets_json.background_image);
} else {
localStorage.removeItem("background_image");
}
if (assets_json.type == "theme") {
localStorage.setItem("stylesheet", "/styles/" + assets_json.payload);
}
location.reload();
}
function reset_theme() {
localStorage.removeItem("background_video");
if (assets_json.background_image) {
localStorage.setItem("background_image", assets_json.background_image);
} else {
localStorage.removeItem("background_image");
localStorage.removeItem("stylesheet");
location.reload();
}
function delete_theme(key) {
let items = JSON.parse(localStorage.getItem("installed_themes")) || [];
const index = items.indexOf(key);
items.splice(index, 1);
localStorage.setItem("installed_themes", JSON.stringify(items));
reset_theme();
if (assets_json.type == "theme") {
localStorage.setItem("stylesheet", "/styles/" + assets_json.payload);
}
location.reload();
}
function reset_theme() {
localStorage.removeItem("background_video");
localStorage.removeItem("background_image");
localStorage.removeItem("stylesheet");
location.reload();
}
function delete_theme(key) {
let items = JSON.parse(localStorage.getItem("installed_themes")) || [];
const index = items.indexOf(key);
items.splice(index, 1);
localStorage.setItem("installed_themes", JSON.stringify(items));
reset_theme();
}
</script>
{#await assetPromise}

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

@ -1,41 +1,41 @@
<script lang="ts">
import toast from 'svelte-french-toast';
import { type ToastType, type Position, type Props } from "@utils/toast.ts";
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
}
}
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;
}
}
</script>
<!-- A hacky way to get this to be called. Just click this button (preferably via an EVENT) (see ../../utils/toast.ts) -->
<button id={toastProp.id} class:invisible={'invisible'} class:hidden={'hidden'} class={toastProp.class} on:click={() => {return handleToast(toastProp)}}>Auto clicked for toast notifs</button>

View file

@ -1,5 +1,5 @@
<script lang="ts">
import { Toaster } from "svelte-french-toast";
import { Toaster } from "svelte-french-toast";
</script>
<div class="hidden" id="toastwrapper">

View file

@ -5,5 +5,5 @@ export const defaultLang = "en_US";
export const ui = {
en_US,
jp,
jp
};

View file

@ -1,9 +1,6 @@
import { ui, defaultLang } from "./ui";
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) {
const [, lang] = url.pathname.split("/");

View file

@ -1,8 +1,8 @@
---
import Header from "@components/Header.astro";
import { ViewTransitions } from "astro:transitions";
import Header from "@components/Header.astro";
import MobileNavigation from "@components/MobileNavigation.astro";
import SettingsLoader from '@components/settings/Loader.astro';
import SettingsLoader from "@components/settings/Loader.astro";
interface Props {
title: string;
}

View file

@ -1,10 +1,7 @@
---
import Layout from "@layouts/Layout.astro";
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;
}
export const prerender = true;

View file

@ -1,12 +1,9 @@
---
import Layout from "@layouts/Layout.astro";
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" } },
];
const STATIC_PATHS = [{ params: { lang: "en_US" } }, { params: { lang: "jp" } }];
return STATIC_PATHS;
}
export const prerender = true;

View file

@ -1,20 +1,17 @@
---
import InstalledThemes from "@components/catalog/InstalledThemes.svelte";
import ThemeCard from "@components/settings/ThemeCard.astro";
import Layout from "@layouts/Layout.astro";
import SettingsLayout from "@layouts/SettingsLayout.astro";
import SettingsSection from "@layouts/SettingsSection.astro";
import { getLangFromUrl, useTranslations } from "../../../i18n/utils";
import ThemeCard from "@components/settings/ThemeCard.astro";
import { Icon } from "astro-icon/components";
import fortnite from "../../../assets/fortnite.jpg";
import ClassicNebula from "../../../assets/classic_theme.png";
import InstalledThemes from "@components/catalog/InstalledThemes.svelte";
import fortnite from "../../../assets/fortnite.jpg";
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" } },
];
const STATIC_PATHS = [{ params: { lang: "en_US" } }, { params: { lang: "jp" } }];
return STATIC_PATHS;
}
export const prerender = true;

View file

@ -1,19 +1,16 @@
---
import SettingsCard from "@components/settings/SettingsCard.astro";
import Toast from "@components/toasts/Toast.svelte";
import ToastWrapper from "@components/toasts/ToastWrapper.svelte";
import Layout from "@layouts/Layout.astro";
import SettingsLayout from "@layouts/SettingsLayout.astro";
import SettingsSection from "@layouts/SettingsSection.astro";
import SettingsCard from "@components/settings/SettingsCard.astro";
import ToastWrapper from "@components/toasts/ToastWrapper.svelte";
import Toast from "@components/toasts/Toast.svelte";
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" } },
];
const STATIC_PATHS = [{ params: { lang: "en_US" } }, { params: { lang: "jp" } }];
return STATIC_PATHS;
}
export const prerender = true;

View file

@ -1,18 +1,15 @@
---
import SettingsCard from "@components/settings/SettingsCard.astro";
import Toast from "@components/toasts/Toast.svelte";
import ToastWrapper from "@components/toasts/ToastWrapper.svelte";
import Layout from "@layouts/Layout.astro";
import SettingsLayout from "@layouts/SettingsLayout.astro";
import SettingsSection from "@layouts/SettingsSection.astro";
import SettingsCard from "@components/settings/SettingsCard.astro";
import ToastWrapper from "@components/toasts/ToastWrapper.svelte";
import Toast from "@components/toasts/Toast.svelte";
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" } },
];
const STATIC_PATHS = [{ params: { lang: "en_US" } }, { params: { lang: "jp" } }];
return STATIC_PATHS;
}
export const prerender = true;

View file

@ -1,9 +1,7 @@
---
const { package_name } = Astro.params;
import Layout from "@layouts/Layout.astro";
const response = await fetch(
new URL("/api/packages/" + package_name, Astro.url)
);
const response = await fetch(new URL("/api/packages/" + package_name, Astro.url));
const assets_json = await response.json();
---

View file

@ -1,6 +1,6 @@
---
import Layout from "@layouts/Layout.astro";
import CatalogCard from "@components/catalog/CatalogCard.svelte";
import Layout from "@layouts/Layout.astro";
import Pagnation from "./pagnation.astro";
const { page } = Astro.params;

View file

@ -1,6 +1,6 @@
---
import Layout from "@layouts/Layout.astro";
import Card from "@components/Card.astro";
import Layout from "@layouts/Layout.astro";
---
loading...

View file

@ -1,67 +1,71 @@
import { WispServerURLS, Settings } from "./settings";
import { Settings, WispServerURLS } from "./settings";
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.EpoxyClient", { wisp: wispServer ? WispServerURLS[wispServer] : WispServerURLS.default });
break;
case "libcurl":
BareMux.SetTransport("CurlMod.LibcurlClient", { 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.EpoxyClient", {
wisp: wispServer ? WispServerURLS[wispServer] : WispServerURLS.default
});
break;
case "libcurl":
BareMux.SetTransport("CurlMod.LibcurlClient", {
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 }
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 }
export { search };

View file

@ -1,54 +1,54 @@
import { setTransport as transportSet } from "./registerSW";
const wispUrl = (location.protocol === "https:" ? "wss://" : "ws://") + location.host + "/wisp/";
const TabSettings = {
tabCloak: "nebula||tabCloak",
abblob: "nebula||abBlob"
}
tabCloak: "nebula||tabCloak",
abblob: "nebula||abBlob"
};
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 Settings = {
TabSettings,
ProxySettings
}
TabSettings,
ProxySettings
};
type TabCloaks = "default" | "google" | "wikipedia" | "canvas" | "classroom" | "powerschool";
type AbCloaks = "a:b" | "blob";
type OpenIn = 'a:b' | 'blob' | 'direct' | 'embed';
type OpenIn = "a:b" | "blob" | "direct" | "embed";
type Proxy = "automatic" | "uv" | "rh";
type Transport = "epoxy" | "libcurl";
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/"
};
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>
@ -61,69 +61,69 @@ 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(Settings.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(Settings.TabSettings.abblob, type);
cloak(type as AbCloaks, 'https://google.com', window.location.href);
cloakTab: function (cloak: TabCloaks | string) {
const faviconElement = document.getElementById("favicon") as HTMLLinkElement;
localStorage.setItem(Settings.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(Settings.TabSettings.abblob, type);
cloak(type as AbCloaks, "https://google.com", window.location.href);
}
};
const proxySettings = {
changeProxy: function(proxy: Proxy | string) {
localStorage.setItem(Settings.ProxySettings.proxy, proxy);
},
openIn: function(type: OpenIn | string) {
localStorage.setItem(Settings.ProxySettings.openIn, type);
},
setSearchEngine: function(searchEngine: SearchEngine | string) {
localStorage.setItem(Settings.ProxySettings.searchEngine, searchEngine);
},
setWispURL: function(server: string) {
localStorage.setItem(Settings.ProxySettings.wispServerURL, server);
},
setTransport: function(transport: Transport | string) {
localStorage.setItem(Settings.ProxySettings.transport, transport);
}
}
changeProxy: function (proxy: Proxy | string) {
localStorage.setItem(Settings.ProxySettings.proxy, proxy);
},
openIn: function (type: OpenIn | string) {
localStorage.setItem(Settings.ProxySettings.openIn, type);
},
setSearchEngine: function (searchEngine: SearchEngine | string) {
localStorage.setItem(Settings.ProxySettings.searchEngine, searchEngine);
},
setWispURL: function (server: string) {
localStorage.setItem(Settings.ProxySettings.wispServerURL, server);
},
setTransport: function (transport: Transport | string) {
localStorage.setItem(Settings.ProxySettings.transport, transport);
}
};
export { tabSettings, proxySettings, Settings, WispServerURLS, SearchEngines, cloak }
export { tabSettings, proxySettings, Settings, WispServerURLS, SearchEngines, cloak };

View file

@ -1,22 +1,28 @@
type ToastType = "success" | "error" | "multiline";
type Position = "top-left" | "top-middle" | "top-right" | "bottom-left" | "bottom-right" | "bottom-center";
type Position =
| "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 }
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 {
preprocess: vitePreprocess(),
}
preprocess: vitePreprocess()
};

View file

@ -13,9 +13,9 @@ export default {
"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)",
"border-color": "var(--border-color)"
},
extend: {},
extend: {}
},
plugins: [],
plugins: []
};

View file

@ -1,7 +1,7 @@
// This is a test file to upload files to the Nebula server
import { FormData, File } from "formdata-node";
import { fileFromPath } from "formdata-node/file-from-path";
import fs from "fs";
// This is a test file to upload files to the Nebula server
import { File, FormData } from "formdata-node";
import { fileFromPath } from "formdata-node/file-from-path";
const config = JSON.parse(fs.readFileSync("config.json", "utf8"));
const form = new FormData();
@ -13,8 +13,8 @@ console.log(config.marketplace_psk);
console.log(form);
await fetch("http://localhost:8080/api/upload-image", {
headers: {
PSK: config.marketplace_psk,
PSK: config.marketplace_psk
},
method: "post",
body: form,
body: form
});

View file

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