@runware/sdk-js 1.1.9 → 1.1.10

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.
package/dist/index.d.mts CHANGED
@@ -305,6 +305,7 @@ declare class RunwareBase {
305
305
  taskUUIDs: string[];
306
306
  error: any;
307
307
  }): IImage[];
308
+ disconnect: () => void;
308
309
  connected: () => boolean;
309
310
  }
310
311
 
package/dist/index.d.ts CHANGED
@@ -305,6 +305,7 @@ declare class RunwareBase {
305
305
  taskUUIDs: string[];
306
306
  error: any;
307
307
  }): IImage[];
308
+ disconnect: () => void;
308
309
  connected: () => boolean;
309
310
  }
310
311
 
package/dist/index.js CHANGED
@@ -339,13 +339,6 @@ var getIntervalWithPromise = (callback, {
339
339
  shouldThrowError = true
340
340
  }) => {
341
341
  return new Promise((resolve, reject) => {
342
- let intervalId = setInterval(async () => {
343
- const shouldClear = callback({ resolve, reject, intervalId });
344
- if (shouldClear) {
345
- clearInterval(intervalId);
346
- intervalId = 0;
347
- }
348
- }, POLLING_INTERVAL);
349
342
  const timeoutId = setTimeout(() => {
350
343
  if (intervalId) {
351
344
  clearInterval(intervalId);
@@ -356,6 +349,13 @@ var getIntervalWithPromise = (callback, {
356
349
  }
357
350
  clearTimeout(timeoutId);
358
351
  }, timeOutDuration);
352
+ let intervalId = setInterval(async () => {
353
+ const shouldClear = callback({ resolve, reject, intervalId });
354
+ if (shouldClear) {
355
+ clearInterval(intervalId);
356
+ clearTimeout(timeoutId);
357
+ }
358
+ }, POLLING_INTERVAL);
359
359
  });
360
360
  };
361
361
  var fileToBase64 = (file) => new Promise((resolve) => {
@@ -767,6 +767,11 @@ var RunwareBase = class {
767
767
  return null;
768
768
  return (_b = this._globalMessages[taskUUID]) == null ? void 0 : _b[0];
769
769
  };
770
+ this.disconnect = () => {
771
+ var _a, _b, _c, _d;
772
+ (_b = (_a = this._ws) == null ? void 0 : _a.terminate) == null ? void 0 : _b.call(_a);
773
+ (_d = (_c = this._ws) == null ? void 0 : _c.close) == null ? void 0 : _d.call(_c);
774
+ };
770
775
  this.connected = () => this.isWebsocketReadyState() && !!this._connectionSessionUUID;
771
776
  this._apiKey = apiKey;
772
777
  this._url = url;
@@ -1068,6 +1073,7 @@ var RunwareBase = class {
1068
1073
  numberResults,
1069
1074
  lis
1070
1075
  });
1076
+ lis.destroy();
1071
1077
  return promise;
1072
1078
  },
1073
1079
  {
@@ -1258,7 +1264,9 @@ var RunwareServer = class extends RunwareBase {
1258
1264
  });
1259
1265
  this._ws.on("error", () => {
1260
1266
  });
1261
- this._ws.on("close", () => this.handleClose());
1267
+ this._ws.on("close", () => {
1268
+ this.handleClose();
1269
+ });
1262
1270
  this._ws.on("open", () => {
1263
1271
  if (this._reconnectingIntervalId) {
1264
1272
  clearInterval(this._reconnectingIntervalId);
@@ -1311,7 +1319,6 @@ var RunwareServer = class extends RunwareBase {
1311
1319
  if (this._reconnectingIntervalId) {
1312
1320
  clearInterval(this._reconnectingIntervalId);
1313
1321
  }
1314
- this._reconnectingIntervalId = setInterval(() => this.connect(), 1e3);
1315
1322
  }
1316
1323
  heartBeat() {
1317
1324
  clearTimeout(this._pingTimeout);
package/dist/index.mjs CHANGED
@@ -318,13 +318,6 @@ var getIntervalWithPromise = (callback, {
318
318
  shouldThrowError = true
319
319
  }) => {
320
320
  return new Promise((resolve, reject) => {
321
- let intervalId = setInterval(async () => {
322
- const shouldClear = callback({ resolve, reject, intervalId });
323
- if (shouldClear) {
324
- clearInterval(intervalId);
325
- intervalId = 0;
326
- }
327
- }, POLLING_INTERVAL);
328
321
  const timeoutId = setTimeout(() => {
329
322
  if (intervalId) {
330
323
  clearInterval(intervalId);
@@ -335,6 +328,13 @@ var getIntervalWithPromise = (callback, {
335
328
  }
336
329
  clearTimeout(timeoutId);
337
330
  }, timeOutDuration);
331
+ let intervalId = setInterval(async () => {
332
+ const shouldClear = callback({ resolve, reject, intervalId });
333
+ if (shouldClear) {
334
+ clearInterval(intervalId);
335
+ clearTimeout(timeoutId);
336
+ }
337
+ }, POLLING_INTERVAL);
338
338
  });
339
339
  };
340
340
  var fileToBase64 = (file) => new Promise((resolve) => {
@@ -746,6 +746,11 @@ var RunwareBase = class {
746
746
  return null;
747
747
  return (_b = this._globalMessages[taskUUID]) == null ? void 0 : _b[0];
748
748
  };
749
+ this.disconnect = () => {
750
+ var _a, _b, _c, _d;
751
+ (_b = (_a = this._ws) == null ? void 0 : _a.terminate) == null ? void 0 : _b.call(_a);
752
+ (_d = (_c = this._ws) == null ? void 0 : _c.close) == null ? void 0 : _d.call(_c);
753
+ };
749
754
  this.connected = () => this.isWebsocketReadyState() && !!this._connectionSessionUUID;
750
755
  this._apiKey = apiKey;
751
756
  this._url = url;
@@ -1047,6 +1052,7 @@ var RunwareBase = class {
1047
1052
  numberResults,
1048
1053
  lis
1049
1054
  });
1055
+ lis.destroy();
1050
1056
  return promise;
1051
1057
  },
1052
1058
  {
@@ -1237,7 +1243,9 @@ var RunwareServer = class extends RunwareBase {
1237
1243
  });
1238
1244
  this._ws.on("error", () => {
1239
1245
  });
1240
- this._ws.on("close", () => this.handleClose());
1246
+ this._ws.on("close", () => {
1247
+ this.handleClose();
1248
+ });
1241
1249
  this._ws.on("open", () => {
1242
1250
  if (this._reconnectingIntervalId) {
1243
1251
  clearInterval(this._reconnectingIntervalId);
@@ -1290,7 +1298,6 @@ var RunwareServer = class extends RunwareBase {
1290
1298
  if (this._reconnectingIntervalId) {
1291
1299
  clearInterval(this._reconnectingIntervalId);
1292
1300
  }
1293
- this._reconnectingIntervalId = setInterval(() => this.connect(), 1e3);
1294
1301
  }
1295
1302
  heartBeat() {
1296
1303
  clearTimeout(this._pingTimeout);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runware/sdk-js",
3
- "version": "1.1.9",
3
+ "version": "1.1.10",
4
4
  "description": "The SDK is used to run image inference with the Runware API, powered by the RunWare inference platform. It can be used to generate imaged with text-to-image and image-to-image. It also allows the use of an existing gallery of models or selecting any model or LoRA from the CivitAI gallery. The API also supports upscaling, background removal, inpainting and outpainting, and a series of other ControlNet models.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
package/readme.md CHANGED
@@ -364,7 +364,13 @@ return interface IControlNetImage {
364
364
 
365
365
  ## Changelog
366
366
 
367
- ### - v1.1.8
367
+ ### - v1.1.10
368
+
369
+ **Added or Changed**
370
+
371
+ - Add disconnect method
372
+
373
+ ### - v1.1.9
368
374
 
369
375
  **Added or Changed**
370
376