aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--docs/package-lock.json14
-rw-r--r--docs/package.json2
-rw-r--r--docs/src/docusaurus-tree-sitter-plugin/index.js30
-rw-r--r--docs/src/keymap-upgrade.js15
-rw-r--r--docs/static/tree-sitter-devicetree.wasmbin34601 -> 40229 bytes
5 files changed, 22 insertions, 39 deletions
diff --git a/docs/package-lock.json b/docs/package-lock.json
index 6f2ab30434..3183a51c14 100644
--- a/docs/package-lock.json
+++ b/docs/package-lock.json
@@ -21,7 +21,7 @@
"react-copy-to-clipboard": "^5.0.3",
"react-dom": "^17.0.2",
"react-toastify": "^7.0.4",
- "web-tree-sitter": "^0.19.4"
+ "web-tree-sitter": "^0.20.8"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "^2.4.0",
@@ -15391,9 +15391,9 @@
}
},
"node_modules/web-tree-sitter": {
- "version": "0.19.4",
- "resolved": "https://registry.npmjs.org/web-tree-sitter/-/web-tree-sitter-0.19.4.tgz",
- "integrity": "sha512-8G0xBj05hqZybCqBtW7RPZ/hWEtP3DiLTauQzGJZuZYfVRgw7qj7iaZ+8djNqJ4VPrdOO+pS2dR1JsTbsLxdYg=="
+ "version": "0.20.8",
+ "resolved": "https://registry.npmjs.org/web-tree-sitter/-/web-tree-sitter-0.20.8.tgz",
+ "integrity": "sha512-weOVgZ3aAARgdnb220GqYuh7+rZU0Ka9k9yfKtGAzEYMa6GgiCzW9JjQRJyCJakvibQW+dfjJdihjInKuuCAUQ=="
},
"node_modules/webidl-conversions": {
"version": "3.0.1",
@@ -27040,9 +27040,9 @@
"integrity": "sha512-wYxSGajtmoP4WxfejAPIr4l0fVh+jeMXZb08wNc0tMg6xsfZXj3cECqIK0G7ZAqUq0PP8WlMDtaOGVBTAWztNw=="
},
"web-tree-sitter": {
- "version": "0.19.4",
- "resolved": "https://registry.npmjs.org/web-tree-sitter/-/web-tree-sitter-0.19.4.tgz",
- "integrity": "sha512-8G0xBj05hqZybCqBtW7RPZ/hWEtP3DiLTauQzGJZuZYfVRgw7qj7iaZ+8djNqJ4VPrdOO+pS2dR1JsTbsLxdYg=="
+ "version": "0.20.8",
+ "resolved": "https://registry.npmjs.org/web-tree-sitter/-/web-tree-sitter-0.20.8.tgz",
+ "integrity": "sha512-weOVgZ3aAARgdnb220GqYuh7+rZU0Ka9k9yfKtGAzEYMa6GgiCzW9JjQRJyCJakvibQW+dfjJdihjInKuuCAUQ=="
},
"webidl-conversions": {
"version": "3.0.1",
diff --git a/docs/package.json b/docs/package.json
index 44274becbb..15d5aa38ee 100644
--- a/docs/package.json
+++ b/docs/package.json
@@ -28,7 +28,7 @@
"react-copy-to-clipboard": "^5.0.3",
"react-dom": "^17.0.2",
"react-toastify": "^7.0.4",
- "web-tree-sitter": "^0.19.4"
+ "web-tree-sitter": "^0.20.8"
},
"browserslist": {
"production": [
diff --git a/docs/src/docusaurus-tree-sitter-plugin/index.js b/docs/src/docusaurus-tree-sitter-plugin/index.js
index e782aea8d4..a6952ce7c5 100644
--- a/docs/src/docusaurus-tree-sitter-plugin/index.js
+++ b/docs/src/docusaurus-tree-sitter-plugin/index.js
@@ -16,36 +16,6 @@ module.exports = function () {
test: /web-tree-sitter/,
loader: "null-loader",
});
- } else {
- // The way web-tree-sitter loads tree-sitter.wasm isn't something that
- // Docusaurus/Webpack identify as an asset. There is currently no way to
- // set location of the file other than patching web-tree-sitter.
- // (see https://github.com/tree-sitter/tree-sitter/issues/559)
- rules.push({
- test: /tree-sitter\.js$/,
- loader: "string-replace-loader",
- options: {
- multiple: [
- // Replace the path to tree-sitter.wasm with a "new URL()" to clue
- // Webpack in that it is an asset.
- {
- search: '"tree-sitter.wasm"',
- replace: '(new URL("tree-sitter.wasm", import.meta.url)).href',
- strict: true,
- },
- // Webpack replaces "new URL()" with the full URL to the asset, but
- // web-tree-sitter will still add a prefix to it unless there is a
- // Module.locateFile() function.
- {
- search: "var Module=void 0!==Module?Module:{};",
- replace: `var Module = {
- locateFile: (path, prefix) => path.startsWith('http') ? path : prefix + path,
- };`,
- strict: true,
- },
- ],
- },
- });
}
return {
diff --git a/docs/src/keymap-upgrade.js b/docs/src/keymap-upgrade.js
index 19a5d8e32c..788ab31ab5 100644
--- a/docs/src/keymap-upgrade.js
+++ b/docs/src/keymap-upgrade.js
@@ -2,10 +2,23 @@ import Parser from "web-tree-sitter";
import { Codes, Behaviors } from "./data/keymap-upgrade";
+const TREE_SITTER_WASM_URL = new URL(
+ "/node_modules/web-tree-sitter/tree-sitter.wasm",
+ import.meta.url
+);
+
let Devicetree;
export async function initParser() {
- await Parser.init();
+ await Parser.init({
+ locateFile: (path, prefix) => {
+ // When locating tree-sitter.wasm, use a path that Webpack can map to the correct URL.
+ if (path == "tree-sitter.wasm") {
+ return TREE_SITTER_WASM_URL.href;
+ }
+ return prefix + path;
+ },
+ });
Devicetree = await Parser.Language.load("/tree-sitter-devicetree.wasm");
}
diff --git a/docs/static/tree-sitter-devicetree.wasm b/docs/static/tree-sitter-devicetree.wasm
index fbcb0f18a7..cce5ac9656 100644
--- a/docs/static/tree-sitter-devicetree.wasm
+++ b/docs/static/tree-sitter-devicetree.wasm
Binary files differ