Upgrade to vite build

This commit is contained in:
Kieran 2023-12-22 12:51:53 +00:00
parent 935e8c673e
commit b9a9d7bd26
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
55 changed files with 5132 additions and 10349 deletions

1
.gitignore vendored
View File

@ -17,3 +17,4 @@ sw.js
.idea/
appsettings.*.json
VoidCat.xml
build/

View File

@ -3,13 +3,13 @@
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Microsoft.EntityFrameworkCore": "Warning"
"Microsoft.EntityFrameworkCore": "Warning",
"Microsoft.AspNetCore.Cors.Infrastructure.CorsService": "Information"
}
},
"AllowedHosts": "*",
"Settings": {
"SiteUrl": "http://localhost:7195",
"DataDirectory": "./data",
"CorsOrigins": []
"DataDirectory": "./data"
}
}

File diff suppressed because one or more lines are too long

893
VoidCat/spa/.yarn/releases/yarn-4.0.2.cjs vendored Executable file

File diff suppressed because one or more lines are too long

View File

@ -1 +1,5 @@
yarnPath: .yarn/releases/yarn-3.6.4.cjs
compressionLevel: mixed
enableGlobalCache: false
yarnPath: .yarn/releases/yarn-4.0.2.cjs

View File

@ -7,10 +7,10 @@
"build": "yarn workspace @void-cat/api build && yarn workspace @void-cat/app build",
"start": "yarn workspace @void-cat/api build && yarn workspace @void-cat/app start"
},
"packageManager": "yarn@3.6.4",
"packageManager": "yarn@4.0.2",
"devDependencies": {
"eslint": "^8.51.0",
"prettier": "^3.0.3",
"typescript": "^5.2.2"
"typescript": "^5.3.3"
}
}

View File

@ -1,9 +1,10 @@
{
"name": "@void-cat/api",
"version": "1.0.10",
"version": "1.0.11",
"description": "void.cat API package",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"module": "src/index.ts",
"repository": "https://git.v0l.io/Kieran/void.cat",
"author": "Kieran",
"license": "MIT",
@ -12,7 +13,7 @@
},
"devDependencies": {
"@types/sjcl": "^1.0.30",
"typescript": "^5.0.4"
"typescript": "^5.3.3"
},
"dependencies": {
"sjcl": "^1.0.8"

View File

@ -145,32 +145,32 @@ export interface ApiKey {
token: string;
}
export enum PaymentCurrencies {
export const enum PaymentCurrencies {
BTC = 0,
USD = 1,
EUR = 2,
GBP = 3,
}
export enum PaymentServices {
export const enum PaymentServices {
None = 0,
Strike = 1,
}
export enum PaymentOrderState {
export const enum PaymentOrderState {
Unpaid = 0,
Paid = 1,
Expired = 2,
}
export enum PagedSortBy {
export const enum PagedSortBy {
Name = 0,
Date = 1,
Size = 2,
Id = 3,
}
export enum PageSortOrder {
export const enum PageSortOrder {
Asc = 0,
Dsc = 1,
}

View File

@ -1,2 +1 @@
BROWSER=none
API_HOST=http://localhost:7195
VITE_API_HOST=http://localhost:7195

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -5,9 +5,24 @@
"description": "Void.cat file hosting",
"icons": [
{
"src": "voidcat_512.png",
"type": "image/png",
"src": "logo_512.jpg",
"type": "image/jpg",
"sizes": "512x512"
},
{
"src": "logo_256.jpg",
"type": "image/jpg",
"sizes": "256x256"
},
{
"src": "logo_128.jpg",
"type": "image/jpg",
"sizes": "128x128"
},
{
"src": "logo_32.png",
"type": "image/png",
"sizes": "32x32"
}
],
"start_url": ".",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 401 KiB

View File

@ -1,11 +0,0 @@
module.exports = {
webpack: {
configure: {
resolve: {
fallback: {
crypto: false,
},
},
},
},
};

0
VoidCat/spa/src/app/custom.d.ts vendored Normal file
View File

View File

@ -1,4 +0,0 @@
declare module "*.png" {
const value: string;
export default value;
}

View File

@ -0,0 +1,18 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<link rel="icon" href="/logo_32.png"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="theme-color" content="#000000"/>
<meta name="description" content="void.cat - free, simple file sharing."/>
<link rel="apple-touch-icon" href="/logo_256.png"/>
<link rel="manifest" href="/manifest.json"/>
<title>void.cat</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script src="./src/index.tsx" type="module"></script>
</body>
</html>

View File

@ -6,44 +6,38 @@
"dependencies": {
"@hcaptcha/react-hcaptcha": "^1.1.1",
"@reduxjs/toolkit": "^1.7.2",
"@void-cat/api": "workspace:^",
"@void-cat/api": "^1.0.10",
"moment": "^2.29.4",
"prop-types": "^15.8.1",
"qrcode.react": "^1.0.1",
"qrcode.react": "^3.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-helmet": "^6.1.0",
"react-redux": "^7.2.6",
"react-router-dom": "^6.2.1",
"react-scripts": "5.0.0",
"recharts": "^2.1.10",
"sjcl": "^1.0.8"
},
"devDependencies": {
"@babel/plugin-syntax-flow": "^7.22.5",
"@craco/craco": "^6.4.5",
"@types/node": "^20.5.3",
"@types/preval.macro": "^3.0.0",
"@types/qrcode.react": "^1.0.2",
"@types/react": "^18.2.0",
"@types/react-dom": "^18.2.1",
"@types/react-helmet": "^6.1.6",
"@types/react-redux": "^7.1.26",
"@types/sjcl": "^1.0.30",
"chalk": "^5.3.0",
"cra-bundle-analyzer": "^0.1.1",
"@vitejs/plugin-react": "^4.2.1",
"eslint": "^8.47.0",
"eslint-config-react-app": "^7.0.1",
"http-proxy-middleware": "^2.0.6",
"preval.macro": "^5.0.0",
"typescript": "^5.1.6",
"webpack": "^5.88.2"
"rollup-plugin-visualizer": "^5.11.0",
"typescript": "^5.3.3",
"vite": "^5.0.10",
"vite-plugin-pwa": "^0.17.4",
"vite-plugin-version-mark": "^0.0.10"
},
"scripts": {
"start": "craco start",
"build": "craco build",
"test": "craco test",
"eject": "react-scripts eject"
"start": "vite start",
"build": "vite build"
},
"eslintConfig": {
"extends": [

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -1,17 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="void.cat - free, simple file sharing." />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo.png" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<title>void.cat</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

View File

@ -5,9 +5,24 @@
"description": "Void.cat file hosting",
"icons": [
{
"src": "voidcat_512.png",
"type": "image/png",
"src": "logo_512.jpg",
"type": "image/jpg",
"sizes": "512x512"
},
{
"src": "logo_256.jpg",
"type": "image/jpg",
"sizes": "256x256"
},
{
"src": "logo_128.jpg",
"type": "image/jpg",
"sizes": "128x128"
},
{
"src": "logo_32.png",
"type": "image/png",
"sizes": "32x32"
}
],
"start_url": ".",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 401 KiB

View File

@ -5,13 +5,13 @@ import { Navigate } from "react-router-dom";
import { AdminProfile } from "@void-cat/api";
import { UserList } from "./UserList";
import { VoidButton } from "../Components/Shared/VoidButton";
import VoidModal from "../Components/Shared/VoidModal";
import { VoidButton } from "@/Components/Shared/VoidButton";
import VoidModal from "@/Components/Shared/VoidModal";
import EditUser from "./EditUser";
import useApi from "Hooks/UseApi";
import { RootState } from "Store";
import ImageGrid from "../Components/Shared/ImageGrid";
import useApi from "@/Hooks/UseApi";
import { RootState } from "@/Store";
import ImageGrid from "@/Components/Shared/ImageGrid";
export function Admin() {
const auth = useSelector((state: RootState) => state.login.jwt);

View File

@ -2,9 +2,9 @@ import { useState } from "react";
import { useSelector } from "react-redux";
import { AdminProfile } from "@void-cat/api";
import { VoidButton } from "../Components/Shared/VoidButton";
import useApi from "Hooks/UseApi";
import { RootState } from "Store";
import { VoidButton } from "@/Components/Shared/VoidButton";
import useApi from "@/Hooks/UseApi";
import { RootState } from "@/Store";
export default function EditUser({
user,

View File

@ -10,10 +10,10 @@ import {
PageSortOrder,
} from "@void-cat/api";
import { logout } from "../LoginState";
import { logout } from "@/LoginState";
import { PageSelector } from "../Components/Shared/PageSelector";
import useApi from "Hooks/UseApi";
import useApi from "@/Hooks/UseApi";
interface UserListProps {
actions: (u: AdminProfile) => ReactNode;

View File

@ -7,6 +7,7 @@ import {
RouterProvider,
} from "react-router-dom";
import { Provider } from "react-redux";
import { VoidApi } from "@void-cat/api";
import store from "./Store";
import { FilePreview } from "./Pages/FilePreview";
@ -16,8 +17,6 @@ import { UserLogin } from "./Pages/UserLogin";
import { ProfilePage } from "./Pages/Profile";
import { Header } from "./Components/Shared/Header";
import { Donate } from "./Pages/Donate";
import { VoidApi } from "@void-cat/api";
import { ApiHost } from "./Const";
const router = createBrowserRouter([
{
@ -35,7 +34,7 @@ const router = createBrowserRouter([
path: "/u/:id",
loader: async ({ params }: LoaderFunctionArgs) => {
const state = store.getState();
const api = new VoidApi(ApiHost, state.login.jwt ? () => Promise.resolve(`Bearer ${state.login.jwt}`) : undefined);
const api = new VoidApi(import.meta.env.VITE_API_HOST, state.login.jwt ? () => Promise.resolve(`Bearer ${state.login.jwt}`) : undefined);
if (params.id) {
try {
return await api.getUser(params.id);

View File

@ -12,8 +12,8 @@ import { StrikePaymentConfig } from "./StrikePaymentConfig";
import { NoPaymentConfig } from "./NoPaymentConfig";
import { VoidButton } from "../Shared/VoidButton";
import useApi from "Hooks/UseApi";
import { RootState } from "Store";
import useApi from "@/Hooks/UseApi";
import { RootState } from "@/Store";
interface FileEditProps {
file: VoidFileResponse;

View File

@ -4,8 +4,8 @@ import { LightningPayment } from "./LightningPayment";
import { VoidButton } from "../Shared/VoidButton";
import { PaymentOrder, PaymentServices, VoidFileResponse } from "@void-cat/api";
import useApi from "Hooks/UseApi";
import { FormatCurrency } from "Util";
import useApi from "@/Hooks/UseApi";
import { FormatCurrency } from "@/Util";
interface FilePaymentProps {
file: VoidFileResponse;

View File

@ -8,7 +8,7 @@ import {
import { Countdown } from "../Shared/Countdown";
import useApi from "Hooks/UseApi";
import useApi from "@/Hooks/UseApi";
interface LightningPaymentProps {
file: VoidFileResponse;

View File

@ -6,9 +6,9 @@ import { UploadState, VoidFileResponse } from "@void-cat/api";
import { VoidButton } from "../Shared/VoidButton";
import { useFileTransfer } from "../Shared/FileTransferHook";
import { RootState } from "Store";
import { ConstName, FormatBytes } from "Util";
import useApi from "Hooks/UseApi";
import { RootState } from "@/Store";
import { ConstName, FormatBytes } from "@/Util";
import useApi from "@/Hooks/UseApi";
interface FileUploadProps {
file: File | Blob;

View File

@ -2,7 +2,7 @@ import "./FooterLinks.css";
import { useSelector } from "react-redux";
import { Link } from "react-router-dom";
import { RootState } from "Store";
import { RootState } from "@/Store";
export function FooterLinks() {
const profile = useSelector((s: RootState) => s.login.profile);

View File

@ -3,9 +3,9 @@ import { Fragment } from "react";
import moment from "moment";
import { useSelector } from "react-redux";
import Icon from "Components/Shared/Icon";
import { RootState } from "Store";
import { FormatBytes } from "Util";
import Icon from "@/Components/Shared/Icon";
import { RootState } from "@/Store";
import { FormatBytes } from "@/Util";
export function GlobalStats() {
let stats = useSelector((s: RootState) => s.info.info);

View File

@ -2,7 +2,7 @@ import { Bar, BarChart, Tooltip, XAxis } from "recharts";
import moment from "moment";
import { BandwidthPoint } from "@void-cat/api";
import { FormatBytes } from "Util";
import { FormatBytes } from "@/Util";
interface MetricsGraphProps {
metrics?: Array<BandwidthPoint>;

View File

@ -5,7 +5,7 @@ import { ApiKey } from "@void-cat/api";
import { VoidButton } from "../Shared/VoidButton";
import VoidModal from "../Shared/VoidModal";
import useApi from "Hooks/UseApi";
import useApi from "@/Hooks/UseApi";
export default function ApiKeyList() {
const Api = useApi();

View File

@ -11,10 +11,10 @@ import {
VoidFileResponse,
} from "@void-cat/api";
import { logout } from "../../LoginState";
import { logout } from "@/LoginState";
import { PageSelector } from "./PageSelector";
import { FormatBytes } from "Util";
import { FormatBytes } from "@/Util";
interface FileListProps {
actions?: (f: VoidFileResponse) => ReactNode;

View File

@ -1,16 +1,14 @@
import "./Header.css";
import VoidCat from "../../image/voidcat.png";
import { useEffect } from "react";
import { Link } from "react-router-dom";
import { useDispatch, useSelector } from "react-redux";
import { InlineProfile } from "./InlineProfile";
import { logout, setAuth, setProfile } from "../../LoginState";
import { setInfo } from "../../SiteInfoStore";
import useApi from "Hooks/UseApi";
import { RootState } from "Store";
import { logout, setAuth, setProfile } from "@/LoginState";
import { setInfo } from "@/SiteInfoStore";
import useApi from "@/Hooks/UseApi";
import { RootState } from "@/Store";
export function Header() {
const dispatch = useDispatch();
@ -51,7 +49,7 @@ export function Header() {
return (
<div className="header page">
<img src={VoidCat} alt="logo" className="logo" />
<img src="/logo_128.jpg" alt="logo" className="logo" />
<div className="title">
<Link to="/">{window.location.hostname}</Link>
</div>

View File

@ -12,7 +12,7 @@ import { useEffect, useState } from "react";
import { Link } from "react-router-dom";
import { useDispatch } from "react-redux";
import { logout } from "../../LoginState";
import { logout } from "@/LoginState";
import { PageSelector } from "./PageSelector";
interface ImageGridProps {

View File

@ -3,7 +3,7 @@ import { CSSProperties } from "react";
import { Link } from "react-router-dom";
import { Profile } from "@void-cat/api";
import { DefaultAvatar } from "Const";
import { DefaultAvatar } from "@/Const";
const DefaultSize = 64;

View File

@ -3,11 +3,11 @@ import { useDispatch, useSelector } from "react-redux";
import HCaptcha from "@hcaptcha/react-hcaptcha";
import "./Login.css";
import { setAuth } from "../../LoginState";
import { setAuth } from "@/LoginState";
import { VoidButton } from "./VoidButton";
import useApi from "Hooks/UseApi";
import { RootState } from "Store";
import useApi from "@/Hooks/UseApi";
import { RootState } from "@/Store";
export function Login() {
const Api = useApi();

View File

@ -1,7 +1,3 @@
import preval from "preval.macro";
export const ApiHost = preval`module.exports = process.env.API_HOST || '';`;
export const DefaultAvatar = "https://i.imgur.com/8A5Fu65.jpeg";
/**

View File

@ -1,10 +1,9 @@
import { useSelector } from "react-redux";
import { VoidApi } from "@void-cat/api";
import { RootState } from "Store";
import { ApiHost } from "Const";
import { RootState } from "@/Store";
export default function useApi() {
const auth = useSelector((s: RootState) => s.login.jwt);
return new VoidApi(ApiHost, auth ? () => Promise.resolve(`Bearer ${auth}`) : undefined);
return new VoidApi(import.meta.env.VITE_API_HOST, auth ? () => Promise.resolve(`Bearer ${auth}`) : undefined);
}

View File

@ -8,17 +8,16 @@ import {
StreamEncryption,
} from "@void-cat/api";
import { TextPreview } from "../Components/FilePreview/TextPreview";
import { FileEdit } from "../Components/FileEdit/FileEdit";
import { FilePayment } from "../Components/FilePreview/FilePayment";
import { InlineProfile } from "../Components/Shared/InlineProfile";
import { VoidButton } from "../Components/Shared/VoidButton";
import { useFileTransfer } from "../Components/Shared/FileTransferHook";
import Icon from "../Components/Shared/Icon";
import { TextPreview } from "@/Components/FilePreview/TextPreview";
import { FileEdit } from "@/Components/FileEdit/FileEdit";
import { FilePayment } from "@/Components/FilePreview/FilePayment";
import { InlineProfile } from "@/Components/Shared/InlineProfile";
import { VoidButton } from "@/Components/Shared/VoidButton";
import { useFileTransfer } from "@/Components/Shared/FileTransferHook";
import Icon from "@/Components/Shared/Icon";
import useApi from "Hooks/UseApi";
import { FormatBytes } from "Util";
import { ApiHost } from "Const";
import useApi from "@/Hooks/UseApi";
import { FormatBytes } from "@/Util";
export function FilePreview() {
const Api = useApi();
@ -249,7 +248,7 @@ export function FilePreview() {
useEffect(() => {
if (info) {
const fileLink = info.metadata?.url ?? `${ApiHost}/d/${info.id}`;
const fileLink = info.metadata?.url ?? `${import.meta.env.VITE_API_HOST}/d/${info.id}`;
setFileSize(info.metadata?.size ?? 0);
const order = window.localStorage.getItem(`payment-${info.id}`);

View File

@ -1,11 +1,11 @@
import { useSelector } from "react-redux";
import { Dropzone } from "../Components/FileUpload/Dropzone";
import { GlobalStats } from "../Components/HomePage/GlobalStats";
import { FooterLinks } from "../Components/HomePage/FooterLinks";
import { MetricsGraph } from "../Components/HomePage/MetricsGraph";
import { Dropzone } from "@/Components/FileUpload/Dropzone";
import { GlobalStats } from "@/Components/HomePage/GlobalStats";
import { FooterLinks } from "@/Components/HomePage/FooterLinks";
import { MetricsGraph } from "@/Components/HomePage/MetricsGraph";
import { RootState } from "Store";
import { RootState } from "@/Store";
export function HomePage() {
const metrics = useSelector((s: RootState) => s.info.info);

View File

@ -5,14 +5,14 @@ import { default as moment } from "moment";
import { useLoaderData } from "react-router-dom";
import { Profile } from "@void-cat/api";
import useApi from "Hooks/UseApi";
import { RootState } from "Store";
import { DefaultAvatar } from "Const";
import useApi from "@/Hooks/UseApi";
import { RootState } from "@/Store";
import { DefaultAvatar } from "@/Const";
import { logout, setProfile as setGlobalProfile } from "../LoginState";
import { FileList } from "../Components/Shared/FileList";
import { VoidButton } from "../Components/Shared/VoidButton";
import ApiKeyList from "../Components/Profile/ApiKeyList";
import { logout, setProfile as setGlobalProfile } from "@/LoginState";
import { FileList } from "@/Components/Shared/FileList";
import { VoidButton } from "@/Components/Shared/VoidButton";
import ApiKeyList from "@/Components/Profile/ApiKeyList";
export function ProfilePage() {
const dispatch = useDispatch();

View File

@ -2,8 +2,8 @@ import { useSelector } from "react-redux";
import { useNavigate } from "react-router-dom";
import { useEffect } from "react";
import { Login } from "../Components/Shared/Login";
import { RootState } from "Store";
import { Login } from "@/Components/Shared/Login";
import { RootState } from "@/Store";
export function UserLogin() {
const auth = useSelector((s: RootState) => s.login.jwt);

View File

@ -1,4 +1,4 @@
import * as Const from "Const";
import * as Const from "@/Const";
/**
* Formats bytes into binary notation

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

View File

@ -1,14 +1,18 @@
{
"compilerOptions": {
"baseUrl": "src",
"target": "es2020",
"baseUrl": ".",
"target": "ESNext",
"module": "ESNext",
"jsx": "react-jsx",
"moduleResolution": "node",
"moduleResolution": "Bundler",
"sourceMap": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"allowJs": true
"paths": {
"@/*": ["./src/*"]
}
}
}

View File

@ -0,0 +1,33 @@
import react from "@vitejs/plugin-react";
import {visualizer} from "rollup-plugin-visualizer";
import {defineConfig} from "vite";
import {vitePluginVersionMark} from "vite-plugin-version-mark";
export default defineConfig({
plugins: [
react(),
visualizer({
open: true,
gzipSize: true,
filename: "build/stats.html",
}),
vitePluginVersionMark({
name: "void_cat",
ifGitSHA: true,
command: "git describe --always --tags",
ifMeta: false,
}),
],
assetsInclude: [],
build: {
outDir: "build",
},
clearScreen: false,
resolve: {
alias: {
"@": "/src",
},
},
define: {}
});

File diff suppressed because it is too large Load Diff