@alt-t4b/pm-web 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/index-Bonqd4_2.js +49 -0
- package/dist/index.html +28 -0
- package/package.json +27 -0
- package/src/App.tsx +829 -0
- package/src/api.ts +1 -0
- package/src/components/Badge.tsx +54 -0
- package/src/components/Button.tsx +58 -0
- package/src/components/Card.tsx +40 -0
- package/src/components/Icon.tsx +22 -0
- package/src/components/IconButton.tsx +50 -0
- package/src/components/Input.tsx +47 -0
- package/src/components/Select.tsx +41 -0
- package/src/components/Stack.tsx +38 -0
- package/src/components/ThemeContext.tsx +53 -0
- package/src/components/ThemeSwitcher.tsx +49 -0
- package/src/components/TopBar.tsx +38 -0
- package/src/components/index.ts +12 -0
- package/src/components/theme.ts +185 -0
- package/src/main.tsx +12 -0
- package/src/serve.ts +71 -0
package/src/main.tsx
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StrictMode } from "react";
|
|
2
|
+
import { createRoot } from "react-dom/client";
|
|
3
|
+
import { App } from "./App";
|
|
4
|
+
import { ThemeProvider } from "./components";
|
|
5
|
+
|
|
6
|
+
createRoot(document.getElementById("root")!).render(
|
|
7
|
+
<StrictMode>
|
|
8
|
+
<ThemeProvider>
|
|
9
|
+
<App />
|
|
10
|
+
</ThemeProvider>
|
|
11
|
+
</StrictMode>,
|
|
12
|
+
);
|
package/src/serve.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { Hono } from "hono";
|
|
3
|
+
import { serveStatic } from "hono/bun";
|
|
4
|
+
import { compress } from "hono/compress";
|
|
5
|
+
import { secureHeaders } from "hono/secure-headers";
|
|
6
|
+
import { etag } from "hono/etag";
|
|
7
|
+
import { join } from "path";
|
|
8
|
+
import { readFileSync, existsSync } from "fs";
|
|
9
|
+
|
|
10
|
+
const port = Number(process.env.PM_WEB_PORT) || 3002;
|
|
11
|
+
const host = process.env.PM_HOST ?? "127.0.0.1";
|
|
12
|
+
const apiPort = Number(process.env.PM_PORT) || 3000;
|
|
13
|
+
const apiOrigin = `http://${host === "0.0.0.0" ? "127.0.0.1" : host}:${apiPort}`;
|
|
14
|
+
const dist = join(import.meta.dir, "../dist");
|
|
15
|
+
|
|
16
|
+
const indexPath = join(dist, "index.html");
|
|
17
|
+
const indexHtml = existsSync(indexPath)
|
|
18
|
+
? readFileSync(indexPath, "utf-8")
|
|
19
|
+
: null;
|
|
20
|
+
|
|
21
|
+
const app = new Hono();
|
|
22
|
+
|
|
23
|
+
app.use("*", secureHeaders());
|
|
24
|
+
app.use("*", compress());
|
|
25
|
+
|
|
26
|
+
// Hashed assets get long-lived cache
|
|
27
|
+
app.use(
|
|
28
|
+
"/assets/*",
|
|
29
|
+
etag(),
|
|
30
|
+
async (c, next) => {
|
|
31
|
+
await next();
|
|
32
|
+
c.header("Cache-Control", "public, max-age=31536000, immutable");
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
// Non-hashed files get short cache with revalidation
|
|
37
|
+
app.use("/*", etag());
|
|
38
|
+
|
|
39
|
+
app.use("/*", serveStatic({ root: dist }));
|
|
40
|
+
|
|
41
|
+
// Proxy /api requests to the API server
|
|
42
|
+
app.all("/api/*", async (c) => {
|
|
43
|
+
const url = new URL(c.req.url);
|
|
44
|
+
const target = `${apiOrigin}${url.pathname}${url.search}`;
|
|
45
|
+
const res = await fetch(target, {
|
|
46
|
+
method: c.req.method,
|
|
47
|
+
headers: c.req.raw.headers,
|
|
48
|
+
body: c.req.raw.body,
|
|
49
|
+
});
|
|
50
|
+
return new Response(res.body, {
|
|
51
|
+
status: res.status,
|
|
52
|
+
headers: res.headers,
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// SPA fallback
|
|
57
|
+
app.get("/*", (c) => {
|
|
58
|
+
if (indexHtml) {
|
|
59
|
+
return c.html(indexHtml);
|
|
60
|
+
}
|
|
61
|
+
return c.text("Not found — run `bun run build` first", 404);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const displayHost = host === "0.0.0.0" ? "localhost" : host;
|
|
65
|
+
console.error(`tab-pm web listening on http://${displayHost}:${port}`);
|
|
66
|
+
|
|
67
|
+
export default {
|
|
68
|
+
port,
|
|
69
|
+
hostname: host,
|
|
70
|
+
fetch: app.fetch,
|
|
71
|
+
};
|