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