@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.
- package/dist/index.global.js +29 -20
- 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 +29 -20
- 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.mjs
CHANGED
@@ -911,36 +911,45 @@ var _FuelGraphqlSubscriber = class {
|
|
911
911
|
});
|
912
912
|
this.stream = response.body.getReader();
|
913
913
|
}
|
914
|
+
events = [];
|
915
|
+
parsingLeftover = "";
|
914
916
|
async next() {
|
915
917
|
if (!this.stream) {
|
916
918
|
await this.setStream();
|
917
919
|
}
|
918
920
|
while (true) {
|
921
|
+
if (this.events.length > 0) {
|
922
|
+
const { data, errors } = this.events.shift();
|
923
|
+
if (Array.isArray(errors)) {
|
924
|
+
throw new FuelError(
|
925
|
+
FuelError.CODES.INVALID_REQUEST,
|
926
|
+
errors.map((err) => err.message).join("\n\n")
|
927
|
+
);
|
928
|
+
}
|
929
|
+
return { value: data, done: false };
|
930
|
+
}
|
919
931
|
const { value, done } = await this.stream.read();
|
920
932
|
if (done) {
|
921
933
|
return { value, done };
|
922
934
|
}
|
923
|
-
const
|
924
|
-
if (
|
935
|
+
const decoded = _FuelGraphqlSubscriber.textDecoder.decode(value).replace(":keep-alive-text\n\n", "");
|
936
|
+
if (decoded === "") {
|
925
937
|
continue;
|
926
938
|
}
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
);
|
942
|
-
}
|
943
|
-
return { value: data, done: false };
|
939
|
+
const text = `${this.parsingLeftover}${decoded}`;
|
940
|
+
const regex = /data:.*\n\n/g;
|
941
|
+
const matches = [...text.matchAll(regex)].flatMap((match) => match);
|
942
|
+
matches.forEach((match) => {
|
943
|
+
try {
|
944
|
+
this.events.push(JSON.parse(match.replace(/^data:/, "")));
|
945
|
+
} catch (e) {
|
946
|
+
throw new FuelError(
|
947
|
+
ErrorCode.STREAM_PARSING_ERROR,
|
948
|
+
`Error while parsing stream data response: ${text}`
|
949
|
+
);
|
950
|
+
}
|
951
|
+
});
|
952
|
+
this.parsingLeftover = text.replace(matches.join(), "");
|
944
953
|
}
|
945
954
|
}
|
946
955
|
/**
|