@willbooster/tree-sitter-javascript 18.0.0 → 19.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
@@ -5,7 +5,7 @@
5
5
  [![Test](https://github.com/WillBooster/tree-sitter-javascript/actions/workflows/test.yml/badge.svg)](https://github.com/WillBooster/tree-sitter-javascript/actions/workflows/test.yml)
6
6
  [![Test rust](https://github.com/WillBooster/tree-sitter-javascript/actions/workflows/test-rust.yml/badge.svg)](https://github.com/WillBooster/tree-sitter-javascript/actions/workflows/test-rust.yml)
7
7
  [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
8
- [![wbfy](https://img.shields.io/badge/wbfy-20.51.1-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
8
+ [![wbfy](https://img.shields.io/badge/wbfy-21.3.0-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
9
9
  [![crates.io](https://img.shields.io/crates/v/willbooster-tree-sitter-javascript.svg)](https://crates.io/crates/willbooster-tree-sitter-javascript)
10
10
 
11
11
  JavaScript and JSX grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter), forked from
@@ -82,10 +82,9 @@ array/formal and object-rest extension hooks. The crate ships `tree-sitter.json`
82
82
  In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-javascript) and the
83
83
  [willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter) runtime with the matching ABI. The tested version is 15.5.4:
84
84
 
85
- ```toml
86
- [dependencies]
87
- tree-sitter = { package = "willbooster-tree-sitter", version = "15.5.4" }
88
- tree-sitter-javascript = { package = "willbooster-tree-sitter-javascript", version = "16" }
85
+ ```sh
86
+ cargo add willbooster-tree-sitter@15.5.4 --rename tree-sitter
87
+ cargo add willbooster-tree-sitter-javascript --rename tree-sitter-javascript
89
88
  ```
90
89
 
91
90
  ```rust
package/grammar.js CHANGED
@@ -1039,7 +1039,7 @@ module.exports = grammar({
1039
1039
  'template_call',
1040
1040
  seq(
1041
1041
  field('function', alias($._assignment_call_primary, $.primary_expression)),
1042
- field('arguments', $.template_string)
1042
+ field('arguments', alias($._tagged_template_string, $.template_string))
1043
1043
  )
1044
1044
  ),
1045
1045
 
@@ -1149,7 +1149,7 @@ module.exports = grammar({
1149
1149
  'template_call',
1150
1150
  seq(
1151
1151
  field('function', alias($._constructor_chain_base, $.primary_expression)),
1152
- field('arguments', $.template_string)
1152
+ field('arguments', alias($._tagged_template_string, $.template_string))
1153
1153
  )
1154
1154
  ),
1155
1155
 
@@ -1373,23 +1373,10 @@ module.exports = grammar({
1373
1373
  // http://stackoverflow.com/questions/13014947/regex-to-match-a-c-style-multiline-comment/36328890#36328890
1374
1374
  comment: () => token(choice(seq('//', /[^\r\n\u2028\u2029]*/), seq('/*', /[^*]*\*+([^/*][^*]*\*+)*/, '/'))),
1375
1375
 
1376
- template_string: ($) =>
1377
- seq(
1378
- '`',
1379
- repeat(
1380
- choice(
1381
- alias(sym('_template_chars'), sym('string_fragment')),
1382
- $.escape_sequence,
1383
- alias($._invalid_template_escape, $.escape_sequence),
1384
- $.template_substitution
1385
- )
1386
- ),
1387
- '`'
1388
- ),
1376
+ template_string: ($) => templateString($, false),
1377
+
1378
+ _tagged_template_string: ($) => templateString($, true),
1389
1379
 
1390
- // Tagged templates allow `\x` and `\u` without the hex digits an escape_sequence needs (the cooked string is
1391
- // undefined). The lexer prefers the longer escape_sequence when the digits follow. Untagged templates reject these
1392
- // escapes, but the lexer cannot tell the two apart.
1393
1380
  _invalid_template_escape: () => token.immediate(seq('\\', /[xu]/)),
1394
1381
 
1395
1382
  template_substitution: ($) => seq('${', $._expressions, '}'),
@@ -1754,14 +1741,17 @@ function contextualIdentifier($, heritage) {
1754
1741
  }
1755
1742
 
1756
1743
  /**
1757
- * @param {GrammarSymbols<'import' | 'arguments' | 'template_string' | 'optional_chain'>} $
1744
+ * @param {GrammarSymbols<'import' | 'arguments' | '_tagged_template_string' | 'template_string' | 'optional_chain'>} $
1758
1745
  * @param {RuleOrLiteral} callee
1759
1746
  * @param {RuleOrLiteral} primary
1760
1747
  */
1761
1748
  function callExpression($, callee, primary) {
1762
1749
  return choice(
1763
1750
  prec('call', seq(field('function', choice(callee, $.import)), field('arguments', $.arguments))),
1764
- prec('template_call', seq(field('function', primary), field('arguments', $.template_string))),
1751
+ prec(
1752
+ 'template_call',
1753
+ seq(field('function', primary), field('arguments', alias($._tagged_template_string, $.template_string)))
1754
+ ),
1765
1755
  prec(
1766
1756
  'member',
1767
1757
  seq(field('function', primary), field('optional_chain', $.optional_chain), field('arguments', $.arguments))
@@ -1872,3 +1862,22 @@ function functionScope(async, content, kind = 'function_signature') {
1872
1862
  const name = kind === 'function' && !async ? 'sync_function' : `${async ? 'async_' : ''}${kind}`;
1873
1863
  return seq(sym(`_${name}_start`), content, sym('_function_context_end'));
1874
1864
  }
1865
+
1866
+ /**
1867
+ * @param {GrammarSymbols<'escape_sequence' | '_invalid_template_escape' | 'template_substitution'>} $
1868
+ * @param {boolean} tagged
1869
+ */
1870
+ function templateString($, tagged) {
1871
+ return seq(
1872
+ '`',
1873
+ repeat(
1874
+ choice(
1875
+ alias(sym('_template_chars'), sym('string_fragment')),
1876
+ $.escape_sequence,
1877
+ ...(tagged ? [alias($._invalid_template_escape, $.escape_sequence)] : []),
1878
+ $.template_substitution
1879
+ )
1880
+ ),
1881
+ '`'
1882
+ );
1883
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-javascript",
3
- "version": "18.0.0",
3
+ "version": "19.0.0",
4
4
  "description": "JavaScript grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -46,12 +46,12 @@
46
46
  "verify-full": "bun wb verify --full"
47
47
  },
48
48
  "devDependencies": {
49
- "@babel/parser": "8.0.7",
49
+ "@babel/parser": "8.0.8",
50
50
  "@tsconfig/bun": "1.0.11",
51
51
  "@types/bun": "1.4.4",
52
52
  "@vitest/browser-playwright": "5.0.5",
53
53
  "@willbooster/oxlint-config": "1.4.9",
54
- "@willbooster/wb": "22.32.3",
54
+ "@willbooster/wb": "23.0.2",
55
55
  "@willbooster/web-tree-sitter": "15.5.4",
56
56
  "acorn": "8.19.0",
57
57
  "acorn-jsx": "5.3.2",
@@ -61,9 +61,9 @@
61
61
  "oxlint-tsgolint": "7.0.2005",
62
62
  "playwright": "1.64.1",
63
63
  "semantic-release": "25.0.9",
64
- "vite": "8.3.4",
64
+ "vite": "8.3.5",
65
65
  "vitest": "5.0.5",
66
- "wrangler": "4.151.1"
66
+ "wrangler": "4.152.0"
67
67
  },
68
68
  "peerDependencies": {
69
69
  "@willbooster/web-tree-sitter": "^15.0.0"
Binary file
Binary file
package/tree-sitter.json CHANGED
@@ -32,7 +32,7 @@
32
32
  }
33
33
  ],
34
34
  "metadata": {
35
- "version": "18.0.0",
35
+ "version": "19.0.0",
36
36
  "license": "MIT",
37
37
  "description": "JavaScript grammar for tree-sitter",
38
38
  "authors": [