@pumped-fn/lite-devtools-server 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License Copyright (c) 2025 Duke
2
+
3
+ Permission is hereby granted, free of
4
+ charge, to any person obtaining a copy of this software and associated
5
+ documentation files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use, copy, modify, merge,
7
+ publish, distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to the
9
+ following conditions:
10
+
11
+ The above copyright notice and this permission notice
12
+ (including the next paragraph) shall be included in all copies or substantial
13
+ portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
16
+ ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
18
+ EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # @pumped-fn/lite-devtools-server
2
+
3
+ Standalone TUI server for receiving devtools events from `@pumped-fn/lite-devtools` via HTTP.
4
+
5
+ ## Architecture
6
+
7
+ ```mermaid
8
+ graph LR
9
+ subgraph "Application Process"
10
+ App[Your App]
11
+ DT["@pumped-fn/lite-devtools"]
12
+ HTTP["httpTransport()"]
13
+ end
14
+
15
+ subgraph "Server Process"
16
+ Server["@pumped-fn/lite-devtools-server"]
17
+ TUI[Terminal Dashboard]
18
+ end
19
+
20
+ App -->|events| DT
21
+ DT -->|fire-and-forget| HTTP
22
+ HTTP -->|POST /events| Server
23
+ Server -->|renders| TUI
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ ### Start the server
29
+
30
+ ```bash
31
+ npx @pumped-fn/lite-devtools-server
32
+ # Or with custom port
33
+ PORT=4000 npx @pumped-fn/lite-devtools-server
34
+ ```
35
+
36
+ ### Configure your app
37
+
38
+ ```typescript
39
+ import { createScope } from '@pumped-fn/lite'
40
+ import { createDevtools, httpTransport } from '@pumped-fn/lite-devtools'
41
+
42
+ const scope = createScope({
43
+ extensions: [
44
+ createDevtools({
45
+ transports: [httpTransport({ url: 'http://localhost:3001/events' })]
46
+ })
47
+ ]
48
+ })
49
+ ```
50
+
51
+ ## API
52
+
53
+ ### HTTP Endpoints
54
+
55
+ | Endpoint | Method | Description |
56
+ |----------|--------|-------------|
57
+ | `/events` | POST | Receive events from httpTransport |
58
+ | `/events` | GET | Retrieve buffered events (last 100) |
59
+ | `/health` | GET | Health check |
60
+
61
+ ## How It Works
62
+
63
+ 1. Server starts Hono HTTP server on specified port (default: 3001)
64
+ 2. Events POSTed to `/events` are buffered (max 100 events)
65
+ 3. TUI dashboard displays last 20 events in real-time
66
+ 4. Uses `@pumped-fn/lite` atoms for reactive state management
package/dist/bin.cjs ADDED
@@ -0,0 +1,26 @@
1
+ const require_ui = require('./ui-Dj5OAu7J.cjs');
2
+ let __opentui_core = require("@opentui/core");
3
+ let __opentui_react_jsx_runtime = require("@opentui/react/jsx-runtime");
4
+ let __hono_node_server = require("@hono/node-server");
5
+ let __opentui_react = require("@opentui/react");
6
+
7
+ //#region src/bin.tsx
8
+ const PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3001;
9
+ async function main() {
10
+ await require_ui.scope.ready;
11
+ await require_ui.scope.resolve(require_ui.eventsAtom);
12
+ (0, __hono_node_server.serve)({
13
+ fetch: require_ui.createApp(require_ui.scope.controller(require_ui.eventsAtom)).fetch,
14
+ port: PORT
15
+ }, (info) => {
16
+ console.log(`HTTP server listening on http://localhost:${info.port}`);
17
+ });
18
+ try {
19
+ (0, __opentui_react.createRoot)(await (0, __opentui_core.createCliRenderer)()).render(/* @__PURE__ */ (0, __opentui_react_jsx_runtime.jsx)(require_ui.App, { port: PORT }));
20
+ } catch {
21
+ console.log("TUI unavailable, running headless");
22
+ }
23
+ }
24
+ main().catch(console.error);
25
+
26
+ //#endregion
package/dist/bin.d.cts ADDED
@@ -0,0 +1 @@
1
+ export { };
package/dist/bin.d.mts ADDED
@@ -0,0 +1 @@
1
+ export { };
package/dist/bin.mjs ADDED
@@ -0,0 +1,27 @@
1
+ import { i as createApp, n as eventsAtom, r as scope, t as App } from "./ui-CVLj3SJk.mjs";
2
+ import { createCliRenderer } from "@opentui/core";
3
+ import { jsx } from "@opentui/react/jsx-runtime";
4
+ import { serve } from "@hono/node-server";
5
+ import { createRoot } from "@opentui/react";
6
+
7
+ //#region src/bin.tsx
8
+ const PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3001;
9
+ async function main() {
10
+ await scope.ready;
11
+ await scope.resolve(eventsAtom);
12
+ serve({
13
+ fetch: createApp(scope.controller(eventsAtom)).fetch,
14
+ port: PORT
15
+ }, (info) => {
16
+ console.log(`HTTP server listening on http://localhost:${info.port}`);
17
+ });
18
+ try {
19
+ createRoot(await createCliRenderer()).render(/* @__PURE__ */ jsx(App, { port: PORT }));
20
+ } catch {
21
+ console.log("TUI unavailable, running headless");
22
+ }
23
+ }
24
+ main().catch(console.error);
25
+
26
+ //#endregion
27
+ export { };
package/dist/index.cjs ADDED
@@ -0,0 +1,6 @@
1
+ const require_ui = require('./ui-Dj5OAu7J.cjs');
2
+
3
+ exports.App = require_ui.App;
4
+ exports.createApp = require_ui.createApp;
5
+ exports.eventsAtom = require_ui.eventsAtom;
6
+ exports.scope = require_ui.scope;
@@ -0,0 +1,22 @@
1
+ import * as hono_types0 from "hono/types";
2
+ import { Hono } from "hono";
3
+ import { Devtools } from "@pumped-fn/lite-devtools";
4
+ import * as _pumped_fn_lite0 from "@pumped-fn/lite";
5
+ import { Lite } from "@pumped-fn/lite";
6
+ import { ReactNode } from "react";
7
+
8
+ //#region src/server.d.ts
9
+ declare function createApp(ctrl: Lite.Controller<Devtools.Event[]>): Hono<hono_types0.BlankEnv, hono_types0.BlankSchema, "/">;
10
+ //#endregion
11
+ //#region src/state.d.ts
12
+ declare const eventsAtom: _pumped_fn_lite0.Lite.Atom<Devtools.Event[]>;
13
+ declare const scope: _pumped_fn_lite0.Lite.Scope;
14
+ //#endregion
15
+ //#region src/ui.d.ts
16
+ declare function App({
17
+ port
18
+ }: {
19
+ port: number;
20
+ }): ReactNode;
21
+ //#endregion
22
+ export { App, createApp, eventsAtom, scope };
@@ -0,0 +1,22 @@
1
+ import { Hono } from "hono";
2
+ import * as _pumped_fn_lite0 from "@pumped-fn/lite";
3
+ import { Lite } from "@pumped-fn/lite";
4
+ import * as hono_types0 from "hono/types";
5
+ import { Devtools } from "@pumped-fn/lite-devtools";
6
+ import { ReactNode } from "react";
7
+
8
+ //#region src/server.d.ts
9
+ declare function createApp(ctrl: Lite.Controller<Devtools.Event[]>): Hono<hono_types0.BlankEnv, hono_types0.BlankSchema, "/">;
10
+ //#endregion
11
+ //#region src/state.d.ts
12
+ declare const eventsAtom: _pumped_fn_lite0.Lite.Atom<Devtools.Event[]>;
13
+ declare const scope: _pumped_fn_lite0.Lite.Scope;
14
+ //#endregion
15
+ //#region src/ui.d.ts
16
+ declare function App({
17
+ port
18
+ }: {
19
+ port: number;
20
+ }): ReactNode;
21
+ //#endregion
22
+ export { App, createApp, eventsAtom, scope };
package/dist/index.mjs ADDED
@@ -0,0 +1,3 @@
1
+ import { i as createApp, n as eventsAtom, r as scope, t as App } from "./ui-CVLj3SJk.mjs";
2
+
3
+ export { App, createApp, eventsAtom, scope };
@@ -0,0 +1,108 @@
1
+ import { Hono } from "hono";
2
+ import { cors } from "hono/cors";
3
+ import { atom, createScope } from "@pumped-fn/lite";
4
+ import { ScopeProvider, useAtom } from "@pumped-fn/lite-react";
5
+ import { TextAttributes } from "@opentui/core";
6
+ import { jsx, jsxs } from "@opentui/react/jsx-runtime";
7
+
8
+ //#region src/server.ts
9
+ const MAX_EVENTS = 100;
10
+ function createApp(ctrl) {
11
+ const app = new Hono();
12
+ app.use("*", cors());
13
+ app.post("/events", async (c) => {
14
+ try {
15
+ const newEvents = await c.req.json();
16
+ ctrl.update((prev) => {
17
+ const next = prev.concat(newEvents);
18
+ return next.length > MAX_EVENTS ? next.slice(-MAX_EVENTS) : next;
19
+ });
20
+ return c.json({ ok: true });
21
+ } catch {
22
+ return c.json({ ok: false }, 400);
23
+ }
24
+ });
25
+ app.get("/health", (c) => c.json({ status: "ok" }));
26
+ app.get("/events", (c) => c.json(ctrl.get()));
27
+ return app;
28
+ }
29
+
30
+ //#endregion
31
+ //#region src/state.ts
32
+ const eventsAtom = atom({ factory: () => [] });
33
+ const scope = createScope();
34
+
35
+ //#endregion
36
+ //#region src/ui.tsx
37
+ function ReactTypeBridge({ children }) {
38
+ return /* @__PURE__ */ jsx(ScopeProvider, {
39
+ scope,
40
+ children
41
+ });
42
+ }
43
+ const ICONS = {
44
+ "atom:resolve": "⚡",
45
+ "atom:resolved": "✓",
46
+ "flow:exec": "▶",
47
+ "flow:complete": "✓",
48
+ error: "✗"
49
+ };
50
+ function formatEvent(event) {
51
+ const time = new Date(event.timestamp).toISOString().slice(11, 23);
52
+ const duration = event.duration ? ` (${event.duration.toFixed(1)}ms)` : "";
53
+ return `[${time}] ${ICONS[event.type]} ${event.type.padEnd(14)} ${event.name}${duration}`;
54
+ }
55
+ function EventList() {
56
+ const events = useAtom(eventsAtom);
57
+ if (events.length === 0) return /* @__PURE__ */ jsx("text", {
58
+ fg: "gray",
59
+ children: "Waiting for events..."
60
+ });
61
+ return /* @__PURE__ */ jsx("box", {
62
+ flexDirection: "column",
63
+ children: events.slice(-20).map((e) => /* @__PURE__ */ jsx("text", {
64
+ fg: e.type === "error" ? "red" : "white",
65
+ children: formatEvent(e)
66
+ }, e.id))
67
+ });
68
+ }
69
+ function StatusBar({ port }) {
70
+ return /* @__PURE__ */ jsxs("text", {
71
+ fg: "cyan",
72
+ children: [
73
+ "Port: ",
74
+ port,
75
+ " | Events: ",
76
+ useAtom(eventsAtom).length
77
+ ]
78
+ });
79
+ }
80
+ function Content({ port }) {
81
+ return /* @__PURE__ */ jsxs("box", {
82
+ flexDirection: "column",
83
+ padding: 1,
84
+ children: [
85
+ /* @__PURE__ */ jsx("text", {
86
+ attributes: TextAttributes.BOLD,
87
+ fg: "green",
88
+ children: "Lite Devtools Server"
89
+ }),
90
+ /* @__PURE__ */ jsx("box", {
91
+ marginTop: 1,
92
+ flexDirection: "column",
93
+ flexGrow: 1,
94
+ children: /* @__PURE__ */ jsx(EventList, {})
95
+ }),
96
+ /* @__PURE__ */ jsx("box", {
97
+ marginTop: 1,
98
+ children: /* @__PURE__ */ jsx(StatusBar, { port })
99
+ })
100
+ ]
101
+ });
102
+ }
103
+ function App({ port }) {
104
+ return /* @__PURE__ */ jsx(ReactTypeBridge, { children: /* @__PURE__ */ jsx(Content, { port }) });
105
+ }
106
+
107
+ //#endregion
108
+ export { createApp as i, eventsAtom as n, scope as r, App as t };
@@ -0,0 +1,131 @@
1
+ let hono = require("hono");
2
+ let hono_cors = require("hono/cors");
3
+ let __pumped_fn_lite = require("@pumped-fn/lite");
4
+ let __pumped_fn_lite_react = require("@pumped-fn/lite-react");
5
+ let __opentui_core = require("@opentui/core");
6
+ let __opentui_react_jsx_runtime = require("@opentui/react/jsx-runtime");
7
+
8
+ //#region src/server.ts
9
+ const MAX_EVENTS = 100;
10
+ function createApp(ctrl) {
11
+ const app = new hono.Hono();
12
+ app.use("*", (0, hono_cors.cors)());
13
+ app.post("/events", async (c) => {
14
+ try {
15
+ const newEvents = await c.req.json();
16
+ ctrl.update((prev) => {
17
+ const next = prev.concat(newEvents);
18
+ return next.length > MAX_EVENTS ? next.slice(-MAX_EVENTS) : next;
19
+ });
20
+ return c.json({ ok: true });
21
+ } catch {
22
+ return c.json({ ok: false }, 400);
23
+ }
24
+ });
25
+ app.get("/health", (c) => c.json({ status: "ok" }));
26
+ app.get("/events", (c) => c.json(ctrl.get()));
27
+ return app;
28
+ }
29
+
30
+ //#endregion
31
+ //#region src/state.ts
32
+ const eventsAtom = (0, __pumped_fn_lite.atom)({ factory: () => [] });
33
+ const scope = (0, __pumped_fn_lite.createScope)();
34
+
35
+ //#endregion
36
+ //#region src/ui.tsx
37
+ function ReactTypeBridge({ children }) {
38
+ return /* @__PURE__ */ (0, __opentui_react_jsx_runtime.jsx)(__pumped_fn_lite_react.ScopeProvider, {
39
+ scope,
40
+ children
41
+ });
42
+ }
43
+ const ICONS = {
44
+ "atom:resolve": "⚡",
45
+ "atom:resolved": "✓",
46
+ "flow:exec": "▶",
47
+ "flow:complete": "✓",
48
+ error: "✗"
49
+ };
50
+ function formatEvent(event) {
51
+ const time = new Date(event.timestamp).toISOString().slice(11, 23);
52
+ const duration = event.duration ? ` (${event.duration.toFixed(1)}ms)` : "";
53
+ return `[${time}] ${ICONS[event.type]} ${event.type.padEnd(14)} ${event.name}${duration}`;
54
+ }
55
+ function EventList() {
56
+ const events = (0, __pumped_fn_lite_react.useAtom)(eventsAtom);
57
+ if (events.length === 0) return /* @__PURE__ */ (0, __opentui_react_jsx_runtime.jsx)("text", {
58
+ fg: "gray",
59
+ children: "Waiting for events..."
60
+ });
61
+ return /* @__PURE__ */ (0, __opentui_react_jsx_runtime.jsx)("box", {
62
+ flexDirection: "column",
63
+ children: events.slice(-20).map((e) => /* @__PURE__ */ (0, __opentui_react_jsx_runtime.jsx)("text", {
64
+ fg: e.type === "error" ? "red" : "white",
65
+ children: formatEvent(e)
66
+ }, e.id))
67
+ });
68
+ }
69
+ function StatusBar({ port }) {
70
+ return /* @__PURE__ */ (0, __opentui_react_jsx_runtime.jsxs)("text", {
71
+ fg: "cyan",
72
+ children: [
73
+ "Port: ",
74
+ port,
75
+ " | Events: ",
76
+ (0, __pumped_fn_lite_react.useAtom)(eventsAtom).length
77
+ ]
78
+ });
79
+ }
80
+ function Content({ port }) {
81
+ return /* @__PURE__ */ (0, __opentui_react_jsx_runtime.jsxs)("box", {
82
+ flexDirection: "column",
83
+ padding: 1,
84
+ children: [
85
+ /* @__PURE__ */ (0, __opentui_react_jsx_runtime.jsx)("text", {
86
+ attributes: __opentui_core.TextAttributes.BOLD,
87
+ fg: "green",
88
+ children: "Lite Devtools Server"
89
+ }),
90
+ /* @__PURE__ */ (0, __opentui_react_jsx_runtime.jsx)("box", {
91
+ marginTop: 1,
92
+ flexDirection: "column",
93
+ flexGrow: 1,
94
+ children: /* @__PURE__ */ (0, __opentui_react_jsx_runtime.jsx)(EventList, {})
95
+ }),
96
+ /* @__PURE__ */ (0, __opentui_react_jsx_runtime.jsx)("box", {
97
+ marginTop: 1,
98
+ children: /* @__PURE__ */ (0, __opentui_react_jsx_runtime.jsx)(StatusBar, { port })
99
+ })
100
+ ]
101
+ });
102
+ }
103
+ function App({ port }) {
104
+ return /* @__PURE__ */ (0, __opentui_react_jsx_runtime.jsx)(ReactTypeBridge, { children: /* @__PURE__ */ (0, __opentui_react_jsx_runtime.jsx)(Content, { port }) });
105
+ }
106
+
107
+ //#endregion
108
+ Object.defineProperty(exports, 'App', {
109
+ enumerable: true,
110
+ get: function () {
111
+ return App;
112
+ }
113
+ });
114
+ Object.defineProperty(exports, 'createApp', {
115
+ enumerable: true,
116
+ get: function () {
117
+ return createApp;
118
+ }
119
+ });
120
+ Object.defineProperty(exports, 'eventsAtom', {
121
+ enumerable: true,
122
+ get: function () {
123
+ return eventsAtom;
124
+ }
125
+ });
126
+ Object.defineProperty(exports, 'scope', {
127
+ enumerable: true,
128
+ get: function () {
129
+ return scope;
130
+ }
131
+ });
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@pumped-fn/lite-devtools-server",
3
+ "version": "0.1.0",
4
+ "description": "Standalone TUI devtools server for @pumped-fn/lite",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.mjs",
8
+ "types": "./dist/index.d.cts",
9
+ "bin": {
10
+ "lite-devtools-server": "./dist/bin.mjs"
11
+ },
12
+ "exports": {
13
+ ".": {
14
+ "import": {
15
+ "types": "./dist/index.d.mts",
16
+ "default": "./dist/index.mjs"
17
+ },
18
+ "require": {
19
+ "types": "./dist/index.d.cts",
20
+ "default": "./dist/index.cjs"
21
+ }
22
+ }
23
+ },
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "dependencies": {
28
+ "@hono/node-server": "^1.13.8",
29
+ "@opentui/core": "^0.1.59",
30
+ "@opentui/react": "^0.1.59",
31
+ "hono": "^4.7.0",
32
+ "react": "^19.0.0",
33
+ "@pumped-fn/lite": "1.7.0",
34
+ "@pumped-fn/lite-react": "1.0.0"
35
+ },
36
+ "devDependencies": {
37
+ "@types/node": "^20.19.22",
38
+ "@types/react": "^19.0.0",
39
+ "tsdown": "^0.17.2",
40
+ "tsx": "^4.19.4",
41
+ "typescript": "^5.9.3",
42
+ "vitest": "^4.0.15",
43
+ "@pumped-fn/lite-devtools": "1.1.0"
44
+ },
45
+ "license": "MIT",
46
+ "scripts": {
47
+ "build": "tsdown",
48
+ "typecheck": "tsc --noEmit",
49
+ "test": "vitest run",
50
+ "dev": "tsx src/bin.tsx",
51
+ "demo": "tsx examples/demo.ts"
52
+ }
53
+ }