Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

Commit

Permalink
fix libcurl? and orgainize
Browse files Browse the repository at this point in the history
  • Loading branch information
IncognitoTGT committed Apr 5, 2024
1 parent 11e43fd commit 0e2a795
Show file tree
Hide file tree
Showing 23 changed files with 62 additions and 94 deletions.
31 changes: 0 additions & 31 deletions src/components/Spinner.tsx

This file was deleted.

6 changes: 3 additions & 3 deletions src/components/layout-components.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { useEffect, useState } from "react";
import { Link, useNavigate } from "react-router-dom";
import { fetch } from "@/utils/fetch";
import { fetch } from "@/lib/fetch";
import { libcurl } from "libcurl.js/bundled";
import { useAsync } from "@/hooks";
import encoder from "@/utils/encoder";
import { openCloaked } from "@/utils/open-cloaked";
import encoder from "@/lib/encoder";
import { openCloaked } from "@/lib/open-cloaked";
import type { Application } from "@/types/apps";
import {
LucideHome,
Expand Down
2 changes: 1 addition & 1 deletion src/components/shortcut-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Link } from "react-router-dom";
import { useAsync } from "@/hooks";
import { libcurl } from "libcurl.js/bundled";
import type { Application } from "@/types/apps";
import encoder from "@/utils/encoder";
import encoder from "@/lib/encoder";
import {
Card,
CardContent,
Expand Down
52 changes: 26 additions & 26 deletions src/components/shortcut-carousel.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useEffect } from "react";
import { fetch } from "@/utils/fetch";
import { fetch } from "@/lib/fetch";
import { libcurl } from "libcurl.js/bundled";
import { Link } from "react-router-dom";
import encoder from "@/utils/encoder";
import encoder from "@/lib/encoder";
import {
Carousel,
CarouselContent,
Expand Down Expand Up @@ -54,30 +54,30 @@ export function ShortcutCarousel() {
return (
<Carousel>
<CarouselContent>
{!appError
? !loading
? apps
? apps
.filter((app) => app.featured)
.map((app) => (
<CarouselItem key={app.name} className="basis-1/4">
<Link
key={app.name}
to={`/view/${encodeURIComponent(encoder.encode(app.url))}`}
className="group relative"
>
<AppImage imageUrl={app.image} />
<div className="invisible absolute bottom-0 left-0 flex h-full w-full items-end justify-start rounded-lg bg-gradient-to-t from-card to-accent/50 p-4 text-left text-foreground group-hover:visible">
<h3 className="text-center font-medium">
{app.name}
</h3>
</div>
</Link>
</CarouselItem>
))
: null
: null
: null}
{!appError ? (
!loading ? (
apps ? (
apps
.filter((app) => app.featured)
.map((app) => (
<CarouselItem key={app.name} className="basis-1/4">
<Link
key={app.name}
to={`/view/${encodeURIComponent(encoder.encode(app.url))}`}
className="group relative"
>
<AppImage imageUrl={app.image} />
<div className="invisible absolute bottom-0 left-0 flex h-full w-full items-end justify-start rounded-lg bg-gradient-to-t from-card to-accent/50 p-4 text-left text-foreground group-hover:visible">
<h3 className="text-center font-medium">{app.name}</h3>
</div>
</Link>
</CarouselItem>
))
) : null
) : (
<Skeleton className="h-32 w-[56rem]" />
)
) : null}
</CarouselContent>
<CarouselPrevious />
<CarouselNext />
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import localforage from "localforage";
import { useState, useEffect, useRef, useCallback } from "react";
import { fetch } from "@/utils/fetch";
import { transports } from "@/utils/transports";
import { fetch } from "@/lib/fetch";
import { transports } from "@/lib/transports";

interface Options {
useCurrentData?: boolean;
Expand Down
4 changes: 2 additions & 2 deletions src/main-layout.tsx → src/layouts/main-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import {
TooltipTrigger,
} from "@/components/ui/tooltip";
import { Navbar } from "@/components/layout-components";
import packageJson from "../package.json";
import encoder from "./utils/encoder";
import packageJson from "../../package.json";
import encoder from "../lib/encoder";
const projectsUsed = [
{
name: "Ultraviolet",
Expand Down
2 changes: 1 addition & 1 deletion src/root-layout.tsx → src/layouts/root-layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Helmet } from "react-helmet-async";
import { useConfig } from "@/hooks";
import Meta from "@/components/Meta";
import Meta from "@/components/meta";
import { Toaster } from "@/components/ui/toaster";
import { Outlet } from "react-router-dom";
const allowedOrigins = [
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/pages/Apps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useState, useEffect, useRef } from "react";
import { useAsync } from "@/hooks";
import type { Application } from "@/types/apps";
import { Loader2, X } from "lucide-react";
import { fetch } from "@/utils/fetch";
import { fetch } from "@/lib/fetch";
export default function Apps() {
const { loading, data: apps, error, run } = useAsync<Application[]>([]);
const [searchTerm, setSearchTerm] = useState("");
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useRef, useCallback, useEffect, useState } from "react";
import { throttle } from "@/utils/throttle";
import { throttle } from "@/lib/throttle";
import { Link, useNavigate } from "react-router-dom";
import encoder from "@/utils/encoder";
import encoder from "@/lib/encoder";
import {
Command,
CommandGroup,
Expand Down
6 changes: 3 additions & 3 deletions src/pages/Settings.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ProxySettings from "./settings/ProxySettings";
import CloakSettings from "./settings/CloakSettings";
import SearchSettings from "./settings/SearchSettings";
import ProxySettings from "./settings/proxy";
import CloakSettings from "./settings/cloak";
import SearchSettings from "./settings/search";

export default function Settings() {
return (
Expand Down
6 changes: 3 additions & 3 deletions src/pages/View.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState, useRef, useEffect, useCallback, useMemo } from "react";
import { Link, useParams } from "react-router-dom";
import type { Eruda as baseEruda } from "eruda";
import encoder from "@/utils/encoder";
import encoder from "@/lib/encoder";
import {
ArrowUpRightFromSquare,
ChevronLeft,
Expand All @@ -21,10 +21,10 @@ import {
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { useToast } from "@/components/ui/use-toast";
import { throttle } from "@/utils/throttle";
import { throttle } from "@/lib/throttle";
import { useSuggestions, useConfig } from "@/hooks";
import type { NavButton } from "@/types/view";
import { injectPlugins } from "@/utils/injector";
import { injectPlugins } from "@/lib/injector";
interface Eruda extends baseEruda {
_isInit: boolean;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
import { Label } from "@/components/ui/label";
import { useToast } from "@/components/ui/use-toast";
import { useConfig } from "@/hooks";
import { openCloaked } from "@/utils/open-cloaked";
import { openCloaked } from "@/lib/open-cloaked";
import { Skeleton } from "@/components/ui/skeleton";

export default function CloakSettings() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
SelectContent,
SelectItem,
} from "@/components/ui/select";
import { unregisterServiceWorker } from "@/utils/swUtil";
import { unregisterServiceWorker } from "@/lib/sw";
export default function ProxySettings() {
const { toast } = useToast();
const [config, reset, loading] = useConfig("proxy"); // Using the useConfig hook to get proxy settings
Expand Down
File renamed without changes.
File renamed without changes.
33 changes: 16 additions & 17 deletions src/routes.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { useEffect } from "react";
import { createBrowserRouter, RouterProvider } from "react-router-dom";
// layouts
import RootLayout from "@/root-layout";
import MainLayout from "@/main-layout";
import RootLayout from "@/layouts/root-layout";
import MainLayout from "@/layouts/main-layout";
// pages
import Home from "@/pages/Home";
import View from "@/pages/View";
import Settings from "@/pages/Settings";
import Apps from "@/pages/Apps";
import ServiceWorkerError from "@/pages/ServiceWorkerError";
import Home from "@/pages/home";
import View from "@/pages/view";
import Settings from "@/pages/settings";
import Apps from "@/pages/apps";
import ServiceWorkerError from "@/pages/sw-error";
import Error from "@/pages/error";
// utils
import { libcurl } from "libcurl.js/bundled";
import { useConfig } from "./hooks";
import { transports } from "./utils/transports";
import { transports } from "./lib/transports";
import {
SetTransport,
registerRemoteListener,
Expand Down Expand Up @@ -56,20 +56,19 @@ const routes = createBrowserRouter([
export default function AppRoutes() {
const [config] = useConfig("proxy");
useEffect(() => {
libcurl.set_websocket(config.wispServer);
libcurl.onload = () => {
console.log(
"\x1b[34;49;1m[Ephemeral] \x1B[32mINFO: Libcurl.js version " +
libcurl.version.lib +
" loaded",
);
if (libcurl.ready) window.dispatchEvent(new Event("libcurlReady"));
};
try {
registerRemoteListener(navigator.serviceWorker.controller!);
SetTransport(transports[config.transport], {
wisp: config.wispServer,
});
libcurl.set_websocket(config.wispServer);
if (libcurl.ready) {
console.log(
"\x1b[34;49;1m[Ephemeral] \x1B[32mINFO: Libcurl.js version " +
libcurl.version.lib +
" loaded",
);
}
} catch (e) {
console.error(e);
}
Expand Down

0 comments on commit 0e2a795

Please sign in to comment.