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