@willbooster/web-tree-sitter 1.5.1 → 2.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.
@@ -3251,6 +3251,15 @@ __name(checkModule, "checkModule");
3251
3251
  // src/parser.ts
3252
3252
  var TRANSFER_BUFFER;
3253
3253
  var LANGUAGE_VERSION;
3254
+ function assertSupportedLanguage(language) {
3255
+ const version = C._ts_language_abi_version(language[0]);
3256
+ if (version !== LANGUAGE_VERSION) {
3257
+ throw new Error(
3258
+ `Incompatible language version 0x${(version >>> 0).toString(16)}. Expected 0x${LANGUAGE_VERSION.toString(16)}.`
3259
+ );
3260
+ }
3261
+ }
3262
+ __name(assertSupportedLanguage, "assertSupportedLanguage");
3254
3263
  var MIN_COMPATIBLE_VERSION;
3255
3264
  var finalizer4 = newFinalizer((addresses) => {
3256
3265
  C._ts_parser_delete(addresses[0]);
@@ -3313,8 +3322,8 @@ var Parser = class {
3313
3322
  * If the language was not successfully assigned, an error will be thrown.
3314
3323
  * This happens if the language was generated with an incompatible
3315
3324
  * version of the Tree-sitter CLI. Check the language's version using
3316
- * {@link Language#version} and compare it to this library's
3317
- * {@link LANGUAGE_VERSION} and {@link MIN_COMPATIBLE_VERSION} constants.
3325
+ * {@link Language#abiVersion} and compare it to this library's
3326
+ * {@link LANGUAGE_VERSION} constant.
3318
3327
  */
3319
3328
  setLanguage(language) {
3320
3329
  let address;
@@ -3323,12 +3332,7 @@ var Parser = class {
3323
3332
  this.language = null;
3324
3333
  } else if (language.constructor === Language) {
3325
3334
  address = language[0];
3326
- const version = C._ts_language_abi_version(address);
3327
- if (version < MIN_COMPATIBLE_VERSION || LANGUAGE_VERSION < version) {
3328
- throw new Error(
3329
- `Incompatible language version ${version}. Compatibility range ${MIN_COMPATIBLE_VERSION} through ${LANGUAGE_VERSION}.`
3330
- );
3331
- }
3335
+ assertSupportedLanguage(language);
3332
3336
  this.language = language;
3333
3337
  } else {
3334
3338
  throw new Error("Argument must be a Language");
@@ -3726,6 +3730,7 @@ var Query = class {
3726
3730
  * @link {@see https://tree-sitter.github.io/tree-sitter/using-parsers/queries}
3727
3731
  */
3728
3732
  constructor(language, source) {
3733
+ assertSupportedLanguage(language);
3729
3734
  const sourceLength = C.lengthBytesUTF8(source);
3730
3735
  const sourceAddress = C._malloc(sourceLength + 1);
3731
3736
  C.stringToUTF8(source, sourceAddress, sourceLength + 1);