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