Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/.agent-shell/
/clayterm.wasm
/wasm.ts
/build/
/node_modules/
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@ LDFLAGS = -Wl,--no-entry \
-Wl,--undefined=Clay__MeasureText \
-Wl,--undefined=Clay__QueryScrollOffset

all: $(TARGET)
all: $(TARGET) wasm.ts
@echo "Built $(TARGET) ($$(wc -c < $(TARGET)) bytes)"

DEPS = $(wildcard src/*.c src/*.h)

$(TARGET): $(DEPS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(SRC)

wasm.ts: $(TARGET)
deno run --allow-read --allow-write tasks/bundle-wasm.ts

clean:
rm -f $(TARGET)
rm -f $(TARGET) wasm.ts

.PHONY: all clean
10 changes: 6 additions & 4 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,28 @@
"name": "@clayterm/clayterm",
"license": "MIT",
"tasks": {
"test": "deno test --allow-read",
"test": "deno test",
"fmt": "deno fmt && clang-format -i src/*.c src/*.h",
"fmt:check": "deno fmt --check && clang-format --dry-run --Werror src/*.c src/*.h",
"build:npm": "deno run -A tasks/build-npm.ts",
"build:jsr": "deno run -A tasks/build-jsr.ts",
"demo": "deno run -A demo/keyboard.ts"
"demo": "deno run demo/keyboard.ts"
},
"imports": {
"@std/testing": "jsr:@std/testing@1",
"@std/expect": "jsr:@std/expect@1",
"@sinclair/typebox": "npm:@sinclair/typebox@^0.34",
"dnt": "jsr:@deno/dnt@0.42.3",
"effection": "npm:effection@^4.0.2"
"effection": "npm:effection@^4.0.2",
"@std/encoding": "jsr:@std/encoding@1"
},
"exports": {
".": "./mod.ts",
"./validate": "./validate.ts"
},
"publish": {
"include": ["*.ts", "clayterm.wasm"]
"include": ["*.ts"],
"exclude": ["!wasm.ts"]
},
"fmt": {
"exclude": ["clay", "build"]
Expand Down
5 changes: 5 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion tasks/build-npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,3 @@ await build({
});

await Deno.copyFile("README.md", `${outDir}/README.md`);
await Deno.copyFile("clayterm.wasm", `${outDir}/esm/clayterm.wasm`);
13 changes: 13 additions & 0 deletions tasks/bundle-wasm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { encodeBase64 } from "@std/encoding/base64";

const wasm = await Deno.readFile("clayterm.wasm");
const base64 = encodeBase64(wasm);

const source = `const bin = atob("${base64}");
const bytes = new Uint8Array(bin.length);
for (let i = 0; i < bin.length; i++) bytes[i] = bin.charCodeAt(i);
export const compiled = await WebAssembly.compile(bytes);
`;

await Deno.writeTextFile("wasm.ts", source);
console.log(`wrote wasm.ts (${wasm.length} bytes encoded)`);
7 changes: 0 additions & 7 deletions wasm.ts

This file was deleted.

Loading