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
This commit is contained in:
Amaan Qureshi 2025-02-08 13:06:44 -05:00
parent 74d7ca8582
commit a40265cbeb
19 changed files with 853 additions and 374 deletions

View file

@ -92,7 +92,7 @@
<script>LANGUAGE_BASE_URL = "";</script>
<script type="module" src="playground.js"></script>
<script type="module">
import * as TreeSitter from './tree-sitter.js';
import * as TreeSitter from './web-tree-sitter.js';
window.TreeSitter = TreeSitter;
setTimeout(() => window.initializePlayground({local: true}), 1)
</script>

View file

@ -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)
}