@runware/sdk-js 1.1.1 → 1.1.3
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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +40 -0
- package/dist/index.mjs +40 -0
- package/package.json +2 -2
- package/readme.md +13 -0
package/dist/index.d.mts
CHANGED
|
@@ -279,7 +279,7 @@ declare class RunwareBase {
|
|
|
279
279
|
removeImageBackground: ({ inputImage, outputType, outputFormat, rgba, postProcessMask, returnOnlyMask, alphaMatting, alphaMattingForegroundThreshold, alphaMattingBackgroundThreshold, alphaMattingErodeSize, includeCost, }: IRemoveImageBackground) => Promise<IRemoveImage[]>;
|
|
280
280
|
upscaleGan: ({ inputImage, upscaleFactor, outputType, outputFormat, includeCost, }: IUpscaleGan) => Promise<IImage[]>;
|
|
281
281
|
enhancePrompt: ({ prompt, promptMaxLength, promptVersions, includeCost, }: IPromptEnhancer) => Promise<IEnhancedPrompt[]>;
|
|
282
|
-
ensureConnection(): Promise<
|
|
282
|
+
ensureConnection(): Promise<unknown>;
|
|
283
283
|
getSimilarImages({ taskUUID, numberResults, shouldThrowError, lis, }: {
|
|
284
284
|
taskUUID: string | string[];
|
|
285
285
|
numberResults: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -279,7 +279,7 @@ declare class RunwareBase {
|
|
|
279
279
|
removeImageBackground: ({ inputImage, outputType, outputFormat, rgba, postProcessMask, returnOnlyMask, alphaMatting, alphaMattingForegroundThreshold, alphaMattingBackgroundThreshold, alphaMattingErodeSize, includeCost, }: IRemoveImageBackground) => Promise<IRemoveImage[]>;
|
|
280
280
|
upscaleGan: ({ inputImage, upscaleFactor, outputType, outputFormat, includeCost, }: IUpscaleGan) => Promise<IImage[]>;
|
|
281
281
|
enhancePrompt: ({ prompt, promptMaxLength, promptVersions, includeCost, }: IPromptEnhancer) => Promise<IEnhancedPrompt[]>;
|
|
282
|
-
ensureConnection(): Promise<
|
|
282
|
+
ensureConnection(): Promise<unknown>;
|
|
283
283
|
getSimilarImages({ taskUUID, numberResults, shouldThrowError, lis, }: {
|
|
284
284
|
taskUUID: string | string[];
|
|
285
285
|
numberResults: number;
|
package/dist/index.js
CHANGED
|
@@ -1068,9 +1068,35 @@ var RunwareBase = class {
|
|
|
1068
1068
|
async ensureConnection() {
|
|
1069
1069
|
var _a;
|
|
1070
1070
|
let isConnected = this.connected();
|
|
1071
|
+
console.log("afah");
|
|
1072
|
+
if (isConnected || this._url === BASE_RUNWARE_URLS.TEST)
|
|
1073
|
+
return;
|
|
1074
|
+
const interval = 200;
|
|
1071
1075
|
try {
|
|
1072
1076
|
if (this._invalidAPIkey)
|
|
1073
1077
|
throw this._invalidAPIkey;
|
|
1078
|
+
return new Promise((resolve, reject) => {
|
|
1079
|
+
let retry = 0;
|
|
1080
|
+
const MAX_RETRY = 2;
|
|
1081
|
+
const intervalId = setInterval(async () => {
|
|
1082
|
+
try {
|
|
1083
|
+
const hasConnected = this.connected();
|
|
1084
|
+
if (hasConnected) {
|
|
1085
|
+
clearInterval(intervalId);
|
|
1086
|
+
resolve(true);
|
|
1087
|
+
} else if (retry >= MAX_RETRY) {
|
|
1088
|
+
clearInterval(intervalId);
|
|
1089
|
+
reject(new Error("Polling timed out"));
|
|
1090
|
+
} else {
|
|
1091
|
+
this.connect();
|
|
1092
|
+
retry++;
|
|
1093
|
+
}
|
|
1094
|
+
} catch (error) {
|
|
1095
|
+
clearInterval(intervalId);
|
|
1096
|
+
reject(error);
|
|
1097
|
+
}
|
|
1098
|
+
}, interval);
|
|
1099
|
+
});
|
|
1074
1100
|
if (!isConnected) {
|
|
1075
1101
|
this.connect();
|
|
1076
1102
|
await delay(2);
|
|
@@ -1211,6 +1237,20 @@ var RunwareServer = class extends RunwareBase {
|
|
|
1211
1237
|
});
|
|
1212
1238
|
}
|
|
1213
1239
|
}
|
|
1240
|
+
this.addListener({
|
|
1241
|
+
taskUUID: "authentication" /* AUTHENTICATION */,
|
|
1242
|
+
lis: (m) => {
|
|
1243
|
+
var _a, _b;
|
|
1244
|
+
if (m == null ? void 0 : m.error) {
|
|
1245
|
+
if (m.errorId === 19) {
|
|
1246
|
+
this._invalidAPIkey = "Invalid API key";
|
|
1247
|
+
}
|
|
1248
|
+
return;
|
|
1249
|
+
}
|
|
1250
|
+
this._connectionSessionUUID = (_b = (_a = m == null ? void 0 : m["authentication" /* AUTHENTICATION */]) == null ? void 0 : _a[0]) == null ? void 0 : _b.connectionSessionUUID;
|
|
1251
|
+
this._invalidAPIkey = void 0;
|
|
1252
|
+
}
|
|
1253
|
+
});
|
|
1214
1254
|
});
|
|
1215
1255
|
this._ws.on("message", (e, isBinary) => {
|
|
1216
1256
|
const data = isBinary ? e : e == null ? void 0 : e.toString();
|
package/dist/index.mjs
CHANGED
|
@@ -1047,9 +1047,35 @@ var RunwareBase = class {
|
|
|
1047
1047
|
async ensureConnection() {
|
|
1048
1048
|
var _a;
|
|
1049
1049
|
let isConnected = this.connected();
|
|
1050
|
+
console.log("afah");
|
|
1051
|
+
if (isConnected || this._url === BASE_RUNWARE_URLS.TEST)
|
|
1052
|
+
return;
|
|
1053
|
+
const interval = 200;
|
|
1050
1054
|
try {
|
|
1051
1055
|
if (this._invalidAPIkey)
|
|
1052
1056
|
throw this._invalidAPIkey;
|
|
1057
|
+
return new Promise((resolve, reject) => {
|
|
1058
|
+
let retry = 0;
|
|
1059
|
+
const MAX_RETRY = 2;
|
|
1060
|
+
const intervalId = setInterval(async () => {
|
|
1061
|
+
try {
|
|
1062
|
+
const hasConnected = this.connected();
|
|
1063
|
+
if (hasConnected) {
|
|
1064
|
+
clearInterval(intervalId);
|
|
1065
|
+
resolve(true);
|
|
1066
|
+
} else if (retry >= MAX_RETRY) {
|
|
1067
|
+
clearInterval(intervalId);
|
|
1068
|
+
reject(new Error("Polling timed out"));
|
|
1069
|
+
} else {
|
|
1070
|
+
this.connect();
|
|
1071
|
+
retry++;
|
|
1072
|
+
}
|
|
1073
|
+
} catch (error) {
|
|
1074
|
+
clearInterval(intervalId);
|
|
1075
|
+
reject(error);
|
|
1076
|
+
}
|
|
1077
|
+
}, interval);
|
|
1078
|
+
});
|
|
1053
1079
|
if (!isConnected) {
|
|
1054
1080
|
this.connect();
|
|
1055
1081
|
await delay(2);
|
|
@@ -1190,6 +1216,20 @@ var RunwareServer = class extends RunwareBase {
|
|
|
1190
1216
|
});
|
|
1191
1217
|
}
|
|
1192
1218
|
}
|
|
1219
|
+
this.addListener({
|
|
1220
|
+
taskUUID: "authentication" /* AUTHENTICATION */,
|
|
1221
|
+
lis: (m) => {
|
|
1222
|
+
var _a, _b;
|
|
1223
|
+
if (m == null ? void 0 : m.error) {
|
|
1224
|
+
if (m.errorId === 19) {
|
|
1225
|
+
this._invalidAPIkey = "Invalid API key";
|
|
1226
|
+
}
|
|
1227
|
+
return;
|
|
1228
|
+
}
|
|
1229
|
+
this._connectionSessionUUID = (_b = (_a = m == null ? void 0 : m["authentication" /* AUTHENTICATION */]) == null ? void 0 : _a[0]) == null ? void 0 : _b.connectionSessionUUID;
|
|
1230
|
+
this._invalidAPIkey = void 0;
|
|
1231
|
+
}
|
|
1232
|
+
});
|
|
1193
1233
|
});
|
|
1194
1234
|
this._ws.on("message", (e, isBinary) => {
|
|
1195
1235
|
const data = isBinary ? e : e == null ? void 0 : e.toString();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runware/sdk-js",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
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",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"uuid": "^9.0.1",
|
|
36
|
-
"ws": "^8.
|
|
36
|
+
"ws": "^8.18.0"
|
|
37
37
|
},
|
|
38
38
|
"optionalDependencies": {
|
|
39
39
|
"bufferutil": "^4.0.8"
|
package/readme.md
CHANGED
|
@@ -356,10 +356,23 @@ return interface IControlNetImage {
|
|
|
356
356
|
|
|
357
357
|
## Changelog
|
|
358
358
|
|
|
359
|
+
### - v1.1.3
|
|
360
|
+
|
|
361
|
+
**Added or Changed**
|
|
362
|
+
|
|
363
|
+
- Reduce connection time
|
|
364
|
+
|
|
365
|
+
### - v1.1.2
|
|
366
|
+
|
|
367
|
+
**Added or Changed**
|
|
368
|
+
|
|
369
|
+
- Retry connection for server side
|
|
370
|
+
|
|
359
371
|
### - v1.1.1
|
|
360
372
|
|
|
361
373
|
**Added or Changed**
|
|
362
374
|
|
|
375
|
+
- Upgraded WS
|
|
363
376
|
- Fix delay time
|
|
364
377
|
|
|
365
378
|
### - v1.1.0
|