[READ-ONLY] Mirror of https://github.com/bombshell-dev/tty. Platform independent 2D layout engine for terminal applications based on Clay
5

Configure Feed

Select the types of activity you want to include in your feed.

♻️ inline WASM binary into generated TypeScript module

Replace runtime filesystem read of clayterm.wasm with a build step
that base64-encodes the binary into wasm.ts. This removes the
node:fs/promises dependency and --allow-read requirement for the
WASM file.

Charles Lowell (Apr 10, 2026, 4:04 PM -0500) f9338e0d d402924f

+30 -14
+1
.gitignore
··· 1 1 /.agent-shell/ 2 2 /clayterm.wasm 3 + /wasm.ts 3 4 /build/ 4 5 /node_modules/
+5 -2
Makefile
··· 13 13 -Wl,--undefined=Clay__MeasureText \ 14 14 -Wl,--undefined=Clay__QueryScrollOffset 15 15 16 - all: $(TARGET) 16 + all: $(TARGET) wasm.ts 17 17 @echo "Built $(TARGET) ($$(wc -c < $(TARGET)) bytes)" 18 18 19 19 DEPS = $(wildcard src/*.c src/*.h) ··· 21 21 $(TARGET): $(DEPS) 22 22 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(SRC) 23 23 24 + wasm.ts: $(TARGET) 25 + deno run --allow-read --allow-write tasks/bundle-wasm.ts 26 + 24 27 clean: 25 - rm -f $(TARGET) 28 + rm -f $(TARGET) wasm.ts 26 29 27 30 .PHONY: all clean
+6 -4
deno.json
··· 2 2 "name": "@clayterm/clayterm", 3 3 "license": "MIT", 4 4 "tasks": { 5 - "test": "deno test --allow-read", 5 + "test": "deno test", 6 6 "fmt": "deno fmt && clang-format -i src/*.c src/*.h", 7 7 "fmt:check": "deno fmt --check && clang-format --dry-run --Werror src/*.c src/*.h", 8 8 "build:npm": "deno run -A tasks/build-npm.ts", 9 9 "build:jsr": "deno run -A tasks/build-jsr.ts", 10 - "demo": "deno run -A demo/keyboard.ts" 10 + "demo": "deno run demo/keyboard.ts" 11 11 }, 12 12 "imports": { 13 13 "@std/testing": "jsr:@std/testing@1", 14 14 "@std/expect": "jsr:@std/expect@1", 15 15 "@sinclair/typebox": "npm:@sinclair/typebox@^0.34", 16 16 "dnt": "jsr:@deno/dnt@0.42.3", 17 - "effection": "npm:effection@^4.0.2" 17 + "effection": "npm:effection@^4.0.2", 18 + "@std/encoding": "jsr:@std/encoding@1" 18 19 }, 19 20 "exports": { 20 21 ".": "./mod.ts", 21 22 "./validate": "./validate.ts" 22 23 }, 23 24 "publish": { 24 - "include": ["*.ts", "clayterm.wasm"] 25 + "include": ["*.ts"], 26 + "exclude": ["!wasm.ts"] 25 27 }, 26 28 "fmt": { 27 29 "exclude": ["clay", "build"]
+5
deno.lock
··· 8 8 "jsr:@std/assert@^1.0.17": "1.0.18", 9 9 "jsr:@std/async@^1.1.0": "1.1.1", 10 10 "jsr:@std/data-structures@^1.0.10": "1.0.10", 11 + "jsr:@std/encoding@1": "1.0.10", 11 12 "jsr:@std/expect@1": "1.0.17", 12 13 "jsr:@std/fmt@1": "1.0.8", 13 14 "jsr:@std/fs@1": "1.0.22", ··· 52 53 }, 53 54 "@std/data-structures@1.0.10": { 54 55 "integrity": "f574f86b0e07c69b9edc555fcc814b57d29258bad39fd5a34ba8a80ecf033cfe" 56 + }, 57 + "@std/encoding@1.0.10": { 58 + "integrity": "8783c6384a2d13abd5e9e87a7ae0520a30e9f56aeeaa3bdf910a3eaaf5c811a1" 55 59 }, 56 60 "@std/expect@1.0.17": { 57 61 "integrity": "316b47dd65c33e3151344eb3267bf42efba17d1415425f07ed96185d67fc04d9", ··· 118 122 "workspace": { 119 123 "dependencies": [ 120 124 "jsr:@deno/dnt@0.42.3", 125 + "jsr:@std/encoding@1", 121 126 "jsr:@std/expect@1", 122 127 "jsr:@std/testing@1", 123 128 "npm:@sinclair/typebox@0.34",
-1
tasks/build-npm.ts
··· 44 44 }); 45 45 46 46 await Deno.copyFile("README.md", `${outDir}/README.md`); 47 - await Deno.copyFile("clayterm.wasm", `${outDir}/esm/clayterm.wasm`);
+13
tasks/bundle-wasm.ts
··· 1 + import { encodeBase64 } from "@std/encoding/base64"; 2 + 3 + const wasm = await Deno.readFile("clayterm.wasm"); 4 + const base64 = encodeBase64(wasm); 5 + 6 + const source = `const bin = atob("${base64}"); 7 + const bytes = new Uint8Array(bin.length); 8 + for (let i = 0; i < bin.length; i++) bytes[i] = bin.charCodeAt(i); 9 + export const compiled = await WebAssembly.compile(bytes); 10 + `; 11 + 12 + await Deno.writeTextFile("wasm.ts", source); 13 + console.log(`wrote wasm.ts (${wasm.length} bytes encoded)`);
-7
wasm.ts
··· 1 - import { readFile } from "node:fs/promises"; 2 - 3 - const wasm = new Uint8Array( 4 - await readFile(new URL("./clayterm.wasm", import.meta.url)), 5 - ); 6 - 7 - export const compiled = await WebAssembly.compile(wasm);