@willbooster/tree-sitter-javascript 12.0.0 → 14.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
@@ -19,8 +19,8 @@ This fork fixes parsing bugs and raises conformance with [ECMAScript (ECMA-262)]
19
19
 
20
20
  The npm package ships two languages for
21
21
  [@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter), which runs in Node.js, Bun,
22
- browsers, and Cloudflare Workers. The parser carries the ABI number of WillBooster/tree-sitter (`0x57420009`), so it
23
- requires that runtime ABI; the upstream runtime rejects it. This package is tested with runtime 13.0.0, and its optional peer dependency covers major 13. In Node.js and Bun, load it from
22
+ browsers, and Cloudflare Workers. The parser carries the ABI number of WillBooster/tree-sitter (`0x5742000b`), so it
23
+ requires that runtime ABI; the upstream runtime rejects it. This package is tested with runtime 15.0.0, and its optional peer dependency covers major 15. In Node.js and Bun, load it from
24
24
  the package. Choose `tree-sitter-javascript.wasm` for the Module goal, or
25
25
  `tree-sitter-javascript_script.wasm` for the Script goal. The source goal comes from the host or file type;
26
26
  `.mjs` uses Module and `.cjs` uses Script, while `.js` depends on the host. For example, `await\nvalue` is one
@@ -73,12 +73,12 @@ The package also ships the node types in `src/node-types.json`, the highlight, i
73
73
  `require('@willbooster/tree-sitter-javascript/grammar')`). The crate ships `tree-sitter.json` and `queries/` too.
74
74
 
75
75
  In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-javascript) and the
76
- [willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter) runtime with the matching ABI. The tested version is 13.0.0:
76
+ [willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter) runtime with the matching ABI. The tested version is 15.0.0:
77
77
 
78
78
  ```toml
79
79
  [dependencies]
80
- tree-sitter = { package = "willbooster-tree-sitter", version = "13.0.0" }
81
- tree-sitter-javascript = { package = "willbooster-tree-sitter-javascript", version = "11" }
80
+ tree-sitter = { package = "willbooster-tree-sitter", version = "15.0.0" }
81
+ tree-sitter-javascript = { package = "willbooster-tree-sitter-javascript", version = "13" }
82
82
  ```
83
83
 
84
84
  ```rust
package/grammar.js CHANGED
@@ -152,6 +152,10 @@ module.exports = grammar({
152
152
  $._assignment_call_callee,
153
153
  $._call_callee,
154
154
  $._assignment_call_primary,
155
+ $._simple_target_expression,
156
+ $._simple_target_primary,
157
+ $._call_target_expression,
158
+ $._call_target_primary,
155
159
  ],
156
160
 
157
161
  inline: ($) => [
@@ -209,6 +213,9 @@ module.exports = grammar({
209
213
  ],
210
214
 
211
215
  conflicts: ($) => [
216
+ [$._primary_atom, $._simple_target_primary],
217
+ [$._simple_target_primary, $.pattern],
218
+ [$._primary_atom, $._simple_target_primary, $.pattern],
212
219
  [$._call_callee, $.call_expression],
213
220
  [$.for_in_clause, $._primary_atom],
214
221
  [$._primary_atom, $.rest_pattern],
@@ -516,7 +523,14 @@ module.exports = grammar({
516
523
  choice(
517
524
  seq(
518
525
  choice(
519
- field('left', choice($._lhs_expression, $.parenthesized_expression)),
526
+ field(
527
+ 'left',
528
+ choice(
529
+ $._lhs_expression,
530
+ alias($._parenthesized_simple_target, $.parenthesized_expression),
531
+ alias($._parenthesized_call_target, $.parenthesized_expression)
532
+ )
533
+ ),
520
534
  seq(
521
535
  field('kind', 'var'),
522
536
  field('left', choice($.identifier, alias('of', $.identifier), $._destructuring_pattern)),
@@ -1239,13 +1253,43 @@ module.exports = grammar({
1239
1253
  $._destructuring_pattern
1240
1254
  ),
1241
1255
 
1256
+ _simple_target_expression: ($) => alias($._simple_target_primary, $.primary_expression),
1257
+
1258
+ _simple_target_primary: ($) =>
1259
+ choice(
1260
+ $._identifier,
1261
+ alias(sym('_await_yield_identifier'), $.identifier),
1262
+ aliasWithAsyncKeyword($._reserved_identifier, $.identifier),
1263
+ alias($._assignment_member, $.member_expression),
1264
+ alias($._assignment_subscript, $.subscript_expression),
1265
+ alias($._parenthesized_simple_target, $.parenthesized_expression)
1266
+ ),
1267
+
1268
+ _parenthesized_simple_target: ($) => seq('(', alias($._simple_target_expression, $.expression), ')'),
1269
+
1270
+ _call_target_expression: ($) => alias($._call_target_primary, $.primary_expression),
1271
+
1272
+ _call_target_primary: ($) => $._classic_call_target,
1273
+
1274
+ _parenthesized_call_target: ($) => seq('(', alias($._call_target_expression, $.expression), ')'),
1275
+
1276
+ _classic_call_target: ($) =>
1277
+ choice(
1278
+ alias($._assignment_call, $.call_expression),
1279
+ alias($._parenthesized_call_target, $.parenthesized_expression)
1280
+ ),
1281
+
1242
1282
  assignment_expression: ($) =>
1243
1283
  prec.right(
1244
1284
  'assign',
1245
1285
  seq(
1246
1286
  field(
1247
1287
  'left',
1248
- choice($.parenthesized_expression, $._lhs_expression, alias($._assignment_call, $.call_expression))
1288
+ choice(
1289
+ alias($._parenthesized_simple_target, $.parenthesized_expression),
1290
+ $._lhs_expression,
1291
+ $._classic_call_target
1292
+ )
1249
1293
  ),
1250
1294
  '=',
1251
1295
  field('right', $.expression)
@@ -1258,7 +1302,7 @@ module.exports = grammar({
1258
1302
  $.subscript_expression,
1259
1303
  aliasWithAsyncKeyword($._reserved_identifier, $.identifier),
1260
1304
  $._identifier,
1261
- $.parenthesized_expression
1305
+ alias($._parenthesized_simple_target, $.parenthesized_expression)
1262
1306
  ),
1263
1307
 
1264
1308
  augmented_assignment_expression: ($) =>
@@ -1270,10 +1314,7 @@ module.exports = grammar({
1270
1314
  field('left', $._augmented_assignment_lhs),
1271
1315
  field('operator', choice(...CLASSIC_ASSIGNMENT_OPERATORS, '&&=', '||=', '??='))
1272
1316
  ),
1273
- seq(
1274
- field('left', alias($._assignment_call, $.call_expression)),
1275
- field('operator', choice(...CLASSIC_ASSIGNMENT_OPERATORS))
1276
- )
1317
+ seq(field('left', $._classic_call_target), field('operator', choice(...CLASSIC_ASSIGNMENT_OPERATORS)))
1277
1318
  ),
1278
1319
  field('right', $.expression)
1279
1320
  )
@@ -1628,9 +1669,16 @@ module.exports = grammar({
1628
1669
  // This negative dynamic precedence ensures that during error recovery,
1629
1670
  // unfinished constructs are generally treated as literal expressions,
1630
1671
  // not patterns.
1631
- pattern: ($) => prec.dynamic(-1, choice($._lhs_expression, $.parenthesized_expression, $.rest_pattern)),
1672
+ pattern: ($) =>
1673
+ prec.dynamic(
1674
+ -1,
1675
+ choice($._lhs_expression, alias($._parenthesized_simple_target, $.parenthesized_expression), $.rest_pattern)
1676
+ ),
1632
1677
 
1633
- rest_pattern: ($) => prec.right(seq('...', choice($._lhs_expression, $.parenthesized_expression))),
1678
+ rest_pattern: ($) =>
1679
+ prec.right(
1680
+ seq('...', choice($._lhs_expression, alias($._parenthesized_simple_target, $.parenthesized_expression)))
1681
+ ),
1634
1682
 
1635
1683
  method_definition: ($) =>
1636
1684
  functionContext((async) =>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-javascript",
3
- "version": "12.0.0",
3
+ "version": "14.0.0",
4
4
  "description": "JavaScript grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -53,7 +53,7 @@
53
53
  "@vitest/browser-playwright": "5.0.5",
54
54
  "@willbooster/oxlint-config": "1.4.9",
55
55
  "@willbooster/wb": "22.29.3",
56
- "@willbooster/web-tree-sitter": "13.0.0",
56
+ "@willbooster/web-tree-sitter": "15.0.0",
57
57
  "acorn": "8.19.0",
58
58
  "acorn-jsx": "5.3.2",
59
59
  "conventional-changelog-conventionalcommits": "10.4.1",
@@ -67,7 +67,7 @@
67
67
  "wrangler": "4.151.1"
68
68
  },
69
69
  "peerDependencies": {
70
- "@willbooster/web-tree-sitter": "^13.0.0"
70
+ "@willbooster/web-tree-sitter": "^15.0.0"
71
71
  },
72
72
  "peerDependenciesMeta": {
73
73
  "@willbooster/web-tree-sitter": {
Binary file
Binary file
package/tree-sitter.json CHANGED
@@ -48,7 +48,7 @@
48
48
  }
49
49
  ],
50
50
  "metadata": {
51
- "version": "12.0.0",
51
+ "version": "14.0.0",
52
52
  "license": "MIT",
53
53
  "description": "JavaScript grammar for tree-sitter",
54
54
  "authors": [