chore: fix prettier ignore, reformat everything

This commit is contained in:
2025-07-14 16:44:28 -05:00
parent 88658fc6f5
commit c172fe4e31
19 changed files with 2013 additions and 1244 deletions

3
.prettierignore Normal file
View File

@@ -0,0 +1,3 @@
src/bindings.ts
src-tauri/target/**
src-tauri/gen/**

View File

@@ -1,5 +1,4 @@
{ {
"ignore": ["src/bindings.ts"],
"useTabs": true, "useTabs": true,
"tabWidth": 2 "tabWidth": 2
} }

View File

@@ -1,3 +1,3 @@
{ {
"recommendations": ["tauri-apps.tauri-vscode", "rust-lang.rust-analyzer"] "recommendations": ["tauri-apps.tauri-vscode", "rust-lang.rust-analyzer"]
} }

View File

@@ -1,14 +1,14 @@
<!DOCTYPE html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> <link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>byte-me</title> <title>byte-me</title>
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>
<script type="module" src="/src/main.tsx"></script> <script type="module" src="/src/main.tsx"></script>
</body> </body>
</html> </html>

View File

@@ -1,33 +1,34 @@
{ {
"name": "byte-me", "name": "byte-me",
"private": true, "private": true,
"version": "0.1.0", "version": "0.1.0",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "tsc && vite build", "build": "tsc && vite build",
"preview": "vite preview", "preview": "vite preview",
"tauri": "tauri" "tauri": "tauri"
}, },
"dependencies": { "dependencies": {
"@nivo/core": "^0.99.0", "@nivo/core": "^0.99.0",
"@nivo/line": "^0.99.0", "@nivo/line": "^0.99.0",
"@tailwindcss/vite": "^4.1.11", "@tailwindcss/vite": "^4.1.11",
"@tauri-apps/api": "^2", "@tauri-apps/api": "^2",
"@tauri-apps/plugin-opener": "^2", "@tauri-apps/plugin-opener": "^2",
"lucide-react": "^0.525.0", "lucide-react": "^0.525.0",
"react": "^18.3.1", "react": "^18.3.1",
"react-dom": "^18.3.1", "react-dom": "^18.3.1",
"tailwindcss": "^4.1.11", "tailwindcss": "^4.1.11",
"ts-pattern": "^5.7.1" "ts-pattern": "^5.7.1"
}, },
"devDependencies": { "devDependencies": {
"@tauri-apps/cli": "^2", "@tauri-apps/cli": "^2",
"@types/react": "^18.3.1", "@types/react": "^18.3.1",
"@types/react-dom": "^18.3.1", "@types/react-dom": "^18.3.1",
"@vitejs/plugin-react": "^4.3.4", "@vitejs/plugin-react": "^4.3.4",
"typescript": "~5.6.2", "prettier": "^3.6.2",
"vite": "^6.0.3", "typescript": "~5.6.2",
"vitest": "^3.2.4" "vite": "^6.0.3",
} "vitest": "^3.2.4"
}
} }

2673
pnpm-lock.yaml generated
View File

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +1,3 @@
onlyBuiltDependencies: onlyBuiltDependencies:
- '@tailwindcss/oxide' - "@tailwindcss/oxide"
- esbuild - esbuild

View File

@@ -1,10 +1,7 @@
{ {
"$schema": "../gen/schemas/desktop-schema.json", "$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default", "identifier": "default",
"description": "Capability for the main window", "description": "Capability for the main window",
"windows": ["main"], "windows": ["main"],
"permissions": [ "permissions": ["core:default", "opener:default"]
"core:default",
"opener:default"
]
} }

View File

@@ -1,35 +1,35 @@
{ {
"$schema": "https://schema.tauri.app/config/2", "$schema": "https://schema.tauri.app/config/2",
"productName": "byte-me", "productName": "byte-me",
"version": "0.1.0", "version": "0.1.0",
"identifier": "com.xevion.byteme", "identifier": "com.xevion.byteme",
"build": { "build": {
"beforeDevCommand": "pnpm dev", "beforeDevCommand": "pnpm dev",
"devUrl": "http://localhost:1420", "devUrl": "http://localhost:1420",
"beforeBuildCommand": "pnpm build", "beforeBuildCommand": "pnpm build",
"frontendDist": "../dist" "frontendDist": "../dist"
}, },
"app": { "app": {
"windows": [ "windows": [
{ {
"title": "byte-me", "title": "byte-me",
"width": 800, "width": 800,
"height": 600 "height": 600
} }
], ],
"security": { "security": {
"csp": null "csp": null
} }
}, },
"bundle": { "bundle": {
"active": true, "active": true,
"targets": "all", "targets": "all",
"icon": [ "icon": [
"icons/32x32.png", "icons/32x32.png",
"icons/128x128.png", "icons/128x128.png",
"icons/128x128@2x.png", "icons/128x128@2x.png",
"icons/icon.icns", "icons/icon.icns",
"icons/icon.ico" "icons/icon.ico"
] ]
} }
} }

View File

@@ -1,6 +1,6 @@
type Frame = { type Frame = {
id: string; id: string;
data: { x: string | number; y: number }[]; data: { x: string | number; y: number }[];
}; };
import { getCurrentWebview } from "@tauri-apps/api/webview"; import { getCurrentWebview } from "@tauri-apps/api/webview";
@@ -9,43 +9,43 @@ import Graph from "./components/graph.js";
import DropOverlay from "./components/drop-overlay.js"; import DropOverlay from "./components/drop-overlay.js";
function App() { function App() {
const data: Frame[] = []; const data: Frame[] = [];
const [paths, setPaths] = useState<string[]>([]); const [paths, setPaths] = useState<string[]>([]);
useEffect(() => { useEffect(() => {
const unlistenPromise = getCurrentWebview().onDragDropEvent( const unlistenPromise = getCurrentWebview().onDragDropEvent(
async ({ payload }) => { async ({ payload }) => {
if (payload.type === "enter") { if (payload.type === "enter") {
setPaths(payload.paths); setPaths(payload.paths);
console.log("User hovering", payload); console.log("User hovering", payload);
} else if (payload.type === "leave" || payload.type === "drop") { } else if (payload.type === "leave" || payload.type === "drop") {
setPaths([]); setPaths([]);
console.log("User left", payload); console.log("User left", payload);
} }
} },
); );
// you need to call unlisten if your handler goes out of scope e.g. the component is unmounted // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
return () => { return () => {
unlistenPromise.then((unlisten) => { unlistenPromise.then((unlisten) => {
unlisten(); unlisten();
console.log("Unlistened"); console.log("Unlistened");
}); });
}; };
}, []); }, []);
const graph = <Graph data={data} />; const graph = <Graph data={data} />;
return ( return (
<div <div
id="App" id="App"
className="min-h-screen min-w-screen overflow-hidden" className="min-h-screen min-w-screen overflow-hidden"
style={{ "--wails-drop-target": "drop" } as React.CSSProperties} style={{ "--wails-drop-target": "drop" } as React.CSSProperties}
> >
<DropOverlay paths={paths} /> <DropOverlay paths={paths} />
{graph} {graph}
</div> </div>
); );
} }
export default App; export default App;

View File

@@ -116,7 +116,7 @@ const DropOverlay = ({ paths }: DropOverlayProps) => {
<span className="inline-block w-32 h-5 bg-neutral-300/10 rounded animate-pulse" /> <span className="inline-block w-32 h-5 bg-neutral-300/10 rounded animate-pulse" />
} }
/> />
)) )),
) )
.with({ status: "ready" }, (r) => { .with({ status: "ready" }, (r) => {
return r.files return r.files

View File

@@ -2,84 +2,84 @@ import { ResponsiveLine } from "@nivo/line";
import { formatBytes } from "../lib/format.js"; import { formatBytes } from "../lib/format.js";
type Frame = { type Frame = {
id: string; id: string;
data: { x: string | number; y: number }[]; data: { x: string | number; y: number }[];
}; };
type GraphProps = { type GraphProps = {
data: Frame[]; data: Frame[];
}; };
const Graph = ({ data }: GraphProps) => ( const Graph = ({ data }: GraphProps) => (
<ResponsiveLine <ResponsiveLine
data={data} data={data}
margin={{ top: 50, right: 110, bottom: 50, left: 60 }} margin={{ top: 50, right: 110, bottom: 50, left: 60 }}
xScale={{ type: "linear" }} xScale={{ type: "linear" }}
yScale={{ yScale={{
type: "linear", type: "linear",
min: 0, min: 0,
max: "auto", max: "auto",
stacked: false, stacked: false,
reverse: false, reverse: false,
}} }}
theme={{ theme={{
tooltip: { tooltip: {
container: { container: {
backgroundColor: "#2e2b45", backgroundColor: "#2e2b45",
}, },
}, },
grid: { grid: {
line: { line: {
stroke: "rgb(252, 191, 212)", stroke: "rgb(252, 191, 212)",
strokeWidth: 0.35, strokeWidth: 0.35,
strokeOpacity: 0.75, strokeOpacity: 0.75,
}, },
}, },
crosshair: { crosshair: {
line: { line: {
stroke: "#fdd3e2", stroke: "#fdd3e2",
strokeWidth: 1, strokeWidth: 1,
}, },
}, },
axis: { axis: {
legend: {}, legend: {},
domain: { domain: {
line: { line: {
stroke: "rgb(252, 191, 212)", stroke: "rgb(252, 191, 212)",
strokeWidth: 0.5, strokeWidth: 0.5,
strokeOpacity: 0.5, strokeOpacity: 0.5,
}, },
}, },
}, },
text: { text: {
fill: "#6e6a86", fill: "#6e6a86",
}, },
}} }}
axisBottom={{ legend: "transportation", legendOffset: 36 }} axisBottom={{ legend: "transportation", legendOffset: 36 }}
axisLeft={{ axisLeft={{
legend: "count", legend: "count",
legendOffset: -40, legendOffset: -40,
format: (v) => formatBytes(v * 1024 * 53), format: (v) => formatBytes(v * 1024 * 53),
}} }}
pointSize={10} pointSize={10}
colors={["#3e8faf", "#c4a7e7", "#f5c276", "#EA9B96", "#EB7092", "#9CCFD8"]} colors={["#3e8faf", "#c4a7e7", "#f5c276", "#EA9B96", "#EB7092", "#9CCFD8"]}
pointBorderWidth={0} pointBorderWidth={0}
pointBorderColor={{ from: "seriesColor" }} pointBorderColor={{ from: "seriesColor" }}
pointLabelYOffset={-12} pointLabelYOffset={-12}
enableSlices={"x"} enableSlices={"x"}
enableTouchCrosshair={true} enableTouchCrosshair={true}
useMesh={true} useMesh={true}
legends={[ legends={[
{ {
anchor: "bottom-right", anchor: "bottom-right",
direction: "column", direction: "column",
translateX: 100, translateX: 100,
itemWidth: 80, itemWidth: 80,
itemHeight: 22, itemHeight: 22,
symbolShape: "circle", symbolShape: "circle",
}, },
]} ]}
/> />
); );
export default Graph; export default Graph;

View File

@@ -1,22 +1,22 @@
@import "tailwindcss"; @import "tailwindcss";
:root { :root {
font-family: Inter, Avenir, Helvetica, Arial, sans-serif; font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
font-size: 16px; font-size: 16px;
line-height: 24px; line-height: 24px;
font-weight: 400; font-weight: 400;
color: #e0def4; color: #e0def4;
background-color: #232136; background-color: #232136;
font-synthesis: none; font-synthesis: none;
text-rendering: optimizeLegibility; text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
-webkit-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;
} }
#app { #app {
height: 100vh; height: 100vh;
text-align: center; text-align: center;
} }

View File

@@ -2,27 +2,27 @@ import { formatBytes } from "./format.js";
import { test, expect } from "vitest"; import { test, expect } from "vitest";
test("formats bytes less than 1024", () => { test("formats bytes less than 1024", () => {
expect(formatBytes(512)).toBe("512 B"); expect(formatBytes(512)).toBe("512 B");
}); });
test("formats KiB correctly", () => { test("formats KiB correctly", () => {
expect(formatBytes(2048)).toBe("2 KiB"); expect(formatBytes(2048)).toBe("2 KiB");
expect(formatBytes(1536)).toBe("1.5 KiB"); expect(formatBytes(1536)).toBe("1.5 KiB");
expect(formatBytes(1024)).toBe("1 KiB"); expect(formatBytes(1024)).toBe("1 KiB");
}); });
test("formats MiB correctly", () => { test("formats MiB correctly", () => {
expect(formatBytes(1048576)).toBe("1 MiB"); expect(formatBytes(1048576)).toBe("1 MiB");
expect(formatBytes(1572864)).toBe("1.5 MiB"); expect(formatBytes(1572864)).toBe("1.5 MiB");
expect(formatBytes(2097152)).toBe("2 MiB"); expect(formatBytes(2097152)).toBe("2 MiB");
}); });
test("formats GiB correctly", () => { test("formats GiB correctly", () => {
expect(formatBytes(1073741824)).toBe("1 GiB"); expect(formatBytes(1073741824)).toBe("1 GiB");
expect(formatBytes(1610612736)).toBe("1.5 GiB"); expect(formatBytes(1610612736)).toBe("1.5 GiB");
expect(formatBytes(2147483648)).toBe("2 GiB"); expect(formatBytes(2147483648)).toBe("2 GiB");
}); });
test("formats large values with no decimal if intValue >= 1000", () => { test("formats large values with no decimal if intValue >= 1000", () => {
expect(formatBytes(1024 * 1024 * 1000)).toBe("1000 MiB"); expect(formatBytes(1024 * 1024 * 1000)).toBe("1000 MiB");
}); });

View File

@@ -11,28 +11,28 @@
* @returns The formatted string with the appropriate unit. * @returns The formatted string with the appropriate unit.
*/ */
export function formatBytes(v: number): string { export function formatBytes(v: number): string {
if (v < 1024) return `${v} B`; if (v < 1024) return `${v} B`;
const units = ["KiB", "MiB", "GiB", "TiB"]; const units = ["KiB", "MiB", "GiB", "TiB"];
let unitIndex = -1; let unitIndex = -1;
let value = v; let value = v;
while (value >= 1024 && unitIndex < units.length - 1) { while (value >= 1024 && unitIndex < units.length - 1) {
value /= 1024; value /= 1024;
unitIndex++; unitIndex++;
} }
const intValue = Math.floor(value); const intValue = Math.floor(value);
const decimal = value - intValue; const decimal = value - intValue;
if (intValue >= 1000) { if (intValue >= 1000) {
// More than 3 digits, no decimal // More than 3 digits, no decimal
return `${intValue} ${units[unitIndex]}`; return `${intValue} ${units[unitIndex]}`;
} else if (decimal >= 0.1) { } else if (decimal >= 0.1) {
// Show 1 decimal if decimal >= 0.1 // Show 1 decimal if decimal >= 0.1
return `${value.toFixed(1)} ${units[unitIndex]}`; return `${value.toFixed(1)} ${units[unitIndex]}`;
} else { } else {
// No decimal // No decimal
return `${intValue} ${units[unitIndex]}`; return `${intValue} ${units[unitIndex]}`;
} }
} }

View File

@@ -4,7 +4,7 @@ import App from "./App";
import "./global.css"; import "./global.css";
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render( ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<React.StrictMode> <React.StrictMode>
<App /> <App />
</React.StrictMode> </React.StrictMode>,
); );

View File

@@ -1,25 +1,25 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "ES2020", "target": "ES2020",
"useDefineForClassFields": true, "useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"], "lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext", "module": "ESNext",
"skipLibCheck": true, "skipLibCheck": true,
/* Bundler mode */ /* Bundler mode */
"moduleResolution": "bundler", "moduleResolution": "bundler",
"allowImportingTsExtensions": true, "allowImportingTsExtensions": true,
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": true, "isolatedModules": true,
"noEmit": true, "noEmit": true,
"jsx": "react-jsx", "jsx": "react-jsx",
/* Linting */ /* Linting */
"strict": true, "strict": true,
"noUnusedLocals": true, "noUnusedLocals": true,
"noUnusedParameters": true, "noUnusedParameters": true,
"noFallthroughCasesInSwitch": true "noFallthroughCasesInSwitch": true
}, },
"include": ["src"], "include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }] "references": [{ "path": "./tsconfig.node.json" }]
} }

View File

@@ -1,10 +1,10 @@
{ {
"compilerOptions": { "compilerOptions": {
"composite": true, "composite": true,
"skipLibCheck": true, "skipLibCheck": true,
"module": "ESNext", "module": "ESNext",
"moduleResolution": "bundler", "moduleResolution": "bundler",
"allowSyntheticDefaultImports": true "allowSyntheticDefaultImports": true
}, },
"include": ["vite.config.ts"] "include": ["vite.config.ts"]
} }

View File

@@ -7,27 +7,27 @@ const host = process.env.TAURI_DEV_HOST;
// https://vite.dev/config/ // https://vite.dev/config/
export default defineConfig(async () => ({ export default defineConfig(async () => ({
plugins: [react(), tailwindcss()], plugins: [react(), tailwindcss()],
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build` // Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
// //
// 1. prevent Vite from obscuring rust errors // 1. prevent Vite from obscuring rust errors
clearScreen: false, clearScreen: false,
// 2. tauri expects a fixed port, fail if that port is not available // 2. tauri expects a fixed port, fail if that port is not available
server: { server: {
port: 1420, port: 1420,
strictPort: true, strictPort: true,
host: host || false, host: host || false,
hmr: host hmr: host
? { ? {
protocol: "ws", protocol: "ws",
host, host,
port: 1421, port: 1421,
} }
: undefined, : undefined,
watch: { watch: {
// 3. tell Vite to ignore watching `src-tauri` // 3. tell Vite to ignore watching `src-tauri`
ignored: ["**/src-tauri/**"], ignored: ["**/src-tauri/**"],
}, },
}, },
})); }));