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

Commit

Permalink
get ready for production
Browse files Browse the repository at this point in the history
  • Loading branch information
IncognitoTGT committed Apr 14, 2024
1 parent f2077b8 commit 6533491
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 37 deletions.
2 changes: 0 additions & 2 deletions ephemeral

This file was deleted.

14 changes: 0 additions & 14 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,6 @@ const port =
process.env.PORT ||
(argv.includes("--port") && argv[argv.indexOf("--port") + 1]) ||
8080;
process.chdir(import.meta.url.replace("file://", "").replace("index.ts", ""));
if (argv.includes("-h") || argv.includes("--help")) {
console.log(`
\x1b[34;49mEphemeral
\x1b[37;49m
default: Run in production mode
--port <port>: Specify the port to run on
--dev: Run in development mode
--help, -h: Display this help message
--masqr: Enable masqr
`);
process.exit(0);
}
const vite = await createViteServer({
server: { middlewareMode: true },
});
Expand All @@ -42,7 +29,6 @@ app.use(express.static("dist"));
app.get("*", (_, response) => {
response.sendFile(path.resolve("dist", "index.html"));
});
vite.bindCLIShortcuts({ print: true });
const server = createServer();
server.on("request", devMode ? vite.middlewares : app);
server.on("upgrade", (req, socket: Socket, head) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ephemeral",
"private": true,
"version": "0.9.5",
"version": "1.0.0",
"type": "module",
"scripts": {
"preinstall": "npx only-allow pnpm",
Expand Down
10 changes: 10 additions & 0 deletions src/components/loading-suspense.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Loader2 } from "lucide-react";

export default function LoadSuspense() {
return (
<div className="flex h-screen w-screen flex-col items-center justify-center gap-2 bg-background text-foreground">
<Loader2 size={64} className="animate-spin" />
<p className="text-xl font-bold">Ephemeral is loading</p>
</div>
);
}
11 changes: 4 additions & 7 deletions src/components/theme-provider.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createContext, useContext, useEffect, useState } from "react";

export type Theme =
type Theme =
| "light"
| "dark"
| "zinc"
Expand All @@ -10,8 +10,7 @@ export type Theme =
| "frappe"
| "latte"
| "system";
// eslint-disable-next-line
export const themes: Theme[] = [
const themes: Theme[] = [
"light",
"dark",
"zinc",
Expand Down Expand Up @@ -44,7 +43,7 @@ const ThemeProviderContext = createContext<ThemeProviderState>(initialState);
export function ThemeProvider({
children,
defaultTheme = "system",
storageKey = "vite-ui-theme",
storageKey = "ephemeral-ui-theme",
...props
}: ThemeProviderProps) {
const [theme, setTheme] = useState<Theme>(
Expand All @@ -54,9 +53,7 @@ export function ThemeProvider({
useEffect(() => {
const root = window.document.documentElement;

themes.forEach((theme) => {
root.classList.remove(theme);
});
themes.forEach((theme) => root.classList.remove(theme));

if (theme === "system") {
const systemTheme = window.matchMedia("(prefers-color-scheme: dark)")
Expand Down
12 changes: 3 additions & 9 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,16 @@ import ReactDOM from "react-dom/client";
import "@/index.css";
// routes
const AppRoutes = lazy(() => import("@/routes"));
// components
import LoadSuspense from "@/components/loading-suspense";
// providers
import { ThemeProvider } from "@/components/theme-provider";
import { HelmetProvider } from "react-helmet-async";
import { Loader2 } from "lucide-react";
export default function App() {
return (
<HelmetProvider>
<ThemeProvider>
<Suspense
fallback={
<div className="flex h-screen w-screen flex-col items-center justify-center gap-2 bg-background text-foreground">
<Loader2 size={64} className="animate-spin" />
<p className="text-xl font-bold">Ephemeral is loading</p>
</div>
}
>
<Suspense fallback={<LoadSuspense />}>
<AppRoutes />
</Suspense>
</ThemeProvider>
Expand Down
3 changes: 1 addition & 2 deletions src/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ export default function AppRoutes() {
const [config] = useConfig("proxy");
useEffect(() => {
if ("serviceWorker" in navigator) {
navigator.serviceWorker.ready.then((registration) => {
BareMux.registerRemoteListener(registration.active);
navigator.serviceWorker.ready.then(() => {
BareMux.SetTransport(transports[config.transport], {
wisp: config.wispServer,
});
Expand Down
4 changes: 2 additions & 2 deletions tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Config } from "tailwindcss";

const config = {
const config: Config = {
darkMode: ["class"],
content: [
"./pages/**/*.{ts,tsx}",
Expand Down Expand Up @@ -78,6 +78,6 @@ const config = {
},
},
plugins: [require("tailwindcss-animate")],
} satisfies Config;
};

export default config;

0 comments on commit 6533491

Please sign in to comment.