This commit is contained in:
2026-01-27 10:23:07 -05:00
parent a275364cd1
commit 60fb12e52c
10 changed files with 302 additions and 238 deletions

89
README.md Normal file
View File

@@ -0,0 +1,89 @@
# Poiesis
A Go tool that transpiles TypeScript to JavaScript using esbuild and executes it with goja, with an extensible builtin system.
## Project Structure
```
reichard.io/poiesis/
├── cmd/
│ └── poiesis/ # CLI application entry point
│ └── main.go
├── internal/
│ ├── builtin/ # Builtin function framework
│ │ ├── builtin.go
│ │ └── builtin_test.go
│ └── runtime/ # TypeScript transpilation and execution
│ ├── runtime.go
│ └── runtime_test.go
└── examples/ # Example TypeScript files
```
## Installation & Build
```bash
go build ./cmd/poiesis
```
## Testing
```bash
go test ./...
golangci-lint run
```
## Usage
```bash
poiesis <typescript-file>
```
## Builtin System
The builtin system allows you to easily expose Go functions to TypeScript/JavaScript.
### Adding a Builtin
Just write a Go function and register it:
```go
// Your function
func add(a, b int) int {
return a + b
}
// Register it
func init() {
builtin.RegisterBuiltin("add", add)
}
```
That's it! The framework automatically:
- Converts TypeScript values to Go types
- Handles errors (panics as JS errors)
- Generates TypeScript definitions
- Manages the goja integration
### Example
```typescript
// TypeScript code
console.log("5 + 10 =", add(5, 10));
const response = fetch("https://httpbin.org/get");
console.log("OK:", response.ok);
console.log("Status:", response.status);
console.log("Body:", response.text());
```
### Built-in Functions
- `fetch(url, options?)` - HTTP requests
- `add(a, b)` - Simple arithmetic example
- `greet(name)` - String manipulation example
## Dependencies
- `github.com/evanw/esbuild/pkg/api` - TypeScript transpilation
- `github.com/dop251/goja` - JavaScript execution
- `github.com/stretchr/testify/assert` - Test assertions