@fuel-ts/account 0.80.0 → 0.82.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.
- package/dist/index.global.js +47 -22
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +28 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -19
- package/dist/index.mjs.map +1 -1
- package/dist/providers/fuel-graphql-subscriber.d.ts +2 -0
- package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
- package/dist/test-utils.global.js +47 -22
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +28 -19
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +28 -19
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +21 -26
package/dist/test-utils.js
CHANGED
@@ -944,36 +944,45 @@ var _FuelGraphqlSubscriber = class {
|
|
944
944
|
});
|
945
945
|
this.stream = response.body.getReader();
|
946
946
|
}
|
947
|
+
events = [];
|
948
|
+
parsingLeftover = "";
|
947
949
|
async next() {
|
948
950
|
if (!this.stream) {
|
949
951
|
await this.setStream();
|
950
952
|
}
|
951
953
|
while (true) {
|
954
|
+
if (this.events.length > 0) {
|
955
|
+
const { data, errors } = this.events.shift();
|
956
|
+
if (Array.isArray(errors)) {
|
957
|
+
throw new import_errors.FuelError(
|
958
|
+
import_errors.FuelError.CODES.INVALID_REQUEST,
|
959
|
+
errors.map((err) => err.message).join("\n\n")
|
960
|
+
);
|
961
|
+
}
|
962
|
+
return { value: data, done: false };
|
963
|
+
}
|
952
964
|
const { value, done } = await this.stream.read();
|
953
965
|
if (done) {
|
954
966
|
return { value, done };
|
955
967
|
}
|
956
|
-
const
|
957
|
-
if (
|
968
|
+
const decoded = _FuelGraphqlSubscriber.textDecoder.decode(value).replace(":keep-alive-text\n\n", "");
|
969
|
+
if (decoded === "") {
|
958
970
|
continue;
|
959
971
|
}
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
);
|
975
|
-
}
|
976
|
-
return { value: data, done: false };
|
972
|
+
const text = `${this.parsingLeftover}${decoded}`;
|
973
|
+
const regex = /data:.*\n\n/g;
|
974
|
+
const matches = [...text.matchAll(regex)].flatMap((match) => match);
|
975
|
+
matches.forEach((match) => {
|
976
|
+
try {
|
977
|
+
this.events.push(JSON.parse(match.replace(/^data:/, "")));
|
978
|
+
} catch (e) {
|
979
|
+
throw new import_errors.FuelError(
|
980
|
+
import_errors.ErrorCode.STREAM_PARSING_ERROR,
|
981
|
+
`Error while parsing stream data response: ${text}`
|
982
|
+
);
|
983
|
+
}
|
984
|
+
});
|
985
|
+
this.parsingLeftover = text.replace(matches.join(), "");
|
977
986
|
}
|
978
987
|
}
|
979
988
|
/**
|