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