@runware/sdk-js 1.1.8 → 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;
@@ -883,14 +888,15 @@ var RunwareBase = class {
883
888
  let images = (_a = m == null ? void 0 : m[taskUUID]) == null ? void 0 : _a.filter(
884
889
  (img) => img.taskUUID === taskUUID
885
890
  );
886
- onPartialImages == null ? void 0 : onPartialImages(images, (m == null ? void 0 : m.error) && m);
887
891
  if (m.error) {
892
+ onPartialImages == null ? void 0 : onPartialImages(images, (m == null ? void 0 : m.error) && m);
888
893
  this._globalError = m;
889
894
  } else {
890
895
  images = images.map((image) => __spreadProps(__spreadValues({}, image), {
891
896
  positivePrompt,
892
897
  negativePrompt
893
898
  }));
899
+ onPartialImages == null ? void 0 : onPartialImages(images, (m == null ? void 0 : m.error) && m);
894
900
  if (this._sdkType === "CLIENT" /* CLIENT */) {
895
901
  this._globalImages = [
896
902
  ...this._globalImages,
@@ -1067,6 +1073,7 @@ var RunwareBase = class {
1067
1073
  numberResults,
1068
1074
  lis
1069
1075
  });
1076
+ lis.destroy();
1070
1077
  return promise;
1071
1078
  },
1072
1079
  {
@@ -1257,7 +1264,9 @@ var RunwareServer = class extends RunwareBase {
1257
1264
  });
1258
1265
  this._ws.on("error", () => {
1259
1266
  });
1260
- this._ws.on("close", () => this.handleClose());
1267
+ this._ws.on("close", () => {
1268
+ this.handleClose();
1269
+ });
1261
1270
  this._ws.on("open", () => {
1262
1271
  if (this._reconnectingIntervalId) {
1263
1272
  clearInterval(this._reconnectingIntervalId);
@@ -1310,7 +1319,6 @@ var RunwareServer = class extends RunwareBase {
1310
1319
  if (this._reconnectingIntervalId) {
1311
1320
  clearInterval(this._reconnectingIntervalId);
1312
1321
  }
1313
- this._reconnectingIntervalId = setInterval(() => this.connect(), 1e3);
1314
1322
  }
1315
1323
  heartBeat() {
1316
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;
@@ -862,14 +867,15 @@ var RunwareBase = class {
862
867
  let images = (_a = m == null ? void 0 : m[taskUUID]) == null ? void 0 : _a.filter(
863
868
  (img) => img.taskUUID === taskUUID
864
869
  );
865
- onPartialImages == null ? void 0 : onPartialImages(images, (m == null ? void 0 : m.error) && m);
866
870
  if (m.error) {
871
+ onPartialImages == null ? void 0 : onPartialImages(images, (m == null ? void 0 : m.error) && m);
867
872
  this._globalError = m;
868
873
  } else {
869
874
  images = images.map((image) => __spreadProps(__spreadValues({}, image), {
870
875
  positivePrompt,
871
876
  negativePrompt
872
877
  }));
878
+ onPartialImages == null ? void 0 : onPartialImages(images, (m == null ? void 0 : m.error) && m);
873
879
  if (this._sdkType === "CLIENT" /* CLIENT */) {
874
880
  this._globalImages = [
875
881
  ...this._globalImages,
@@ -1046,6 +1052,7 @@ var RunwareBase = class {
1046
1052
  numberResults,
1047
1053
  lis
1048
1054
  });
1055
+ lis.destroy();
1049
1056
  return promise;
1050
1057
  },
1051
1058
  {
@@ -1236,7 +1243,9 @@ var RunwareServer = class extends RunwareBase {
1236
1243
  });
1237
1244
  this._ws.on("error", () => {
1238
1245
  });
1239
- this._ws.on("close", () => this.handleClose());
1246
+ this._ws.on("close", () => {
1247
+ this.handleClose();
1248
+ });
1240
1249
  this._ws.on("open", () => {
1241
1250
  if (this._reconnectingIntervalId) {
1242
1251
  clearInterval(this._reconnectingIntervalId);
@@ -1289,7 +1298,6 @@ var RunwareServer = class extends RunwareBase {
1289
1298
  if (this._reconnectingIntervalId) {
1290
1299
  clearInterval(this._reconnectingIntervalId);
1291
1300
  }
1292
- this._reconnectingIntervalId = setInterval(() => this.connect(), 1e3);
1293
1301
  }
1294
1302
  heartBeat() {
1295
1303
  clearTimeout(this._pingTimeout);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runware/sdk-js",
3
- "version": "1.1.8",
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,6 +364,18 @@ return interface IControlNetImage {
364
364
 
365
365
  ## Changelog
366
366
 
367
+ ### - v1.1.10
368
+
369
+ **Added or Changed**
370
+
371
+ - Add disconnect method
372
+
373
+ ### - v1.1.9
374
+
375
+ **Added or Changed**
376
+
377
+ - Fix partial images not including prompt
378
+
367
379
  ### - v1.1.8
368
380
 
369
381
  **Added or Changed**