@willbooster/web-tree-sitter 1.5.1 → 2.0.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/web-tree-sitter",
3
- "version": "1.5.1",
3
+ "version": "2.0.1",
4
4
  "description": "Tree-sitter bindings for the web",
5
5
  "repository": {
6
6
  "type": "git",
@@ -3277,6 +3277,15 @@ __name(checkModule, "checkModule");
3277
3277
  // src/parser.ts
3278
3278
  var TRANSFER_BUFFER;
3279
3279
  var LANGUAGE_VERSION;
3280
+ function assertSupportedLanguage(language) {
3281
+ const version = C._ts_language_abi_version(language[0]);
3282
+ if (version !== LANGUAGE_VERSION) {
3283
+ throw new Error(
3284
+ `Incompatible language version 0x${(version >>> 0).toString(16)}. Expected 0x${LANGUAGE_VERSION.toString(16)}.`
3285
+ );
3286
+ }
3287
+ }
3288
+ __name(assertSupportedLanguage, "assertSupportedLanguage");
3280
3289
  var MIN_COMPATIBLE_VERSION;
3281
3290
  var finalizer4 = newFinalizer((addresses) => {
3282
3291
  C._ts_parser_delete(addresses[0]);
@@ -3339,8 +3348,8 @@ var Parser = class {
3339
3348
  * If the language was not successfully assigned, an error will be thrown.
3340
3349
  * This happens if the language was generated with an incompatible
3341
3350
  * version of the Tree-sitter CLI. Check the language's version using
3342
- * {@link Language#version} and compare it to this library's
3343
- * {@link LANGUAGE_VERSION} and {@link MIN_COMPATIBLE_VERSION} constants.
3351
+ * {@link Language#abiVersion} and compare it to this library's
3352
+ * {@link LANGUAGE_VERSION} constant.
3344
3353
  */
3345
3354
  setLanguage(language) {
3346
3355
  let address;
@@ -3349,12 +3358,7 @@ var Parser = class {
3349
3358
  this.language = null;
3350
3359
  } else if (language.constructor === Language) {
3351
3360
  address = language[0];
3352
- const version = C._ts_language_abi_version(address);
3353
- if (version < MIN_COMPATIBLE_VERSION || LANGUAGE_VERSION < version) {
3354
- throw new Error(
3355
- `Incompatible language version ${version}. Compatibility range ${MIN_COMPATIBLE_VERSION} through ${LANGUAGE_VERSION}.`
3356
- );
3357
- }
3361
+ assertSupportedLanguage(language);
3358
3362
  this.language = language;
3359
3363
  } else {
3360
3364
  throw new Error("Argument must be a Language");
@@ -3752,6 +3756,7 @@ var Query = class {
3752
3756
  * @link {@see https://tree-sitter.github.io/tree-sitter/using-parsers/queries}
3753
3757
  */
3754
3758
  constructor(language, source) {
3759
+ assertSupportedLanguage(language);
3755
3760
  const sourceLength = C.lengthBytesUTF8(source);
3756
3761
  const sourceAddress = C._malloc(sourceLength + 1);
3757
3762
  C.stringToUTF8(source, sourceAddress, sourceLength + 1);