@runware/sdk-js 1.1.16 → 1.1.17-beta.2
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 +17 -8
- package/dist/index.d.ts +17 -8
- package/dist/index.js +334 -243
- package/dist/index.mjs +334 -243
- package/package.json +1 -1
- package/readme.md +100 -83
package/dist/index.mjs
CHANGED
|
@@ -21,6 +21,18 @@ var __spreadValues = (a, b) => {
|
|
|
21
21
|
return a;
|
|
22
22
|
};
|
|
23
23
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __objRest = (source, exclude) => {
|
|
25
|
+
var target = {};
|
|
26
|
+
for (var prop in source)
|
|
27
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
if (source != null && __getOwnPropSymbols)
|
|
30
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
31
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
32
|
+
target[prop] = source[prop];
|
|
33
|
+
}
|
|
34
|
+
return target;
|
|
35
|
+
};
|
|
24
36
|
var __commonJS = (cb, mod) => function __require() {
|
|
25
37
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
26
38
|
};
|
|
@@ -240,50 +252,50 @@ var EControlMode = /* @__PURE__ */ ((EControlMode2) => {
|
|
|
240
252
|
EControlMode2["CONTROL_NET"] = "controlnet";
|
|
241
253
|
return EControlMode2;
|
|
242
254
|
})(EControlMode || {});
|
|
243
|
-
var EPreProcessorGroup = /* @__PURE__ */ ((
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
return
|
|
255
|
+
var EPreProcessorGroup = /* @__PURE__ */ ((EPreProcessorGroup2) => {
|
|
256
|
+
EPreProcessorGroup2["canny"] = "canny";
|
|
257
|
+
EPreProcessorGroup2["depth"] = "depth";
|
|
258
|
+
EPreProcessorGroup2["mlsd"] = "mlsd";
|
|
259
|
+
EPreProcessorGroup2["normalbae"] = "normalbae";
|
|
260
|
+
EPreProcessorGroup2["openpose"] = "openpose";
|
|
261
|
+
EPreProcessorGroup2["tile"] = "tile";
|
|
262
|
+
EPreProcessorGroup2["seg"] = "seg";
|
|
263
|
+
EPreProcessorGroup2["lineart"] = "lineart";
|
|
264
|
+
EPreProcessorGroup2["lineart_anime"] = "lineart_anime";
|
|
265
|
+
EPreProcessorGroup2["shuffle"] = "shuffle";
|
|
266
|
+
EPreProcessorGroup2["scribble"] = "scribble";
|
|
267
|
+
EPreProcessorGroup2["softedge"] = "softedge";
|
|
268
|
+
return EPreProcessorGroup2;
|
|
257
269
|
})(EPreProcessorGroup || {});
|
|
258
|
-
var EPreProcessor = /* @__PURE__ */ ((
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
return
|
|
270
|
+
var EPreProcessor = /* @__PURE__ */ ((EPreProcessor2) => {
|
|
271
|
+
EPreProcessor2["canny"] = "canny";
|
|
272
|
+
EPreProcessor2["depth_leres"] = "depth_leres";
|
|
273
|
+
EPreProcessor2["depth_midas"] = "depth_midas";
|
|
274
|
+
EPreProcessor2["depth_zoe"] = "depth_zoe";
|
|
275
|
+
EPreProcessor2["inpaint_global_harmonious"] = "inpaint_global_harmonious";
|
|
276
|
+
EPreProcessor2["lineart_anime"] = "lineart_anime";
|
|
277
|
+
EPreProcessor2["lineart_coarse"] = "lineart_coarse";
|
|
278
|
+
EPreProcessor2["lineart_realistic"] = "lineart_realistic";
|
|
279
|
+
EPreProcessor2["lineart_standard"] = "lineart_standard";
|
|
280
|
+
EPreProcessor2["mlsd"] = "mlsd";
|
|
281
|
+
EPreProcessor2["normal_bae"] = "normal_bae";
|
|
282
|
+
EPreProcessor2["scribble_hed"] = "scribble_hed";
|
|
283
|
+
EPreProcessor2["scribble_pidinet"] = "scribble_pidinet";
|
|
284
|
+
EPreProcessor2["seg_ofade20k"] = "seg_ofade20k";
|
|
285
|
+
EPreProcessor2["seg_ofcoco"] = "seg_ofcoco";
|
|
286
|
+
EPreProcessor2["seg_ufade20k"] = "seg_ufade20k";
|
|
287
|
+
EPreProcessor2["shuffle"] = "shuffle";
|
|
288
|
+
EPreProcessor2["softedge_hed"] = "softedge_hed";
|
|
289
|
+
EPreProcessor2["softedge_hedsafe"] = "softedge_hedsafe";
|
|
290
|
+
EPreProcessor2["softedge_pidinet"] = "softedge_pidinet";
|
|
291
|
+
EPreProcessor2["softedge_pidisafe"] = "softedge_pidisafe";
|
|
292
|
+
EPreProcessor2["tile_gaussian"] = "tile_gaussian";
|
|
293
|
+
EPreProcessor2["openpose"] = "openpose";
|
|
294
|
+
EPreProcessor2["openpose_face"] = "openpose_face";
|
|
295
|
+
EPreProcessor2["openpose_faceonly"] = "openpose_faceonly";
|
|
296
|
+
EPreProcessor2["openpose_full"] = "openpose_full";
|
|
297
|
+
EPreProcessor2["openpose_hand"] = "openpose_hand";
|
|
298
|
+
return EPreProcessor2;
|
|
287
299
|
})(EPreProcessor || {});
|
|
288
300
|
var EOpenPosePreProcessor = /* @__PURE__ */ ((EOpenPosePreProcessor2) => {
|
|
289
301
|
EOpenPosePreProcessor2["openpose"] = "openpose";
|
|
@@ -322,8 +334,7 @@ var getIntervalWithPromise = (callback, {
|
|
|
322
334
|
if (intervalId) {
|
|
323
335
|
clearInterval(intervalId);
|
|
324
336
|
if (shouldThrowError) {
|
|
325
|
-
reject(`
|
|
326
|
-
console.error("Message could not be received for ", debugKey);
|
|
337
|
+
reject(`Response could not be received from server for ${debugKey}`);
|
|
327
338
|
}
|
|
328
339
|
}
|
|
329
340
|
clearTimeout(timeoutId);
|
|
@@ -417,7 +428,9 @@ var RunwareBase = class {
|
|
|
417
428
|
constructor({
|
|
418
429
|
apiKey,
|
|
419
430
|
url = BASE_RUNWARE_URLS.PRODUCTION,
|
|
420
|
-
shouldReconnect = true
|
|
431
|
+
shouldReconnect = true,
|
|
432
|
+
globalMaxRetries = 2,
|
|
433
|
+
timeOutDuration = TIMEOUT_DURATION
|
|
421
434
|
}) {
|
|
422
435
|
this._listeners = [];
|
|
423
436
|
// _globalMessages: any[] = [];
|
|
@@ -466,51 +479,68 @@ var RunwareBase = class {
|
|
|
466
479
|
lowThresholdCanny,
|
|
467
480
|
includeHandsAndFaceOpenPose,
|
|
468
481
|
includeCost,
|
|
469
|
-
customTaskUUID
|
|
482
|
+
customTaskUUID,
|
|
483
|
+
retry
|
|
470
484
|
}) => {
|
|
485
|
+
const totalRetry = retry || this._globalMaxRetries;
|
|
486
|
+
let lis = void 0;
|
|
471
487
|
try {
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
({ resolve, reject }) => {
|
|
496
|
-
const uploadedImage = this.getSingleMessage({
|
|
488
|
+
return await asyncRetry(
|
|
489
|
+
async () => {
|
|
490
|
+
await this.ensureConnection();
|
|
491
|
+
const image = await this.uploadImage(inputImage);
|
|
492
|
+
if (!(image == null ? void 0 : image.imageUUID))
|
|
493
|
+
return null;
|
|
494
|
+
const taskUUID = customTaskUUID || getUUID();
|
|
495
|
+
this.send(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
496
|
+
inputImage: image.imageUUID,
|
|
497
|
+
taskType: "imageControlNetPreProcess" /* IMAGE_CONTROL_NET_PRE_PROCESS */,
|
|
498
|
+
taskUUID,
|
|
499
|
+
preProcessor
|
|
500
|
+
}, evaluateNonTrue({ key: "height", value: height })), evaluateNonTrue({ key: "width", value: width })), evaluateNonTrue({ key: "outputType", value: outputType })), evaluateNonTrue({ key: "outputFormat", value: outputFormat })), evaluateNonTrue({ key: "includeCost", value: includeCost })), evaluateNonTrue({
|
|
501
|
+
key: "highThresholdCanny",
|
|
502
|
+
value: highThresholdCanny
|
|
503
|
+
})), evaluateNonTrue({
|
|
504
|
+
key: "lowThresholdCanny",
|
|
505
|
+
value: lowThresholdCanny
|
|
506
|
+
})), evaluateNonTrue({
|
|
507
|
+
key: "includeHandsAndFaceOpenPose",
|
|
508
|
+
value: includeHandsAndFaceOpenPose
|
|
509
|
+
})));
|
|
510
|
+
lis = this.globalListener({
|
|
497
511
|
taskUUID
|
|
498
512
|
});
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
513
|
+
const guideImage = await getIntervalWithPromise(
|
|
514
|
+
({ resolve, reject }) => {
|
|
515
|
+
const uploadedImage = this.getSingleMessage({
|
|
516
|
+
taskUUID
|
|
517
|
+
});
|
|
518
|
+
if (!uploadedImage)
|
|
519
|
+
return;
|
|
520
|
+
if (uploadedImage == null ? void 0 : uploadedImage.error) {
|
|
521
|
+
reject(uploadedImage);
|
|
522
|
+
return true;
|
|
523
|
+
}
|
|
524
|
+
if (uploadedImage) {
|
|
525
|
+
resolve(uploadedImage);
|
|
526
|
+
return true;
|
|
527
|
+
}
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
debugKey: "unprocessed-image",
|
|
531
|
+
timeOutDuration: this._timeOutDuration
|
|
532
|
+
}
|
|
533
|
+
);
|
|
534
|
+
lis.destroy();
|
|
535
|
+
return guideImage;
|
|
509
536
|
},
|
|
510
|
-
{
|
|
537
|
+
{
|
|
538
|
+
maxRetries: totalRetry,
|
|
539
|
+
callback: () => {
|
|
540
|
+
lis == null ? void 0 : lis.destroy();
|
|
541
|
+
}
|
|
542
|
+
}
|
|
511
543
|
);
|
|
512
|
-
lis.destroy();
|
|
513
|
-
return guideImage;
|
|
514
544
|
} catch (e) {
|
|
515
545
|
throw e;
|
|
516
546
|
}
|
|
@@ -518,43 +548,57 @@ var RunwareBase = class {
|
|
|
518
548
|
this.requestImageToText = async ({
|
|
519
549
|
inputImage,
|
|
520
550
|
includeCost,
|
|
521
|
-
customTaskUUID
|
|
551
|
+
customTaskUUID,
|
|
552
|
+
retry
|
|
522
553
|
}) => {
|
|
554
|
+
const totalRetry = retry || this._globalMaxRetries;
|
|
555
|
+
let lis = void 0;
|
|
523
556
|
try {
|
|
524
|
-
await
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
557
|
+
return await asyncRetry(
|
|
558
|
+
async () => {
|
|
559
|
+
await this.ensureConnection();
|
|
560
|
+
const imageUploaded = inputImage ? await this.uploadImage(inputImage) : null;
|
|
561
|
+
const taskUUID = customTaskUUID || getUUID();
|
|
562
|
+
this.send(__spreadValues({
|
|
563
|
+
taskUUID,
|
|
564
|
+
taskType: "imageCaption" /* IMAGE_CAPTION */,
|
|
565
|
+
inputImage: imageUploaded == null ? void 0 : imageUploaded.imageUUID
|
|
566
|
+
}, evaluateNonTrue({ key: "includeCost", value: includeCost })));
|
|
567
|
+
lis = this.globalListener({
|
|
568
|
+
taskUUID
|
|
569
|
+
});
|
|
570
|
+
const response = await getIntervalWithPromise(
|
|
571
|
+
({ resolve, reject }) => {
|
|
572
|
+
const newReverseClip = this.getSingleMessage({
|
|
573
|
+
taskUUID
|
|
574
|
+
});
|
|
575
|
+
if (!newReverseClip)
|
|
576
|
+
return;
|
|
577
|
+
if (newReverseClip == null ? void 0 : newReverseClip.error) {
|
|
578
|
+
reject(newReverseClip);
|
|
579
|
+
return true;
|
|
580
|
+
}
|
|
581
|
+
if (newReverseClip) {
|
|
582
|
+
delete this._globalMessages[taskUUID];
|
|
583
|
+
resolve(newReverseClip);
|
|
584
|
+
return true;
|
|
585
|
+
}
|
|
586
|
+
},
|
|
587
|
+
{
|
|
588
|
+
debugKey: "remove-image-background",
|
|
589
|
+
timeOutDuration: this._timeOutDuration
|
|
551
590
|
}
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
591
|
+
);
|
|
592
|
+
lis.destroy();
|
|
593
|
+
return response;
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
maxRetries: totalRetry,
|
|
597
|
+
callback: () => {
|
|
598
|
+
lis == null ? void 0 : lis.destroy();
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
);
|
|
558
602
|
} catch (e) {
|
|
559
603
|
throw e;
|
|
560
604
|
}
|
|
@@ -571,53 +615,70 @@ var RunwareBase = class {
|
|
|
571
615
|
alphaMattingBackgroundThreshold,
|
|
572
616
|
alphaMattingErodeSize,
|
|
573
617
|
includeCost,
|
|
574
|
-
customTaskUUID
|
|
618
|
+
customTaskUUID,
|
|
619
|
+
retry
|
|
575
620
|
}) => {
|
|
621
|
+
const totalRetry = retry || this._globalMaxRetries;
|
|
622
|
+
let lis = void 0;
|
|
576
623
|
try {
|
|
577
|
-
await
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
key: "
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
key: "
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
624
|
+
return await asyncRetry(
|
|
625
|
+
async () => {
|
|
626
|
+
await this.ensureConnection();
|
|
627
|
+
const imageUploaded = inputImage ? await this.uploadImage(inputImage) : null;
|
|
628
|
+
const taskUUID = customTaskUUID || getUUID();
|
|
629
|
+
this.send(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
630
|
+
taskType: "imageBackgroundRemoval" /* IMAGE_BACKGROUND_REMOVAL */,
|
|
631
|
+
taskUUID,
|
|
632
|
+
inputImage: imageUploaded == null ? void 0 : imageUploaded.imageUUID
|
|
633
|
+
}, evaluateNonTrue({ key: "rgba", value: rgba })), evaluateNonTrue({
|
|
634
|
+
key: "postProcessMask",
|
|
635
|
+
value: postProcessMask
|
|
636
|
+
})), evaluateNonTrue({
|
|
637
|
+
key: "returnOnlyMask",
|
|
638
|
+
value: returnOnlyMask
|
|
639
|
+
})), evaluateNonTrue({ key: "alphaMatting", value: alphaMatting })), evaluateNonTrue({ key: "includeCost", value: includeCost })), evaluateNonTrue({
|
|
640
|
+
key: "alphaMattingForegroundThreshold",
|
|
641
|
+
value: alphaMattingForegroundThreshold
|
|
642
|
+
})), evaluateNonTrue({
|
|
643
|
+
key: "alphaMattingBackgroundThreshold",
|
|
644
|
+
value: alphaMattingBackgroundThreshold
|
|
645
|
+
})), evaluateNonTrue({
|
|
646
|
+
key: "alphaMattingErodeSize",
|
|
647
|
+
value: alphaMattingErodeSize
|
|
648
|
+
})), evaluateNonTrue({ key: "outputType", value: outputType })), evaluateNonTrue({ key: "outputFormat", value: outputFormat })));
|
|
649
|
+
lis = this.globalListener({
|
|
650
|
+
taskUUID
|
|
651
|
+
});
|
|
652
|
+
const response = await getIntervalWithPromise(
|
|
653
|
+
({ resolve, reject }) => {
|
|
654
|
+
const newRemoveBackground = this.getSingleMessage({ taskUUID });
|
|
655
|
+
if (!newRemoveBackground)
|
|
656
|
+
return;
|
|
657
|
+
if (newRemoveBackground == null ? void 0 : newRemoveBackground.error) {
|
|
658
|
+
reject(newRemoveBackground);
|
|
659
|
+
return true;
|
|
660
|
+
}
|
|
661
|
+
if (newRemoveBackground) {
|
|
662
|
+
delete this._globalMessages[taskUUID];
|
|
663
|
+
resolve(newRemoveBackground);
|
|
664
|
+
return true;
|
|
665
|
+
}
|
|
666
|
+
},
|
|
667
|
+
{
|
|
668
|
+
debugKey: "remove-image-background",
|
|
669
|
+
timeOutDuration: this._timeOutDuration
|
|
614
670
|
}
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
671
|
+
);
|
|
672
|
+
lis.destroy();
|
|
673
|
+
return response;
|
|
674
|
+
},
|
|
675
|
+
{
|
|
676
|
+
maxRetries: totalRetry,
|
|
677
|
+
callback: () => {
|
|
678
|
+
lis == null ? void 0 : lis.destroy();
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
);
|
|
621
682
|
} catch (e) {
|
|
622
683
|
throw e;
|
|
623
684
|
}
|
|
@@ -628,43 +689,54 @@ var RunwareBase = class {
|
|
|
628
689
|
outputType,
|
|
629
690
|
outputFormat,
|
|
630
691
|
includeCost,
|
|
631
|
-
customTaskUUID
|
|
692
|
+
customTaskUUID,
|
|
693
|
+
retry
|
|
632
694
|
}) => {
|
|
695
|
+
const totalRetry = retry || this._globalMaxRetries;
|
|
696
|
+
let lis = void 0;
|
|
633
697
|
try {
|
|
634
|
-
await
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
698
|
+
return await asyncRetry(
|
|
699
|
+
async () => {
|
|
700
|
+
await this.ensureConnection();
|
|
701
|
+
let imageUploaded;
|
|
702
|
+
imageUploaded = await this.uploadImage(inputImage);
|
|
703
|
+
const taskUUID = customTaskUUID || getUUID();
|
|
704
|
+
this.send(__spreadValues(__spreadValues(__spreadValues({
|
|
705
|
+
taskUUID,
|
|
706
|
+
inputImage: imageUploaded == null ? void 0 : imageUploaded.imageUUID,
|
|
707
|
+
taskType: "imageUpscale" /* IMAGE_UPSCALE */,
|
|
708
|
+
upscaleFactor
|
|
709
|
+
}, evaluateNonTrue({ key: "includeCost", value: includeCost })), outputType ? { outputType } : {}), outputFormat ? { outputFormat } : {}));
|
|
710
|
+
lis = this.globalListener({
|
|
711
|
+
taskUUID
|
|
712
|
+
});
|
|
713
|
+
const response = await getIntervalWithPromise(
|
|
714
|
+
({ resolve, reject }) => {
|
|
715
|
+
const newUpscaleGan = this.getSingleMessage({ taskUUID });
|
|
716
|
+
if (!newUpscaleGan)
|
|
717
|
+
return;
|
|
718
|
+
if (newUpscaleGan == null ? void 0 : newUpscaleGan.error) {
|
|
719
|
+
reject(newUpscaleGan);
|
|
720
|
+
return true;
|
|
721
|
+
}
|
|
722
|
+
if (newUpscaleGan) {
|
|
723
|
+
delete this._globalMessages[taskUUID];
|
|
724
|
+
resolve(newUpscaleGan);
|
|
725
|
+
return true;
|
|
726
|
+
}
|
|
727
|
+
},
|
|
728
|
+
{ debugKey: "upscale-gan", timeOutDuration: this._timeOutDuration }
|
|
729
|
+
);
|
|
730
|
+
lis.destroy();
|
|
731
|
+
return response;
|
|
732
|
+
},
|
|
733
|
+
{
|
|
734
|
+
maxRetries: totalRetry,
|
|
735
|
+
callback: () => {
|
|
736
|
+
lis == null ? void 0 : lis.destroy();
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
);
|
|
668
740
|
} catch (e) {
|
|
669
741
|
throw e;
|
|
670
742
|
}
|
|
@@ -674,41 +746,55 @@ var RunwareBase = class {
|
|
|
674
746
|
promptMaxLength = 380,
|
|
675
747
|
promptVersions = 1,
|
|
676
748
|
includeCost,
|
|
677
|
-
customTaskUUID
|
|
749
|
+
customTaskUUID,
|
|
750
|
+
retry
|
|
678
751
|
}) => {
|
|
752
|
+
const totalRetry = retry || this._globalMaxRetries;
|
|
753
|
+
let lis = void 0;
|
|
679
754
|
try {
|
|
680
|
-
await
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
755
|
+
return await asyncRetry(
|
|
756
|
+
async () => {
|
|
757
|
+
await this.ensureConnection();
|
|
758
|
+
const taskUUID = customTaskUUID || getUUID();
|
|
759
|
+
this.send(__spreadProps(__spreadValues({
|
|
760
|
+
prompt,
|
|
761
|
+
taskUUID,
|
|
762
|
+
promptMaxLength,
|
|
763
|
+
promptVersions
|
|
764
|
+
}, evaluateNonTrue({ key: "includeCost", value: includeCost })), {
|
|
765
|
+
taskType: "promptEnhance" /* PROMPT_ENHANCE */
|
|
766
|
+
}));
|
|
767
|
+
lis = this.globalListener({
|
|
768
|
+
taskUUID
|
|
769
|
+
});
|
|
770
|
+
const response = await getIntervalWithPromise(
|
|
771
|
+
({ resolve, reject }) => {
|
|
772
|
+
const reducedPrompt = this._globalMessages[taskUUID];
|
|
773
|
+
if (reducedPrompt == null ? void 0 : reducedPrompt.error) {
|
|
774
|
+
reject(reducedPrompt);
|
|
775
|
+
return true;
|
|
776
|
+
}
|
|
777
|
+
if ((reducedPrompt == null ? void 0 : reducedPrompt.length) >= promptVersions) {
|
|
778
|
+
delete this._globalMessages[taskUUID];
|
|
779
|
+
resolve(reducedPrompt);
|
|
780
|
+
return true;
|
|
781
|
+
}
|
|
782
|
+
},
|
|
783
|
+
{
|
|
784
|
+
debugKey: "enhance-prompt",
|
|
785
|
+
timeOutDuration: this._timeOutDuration
|
|
705
786
|
}
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
787
|
+
);
|
|
788
|
+
lis.destroy();
|
|
789
|
+
return response;
|
|
790
|
+
},
|
|
791
|
+
{
|
|
792
|
+
maxRetries: totalRetry,
|
|
793
|
+
callback: () => {
|
|
794
|
+
lis == null ? void 0 : lis.destroy();
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
);
|
|
712
798
|
} catch (e) {
|
|
713
799
|
throw e;
|
|
714
800
|
}
|
|
@@ -731,6 +817,8 @@ var RunwareBase = class {
|
|
|
731
817
|
this._url = url;
|
|
732
818
|
this._sdkType = "CLIENT" /* CLIENT */;
|
|
733
819
|
this._shouldReconnect = shouldReconnect;
|
|
820
|
+
this._globalMaxRetries = globalMaxRetries;
|
|
821
|
+
this._timeOutDuration = timeOutDuration;
|
|
734
822
|
}
|
|
735
823
|
// protected addListener({
|
|
736
824
|
// lis,
|
|
@@ -929,13 +1017,13 @@ var RunwareBase = class {
|
|
|
929
1017
|
onPartialImages,
|
|
930
1018
|
includeCost,
|
|
931
1019
|
customTaskUUID,
|
|
932
|
-
retry
|
|
1020
|
+
retry
|
|
933
1021
|
}) {
|
|
934
|
-
await this.ensureConnection();
|
|
935
1022
|
let lis = void 0;
|
|
936
1023
|
let requestObject = void 0;
|
|
937
1024
|
let taskUUIDs = [];
|
|
938
1025
|
let retryCount = 0;
|
|
1026
|
+
const totalRetry = retry || this._globalMaxRetries;
|
|
939
1027
|
try {
|
|
940
1028
|
await this.ensureConnection();
|
|
941
1029
|
let seedImageUUID = null;
|
|
@@ -1025,7 +1113,7 @@ var RunwareBase = class {
|
|
|
1025
1113
|
return promise;
|
|
1026
1114
|
},
|
|
1027
1115
|
{
|
|
1028
|
-
maxRetries:
|
|
1116
|
+
maxRetries: totalRetry,
|
|
1029
1117
|
callback: () => {
|
|
1030
1118
|
lis == null ? void 0 : lis.destroy();
|
|
1031
1119
|
}
|
|
@@ -1035,7 +1123,7 @@ var RunwareBase = class {
|
|
|
1035
1123
|
if (e.taskUUID) {
|
|
1036
1124
|
throw e;
|
|
1037
1125
|
}
|
|
1038
|
-
if (retryCount >=
|
|
1126
|
+
if (retryCount >= totalRetry) {
|
|
1039
1127
|
return this.handleIncompleteImages({ taskUUIDs, error: e });
|
|
1040
1128
|
}
|
|
1041
1129
|
}
|
|
@@ -1130,7 +1218,11 @@ var RunwareBase = class {
|
|
|
1130
1218
|
return true;
|
|
1131
1219
|
}
|
|
1132
1220
|
},
|
|
1133
|
-
{
|
|
1221
|
+
{
|
|
1222
|
+
debugKey: "getting images",
|
|
1223
|
+
shouldThrowError,
|
|
1224
|
+
timeOutDuration: this._timeOutDuration
|
|
1225
|
+
}
|
|
1134
1226
|
);
|
|
1135
1227
|
}
|
|
1136
1228
|
handleIncompleteImages({
|
|
@@ -1155,9 +1247,10 @@ var RunwareBase = class {
|
|
|
1155
1247
|
// Runware/Runware-client.ts
|
|
1156
1248
|
var import_reconnect = __toESM(require_reconnect());
|
|
1157
1249
|
var RunwareClient = class extends RunwareBase {
|
|
1158
|
-
constructor(
|
|
1159
|
-
|
|
1160
|
-
|
|
1250
|
+
constructor(props) {
|
|
1251
|
+
const _a = props, { shouldReconnect } = _a, rest = __objRest(_a, ["shouldReconnect"]);
|
|
1252
|
+
super(rest);
|
|
1253
|
+
if (rest.apiKey) {
|
|
1161
1254
|
this._ws = new import_reconnect.default(
|
|
1162
1255
|
this._url
|
|
1163
1256
|
);
|
|
@@ -1169,8 +1262,8 @@ var RunwareClient = class extends RunwareBase {
|
|
|
1169
1262
|
// Runware/Runware-server.ts
|
|
1170
1263
|
import WebSocket2 from "ws";
|
|
1171
1264
|
var RunwareServer = class extends RunwareBase {
|
|
1172
|
-
constructor(
|
|
1173
|
-
super(
|
|
1265
|
+
constructor(props) {
|
|
1266
|
+
super(props);
|
|
1174
1267
|
this._instantiated = false;
|
|
1175
1268
|
this._listeners = [];
|
|
1176
1269
|
this._reconnectingIntervalId = null;
|
|
@@ -1191,7 +1284,7 @@ var RunwareServer = class extends RunwareBase {
|
|
|
1191
1284
|
}
|
|
1192
1285
|
};
|
|
1193
1286
|
this._sdkType = "SERVER" /* SERVER */;
|
|
1194
|
-
if (apiKey) {
|
|
1287
|
+
if (props.apiKey) {
|
|
1195
1288
|
this.connect();
|
|
1196
1289
|
}
|
|
1197
1290
|
}
|
|
@@ -1284,9 +1377,7 @@ var RunwareServer = class extends RunwareBase {
|
|
|
1284
1377
|
if (this._reconnectingIntervalId) {
|
|
1285
1378
|
clearInterval(this._reconnectingIntervalId);
|
|
1286
1379
|
}
|
|
1287
|
-
console.log("should reconnect", this._shouldReconnect);
|
|
1288
1380
|
if (this._shouldReconnect) {
|
|
1289
|
-
console.log("reconnecting");
|
|
1290
1381
|
setTimeout(() => this.connect(), 1e3);
|
|
1291
1382
|
}
|
|
1292
1383
|
}
|