Skip to content

Commit 5e31dd3

Browse files
feat: Custom allocator, deno 2, jsr (#3)
Co-authored-by: Dean Srebnik <load1n9@users.noreply.github.com>
1 parent 06334ff commit 5e31dd3

29 files changed

Lines changed: 878 additions & 152 deletions

.cargo/config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[build]
2+
target = "wasm32-unknown-unknown"

.github/workflows/checks.yml

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,14 @@ jobs:
66
lint:
77
runs-on: ubuntu-latest
88
steps:
9-
- name: Checkout sources
10-
uses: actions/checkout@v2
11-
12-
- name: Setup latest deno version
13-
uses: denolib/setup-deno@v2
14-
with:
15-
deno-version: v1.x
16-
17-
- name: Run deno fmt
18-
run: deno fmt --check
19-
20-
- name: Run deno lint
21-
run: deno lint --unstable
9+
- uses: actions/checkout@v4
10+
- uses: denoland/setup-deno@v1
11+
- run: deno fmt --check
12+
- run: deno lint
2213

2314
test:
2415
runs-on: ubuntu-latest
2516
steps:
26-
- name: Checkout sources
27-
uses: actions/checkout@v2
28-
29-
- name: Setup latest deno version
30-
uses: denolib/setup-deno@v2
31-
with:
32-
deno-version: v1.x
33-
34-
- name: Run deno test
35-
run: deno test --allow-none
17+
- uses: actions/checkout@v4
18+
- uses: denoland/setup-deno@v1
19+
- run: deno test

.github/workflows/publish.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
id-token: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: denoland/setup-deno@v1
17+
- run: deno publish

Cargo.lock

Lines changed: 0 additions & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ edition = "2021"
99
crate-type = ["cdylib"]
1010
path = "wasm/lib.rs"
1111

12-
[dependencies]
13-
wee_alloc = "0.4.5"
14-
1512
[profile.release]
1613
panic = "abort"
1714
opt-level = 3

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021 the denosaurs team
3+
Copyright (c) 2021-2025 the denosaurs team
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313

1414
Game/graphics maths library for deno.
1515

16+
## Usage
17+
18+
```typescript
19+
import * as gmath from "jsr:@denosaurs/gmath";
20+
```
21+
1622
## Maintainers
1723

1824
- Elias Sjögreen ([@eliassjogreen](https://github.com/eliassjogreen))
@@ -31,4 +37,4 @@ Pull request, issues and feedback are very welcome. Code style is formatted with
3137

3238
### Licence
3339

34-
Copyright 2021, the denosaurs team. All rights reserved. MIT license.
40+
Copyright 2021-2025, the denosaurs team. All rights reserved. MIT license.

deno.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "@denosaurs/gmath",
3+
"version": "0.2.0",
4+
"exports": {
5+
".": "./mod.ts"
6+
},
7+
"tasks": {
8+
"build": "deno run -A scripts/build.ts"
9+
},
10+
"lock": false,
11+
"imports": {
12+
"@denosaurs/lz4": "jsr:@denosaurs/lz4@^0.1.4",
13+
"@std/encoding": "jsr:@std/encoding@^1.0.7"
14+
}
15+
}

scripts/build.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
import { encode } from "https://deno.land/std@0.125.0/encoding/base64.ts";
2-
import { compress } from "https://deno.land/x/lz4@v0.1.2/mod.ts";
1+
import { encodeBase64 } from "@std/encoding/base64";
2+
import { compress } from "@denosaurs/lz4";
33

44
const name = "gmath";
55

6-
await Deno.run({
7-
cmd: ["cargo", "build", "--release", "--target", "wasm32-unknown-unknown"],
8-
}).status();
6+
const cmd = new Deno.Command("cargo", {
7+
args: ["build", "--release", "--target", "wasm32-unknown-unknown"],
8+
});
9+
console.assert((await cmd.spawn().status).success);
910

1011
const wasm = await Deno.readFile(
1112
`./target/wasm32-unknown-unknown/release/${name}.wasm`,
1213
);
13-
const encoded = encode(compress(wasm));
14+
const encoded = encodeBase64(compress(wasm));
1415
const js = `// deno-fmt-ignore-file\n// deno-lint-ignore-file
15-
import { decode } from "https://deno.land/std@0.125.0/encoding/base64.ts";
16-
import { decompress } from "https://deno.land/x/lz4@v0.1.2/mod.ts";
17-
export const source = decompress(decode("${encoded}"));`;
16+
import { decodeBase64 } from "@std/encoding/base64";
17+
import { decompress } from "@denosaurs/lz4";
18+
export const source = decompress(decodeBase64("${encoded}"));`;
1819

1920
await Deno.writeTextFile("wasm/wasm.js", js);

src/angle.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export abstract class Angle {
5454
}
5555

5656
export class Rad extends Angle {
57-
static turn = 2 * Math.PI;
57+
static override turn = 2 * Math.PI;
5858

5959
sin(): number {
6060
return Math.sin(this.value);
@@ -157,7 +157,7 @@ export class Rad extends Angle {
157157
}
158158

159159
export class Deg extends Angle {
160-
static turn = 360;
160+
static override turn = 360;
161161

162162
sin(): number {
163163
return this.toRad().sin();

0 commit comments

Comments
 (0)