formatting
This commit is contained in:
parent
8b99bcc6a8
commit
c7b158fd57
8 changed files with 170 additions and 166 deletions
|
|
@ -22,11 +22,11 @@
|
||||||
window.location.href = window.location.href;
|
window.location.href = window.location.href;
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
if (!localStorage["auth"] && new URL(document.all.rcheck.href).password) {
|
if (!localStorage["auth"] && new URL(document.all.rcheck.href).password) {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
localStorage["auth"] = 1;
|
localStorage["auth"] = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
132
package.json
132
package.json
|
|
@ -1,66 +1,66 @@
|
||||||
{
|
{
|
||||||
"name": "nebula",
|
"name": "nebula",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "concurrently \"vite\" \"bare-server-node --port 8080\"",
|
"dev": "concurrently \"vite\" \"bare-server-node --port 8080\"",
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"bstart": "npm run build && tsx server.ts",
|
"bstart": "npm run build && tsx server.ts",
|
||||||
"start": "tsx server.ts",
|
"start": "tsx server.ts",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"format": "prettier --write ."
|
"format": "prettier --write ."
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fastify/compress": "^6.5.0",
|
"@fastify/compress": "^6.5.0",
|
||||||
"@fastify/cookie": "^9.3.1",
|
"@fastify/cookie": "^9.3.1",
|
||||||
"@fastify/static": "^6.12.0",
|
"@fastify/static": "^6.12.0",
|
||||||
"@mercuryworkshop/bare-mux": "^1.0.5",
|
"@mercuryworkshop/bare-mux": "^1.0.5",
|
||||||
"@mercuryworkshop/epoxy-transport": "^1.1.0",
|
"@mercuryworkshop/epoxy-transport": "^1.1.0",
|
||||||
"@mercuryworkshop/libcurl-transport": "^1.2.3",
|
"@mercuryworkshop/libcurl-transport": "^1.2.3",
|
||||||
"@nebula-services/dynamic": "0.7.2-patch.2",
|
"@nebula-services/dynamic": "0.7.2-patch.2",
|
||||||
"@titaniumnetwork-dev/ultraviolet": "^3.0.0",
|
"@titaniumnetwork-dev/ultraviolet": "^3.0.0",
|
||||||
"@tomphttp/bare-server-node": "2.0.3",
|
"@tomphttp/bare-server-node": "2.0.3",
|
||||||
"@tsparticles/engine": "^3.3.0",
|
"@tsparticles/engine": "^3.3.0",
|
||||||
"@tsparticles/react": "^3.0.0",
|
"@tsparticles/react": "^3.0.0",
|
||||||
"@tsparticles/slim": "^3.3.0",
|
"@tsparticles/slim": "^3.3.0",
|
||||||
"@types/express": "^4.17.21",
|
"@types/express": "^4.17.21",
|
||||||
"chalk": "^5.3.0",
|
"chalk": "^5.3.0",
|
||||||
"classnames": "^2.5.1",
|
"classnames": "^2.5.1",
|
||||||
"compression": "^1.7.4",
|
"compression": "^1.7.4",
|
||||||
"cookie-parser": "^1.4.6",
|
"cookie-parser": "^1.4.6",
|
||||||
"crypto-js": "^4.2.0",
|
"crypto-js": "^4.2.0",
|
||||||
"express": "^4.18.3",
|
"express": "^4.18.3",
|
||||||
"fastify": "^4.26.2",
|
"fastify": "^4.26.2",
|
||||||
"framer-motion": "^10.18.0",
|
"framer-motion": "^10.18.0",
|
||||||
"i18next": "^23.10.1",
|
"i18next": "^23.10.1",
|
||||||
"i18next-browser-languagedetector": "^7.2.0",
|
"i18next-browser-languagedetector": "^7.2.0",
|
||||||
"localforage": "^1.10.0",
|
"localforage": "^1.10.0",
|
||||||
"million": "^2.6.4",
|
"million": "^2.6.4",
|
||||||
"preact": "^10.19.6",
|
"preact": "^10.19.6",
|
||||||
"preact-iso": "^2.4.0",
|
"preact-iso": "^2.4.0",
|
||||||
"preact-render-to-string": "^6.4.0",
|
"preact-render-to-string": "^6.4.0",
|
||||||
"preact-router": "^4.1.2",
|
"preact-router": "^4.1.2",
|
||||||
"rammerhead": "https://github.com/NebulaServices/rammerhead/releases/download/rammerhead-1.2.41-nebula.8/rammerhead-1.2.41-nebula.7.tgz",
|
"rammerhead": "https://github.com/NebulaServices/rammerhead/releases/download/rammerhead-1.2.41-nebula.8/rammerhead-1.2.41-nebula.7.tgz",
|
||||||
"react-helmet": "^6.1.0",
|
"react-helmet": "^6.1.0",
|
||||||
"react-i18next": "^13.5.0",
|
"react-i18next": "^13.5.0",
|
||||||
"react-icons": "^4.12.0",
|
"react-icons": "^4.12.0",
|
||||||
"react-toastify": "^9.1.3",
|
"react-toastify": "^9.1.3",
|
||||||
"tsx": "^4.7.1",
|
"tsx": "^4.7.1",
|
||||||
"wisp-server-node": "^1.0.2",
|
"wisp-server-node": "^1.0.2",
|
||||||
"ws": "^8.16.0"
|
"ws": "^8.16.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@preact/preset-vite": "^2.8.1",
|
"@preact/preset-vite": "^2.8.1",
|
||||||
"autoprefixer": "^10.4.18",
|
"autoprefixer": "^10.4.18",
|
||||||
"concurrently": "^8.2.2",
|
"concurrently": "^8.2.2",
|
||||||
"eslint": "^8.57.0",
|
"eslint": "^8.57.0",
|
||||||
"eslint-config-preact": "^1.3.0",
|
"eslint-config-preact": "^1.3.0",
|
||||||
"postcss": "^8.4.35",
|
"postcss": "^8.4.35",
|
||||||
"prettier": "^3.2.5",
|
"prettier": "^3.2.5",
|
||||||
"prettier-plugin-tailwindcss": "^0.5.12",
|
"prettier-plugin-tailwindcss": "^0.5.12",
|
||||||
"tailwindcss": "^3.4.1",
|
"tailwindcss": "^3.4.1",
|
||||||
"typescript": "^5.4.2",
|
"typescript": "^5.4.2",
|
||||||
"vite": "^5.1.6",
|
"vite": "^5.1.6",
|
||||||
"vite-plugin-static-copy": "^1.0.1"
|
"vite-plugin-static-copy": "^1.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ export function Home() {
|
||||||
|
|
||||||
const handleSubmit = (event) => {
|
const handleSubmit = (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
//ensure transport is set
|
//ensure transport is set
|
||||||
setTransport();
|
setTransport();
|
||||||
window.location.href =
|
window.location.href =
|
||||||
"/go/" +
|
"/go/" +
|
||||||
|
|
|
||||||
|
|
@ -1,76 +1,80 @@
|
||||||
import { FaAngleDown } from "react-icons/fa";
|
import { FaAngleDown } from "react-icons/fa";
|
||||||
import { useState, useEffect } from "preact/hooks"
|
import { useState, useEffect } from "preact/hooks";
|
||||||
import { changeTransport } from "../../util/transports.ts";
|
import { changeTransport } from "../../util/transports.ts";
|
||||||
const wispUrl = localStorage.getItem("wispUrl") || (location.protocol === "https:" ? "wss://" : "ws://") + location.host + "/wisp/";
|
const wispUrl =
|
||||||
|
localStorage.getItem("wispUrl") ||
|
||||||
interface Option {
|
(location.protocol === "https:" ? "wss://" : "ws://") +
|
||||||
id: string;
|
location.host +
|
||||||
label: string; // Translations CAN be passed
|
"/wisp/";
|
||||||
}
|
|
||||||
|
interface Option {
|
||||||
const TransportDropdown = ({
|
id: string;
|
||||||
storageKey,
|
label: string; // Translations CAN be passed
|
||||||
options,
|
}
|
||||||
refresh
|
|
||||||
}: {
|
const TransportDropdown = ({
|
||||||
storageKey: string;
|
storageKey,
|
||||||
options: Option[];
|
options,
|
||||||
refresh: boolean;
|
refresh
|
||||||
}) => {
|
}: {
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
storageKey: string;
|
||||||
|
options: Option[];
|
||||||
const [choice, setChoice] = useState(() => {
|
refresh: boolean;
|
||||||
return localStorage.getItem(storageKey) || options[0]?.id || "";
|
}) => {
|
||||||
});
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
|
|
||||||
// update on localstorage change
|
const [choice, setChoice] = useState(() => {
|
||||||
useEffect(() => {
|
return localStorage.getItem(storageKey) || options[0]?.id || "";
|
||||||
setChoice(localStorage.getItem(storageKey) || options[0]?.id || "");
|
});
|
||||||
}, [storageKey, options]);
|
|
||||||
|
// update on localstorage change
|
||||||
return (
|
useEffect(() => {
|
||||||
<div className="relative text-center">
|
setChoice(localStorage.getItem(storageKey) || options[0]?.id || "");
|
||||||
<div
|
}, [storageKey, options]);
|
||||||
className={`font-roboto flex h-14 w-56 cursor-pointer flex-col items-center justify-center border border-input-border-color bg-input text-center text-xl ${
|
|
||||||
isOpen ? "rounded-t-2xl" : "rounded-2xl"
|
return (
|
||||||
}`}
|
<div className="relative text-center">
|
||||||
onClick={() => setIsOpen(!isOpen)}
|
<div
|
||||||
>
|
className={`font-roboto flex h-14 w-56 cursor-pointer flex-col items-center justify-center border border-input-border-color bg-input text-center text-xl ${
|
||||||
<div className="flex h-full w-full select-none flex-row items-center">
|
isOpen ? "rounded-t-2xl" : "rounded-2xl"
|
||||||
<div className="h-full w-1/4"></div>
|
}`}
|
||||||
<div className="flex w-2/4 flex-col items-center text-input-text">
|
onClick={() => setIsOpen(!isOpen)}
|
||||||
{options.find((o) => o.id === choice)?.label}
|
>
|
||||||
</div>
|
<div className="flex h-full w-full select-none flex-row items-center">
|
||||||
<div className="flex w-1/4 flex-col items-center text-input-text">
|
<div className="h-full w-1/4"></div>
|
||||||
<FaAngleDown />
|
<div className="flex w-2/4 flex-col items-center text-input-text">
|
||||||
</div>
|
{options.find((o) => o.id === choice)?.label}
|
||||||
</div>
|
</div>
|
||||||
{isOpen && (
|
<div className="flex w-1/4 flex-col items-center text-input-text">
|
||||||
<div className="absolute top-full w-full">
|
<FaAngleDown />
|
||||||
{options.map((option, index) => (
|
</div>
|
||||||
<div
|
</div>
|
||||||
key={option.id}
|
{isOpen && (
|
||||||
className={`border border-input-border-color bg-input p-2 text-input-text hover:bg-dropdown-option-hover-color ${
|
<div className="absolute top-full w-full">
|
||||||
index === options.length - 1 ? "rounded-b-2xl" : ""
|
{options.map((option, index) => (
|
||||||
}`}
|
<div
|
||||||
onClick={() => {
|
key={option.id}
|
||||||
setIsOpen(false);
|
className={`border border-input-border-color bg-input p-2 text-input-text hover:bg-dropdown-option-hover-color ${
|
||||||
setChoice(option.id);
|
index === options.length - 1 ? "rounded-b-2xl" : ""
|
||||||
localStorage.setItem(storageKey, option.id);
|
}`}
|
||||||
changeTransport(option.id, wispUrl);
|
onClick={() => {
|
||||||
if (refresh === true) {
|
setIsOpen(false);
|
||||||
window.location.reload();
|
setChoice(option.id);
|
||||||
}
|
localStorage.setItem(storageKey, option.id);
|
||||||
}}
|
changeTransport(option.id, wispUrl);
|
||||||
>
|
if (refresh === true) {
|
||||||
{option.label}
|
window.location.reload();
|
||||||
</div>
|
}
|
||||||
))}
|
}}
|
||||||
</div>
|
>
|
||||||
)}
|
{option.label}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
))}
|
||||||
);
|
</div>
|
||||||
};
|
)}
|
||||||
|
</div>
|
||||||
export default TransportDropdown;
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TransportDropdown;
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import "./i18n";
|
||||||
import { setTransport } from "./util/transports";
|
import { setTransport } from "./util/transports";
|
||||||
|
|
||||||
export default function Routes() {
|
export default function Routes() {
|
||||||
if ("serviceWorker" in navigator) {
|
if ("serviceWorker" in navigator) {
|
||||||
window.addEventListener("load", () => {
|
window.addEventListener("load", () => {
|
||||||
navigator.serviceWorker
|
navigator.serviceWorker
|
||||||
.register("/sw.js", {
|
.register("/sw.js", {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
export function isIOS() {
|
export function isIOS() {
|
||||||
if (/iPad|iPhone|iPod/.test(navigator.userAgent)) {
|
if (/iPad|iPhone|iPod/.test(navigator.userAgent)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,16 +19,16 @@ function uninstallServiceWorkers() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function registerServiceWorker() {
|
function registerServiceWorker() {
|
||||||
if ('serviceWorker' in navigator) {
|
if ("serviceWorker" in navigator) {
|
||||||
navigator.serviceWorker
|
navigator.serviceWorker
|
||||||
.register("/sw.js", {
|
.register("/sw.js", {
|
||||||
scope: "/~/"
|
scope: "/~/"
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
console.log("Service worker registered successfully");
|
console.log("Service worker registered successfully");
|
||||||
setTransport();
|
setTransport();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { updateServiceWorkers, uninstallServiceWorkers, registerServiceWorker };
|
export { updateServiceWorkers, uninstallServiceWorkers, registerServiceWorker };
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ registerRemoteListener(navigator.serviceWorker.controller!);
|
||||||
|
|
||||||
//changeTransport(
|
//changeTransport(
|
||||||
// localStorage.getItem("transport") || "libcurl",
|
// localStorage.getItem("transport") || "libcurl",
|
||||||
// localStorage.getItem("wispUrl") || wispUrl
|
// localStorage.getItem("wispUrl") || wispUrl
|
||||||
//);
|
//);
|
||||||
|
|
||||||
// helper function for ../routes.tsx
|
// helper function for ../routes.tsx
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue