From a40265cbebfd6401d21eb095e250937915c9c3f7 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Sat, 8 Feb 2025 13:06:44 -0500 Subject: [PATCH] refactor(web): rename `tree-sitter.js` to `web-tree-sitter.js` This is not breaking for consumers of the web bindings, nor the playground as both filenames will be kept in the .github.io repo --- cli/build.rs | 4 +- cli/src/playground.html | 2 +- cli/src/playground.rs | 12 +- docs/src/6-contributing.md | 2 +- docs/src/7-playground.md | 2 +- lib/binding_web/.gitignore | 4 +- lib/binding_web/CONTRIBUTING.md | 2 +- lib/binding_web/README.md | 14 +- ...{tree-sitter.d.ts => web-tree-sitter.d.ts} | 0 lib/binding_web/package-lock.json | 1099 ++++++++++++----- lib/binding_web/package.json | 46 +- lib/binding_web/script/build.js | 16 +- .../script/check-artifacts-fresh.ts | 2 +- lib/binding_web/src/bindings.ts | 2 +- lib/binding_web/src/constants.ts | 2 +- lib/binding_web/vitest.config.ts | 2 +- xtask/src/build_wasm.rs | 12 +- xtask/src/check_wasm_exports.rs | 2 +- xtask/src/main.rs | 2 +- 19 files changed, 853 insertions(+), 374 deletions(-) rename lib/binding_web/lib/{tree-sitter.d.ts => web-tree-sitter.d.ts} (100%) diff --git a/cli/build.rs b/cli/build.rs index 04406487..f0eacefd 100644 --- a/cli/build.rs +++ b/cli/build.rs @@ -53,8 +53,8 @@ fn main() { fn web_playground_files_present() -> bool { let paths = [ "../docs/src/assets/js/playground.js", - "../lib/binding_web/tree-sitter.js", - "../lib/binding_web/tree-sitter.wasm", + "../lib/binding_web/web-tree-sitter.js", + "../lib/binding_web/web-tree-sitter.wasm", ]; paths.iter().all(|p| Path::new(p).exists()) diff --git a/cli/src/playground.html b/cli/src/playground.html index 018c4ced..e4d02ed5 100644 --- a/cli/src/playground.html +++ b/cli/src/playground.html @@ -92,7 +92,7 @@ diff --git a/cli/src/playground.rs b/cli/src/playground.rs index 1fdaa057..bce1a18c 100644 --- a/cli/src/playground.rs +++ b/cli/src/playground.rs @@ -34,8 +34,8 @@ macro_rules! optional_resource { } optional_resource!(get_playground_js, "docs/src/assets/js/playground.js"); -optional_resource!(get_lib_js, "lib/binding_web/tree-sitter.js"); -optional_resource!(get_lib_wasm, "lib/binding_web/tree-sitter.wasm"); +optional_resource!(get_lib_js, "lib/binding_web/web-tree-sitter.js"); +optional_resource!(get_lib_wasm, "lib/binding_web/web-tree-sitter.wasm"); fn get_main_html(tree_sitter_dir: Option<&Path>) -> Cow<'static, [u8]> { tree_sitter_dir.map_or( @@ -79,16 +79,16 @@ pub fn serve(grammar_path: &Path, open_in_browser: bool) -> Result<()> { response(&playground_js, &js_header) } } - "/tree-sitter.js" => { + "/web-tree-sitter.js" => { if lib_js.is_empty() { - redirect("https://tree-sitter.github.io/tree-sitter.js") + redirect("https://tree-sitter.github.io/web-tree-sitter.js") } else { response(&lib_js, &js_header) } } - "/tree-sitter.wasm" => { + "/web-tree-sitter.wasm" => { if lib_wasm.is_empty() { - redirect("https://tree-sitter.github.io/tree-sitter.wasm") + redirect("https://tree-sitter.github.io/web-tree-sitter.wasm") } else { response(&lib_wasm, &wasm_header) } diff --git a/docs/src/6-contributing.md b/docs/src/6-contributing.md index 4584be4c..e53b85a1 100644 --- a/docs/src/6-contributing.md +++ b/docs/src/6-contributing.md @@ -197,7 +197,7 @@ and the tree-sitter module is fetched from [here][js url]. This, along with the [go package]: https://pkg.go.dev/github.com/tree-sitter/go-tree-sitter [go ts]: https://github.com/tree-sitter/go-tree-sitter [highlight crate]: https://crates.io/crates/tree-sitter-highlight -[js url]: https://tree-sitter.github.io/tree-sitter.js +[js url]: https://tree-sitter.github.io/web-tree-sitter.js [lib crate]: https://crates.io/crates/tree-sitter [mdBook]: https://rust-lang.github.io/mdBook [mdbook cli]: https://rust-lang.github.io/mdBook/guide/installation.html diff --git a/docs/src/7-playground.md b/docs/src/7-playground.md index 90f97685..92e219a8 100644 --- a/docs/src/7-playground.md +++ b/docs/src/7-playground.md @@ -102,7 +102,7 @@ you must use at least one capture, like (node_name) @capture-nameLANGUAGE_BASE_URL = "https://tree-sitter.github.io"; diff --git a/lib/binding_web/.gitignore b/lib/binding_web/.gitignore index d7edb1e8..02a02f64 100644 --- a/lib/binding_web/.gitignore +++ b/lib/binding_web/.gitignore @@ -1,6 +1,8 @@ debug/ dist/ -tree-sitter* +web-tree-sitter* +!web-tree-sitter.d.ts +!web-tree-sitter.d.ts.map lib/tree-sitter* lib/*.c lib/*.h diff --git a/lib/binding_web/CONTRIBUTING.md b/lib/binding_web/CONTRIBUTING.md index 7072abe0..b37989f2 100644 --- a/lib/binding_web/CONTRIBUTING.md +++ b/lib/binding_web/CONTRIBUTING.md @@ -120,7 +120,7 @@ npm test ### Debugging You might have noticed that when you ran `npm build`, the build process generated a couple of [sourcemaps][sourcemap]: -`tree-sitter.js.map` and `tree-sitter.wasm.map`. These sourcemaps can be used to debug the library in the browser, and are +`web-tree-sitter.js.map` and `web-tree-sitter.wasm.map`. These sourcemaps can be used to debug the library in the browser, and are shipped with the library on both NPM and the GitHub releases. #### Tweaking the Emscripten build diff --git a/lib/binding_web/README.md b/lib/binding_web/README.md index 3713df5e..7438aa04 100644 --- a/lib/binding_web/README.md +++ b/lib/binding_web/README.md @@ -9,11 +9,11 @@ WebAssembly bindings to the [Tree-sitter](https://github.com/tree-sitter/tree-si ## Setup -You can download the `tree-sitter.js` and `tree-sitter.wasm` files from [the latest GitHub release][gh release] and load +You can download the `web-tree-sitter.js` and `web-tree-sitter.wasm` files from [the latest GitHub release][gh release] and load them using a standalone script: ```html - +