Skip to content

Commit 5225fb0

Browse files
committed
feat(wasm): Add ast-grep-wasm with an API almost identical to napi with libc shim
1 parent c7bba90 commit 5225fb0

25 files changed

+2066
-37
lines changed

Cargo.lock

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

crates/cli/src/utils/worker.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,7 @@ pub struct Items<T>(mpsc::Receiver<T>);
6969
impl<T> Iterator for Items<T> {
7070
type Item = T;
7171
fn next(&mut self) -> Option<Self::Item> {
72-
if let Ok(match_result) = self.0.recv() {
73-
Some(match_result)
74-
} else {
75-
None
76-
}
72+
self.0.recv().ok()
7773
}
7874
}
7975
impl<T> Items<T> {

crates/wasm/Cargo.toml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[package]
2+
name = "ast-grep-wasm"
3+
edition = "2021"
4+
description = "WebAssembly bindings for ast-grep"
5+
license = "MIT"
6+
authors = ["Mohamad Mohebifar <mo@codemod.com>"]
7+
version.workspace = true
8+
9+
[lib]
10+
crate-type = ["cdylib", "rlib"]
11+
12+
[dependencies]
13+
ast-grep-core.workspace = true
14+
ast-grep-config.workspace = true
15+
ast-grep-language = { path = "../language", default-features = false }
16+
console_error_panic_hook = "0.1.7"
17+
js-sys = "0.3.69"
18+
serde = { version = "1.0", features = ["derive"] }
19+
serde_json = "1.0"
20+
serde-wasm-bindgen = "0.6.5"
21+
thiserror.workspace = true
22+
tree-sitter.workspace = true
23+
wasm-bindgen = "0.2.92"
24+
wasm-bindgen-futures = "0.4.50"
25+
26+
[build-dependencies]
27+
cc = "1.0"
28+
29+
# Enable the wee_alloc feature for smaller code size
30+
[features]
31+
default = ["wee_alloc"]
32+
wee_alloc = ["dep:wee_alloc"]
33+
exhaustive-lang = ["ast-grep-language/wasm-exhaustive-lang"]
34+
small-lang = ["ast-grep-language/wasm-lang"]
35+
36+
[dependencies.wee_alloc]
37+
version = "0.4.5"
38+
optional = true

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy