Bump version to 9.1.0

This commit is contained in:
MotorTruck1221 2025-01-15 00:27:27 -07:00
parent 8240668a5c
commit b2e6810027
No known key found for this signature in database
GPG key ID: 08F417E2B8B61EA4
9 changed files with 9 additions and 509 deletions

View file

@ -26,3 +26,11 @@
- General Bugfixes
- Removes Svelte except for 2 componenents
- Scramjet :rocket:
# 9.1.0
- Rewrites everything in the [utils/](./src/utils) folder
- Bugfixes
- Better logging
- Mobile nav jank is gone
- Component cleanup

View file

@ -1,7 +1,7 @@
{
"name": "nebula",
"type": "module",
"version": "9.0.4",
"version": "9.1.0",
"private": true,
"scripts": {
"dev": "astro dev --host 0.0.0.0 & tsx --watch server/server.ts",

View file

@ -1,54 +0,0 @@
//Combine all of the other settings into one object. And export that (along with types and other things)
import {
AppearanceSettings,
MarketPlaceExtras,
PluginSettings,
marketPlaceSettings
} from "./marketplace/index";
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
} from "./types";
const Settings = {
AppearanceSettings,
TabSettings,
ProxySettings,
MarketPlaceExtras,
PluginSettings
};
const settings = {
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
};

View file

@ -1,224 +0,0 @@
//marketplace code & handlers
import { Settings } from "../index";
import {
type Package,
type PackageType,
type Plugin,
type PluginType,
type SWPagePlugin,
type SWPlugin
} from "../types";
const AppearanceSettings = {
themes: "nebula||themes",
themeName: "nebula||themeName",
stylePayload: "nebula||stylepayload",
video: "nebula||video",
image: "nebula||image"
};
const PluginSettings = {
plugins: "nebula||plugins"
};
const MarketPlaceExtras = {
proxy: "nebula||marketplaceProxy",
hostname: "nebula||marketplaceHostname"
};
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, packageName);
}
resolve();
}
if (p.plugin) {
let plugins = localStorage.getItem(PluginSettings.plugins) as any;
plugins ? (plugins = JSON.parse(plugins)) : (plugins = []);
//@ts-ignore
const plugin = plugins.find(({ name }) => name === packageName) as Plugin;
if (!plugin) {
plugins.push({
name: packageName,
src: p.plugin.src,
type: p.plugin.type
} as unknown as Plugin);
localStorage.setItem(PluginSettings.plugins, JSON.stringify(plugins));
} else if (plugin && plugin.remove) {
plugin.remove = false;
localStorage.setItem(Settings.PluginSettings.plugins, JSON.stringify(plugins));
}
resolve();
}
});
},
uninstall: function (p: PackageType, packageName: string) {
console.log(p);
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.toLowerCase());
items.splice(idx, 1);
localStorage.setItem(AppearanceSettings.themes, JSON.stringify(items));
this.changeTheme(true);
}
resolve();
}
if (p === "plugin-page" || p === "plugin-sw") {
let plugins = localStorage.getItem(PluginSettings.plugins) as any;
plugins ? (plugins = JSON.parse(plugins)) : (plugins = []);
//@ts-ignore
const plugin = plugins.find(({ name }) => name === packageName.toLowerCase());
if (plugin) {
plugin.remove = true;
localStorage.setItem(PluginSettings.plugins, JSON.stringify(plugins));
}
resolve();
}
});
},
handlePlugins: function (worker: never | ServiceWorkerRegistration) {
return new Promise<void>((resolve) => {
let plugins =
JSON.parse(localStorage.getItem(Settings.PluginSettings.plugins) as string) || [];
const swPagePlugins: SWPagePlugin[] = [];
const swPlugins: SWPlugin[] = [];
if (plugins.length === 0) {
console.log("Plugin length is not greater then 0. Resolving.");
return resolve();
}
plugins.forEach(async (plugin: Plugin) => {
if (plugin.type === "page") {
const pluginScript = await fetch(
`/packages/${plugin.name.toLowerCase()}/${plugin.src}`
).then((res) => res.text());
const script = eval(pluginScript);
const inject = (await script()) as unknown as SWPagePlugin;
if (plugin.remove) {
plugins = plugins.filter(
//@ts-ignore freaking types BRO
({ name }) => name !== plugin.name.toLowerCase()
);
swPagePlugins.push({
remove: true,
host: inject.host,
html: inject.html,
injectTo: inject.injectTo,
type: "page"
});
} else {
swPagePlugins.push({
host: inject.host,
html: inject.html,
injectTo: inject.injectTo,
type: "page"
});
}
//only resolve AFTER we have postMessaged to the SW.
worker.active?.postMessage(swPagePlugins);
} else if (plugin.type === "serviceWorker") {
const pluginScript = await fetch(
`/packages/${plugin.name.toLowerCase()}/${plugin.src}`
).then((res) => res.text());
const script = eval(pluginScript);
const inject = (await script()) as unknown as SWPlugin;
if (plugin.remove) {
plugins = plugins.filter(
//@ts-ignore
({ name }) => name !== plugin.name.toLowerCase()
);
swPlugins.push({
remove: true,
function: inject.function.toString(),
name: plugin.name,
events: inject.events,
type: "serviceWorker"
});
} else {
swPlugins.push({
function: inject.function.toString(),
name: plugin.name,
events: inject.events,
type: "serviceWorker"
});
}
worker.active?.postMessage(swPlugins);
}
localStorage.setItem(Settings.PluginSettings.plugins, JSON.stringify(plugins));
resolve();
});
});
},
changeTheme: async function (
reset: Boolean,
payload?: any,
videoSource?: string,
bgSource?: string,
name?: string
) {
async function resetCSS() {
const stylesheet = document.getElementById("stylesheet")! as HTMLLinkElement;
localStorage.removeItem(AppearanceSettings.stylePayload);
localStorage.removeItem(AppearanceSettings.themeName);
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();
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 = `/packages/${name}/${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 = `/packages/${name}/${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);
localStorage.setItem(AppearanceSettings.themeName, name as string);
}
stylesheet.href = `/packages/${name}/${localStorage.getItem(AppearanceSettings.stylePayload)}`;
} else {
if (localStorage.getItem(AppearanceSettings.stylePayload)) {
const stylesheet = document.getElementById("stylesheet")! as HTMLLinkElement;
stylesheet.href = `/packages/${localStorage.getItem(AppearanceSettings.themeName)}/${localStorage.getItem(AppearanceSettings.stylePayload)}`;
}
}
}
};
export { AppearanceSettings, PluginSettings, MarketPlaceExtras, marketPlaceSettings };

View file

@ -1,65 +0,0 @@
//Where all of our types live. Expect to see these exported and used in other files tons.
type PluginType = "page" | "serviceWorker";
type MarketplacePluginType = "plugin-page" | "plugin-sw";
type PackageType = "theme" | MarketplacePluginType;
interface Plug {
name: string;
src: string;
type: PluginType;
remove?: boolean;
}
interface SWPagePlugin extends Omit<Plug, "name" | "src"> {
host: string;
html: string;
injectTo: "head" | "body";
}
type SWPluginFunction<T extends unknown> = (args: T) => void | unknown;
type Events =
| "abortpayment"
| "activate"
| "backgroundfetchabort"
| "backgroundfetchclick"
| "backgroundfetchfail"
| "backgroundfetchsuccess"
| "canmakepayment"
| "contentdelete"
| "cookiechange"
| "fetch"
| "install"
| "message"
| "messageerror"
| "notificationclick"
| "notificationclose"
| "paymentrequest"
| "periodicsync"
| "push"
| "pushsubscriptionchange"
| "sync";
interface SWPlugin extends Omit<Plug, "src"> {
function: string | SWPluginFunction<any>;
events: Events[];
}
interface Package {
theme?: {
payload: string;
video?: string;
bgImage?: string;
};
plugin?: Plug;
}
export {
type PluginType,
type MarketplacePluginType,
type PackageType,
type Plug as Plugin,
type SWPagePlugin,
type SWPlugin,
type Package,
type SWPluginFunction
};

View file

@ -1,10 +0,0 @@
import { type SWPluginFunction as PluginFunction, type SWPagePlugin, type SWPlugin } from "./types";
interface PagePlugin extends Omit<SWPagePlugin, "type"> {}
interface ServiceWorkerPlugin extends Omit<SWPlugin, "type"> {}
declare global {
function entryFunc(): PagePlugin | ServiceWorkerPlugin;
}
export { type PagePlugin, type ServiceWorkerPlugin, type PluginFunction };

View file

@ -1,29 +0,0 @@
//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"
};
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);
}
};
export { ProxySettings, proxySettings };

View file

@ -1,83 +0,0 @@
//Tab specific settings.
import { type AbCloaks, type TabCloaks } from "./types";
const TabSettings = {
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 = `
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
body, html { margin: 0; padding: 0; height: 100%; overflow: hidden; }
</style>
</head>
<body>
<iframe style="border: none; width: 100%; height: 100vh;" src="${window.location.href}"></iframe>
</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;
}
}
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;
}
},
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

@ -1,43 +0,0 @@
import {
type Package,
type PackageType,
type Plugin,
type PluginType,
type SWPagePlugin,
type SWPlugin
} from "./marketplace/types";
const wispUrl = (location.protocol === "https:" ? "wss://" : "ws://") + location.host + "/wisp/";
type TabCloaks = "default" | "google" | "wikipedia" | "canvas" | "classroom" | "powerschool";
type AbCloaks = "a:b" | "blob";
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"
};
type SearchEngine = "ddg" | "google" | "bing";
const WispServerURLS: Record<string, string> = {
default: wispUrl,
ruby: "wss://ruby.rubynetwork.co/wisp/",
custom: localStorage.getItem("customWispUrl") as string
};
export {
type TabCloaks,
type AbCloaks,
type OpenIn,
type Proxy,
type Transport,
type PackageType,
type Package,
type PluginType,
type Plugin,
type SWPagePlugin,
type SWPlugin,
SearchEngines,
type SearchEngine,
WispServerURLS,
wispUrl
};