@willbooster/tree-sitter-embedded-template 9.0.1 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -16,10 +16,10 @@ It parses templating languages such as ERB and EJS, in which scripting code is e
16
16
  `<%` and `%>`. This fork extends upstream's version 0.25.0 grammar with EJS output-tag whitespace slurping,
17
17
  trimming closers on comments, and the `=%>` closer on statements.
18
18
  It generates the parser with the
19
- [WillBooster/tree-sitter](https://github.com/WillBooster/tree-sitter) generator. The parser loads only with that
20
- fork's runtime, version 17.0.1 or later in the 17.x series
21
- ([willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter),
19
+ [WillBooster/tree-sitter](https://github.com/WillBooster/tree-sitter) generator (ABI `0x5742000c`). The parser loads only
20
+ with that fork's runtime ([willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter),
22
21
  [@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter)); upstream's runtime rejects it.
22
+ This package targets and is tested with version 19.1.1 or later in the 19.x series.
23
23
 
24
24
  ## Support Scope
25
25
 
@@ -31,7 +31,7 @@ the trees that error recovery produces may change; such changes are released as
31
31
  ## Usage
32
32
 
33
33
  The npm package ships `tree-sitter-embedded_template.wasm` for
34
- [@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter) version 17.0.1 or later in the 17.x series, which runs in Node.js, Bun, browsers, and Cloudflare Workers.
34
+ [@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter) version 19.1.1 or later in the 19.x series, which runs in Node.js, Bun, browsers, and Cloudflare Workers.
35
35
  In Node.js and Bun, load the grammar from its path:
36
36
 
37
37
  ```js
@@ -80,7 +80,7 @@ In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-
80
80
  fuzzed with:
81
81
 
82
82
  ```sh
83
- cargo add willbooster-tree-sitter@17.0.1 --rename tree-sitter
83
+ cargo add willbooster-tree-sitter@19.1.1 --rename tree-sitter
84
84
  cargo add willbooster-tree-sitter-embedded-template --rename tree-sitter-embedded-template
85
85
  ```
86
86
 
@@ -121,8 +121,9 @@ and the release build regenerate the parsers before compiling them.
121
121
  `script/known-failures.txt`, which is empty now. The first run clones the repositories. The example repositories are pinned to commits in
122
122
  `script/parse-examples`. After a grammar change or a moved pin alters that list, `script/parse-examples` rewrites it;
123
123
  review its diff before committing;
124
- - a performance check (`test/unit/performance.test.ts`) that parsing a template whose last directive is still open
125
- takes linear time, since consumers parse files while they are being edited. It loads the Wasm build through
124
+ - performance checks (`test/unit/performance.test.ts`) that templates ending in an unclosed directive or containing
125
+ long runs of delimiter prefix characters parse in linear time and that generated character-scanning lexer loops hoist
126
+ token marking outside the per-byte loop. It loads the Wasm build through
126
127
  @willbooster/web-tree-sitter, which `bun run build/ci` rebuilds after regenerating the parser;
127
128
  - a check (`test/unit/runtimeVersion.test.ts`) that `@willbooster/web-tree-sitter` in `package.json` and
128
129
  `willbooster-tree-sitter` in `Cargo.lock` are the same version, since the Wasm tests run on the former and the Rust
package/grammar.js CHANGED
@@ -21,9 +21,12 @@ module.exports = grammar({
21
21
  $.content,
22
22
  )),
23
23
 
24
- code: _ => repeat1(choice(/[^%=_-]+|[%=_-]/, '%%>')),
24
+ // Keep pure `[^%=_-]+` and `[^<]*` tails outside any outer `(...)+` so the generated lexer loops have no outgoing
25
+ // transitions to non-accepting states (avoiding per-byte `mark_end` calls), and bound delimiter prefixes (`[=_-]{1,3}`
26
+ // and `<`) so fallback before `%>`, `<%`, or EOF stays linear.
27
+ code: _ => repeat1(choice(/[^%=_-]+|[=_-]{1,3}[^%=_-]+|%[^>%=_-][^%=_-]*|[%=_-]/, '%%>')),
25
28
 
26
- content: _ => prec.right(repeat1(choice(/[^<]+|</, '<%%'))),
29
+ content: _ => prec.right(repeat1(choice(/[^<]+|<([^<%][^<]*)?/, '<%%'))),
27
30
 
28
31
  directive: $ => seq(
29
32
  choice('<%', '<%_', '<%|', '<%~'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-embedded-template",
3
- "version": "9.0.1",
3
+ "version": "10.0.0",
4
4
  "description": "Embedded template (ERB, EJS) grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "embedded-template",
@@ -49,7 +49,7 @@
49
49
  "@vitest/browser-playwright": "5.0.5",
50
50
  "@willbooster/oxlint-config": "1.4.9",
51
51
  "@willbooster/wb": "23.3.0",
52
- "@willbooster/web-tree-sitter": "17.0.1",
52
+ "@willbooster/web-tree-sitter": "19.1.1",
53
53
  "conventional-changelog-conventionalcommits": "10.4.1",
54
54
  "lefthook": "2.2.2",
55
55
  "oxlint": "1.90.0",
@@ -60,7 +60,7 @@
60
60
  "wrangler": "4.156.0"
61
61
  },
62
62
  "peerDependencies": {
63
- "@willbooster/web-tree-sitter": "^17.0.1"
63
+ "@willbooster/web-tree-sitter": "^19.1.1"
64
64
  },
65
65
  "peerDependenciesMeta": {
66
66
  "@willbooster/web-tree-sitter": {
Binary file
package/tree-sitter.json CHANGED
@@ -43,7 +43,7 @@
43
43
  }
44
44
  ],
45
45
  "metadata": {
46
- "version": "9.0.1",
46
+ "version": "10.0.0",
47
47
  "license": "MIT",
48
48
  "description": "Embedded template (ERB, EJS) grammar for tree-sitter",
49
49
  "authors": [