Skip to content

Commit d1a3e17

Browse files
committed
Refactored wasm and rust workspace, and added jsonpath
1 parent fae197d commit d1a3e17

31 files changed

Lines changed: 23587 additions & 2957 deletions

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ html_cov/
1010
cov.lcov
1111
coverage/
1212
docs/
13-
crypto/hash/_wasm/target
13+
_wasm/target

.vscode/settings.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
22
"deno.enable": true,
3-
"deno.unstable": true,
4-
"editor.defaultFormatter": "denoland.vscode-deno"
3+
"deno.unstable": true
54
}

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ console.log(dump(buffer));
5050
utility for text encoding.
5151
- [http](https://jsr.io/@stdext/http): The http package contains utility for
5252
fetching and http servers
53+
- [json](https://jsr.io/@stdext/json): The json package, contains helpers for
54+
json parsing, querying (jsonpath) and processing
55+
- [lexer](https://jsr.io/@stdext/lexer): The lexer package contains general
56+
purpose lexers/tokenizers
57+
- [types](https://jsr.io/@stdext/types): The types package, contains general
58+
purpose type helpers
5359

5460
## Versioning
5561

@@ -68,6 +74,21 @@ implemented.
6874
For modules that use Rust to compile to WASM, we allow the usage of third-party
6975
crates if necessary, but this will be considered on a case-by-case basis.
7076

77+
## WASM
78+
79+
All wasm code is generated from the rust workspace in the [\_wasm](./_wasm)
80+
folder.
81+
82+
To generate the wasm code:
83+
84+
```sh
85+
deno task build:wasm
86+
```
87+
88+
This will call the [build_wasm.ts](./_tools/build_wasm.ts) script and will place
89+
each generated lib in its respective package based on its prefix. See script for
90+
more details.
91+
7192
## Deprecation Policy
7293

7394
We follow the

_tools/build_wasm.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { parse } from "@std/toml";
2+
import { resolve } from "@std/path";
3+
4+
const isCheck = Deno.args.some((a) => a === "--check");
5+
const failFast = Deno.args.some((a) => a === "--fail-fast");
6+
7+
const rawCargo = Deno.readTextFileSync("./_wasm/Cargo.toml");
8+
9+
const parsedCargo = parse(rawCargo) as { workspace: { members: string[] } };
10+
11+
let didFail = false;
12+
13+
for (const member of parsedCargo.workspace.members) {
14+
const [folder] = member.split("_");
15+
const outPath = resolve(
16+
folder,
17+
"_wasm",
18+
);
19+
20+
const args: string[] = [
21+
"run",
22+
"-A",
23+
"jsr:@deno/wasmbuild@0.17.1",
24+
"--js-ext",
25+
"mjs",
26+
"--sync",
27+
"--project",
28+
member,
29+
"--out",
30+
outPath,
31+
];
32+
33+
if (isCheck) {
34+
args.push("--check");
35+
}
36+
37+
const command = new Deno.Command(Deno.execPath(), {
38+
args: args,
39+
cwd: "./_wasm",
40+
});
41+
const child = command.spawn();
42+
const status = await child.status;
43+
if (!status.success) {
44+
didFail = true;
45+
}
46+
if (failFast && didFail) {
47+
Deno.exit(1);
48+
}
49+
}
50+
51+
Deno.exit(didFail ? 1 : 0);
Lines changed: 177 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
[workspace]
22
resolver = "2"
33
members = [
4-
"argon2",
5-
"bcrypt",
6-
"scrypt"
4+
"crypto_hash_argon2",
5+
"crypto_hash_bcrypt",
6+
"crypto_hash_scrypt",
7+
"json_jsonpath"
78
]
89

910
[workspace.package]
@@ -14,6 +15,8 @@ edition = "2021"
1415
wasm-bindgen = "0.2.92"
1516
serde = { version = "1", features = ["derive"] }
1617
serde-wasm-bindgen = "0.4"
18+
serde_json = "1"
19+
serde_json_path = "0.6"
1720
getrandom = { version = "0.2", features = ["js"] }
1821
rand_core = { version = "0.6", features = ["std"] }
1922
js-sys = "0.3"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "deno_stdext_crypto_hash_wasm_argon2"
2+
name = "crypto_hash_argon2"
33
version.workspace = true
44
edition.workspace = true
55

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "deno_stdext_crypto_hash_wasm_bcrypt"
2+
name = "crypto_hash_bcrypt"
33
version.workspace = true
44
edition.workspace = true
55

0 commit comments

Comments
 (0)