Skip to content

Commit

Permalink
Merge pull request #40 from biscuit-auth/0.7
Browse files Browse the repository at this point in the history
biscuit v3.3 support through biscuit-auth 6.0.0
  • Loading branch information
divarvel authored Jan 27, 2025
2 parents 5471de5 + 79c575d commit e441e4a
Show file tree
Hide file tree
Showing 18 changed files with 3,250 additions and 2,793 deletions.
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# How to update tree-sitter

Tree-sitter is packaged in a way that makes it difficult to load it up with `wds`, it is packaged as a CommonJS module (modifying a `module.exports` object) and as such does not play well with es modules.

The simplest solution I have found is to turn the CommonJS module into an ES module by adding the following at the end of the file:

```js
await TreeSitter.init({
locateFile(scriptName, scriptDirectory) {
return "/assets/tree-sitter.wasm";
}
});
export const Parser = TreeSitter;
```

This also calls `init` once, with the proper location of the wasm file.

So to update `tree-sitter`:

- run `npm install --no-save web-tree-sitter` (check if that’s the correct version)
- `cp node_modules/web-tree-sitter/tree-sitter.wasm assets/`
- `cp node_modules/web-tree-sitter/tree-sitter-web.d.ts ./tree-sitter.d.ts`
- edit `tree-sitter.d.ts`
- remove the `declare module` scope
- remove the `export = Parser`
- add `export ` in front of `class Parser`
- add `export ` in front of `namespace Parser`
- `cp node_modules/web-tree-sitter/tree-sitter.js ./`
- ```bash
cat << 'EOF' >> tree-sitter.js
await TreeSitter.init({
locateFile(scriptName, scriptDirectory) {
return "/assets/tree-sitter.wasm";
}
});
export const Parser = TreeSitter;
EOF
```
Binary file modified assets/tree-sitter-biscuit.wasm
Binary file not shown.
Binary file modified assets/tree-sitter.wasm
Binary file not shown.
272 changes: 4 additions & 268 deletions demo-rollup/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion demo/token-generator.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<body>
<h1>demo biscuit</h1>

<bc-token-generator privateKey="4d237d3f206f22d47014b8400e32fd57d77dd275b8ac7a7b6d8a066bd27961b1">
<bc-token-generator privateKey="ed25519/4d237d3f206f22d47014b8400e32fd57d77dd275b8ac7a7b6d8a066bd27961b1">
</bc-token-generator>

</body>
Expand Down
Loading

0 comments on commit e441e4a

Please sign in to comment.