@runware/sdk-js 1.1.15 → 1.1.16
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 +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +27 -3
- package/dist/index.mjs +27 -3
- package/package.json +1 -1
- package/readme.md +6 -0
package/dist/index.d.mts
CHANGED
|
@@ -20,6 +20,7 @@ declare enum ETaskType {
|
|
|
20
20
|
type RunwareBaseType = {
|
|
21
21
|
apiKey: string;
|
|
22
22
|
url?: string;
|
|
23
|
+
shouldReconnect?: boolean;
|
|
23
24
|
};
|
|
24
25
|
type IOutputType = "base64Data" | "dataURI" | "URL";
|
|
25
26
|
type IOutputFormat = "JPG" | "PNG" | "WEBP";
|
|
@@ -253,7 +254,8 @@ declare class RunwareBase {
|
|
|
253
254
|
_connectionSessionUUID: string | undefined;
|
|
254
255
|
_invalidAPIkey: string | undefined;
|
|
255
256
|
_sdkType: SdkType;
|
|
256
|
-
|
|
257
|
+
_shouldReconnect: boolean;
|
|
258
|
+
constructor({ apiKey, url, shouldReconnect, }: RunwareBaseType);
|
|
257
259
|
protected isWebsocketReadyState: () => boolean;
|
|
258
260
|
protected addListener({ lis, groupKey, taskUUID, }: {
|
|
259
261
|
lis: (v: any) => any;
|
|
@@ -292,10 +294,11 @@ declare class RunwareServer extends RunwareBase {
|
|
|
292
294
|
_reconnectingIntervalId: null | any;
|
|
293
295
|
_pingTimeout: any;
|
|
294
296
|
_pongListener: any;
|
|
295
|
-
constructor({ apiKey, url }: RunwareBaseType);
|
|
297
|
+
constructor({ apiKey, url, shouldReconnect }: RunwareBaseType);
|
|
296
298
|
protected connect(): Promise<void>;
|
|
297
299
|
protected send: (msg: Object) => void;
|
|
298
300
|
protected handleClose(): void;
|
|
301
|
+
protected resetConnection: () => void;
|
|
299
302
|
protected heartBeat(): void;
|
|
300
303
|
}
|
|
301
304
|
|
package/dist/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ declare enum ETaskType {
|
|
|
20
20
|
type RunwareBaseType = {
|
|
21
21
|
apiKey: string;
|
|
22
22
|
url?: string;
|
|
23
|
+
shouldReconnect?: boolean;
|
|
23
24
|
};
|
|
24
25
|
type IOutputType = "base64Data" | "dataURI" | "URL";
|
|
25
26
|
type IOutputFormat = "JPG" | "PNG" | "WEBP";
|
|
@@ -253,7 +254,8 @@ declare class RunwareBase {
|
|
|
253
254
|
_connectionSessionUUID: string | undefined;
|
|
254
255
|
_invalidAPIkey: string | undefined;
|
|
255
256
|
_sdkType: SdkType;
|
|
256
|
-
|
|
257
|
+
_shouldReconnect: boolean;
|
|
258
|
+
constructor({ apiKey, url, shouldReconnect, }: RunwareBaseType);
|
|
257
259
|
protected isWebsocketReadyState: () => boolean;
|
|
258
260
|
protected addListener({ lis, groupKey, taskUUID, }: {
|
|
259
261
|
lis: (v: any) => any;
|
|
@@ -292,10 +294,11 @@ declare class RunwareServer extends RunwareBase {
|
|
|
292
294
|
_reconnectingIntervalId: null | any;
|
|
293
295
|
_pingTimeout: any;
|
|
294
296
|
_pongListener: any;
|
|
295
|
-
constructor({ apiKey, url }: RunwareBaseType);
|
|
297
|
+
constructor({ apiKey, url, shouldReconnect }: RunwareBaseType);
|
|
296
298
|
protected connect(): Promise<void>;
|
|
297
299
|
protected send: (msg: Object) => void;
|
|
298
300
|
protected handleClose(): void;
|
|
301
|
+
protected resetConnection: () => void;
|
|
299
302
|
protected heartBeat(): void;
|
|
300
303
|
}
|
|
301
304
|
|
package/dist/index.js
CHANGED
|
@@ -436,7 +436,11 @@ var asyncRetry = async (apiCall, options = {}) => {
|
|
|
436
436
|
|
|
437
437
|
// Runware/Runware-base.ts
|
|
438
438
|
var RunwareBase = class {
|
|
439
|
-
constructor({
|
|
439
|
+
constructor({
|
|
440
|
+
apiKey,
|
|
441
|
+
url = BASE_RUNWARE_URLS.PRODUCTION,
|
|
442
|
+
shouldReconnect = true
|
|
443
|
+
}) {
|
|
440
444
|
this._listeners = [];
|
|
441
445
|
// _globalMessages: any[] = [];
|
|
442
446
|
this._globalMessages = {};
|
|
@@ -748,6 +752,7 @@ var RunwareBase = class {
|
|
|
748
752
|
this._apiKey = apiKey;
|
|
749
753
|
this._url = url;
|
|
750
754
|
this._sdkType = "CLIENT" /* CLIENT */;
|
|
755
|
+
this._shouldReconnect = shouldReconnect;
|
|
751
756
|
}
|
|
752
757
|
// protected addListener({
|
|
753
758
|
// lis,
|
|
@@ -1186,14 +1191,27 @@ var RunwareClient = class extends RunwareBase {
|
|
|
1186
1191
|
// Runware/Runware-server.ts
|
|
1187
1192
|
var import_ws = __toESM(require("ws"));
|
|
1188
1193
|
var RunwareServer = class extends RunwareBase {
|
|
1189
|
-
constructor({ apiKey, url }) {
|
|
1190
|
-
super({ apiKey, url });
|
|
1194
|
+
constructor({ apiKey, url, shouldReconnect }) {
|
|
1195
|
+
super({ apiKey, url, shouldReconnect });
|
|
1191
1196
|
this._instantiated = false;
|
|
1192
1197
|
this._listeners = [];
|
|
1193
1198
|
this._reconnectingIntervalId = null;
|
|
1194
1199
|
this.send = (msg) => {
|
|
1195
1200
|
this._ws.send(JSON.stringify([msg]));
|
|
1196
1201
|
};
|
|
1202
|
+
this.resetConnection = () => {
|
|
1203
|
+
if (this._ws) {
|
|
1204
|
+
this._listeners.forEach((list) => {
|
|
1205
|
+
var _a;
|
|
1206
|
+
(_a = list == null ? void 0 : list.destroy) == null ? void 0 : _a.call(list);
|
|
1207
|
+
});
|
|
1208
|
+
this._ws.removeAllListeners();
|
|
1209
|
+
this._ws.terminate();
|
|
1210
|
+
this._ws.close();
|
|
1211
|
+
this._ws = null;
|
|
1212
|
+
this._listeners = [];
|
|
1213
|
+
}
|
|
1214
|
+
};
|
|
1197
1215
|
this._sdkType = "SERVER" /* SERVER */;
|
|
1198
1216
|
if (apiKey) {
|
|
1199
1217
|
this.connect();
|
|
@@ -1227,6 +1245,7 @@ var RunwareServer = class extends RunwareBase {
|
|
|
1227
1245
|
async connect() {
|
|
1228
1246
|
if (!this._url)
|
|
1229
1247
|
return;
|
|
1248
|
+
this.resetConnection();
|
|
1230
1249
|
this._ws = new import_ws.default(this._url, {
|
|
1231
1250
|
perMessageDeflate: false
|
|
1232
1251
|
});
|
|
@@ -1287,6 +1306,11 @@ var RunwareServer = class extends RunwareBase {
|
|
|
1287
1306
|
if (this._reconnectingIntervalId) {
|
|
1288
1307
|
clearInterval(this._reconnectingIntervalId);
|
|
1289
1308
|
}
|
|
1309
|
+
console.log("should reconnect", this._shouldReconnect);
|
|
1310
|
+
if (this._shouldReconnect) {
|
|
1311
|
+
console.log("reconnecting");
|
|
1312
|
+
setTimeout(() => this.connect(), 1e3);
|
|
1313
|
+
}
|
|
1290
1314
|
}
|
|
1291
1315
|
heartBeat() {
|
|
1292
1316
|
clearTimeout(this._pingTimeout);
|
package/dist/index.mjs
CHANGED
|
@@ -414,7 +414,11 @@ var asyncRetry = async (apiCall, options = {}) => {
|
|
|
414
414
|
|
|
415
415
|
// Runware/Runware-base.ts
|
|
416
416
|
var RunwareBase = class {
|
|
417
|
-
constructor({
|
|
417
|
+
constructor({
|
|
418
|
+
apiKey,
|
|
419
|
+
url = BASE_RUNWARE_URLS.PRODUCTION,
|
|
420
|
+
shouldReconnect = true
|
|
421
|
+
}) {
|
|
418
422
|
this._listeners = [];
|
|
419
423
|
// _globalMessages: any[] = [];
|
|
420
424
|
this._globalMessages = {};
|
|
@@ -726,6 +730,7 @@ var RunwareBase = class {
|
|
|
726
730
|
this._apiKey = apiKey;
|
|
727
731
|
this._url = url;
|
|
728
732
|
this._sdkType = "CLIENT" /* CLIENT */;
|
|
733
|
+
this._shouldReconnect = shouldReconnect;
|
|
729
734
|
}
|
|
730
735
|
// protected addListener({
|
|
731
736
|
// lis,
|
|
@@ -1164,14 +1169,27 @@ var RunwareClient = class extends RunwareBase {
|
|
|
1164
1169
|
// Runware/Runware-server.ts
|
|
1165
1170
|
import WebSocket2 from "ws";
|
|
1166
1171
|
var RunwareServer = class extends RunwareBase {
|
|
1167
|
-
constructor({ apiKey, url }) {
|
|
1168
|
-
super({ apiKey, url });
|
|
1172
|
+
constructor({ apiKey, url, shouldReconnect }) {
|
|
1173
|
+
super({ apiKey, url, shouldReconnect });
|
|
1169
1174
|
this._instantiated = false;
|
|
1170
1175
|
this._listeners = [];
|
|
1171
1176
|
this._reconnectingIntervalId = null;
|
|
1172
1177
|
this.send = (msg) => {
|
|
1173
1178
|
this._ws.send(JSON.stringify([msg]));
|
|
1174
1179
|
};
|
|
1180
|
+
this.resetConnection = () => {
|
|
1181
|
+
if (this._ws) {
|
|
1182
|
+
this._listeners.forEach((list) => {
|
|
1183
|
+
var _a;
|
|
1184
|
+
(_a = list == null ? void 0 : list.destroy) == null ? void 0 : _a.call(list);
|
|
1185
|
+
});
|
|
1186
|
+
this._ws.removeAllListeners();
|
|
1187
|
+
this._ws.terminate();
|
|
1188
|
+
this._ws.close();
|
|
1189
|
+
this._ws = null;
|
|
1190
|
+
this._listeners = [];
|
|
1191
|
+
}
|
|
1192
|
+
};
|
|
1175
1193
|
this._sdkType = "SERVER" /* SERVER */;
|
|
1176
1194
|
if (apiKey) {
|
|
1177
1195
|
this.connect();
|
|
@@ -1205,6 +1223,7 @@ var RunwareServer = class extends RunwareBase {
|
|
|
1205
1223
|
async connect() {
|
|
1206
1224
|
if (!this._url)
|
|
1207
1225
|
return;
|
|
1226
|
+
this.resetConnection();
|
|
1208
1227
|
this._ws = new WebSocket2(this._url, {
|
|
1209
1228
|
perMessageDeflate: false
|
|
1210
1229
|
});
|
|
@@ -1265,6 +1284,11 @@ var RunwareServer = class extends RunwareBase {
|
|
|
1265
1284
|
if (this._reconnectingIntervalId) {
|
|
1266
1285
|
clearInterval(this._reconnectingIntervalId);
|
|
1267
1286
|
}
|
|
1287
|
+
console.log("should reconnect", this._shouldReconnect);
|
|
1288
|
+
if (this._shouldReconnect) {
|
|
1289
|
+
console.log("reconnecting");
|
|
1290
|
+
setTimeout(() => this.connect(), 1e3);
|
|
1291
|
+
}
|
|
1268
1292
|
}
|
|
1269
1293
|
heartBeat() {
|
|
1270
1294
|
clearTimeout(this._pingTimeout);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runware/sdk-js",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.16",
|
|
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",
|