Skip to content
This repository was archived by the owner on Sep 19, 2025. It is now read-only.

Commit c24c57a

Browse files
committed
feat: add web target for testing only
1 parent a9f241f commit c24c57a

File tree

4 files changed

+43
-1
lines changed

4 files changed

+43
-1
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ install:
1919
$(MAKE) -C $(JS) install
2020
cargo install cargo-zigbuild
2121
# brew install binaryen
22+
brew install caddy
2223

2324
bump:
2425
$(MAKE) -C $(JS) bump VERSION=$(VERSION)

js/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
33
build:
44
$(MAKE) build-target WASM_PATH=$(WASM_PATH) TARGET=experimental-nodejs-module
55
$(MAKE) build-target WASM_PATH=$(WASM_PATH) TARGET=deno
6+
$(MAKE) build-target WASM_PATH=$(WASM_PATH) TARGET=web
67

78
# shim workerd
9+
rm -rf $(ROOT_DIR)/pkg-workerd
810
cp -r $(ROOT_DIR)/pkg-experimental-nodejs-module $(ROOT_DIR)/pkg-workerd
911
cp $(ROOT_DIR)/shim-workerd.js $(ROOT_DIR)/pkg-workerd/pulsebeam_core.js
1012

@@ -34,3 +36,6 @@ install:
3436

3537
bump:
3638
bash bump.bash ${VERSION}
39+
40+
serve:
41+
caddy file-server --root .

js/app.html

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
</head>
8+
9+
<body>
10+
11+
<script type="module">
12+
import init, {
13+
AccessToken,
14+
PeerClaims,
15+
PeerPolicy,
16+
} from "./pkg-web/pulsebeam_core.js";
17+
18+
await init();
19+
const app = new AccessToken(
20+
"kid_73d8caa6c387d46c",
21+
"sk_7edea599046490dfd271b863b03398d2b613812b1f23efd023ca3b08026d3e67",
22+
);
23+
24+
const claims = new PeerClaims("default", "alice");
25+
const policy = new PeerPolicy("default", "*");
26+
claims.setAllowPolicy(policy);
27+
28+
const token = app.createToken(claims, 3600);
29+
console.log(token);
30+
</script>
31+
</body>
32+
33+
</html>

js/jsr.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@
1414
".": "./pkg-experimental-nodejs-module/pulsebeam_core.js",
1515
"./node": "./pkg-experimental-nodejs-module/pulsebeam_core.js",
1616
"./deno": "./pkg-deno/pulsebeam_core.js",
17-
"./workerd": "./pkg-workerd/pulsebeam_core.js"
17+
"./workerd": "./pkg-workerd/pulsebeam_core.js",
18+
"./web": "./pkg-web/pulsebeam_core.js"
1819
},
1920
"publish": {
2021
"include": [
2122
"pkg-experimental-nodejs-module",
2223
"pkg-deno",
2324
"pkg-workerd",
25+
"pkg-web",
2426
"README.md",
2527
"LICENSE",
2628
"jsr.json"
@@ -30,6 +32,7 @@
3032
"pkg-experimental-nodejs-module",
3133
"pkg-deno",
3234
"pkg-workerd",
35+
"pkg-web",
3336
"README.md",
3437
"LICENSE",
3538
"package.json"

0 commit comments

Comments
 (0)