feat: add tui app

This commit is contained in:
Max Koon
2025-11-14 13:26:15 -05:00
parent 058f2bb94f
commit 5b14b4e7a4
22 changed files with 2395 additions and 128 deletions

34
apps/tui/.gitignore vendored Normal file
View File

@@ -0,0 +1,34 @@
# dependencies (bun install)
node_modules
# output
out
dist
*.tgz
# code coverage
coverage
*.lcov
# logs
logs
*.log
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# caches
.eslintcache
.cache
*.tsbuildinfo
# IntelliJ based IDEs
.idea
# Finder (MacOS) folder config
.DS_Store

15
apps/tui/README.md Normal file
View File

@@ -0,0 +1,15 @@
# react
To install dependencies:
```bash
bun install
```
To run:
```bash
bun run src/index.tsx
```
This project was created using `bun create tui`. [create-tui](https://git.new/create-tui) is the easiest way to get started with OpenTUI.

41
apps/tui/build.ts Normal file
View File

@@ -0,0 +1,41 @@
import esbuild from "esbuild";
import path from "path";
// Custom plugin to alias "react-native" to react-native-opentui
const aliasPlugin = {
name: "alias-react-native",
setup(build) {
build.onResolve({ filter: /^react-native$/ }, args => {
return {
path: path.resolve(__dirname, "../../packages/react-native-opentui/index.tsx"),
};
});
},
};
// Build configuration
await esbuild.build({
entryPoints: ["src/index.tsx"], // your app entry
bundle: true, // inline all dependencies (ui included)
platform: "node", // Node/Bun target
format: "esm", // keep ESM for top-level await
outfile: "dist/index.js",
sourcemap: true,
plugins: [aliasPlugin],
loader: {
".ts": "ts",
".tsx": "tsx",
},
external: [
// leave OpenTUI and Bun built-ins for Bun runtime
"react",
"@opentui/core",
"@opentui/react",
"@opentui/react/jsx-runtime",
"bun:ffi",
// "./assets/**/*.scm",
// "./assets/**/*.wasm",
],
});
console.log("✅ App bundled successfully");

22
apps/tui/package.json Normal file
View File

@@ -0,0 +1,22 @@
{
"name": "@money/tui",
"version": "0.0.1",
"scripts": {
"build": "bun run build.js",
"start": "bun run dist/index.js"
},
"peerDependencies": {
"react": "*"
},
"dependencies": {
"@money/ui": "workspace:*",
"@money/shared": "workspace:*",
"@opentui/core": "^0.1.39",
"@opentui/react": "^0.1.39",
"react-native": "^0.82.1",
"react-native-opentui": "workspace:*"
},
"devDependencies": {
"esbuild": "^0.27.0"
}
}

20
apps/tui/src/index.tsx Normal file
View File

@@ -0,0 +1,20 @@
import { RGBA, TextAttributes, createCliRenderer } from "@opentui/core";
import { createRoot } from "@opentui/react";
import { Settings } from "@money/ui";
import { ZeroProvider } from "@rocicorp/zero/react";
import { schema } from '@money/shared';
const userID = "anon";
const server = "http://laptop:4848";
const auth = undefined;
function Main() {
return (
<ZeroProvider {...{ userID, auth, server, schema }}>
<Settings />
</ZeroProvider>
);
}
const renderer = await createCliRenderer();
createRoot(renderer).render(<Main />);

33
apps/tui/tsconfig.json Normal file
View File

@@ -0,0 +1,33 @@
{
"compilerOptions": {
"paths": {
"react-native": ["../react-native-opentui"]
},
// Environment setup & latest features
"lib": ["ESNext"],
"target": "ESNext",
"module": "Preserve",
"moduleDetection": "force",
"jsx": "react-jsx",
"jsxImportSource": "@opentui/react",
"allowJs": true,
// Bundler mode
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"noEmit": true,
// Best practices
"strict": true,
"skipLibCheck": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
// Some stricter flags (disabled by default)
"noUnusedLocals": false,
"noUnusedParameters": false,
"noPropertyAccessFromIndexSignature": false
}
}