@willbooster/web-tree-sitter 1.5.0 → 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.
@@ -3819,6 +3819,15 @@ __name(checkModule, "checkModule");
3819
3819
  // src/parser.ts
3820
3820
  var TRANSFER_BUFFER;
3821
3821
  var LANGUAGE_VERSION;
3822
+ function assertSupportedLanguage(language) {
3823
+ const version = C._ts_language_abi_version(language[0]);
3824
+ if (version !== LANGUAGE_VERSION) {
3825
+ throw new Error(
3826
+ `Incompatible language version 0x${(version >>> 0).toString(16)}. Expected 0x${LANGUAGE_VERSION.toString(16)}.`
3827
+ );
3828
+ }
3829
+ }
3830
+ __name(assertSupportedLanguage, "assertSupportedLanguage");
3822
3831
  var MIN_COMPATIBLE_VERSION;
3823
3832
  var finalizer4 = newFinalizer((addresses) => {
3824
3833
  C._ts_parser_delete(addresses[0]);
@@ -3881,8 +3890,8 @@ var Parser = class {
3881
3890
  * If the language was not successfully assigned, an error will be thrown.
3882
3891
  * This happens if the language was generated with an incompatible
3883
3892
  * version of the Tree-sitter CLI. Check the language's version using
3884
- * {@link Language#version} and compare it to this library's
3885
- * {@link LANGUAGE_VERSION} and {@link MIN_COMPATIBLE_VERSION} constants.
3893
+ * {@link Language#abiVersion} and compare it to this library's
3894
+ * {@link LANGUAGE_VERSION} constant.
3886
3895
  */
3887
3896
  setLanguage(language) {
3888
3897
  let address;
@@ -3891,12 +3900,7 @@ var Parser = class {
3891
3900
  this.language = null;
3892
3901
  } else if (language.constructor === Language) {
3893
3902
  address = language[0];
3894
- const version = C._ts_language_abi_version(address);
3895
- if (version < MIN_COMPATIBLE_VERSION || LANGUAGE_VERSION < version) {
3896
- throw new Error(
3897
- `Incompatible language version ${version}. Compatibility range ${MIN_COMPATIBLE_VERSION} through ${LANGUAGE_VERSION}.`
3898
- );
3899
- }
3903
+ assertSupportedLanguage(language);
3900
3904
  this.language = language;
3901
3905
  } else {
3902
3906
  throw new Error("Argument must be a Language");
@@ -4294,6 +4298,7 @@ var Query = class {
4294
4298
  * @link {@see https://tree-sitter.github.io/tree-sitter/using-parsers/queries}
4295
4299
  */
4296
4300
  constructor(language, source) {
4301
+ assertSupportedLanguage(language);
4297
4302
  const sourceLength = C.lengthBytesUTF8(source);
4298
4303
  const sourceAddress = C._malloc(sourceLength + 1);
4299
4304
  C.stringToUTF8(source, sourceAddress, sourceLength + 1);