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