@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/index.js
CHANGED
@@ -1066,36 +1066,45 @@ var _FuelGraphqlSubscriber = class {
|
|
1066
1066
|
});
|
1067
1067
|
this.stream = response.body.getReader();
|
1068
1068
|
}
|
1069
|
+
events = [];
|
1070
|
+
parsingLeftover = "";
|
1069
1071
|
async next() {
|
1070
1072
|
if (!this.stream) {
|
1071
1073
|
await this.setStream();
|
1072
1074
|
}
|
1073
1075
|
while (true) {
|
1076
|
+
if (this.events.length > 0) {
|
1077
|
+
const { data, errors } = this.events.shift();
|
1078
|
+
if (Array.isArray(errors)) {
|
1079
|
+
throw new import_errors.FuelError(
|
1080
|
+
import_errors.FuelError.CODES.INVALID_REQUEST,
|
1081
|
+
errors.map((err) => err.message).join("\n\n")
|
1082
|
+
);
|
1083
|
+
}
|
1084
|
+
return { value: data, done: false };
|
1085
|
+
}
|
1074
1086
|
const { value, done } = await this.stream.read();
|
1075
1087
|
if (done) {
|
1076
1088
|
return { value, done };
|
1077
1089
|
}
|
1078
|
-
const
|
1079
|
-
if (
|
1090
|
+
const decoded = _FuelGraphqlSubscriber.textDecoder.decode(value).replace(":keep-alive-text\n\n", "");
|
1091
|
+
if (decoded === "") {
|
1080
1092
|
continue;
|
1081
1093
|
}
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
);
|
1097
|
-
}
|
1098
|
-
return { value: data, done: false };
|
1094
|
+
const text = `${this.parsingLeftover}${decoded}`;
|
1095
|
+
const regex = /data:.*\n\n/g;
|
1096
|
+
const matches = [...text.matchAll(regex)].flatMap((match) => match);
|
1097
|
+
matches.forEach((match) => {
|
1098
|
+
try {
|
1099
|
+
this.events.push(JSON.parse(match.replace(/^data:/, "")));
|
1100
|
+
} catch (e) {
|
1101
|
+
throw new import_errors.FuelError(
|
1102
|
+
import_errors.ErrorCode.STREAM_PARSING_ERROR,
|
1103
|
+
`Error while parsing stream data response: ${text}`
|
1104
|
+
);
|
1105
|
+
}
|
1106
|
+
});
|
1107
|
+
this.parsingLeftover = text.replace(matches.join(), "");
|
1099
1108
|
}
|
1100
1109
|
}
|
1101
1110
|
/**
|