@flowscripter/template-bun-wasm-rust-library 1.0.8 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -6
- package/package.json +12 -12
- package/src/lib.ts +5 -6
package/README.md
CHANGED
|
@@ -47,20 +47,17 @@ Test:
|
|
|
47
47
|
|
|
48
48
|
`cargo test && bun test`
|
|
49
49
|
|
|
50
|
-
**NOTE**: The following tasks use Deno as it excels at these and Bun does not
|
|
51
|
-
currently provide such functionality:
|
|
52
|
-
|
|
53
50
|
Format:
|
|
54
51
|
|
|
55
|
-
`
|
|
52
|
+
`bunx oxfmt`
|
|
56
53
|
|
|
57
54
|
Lint:
|
|
58
55
|
|
|
59
|
-
`cargo fmt &&
|
|
56
|
+
`cargo fmt && bunx oxlint index.ts src/ tests/`
|
|
60
57
|
|
|
61
58
|
Generate HTML API Documentation:
|
|
62
59
|
|
|
63
|
-
`
|
|
60
|
+
`bunx typedoc --readme none index.ts`
|
|
64
61
|
|
|
65
62
|
## Documentation
|
|
66
63
|
|
package/package.json
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowscripter/template-bun-wasm-rust-library",
|
|
3
|
+
"version": "1.1.0",
|
|
3
4
|
"description": "Project template for a Rust library compiled to WASM exposed as a Bun module",
|
|
4
|
-
"homepage": "https://github.com/flowscripter/template-bun-wasm-rust-library#readme",
|
|
5
|
-
"repository": {
|
|
6
|
-
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/flowscripter/template-bun-wasm-rust-library.git"
|
|
8
|
-
},
|
|
9
|
-
"license": "MIT",
|
|
10
5
|
"keywords": [
|
|
11
6
|
"bun",
|
|
12
|
-
"rust",
|
|
13
|
-
"wasm",
|
|
14
7
|
"example",
|
|
8
|
+
"library",
|
|
9
|
+
"rust",
|
|
15
10
|
"template",
|
|
16
|
-
"
|
|
11
|
+
"wasm"
|
|
17
12
|
],
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
13
|
+
"homepage": "https://github.com/flowscripter/template-bun-wasm-rust-library#readme",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/flowscripter/template-bun-wasm-rust-library.git"
|
|
18
|
+
},
|
|
21
19
|
"files": [
|
|
22
20
|
"src/**/*",
|
|
23
21
|
"pkg/**/*",
|
|
@@ -25,6 +23,8 @@
|
|
|
25
23
|
"README.md",
|
|
26
24
|
"LICENSE"
|
|
27
25
|
],
|
|
26
|
+
"type": "module",
|
|
27
|
+
"module": "index.ts",
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
package/src/lib.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import init, {
|
|
2
|
-
add,
|
|
3
|
-
} from "../pkg/flowscripter_template_bun_wasm_rust_library.js";
|
|
1
|
+
import init, { add } from "../pkg/flowscripter_template_bun_wasm_rust_library.js";
|
|
4
2
|
|
|
5
3
|
// TODO: when https://github.com/oven-sh/bun/pull/20503 is released I believe the following can be removed
|
|
6
4
|
import wasm from "../pkg/flowscripter_template_bun_wasm_rust_library_bg.wasm";
|
|
7
|
-
const wasmBuffer =
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
const wasmBuffer =
|
|
6
|
+
typeof Bun !== "undefined"
|
|
7
|
+
? await Bun.file(wasm as unknown as URL).arrayBuffer()
|
|
8
|
+
: await fetch(wasm as unknown as URL).then((response) => response.arrayBuffer());
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* Adds 3 and 3 and logs the result as "World 6"
|