@fuel-ts/account 0.80.0 → 0.81.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.

Potentially problematic release.


This version of @fuel-ts/account might be problematic. Click here for more details.

@@ -28954,7 +28954,7 @@ spurious results.`);
28954
28954
  return {
28955
28955
  FORC: "0.49.3",
28956
28956
  FUEL_CORE: "0.22.1",
28957
- FUELS: "0.80.0"
28957
+ FUELS: "0.81.0"
28958
28958
  };
28959
28959
  }
28960
28960
  function parseVersion(version2) {
@@ -38761,36 +38761,45 @@ ${MessageCoinFragmentFragmentDoc}`;
38761
38761
  });
38762
38762
  this.stream = response.body.getReader();
38763
38763
  }
38764
+ events = [];
38765
+ parsingLeftover = "";
38764
38766
  async next() {
38765
38767
  if (!this.stream) {
38766
38768
  await this.setStream();
38767
38769
  }
38768
38770
  while (true) {
38771
+ if (this.events.length > 0) {
38772
+ const { data, errors } = this.events.shift();
38773
+ if (Array.isArray(errors)) {
38774
+ throw new FuelError(
38775
+ FuelError.CODES.INVALID_REQUEST,
38776
+ errors.map((err) => err.message).join("\n\n")
38777
+ );
38778
+ }
38779
+ return { value: data, done: false };
38780
+ }
38769
38781
  const { value, done } = await this.stream.read();
38770
38782
  if (done) {
38771
38783
  return { value, done };
38772
38784
  }
38773
- const text = _FuelGraphqlSubscriber.textDecoder.decode(value);
38774
- if (!text.startsWith("data:")) {
38785
+ const decoded = _FuelGraphqlSubscriber.textDecoder.decode(value).replace(":keep-alive-text\n\n", "");
38786
+ if (decoded === "") {
38775
38787
  continue;
38776
38788
  }
38777
- let data;
38778
- let errors;
38779
- try {
38780
- ({ data, errors } = JSON.parse(text.replace(/^data:/, "")));
38781
- } catch (e) {
38782
- throw new FuelError(
38783
- ErrorCode.STREAM_PARSING_ERROR,
38784
- `Error while parsing stream data response: ${text}`
38785
- );
38786
- }
38787
- if (Array.isArray(errors)) {
38788
- throw new FuelError(
38789
- FuelError.CODES.INVALID_REQUEST,
38790
- errors.map((err) => err.message).join("\n\n")
38791
- );
38792
- }
38793
- return { value: data, done: false };
38789
+ const text = `${this.parsingLeftover}${decoded}`;
38790
+ const regex = /data:.*\n\n/g;
38791
+ const matches = [...text.matchAll(regex)].flatMap((match) => match);
38792
+ matches.forEach((match) => {
38793
+ try {
38794
+ this.events.push(JSON.parse(match.replace(/^data:/, "")));
38795
+ } catch (e) {
38796
+ throw new FuelError(
38797
+ ErrorCode.STREAM_PARSING_ERROR,
38798
+ `Error while parsing stream data response: ${text}`
38799
+ );
38800
+ }
38801
+ });
38802
+ this.parsingLeftover = text.replace(matches.join(), "");
38794
38803
  }
38795
38804
  }
38796
38805
  /**