@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
@@ -12,6 +12,8 @@ export declare class FuelGraphqlSubscriber implements AsyncIterator<unknown> {
|
|
12
12
|
private static textDecoder;
|
13
13
|
constructor(options: FuelGraphQLSubscriberOptions);
|
14
14
|
private setStream;
|
15
|
+
private events;
|
16
|
+
private parsingLeftover;
|
15
17
|
next(): Promise<IteratorResult<unknown, unknown>>;
|
16
18
|
/**
|
17
19
|
* Gets called when `break` is called in a `for-await-of` loop.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fuel-graphql-subscriber.d.ts","sourceRoot":"","sources":["../../src/providers/fuel-graphql-subscriber.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG5C,KAAK,4BAA4B,GAAG;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,YAAY,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,OAAO,EAAE,OAAO,KAAK,CAAC;CACvB,CAAC;AAEF,qBAAa,qBAAsB,YAAW,aAAa,CAAC,OAAO,CAAC;IAI/C,OAAO,CAAC,OAAO;IAHlC,OAAO,CAAC,MAAM,CAA2C;IACzD,OAAO,CAAC,MAAM,CAAC,WAAW,CAAqB;gBAEpB,OAAO,EAAE,4BAA4B;YAElD,SAAS;
|
1
|
+
{"version":3,"file":"fuel-graphql-subscriber.d.ts","sourceRoot":"","sources":["../../src/providers/fuel-graphql-subscriber.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG5C,KAAK,4BAA4B,GAAG;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,YAAY,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,OAAO,EAAE,OAAO,KAAK,CAAC;CACvB,CAAC;AAEF,qBAAa,qBAAsB,YAAW,aAAa,CAAC,OAAO,CAAC;IAI/C,OAAO,CAAC,OAAO;IAHlC,OAAO,CAAC,MAAM,CAA2C;IACzD,OAAO,CAAC,MAAM,CAAC,WAAW,CAAqB;gBAEpB,OAAO,EAAE,4BAA4B;YAElD,SAAS;IAmBvB,OAAO,CAAC,MAAM,CAAgE;IAC9E,OAAO,CAAC,eAAe,CAAM;IAEvB,IAAI,IAAI,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IA4DvD;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAM3D,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC;CAGrE"}
|
@@ -42223,36 +42223,45 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42223
42223
|
});
|
42224
42224
|
this.stream = response.body.getReader();
|
42225
42225
|
}
|
42226
|
+
events = [];
|
42227
|
+
parsingLeftover = "";
|
42226
42228
|
async next() {
|
42227
42229
|
if (!this.stream) {
|
42228
42230
|
await this.setStream();
|
42229
42231
|
}
|
42230
42232
|
while (true) {
|
42233
|
+
if (this.events.length > 0) {
|
42234
|
+
const { data, errors } = this.events.shift();
|
42235
|
+
if (Array.isArray(errors)) {
|
42236
|
+
throw new FuelError(
|
42237
|
+
FuelError.CODES.INVALID_REQUEST,
|
42238
|
+
errors.map((err) => err.message).join("\n\n")
|
42239
|
+
);
|
42240
|
+
}
|
42241
|
+
return { value: data, done: false };
|
42242
|
+
}
|
42231
42243
|
const { value, done } = await this.stream.read();
|
42232
42244
|
if (done) {
|
42233
42245
|
return { value, done };
|
42234
42246
|
}
|
42235
|
-
const
|
42236
|
-
if (
|
42247
|
+
const decoded = _FuelGraphqlSubscriber.textDecoder.decode(value).replace(":keep-alive-text\n\n", "");
|
42248
|
+
if (decoded === "") {
|
42237
42249
|
continue;
|
42238
42250
|
}
|
42239
|
-
|
42240
|
-
|
42241
|
-
|
42242
|
-
|
42243
|
-
|
42244
|
-
|
42245
|
-
|
42246
|
-
|
42247
|
-
|
42248
|
-
|
42249
|
-
|
42250
|
-
|
42251
|
-
|
42252
|
-
|
42253
|
-
);
|
42254
|
-
}
|
42255
|
-
return { value: data, done: false };
|
42251
|
+
const text = `${this.parsingLeftover}${decoded}`;
|
42252
|
+
const regex = /data:.*\n\n/g;
|
42253
|
+
const matches = [...text.matchAll(regex)].flatMap((match) => match);
|
42254
|
+
matches.forEach((match) => {
|
42255
|
+
try {
|
42256
|
+
this.events.push(JSON.parse(match.replace(/^data:/, "")));
|
42257
|
+
} catch (e) {
|
42258
|
+
throw new FuelError(
|
42259
|
+
ErrorCode.STREAM_PARSING_ERROR,
|
42260
|
+
`Error while parsing stream data response: ${text}`
|
42261
|
+
);
|
42262
|
+
}
|
42263
|
+
});
|
42264
|
+
this.parsingLeftover = text.replace(matches.join(), "");
|
42256
42265
|
}
|
42257
42266
|
}
|
42258
42267
|
/**
|