@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.js
CHANGED
|
@@ -22,6 +22,18 @@ var __spreadValues = (a, b) => {
|
|
|
22
22
|
return a;
|
|
23
23
|
};
|
|
24
24
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
+
var __objRest = (source, exclude) => {
|
|
26
|
+
var target = {};
|
|
27
|
+
for (var prop in source)
|
|
28
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
if (source != null && __getOwnPropSymbols)
|
|
31
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
32
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
33
|
+
target[prop] = source[prop];
|
|
34
|
+
}
|
|
35
|
+
return target;
|
|
36
|
+
};
|
|
25
37
|
var __commonJS = (cb, mod) => function __require() {
|
|
26
38
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
27
39
|
};
|
|
@@ -262,50 +274,50 @@ var EControlMode = /* @__PURE__ */ ((EControlMode2) => {
|
|
|
262
274
|
EControlMode2["CONTROL_NET"] = "controlnet";
|
|
263
275
|
return EControlMode2;
|
|
264
276
|
})(EControlMode || {});
|
|
265
|
-
var EPreProcessorGroup = /* @__PURE__ */ ((
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
return
|
|
277
|
+
var EPreProcessorGroup = /* @__PURE__ */ ((EPreProcessorGroup2) => {
|
|
278
|
+
EPreProcessorGroup2["canny"] = "canny";
|
|
279
|
+
EPreProcessorGroup2["depth"] = "depth";
|
|
280
|
+
EPreProcessorGroup2["mlsd"] = "mlsd";
|
|
281
|
+
EPreProcessorGroup2["normalbae"] = "normalbae";
|
|
282
|
+
EPreProcessorGroup2["openpose"] = "openpose";
|
|
283
|
+
EPreProcessorGroup2["tile"] = "tile";
|
|
284
|
+
EPreProcessorGroup2["seg"] = "seg";
|
|
285
|
+
EPreProcessorGroup2["lineart"] = "lineart";
|
|
286
|
+
EPreProcessorGroup2["lineart_anime"] = "lineart_anime";
|
|
287
|
+
EPreProcessorGroup2["shuffle"] = "shuffle";
|
|
288
|
+
EPreProcessorGroup2["scribble"] = "scribble";
|
|
289
|
+
EPreProcessorGroup2["softedge"] = "softedge";
|
|
290
|
+
return EPreProcessorGroup2;
|
|
279
291
|
})(EPreProcessorGroup || {});
|
|
280
|
-
var EPreProcessor = /* @__PURE__ */ ((
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
return
|
|
292
|
+
var EPreProcessor = /* @__PURE__ */ ((EPreProcessor2) => {
|
|
293
|
+
EPreProcessor2["canny"] = "canny";
|
|
294
|
+
EPreProcessor2["depth_leres"] = "depth_leres";
|
|
295
|
+
EPreProcessor2["depth_midas"] = "depth_midas";
|
|
296
|
+
EPreProcessor2["depth_zoe"] = "depth_zoe";
|
|
297
|
+
EPreProcessor2["inpaint_global_harmonious"] = "inpaint_global_harmonious";
|
|
298
|
+
EPreProcessor2["lineart_anime"] = "lineart_anime";
|
|
299
|
+
EPreProcessor2["lineart_coarse"] = "lineart_coarse";
|
|
300
|
+
EPreProcessor2["lineart_realistic"] = "lineart_realistic";
|
|
301
|
+
EPreProcessor2["lineart_standard"] = "lineart_standard";
|
|
302
|
+
EPreProcessor2["mlsd"] = "mlsd";
|
|
303
|
+
EPreProcessor2["normal_bae"] = "normal_bae";
|
|
304
|
+
EPreProcessor2["scribble_hed"] = "scribble_hed";
|
|
305
|
+
EPreProcessor2["scribble_pidinet"] = "scribble_pidinet";
|
|
306
|
+
EPreProcessor2["seg_ofade20k"] = "seg_ofade20k";
|
|
307
|
+
EPreProcessor2["seg_ofcoco"] = "seg_ofcoco";
|
|
308
|
+
EPreProcessor2["seg_ufade20k"] = "seg_ufade20k";
|
|
309
|
+
EPreProcessor2["shuffle"] = "shuffle";
|
|
310
|
+
EPreProcessor2["softedge_hed"] = "softedge_hed";
|
|
311
|
+
EPreProcessor2["softedge_hedsafe"] = "softedge_hedsafe";
|
|
312
|
+
EPreProcessor2["softedge_pidinet"] = "softedge_pidinet";
|
|
313
|
+
EPreProcessor2["softedge_pidisafe"] = "softedge_pidisafe";
|
|
314
|
+
EPreProcessor2["tile_gaussian"] = "tile_gaussian";
|
|
315
|
+
EPreProcessor2["openpose"] = "openpose";
|
|
316
|
+
EPreProcessor2["openpose_face"] = "openpose_face";
|
|
317
|
+
EPreProcessor2["openpose_faceonly"] = "openpose_faceonly";
|
|
318
|
+
EPreProcessor2["openpose_full"] = "openpose_full";
|
|
319
|
+
EPreProcessor2["openpose_hand"] = "openpose_hand";
|
|
320
|
+
return EPreProcessor2;
|
|
309
321
|
})(EPreProcessor || {});
|
|
310
322
|
var EOpenPosePreProcessor = /* @__PURE__ */ ((EOpenPosePreProcessor2) => {
|
|
311
323
|
EOpenPosePreProcessor2["openpose"] = "openpose";
|
|
@@ -344,8 +356,7 @@ var getIntervalWithPromise = (callback, {
|
|
|
344
356
|
if (intervalId) {
|
|
345
357
|
clearInterval(intervalId);
|
|
346
358
|
if (shouldThrowError) {
|
|
347
|
-
reject(`
|
|
348
|
-
console.error("Message could not be received for ", debugKey);
|
|
359
|
+
reject(`Response could not be received from server for ${debugKey}`);
|
|
349
360
|
}
|
|
350
361
|
}
|
|
351
362
|
clearTimeout(timeoutId);
|
|
@@ -439,7 +450,9 @@ var RunwareBase = class {
|
|
|
439
450
|
constructor({
|
|
440
451
|
apiKey,
|
|
441
452
|
url = BASE_RUNWARE_URLS.PRODUCTION,
|
|
442
|
-
shouldReconnect = true
|
|
453
|
+
shouldReconnect = true,
|
|
454
|
+
globalMaxRetries = 2,
|
|
455
|
+
timeOutDuration = TIMEOUT_DURATION
|
|
443
456
|
}) {
|
|
444
457
|
this._listeners = [];
|
|
445
458
|
// _globalMessages: any[] = [];
|
|
@@ -488,51 +501,68 @@ var RunwareBase = class {
|
|
|
488
501
|
lowThresholdCanny,
|
|
489
502
|
includeHandsAndFaceOpenPose,
|
|
490
503
|
includeCost,
|
|
491
|
-
customTaskUUID
|
|
504
|
+
customTaskUUID,
|
|
505
|
+
retry
|
|
492
506
|
}) => {
|
|
507
|
+
const totalRetry = retry || this._globalMaxRetries;
|
|
508
|
+
let lis = void 0;
|
|
493
509
|
try {
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
({ resolve, reject }) => {
|
|
518
|
-
const uploadedImage = this.getSingleMessage({
|
|
510
|
+
return await asyncRetry(
|
|
511
|
+
async () => {
|
|
512
|
+
await this.ensureConnection();
|
|
513
|
+
const image = await this.uploadImage(inputImage);
|
|
514
|
+
if (!(image == null ? void 0 : image.imageUUID))
|
|
515
|
+
return null;
|
|
516
|
+
const taskUUID = customTaskUUID || getUUID();
|
|
517
|
+
this.send(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
518
|
+
inputImage: image.imageUUID,
|
|
519
|
+
taskType: "imageControlNetPreProcess" /* IMAGE_CONTROL_NET_PRE_PROCESS */,
|
|
520
|
+
taskUUID,
|
|
521
|
+
preProcessor
|
|
522
|
+
}, 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({
|
|
523
|
+
key: "highThresholdCanny",
|
|
524
|
+
value: highThresholdCanny
|
|
525
|
+
})), evaluateNonTrue({
|
|
526
|
+
key: "lowThresholdCanny",
|
|
527
|
+
value: lowThresholdCanny
|
|
528
|
+
})), evaluateNonTrue({
|
|
529
|
+
key: "includeHandsAndFaceOpenPose",
|
|
530
|
+
value: includeHandsAndFaceOpenPose
|
|
531
|
+
})));
|
|
532
|
+
lis = this.globalListener({
|
|
519
533
|
taskUUID
|
|
520
534
|
});
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
535
|
+
const guideImage = await getIntervalWithPromise(
|
|
536
|
+
({ resolve, reject }) => {
|
|
537
|
+
const uploadedImage = this.getSingleMessage({
|
|
538
|
+
taskUUID
|
|
539
|
+
});
|
|
540
|
+
if (!uploadedImage)
|
|
541
|
+
return;
|
|
542
|
+
if (uploadedImage == null ? void 0 : uploadedImage.error) {
|
|
543
|
+
reject(uploadedImage);
|
|
544
|
+
return true;
|
|
545
|
+
}
|
|
546
|
+
if (uploadedImage) {
|
|
547
|
+
resolve(uploadedImage);
|
|
548
|
+
return true;
|
|
549
|
+
}
|
|
550
|
+
},
|
|
551
|
+
{
|
|
552
|
+
debugKey: "unprocessed-image",
|
|
553
|
+
timeOutDuration: this._timeOutDuration
|
|
554
|
+
}
|
|
555
|
+
);
|
|
556
|
+
lis.destroy();
|
|
557
|
+
return guideImage;
|
|
531
558
|
},
|
|
532
|
-
{
|
|
559
|
+
{
|
|
560
|
+
maxRetries: totalRetry,
|
|
561
|
+
callback: () => {
|
|
562
|
+
lis == null ? void 0 : lis.destroy();
|
|
563
|
+
}
|
|
564
|
+
}
|
|
533
565
|
);
|
|
534
|
-
lis.destroy();
|
|
535
|
-
return guideImage;
|
|
536
566
|
} catch (e) {
|
|
537
567
|
throw e;
|
|
538
568
|
}
|
|
@@ -540,43 +570,57 @@ var RunwareBase = class {
|
|
|
540
570
|
this.requestImageToText = async ({
|
|
541
571
|
inputImage,
|
|
542
572
|
includeCost,
|
|
543
|
-
customTaskUUID
|
|
573
|
+
customTaskUUID,
|
|
574
|
+
retry
|
|
544
575
|
}) => {
|
|
576
|
+
const totalRetry = retry || this._globalMaxRetries;
|
|
577
|
+
let lis = void 0;
|
|
545
578
|
try {
|
|
546
|
-
await
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
579
|
+
return await asyncRetry(
|
|
580
|
+
async () => {
|
|
581
|
+
await this.ensureConnection();
|
|
582
|
+
const imageUploaded = inputImage ? await this.uploadImage(inputImage) : null;
|
|
583
|
+
const taskUUID = customTaskUUID || getUUID();
|
|
584
|
+
this.send(__spreadValues({
|
|
585
|
+
taskUUID,
|
|
586
|
+
taskType: "imageCaption" /* IMAGE_CAPTION */,
|
|
587
|
+
inputImage: imageUploaded == null ? void 0 : imageUploaded.imageUUID
|
|
588
|
+
}, evaluateNonTrue({ key: "includeCost", value: includeCost })));
|
|
589
|
+
lis = this.globalListener({
|
|
590
|
+
taskUUID
|
|
591
|
+
});
|
|
592
|
+
const response = await getIntervalWithPromise(
|
|
593
|
+
({ resolve, reject }) => {
|
|
594
|
+
const newReverseClip = this.getSingleMessage({
|
|
595
|
+
taskUUID
|
|
596
|
+
});
|
|
597
|
+
if (!newReverseClip)
|
|
598
|
+
return;
|
|
599
|
+
if (newReverseClip == null ? void 0 : newReverseClip.error) {
|
|
600
|
+
reject(newReverseClip);
|
|
601
|
+
return true;
|
|
602
|
+
}
|
|
603
|
+
if (newReverseClip) {
|
|
604
|
+
delete this._globalMessages[taskUUID];
|
|
605
|
+
resolve(newReverseClip);
|
|
606
|
+
return true;
|
|
607
|
+
}
|
|
608
|
+
},
|
|
609
|
+
{
|
|
610
|
+
debugKey: "remove-image-background",
|
|
611
|
+
timeOutDuration: this._timeOutDuration
|
|
573
612
|
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
613
|
+
);
|
|
614
|
+
lis.destroy();
|
|
615
|
+
return response;
|
|
616
|
+
},
|
|
617
|
+
{
|
|
618
|
+
maxRetries: totalRetry,
|
|
619
|
+
callback: () => {
|
|
620
|
+
lis == null ? void 0 : lis.destroy();
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
);
|
|
580
624
|
} catch (e) {
|
|
581
625
|
throw e;
|
|
582
626
|
}
|
|
@@ -593,53 +637,70 @@ var RunwareBase = class {
|
|
|
593
637
|
alphaMattingBackgroundThreshold,
|
|
594
638
|
alphaMattingErodeSize,
|
|
595
639
|
includeCost,
|
|
596
|
-
customTaskUUID
|
|
640
|
+
customTaskUUID,
|
|
641
|
+
retry
|
|
597
642
|
}) => {
|
|
643
|
+
const totalRetry = retry || this._globalMaxRetries;
|
|
644
|
+
let lis = void 0;
|
|
598
645
|
try {
|
|
599
|
-
await
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
key: "
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
key: "
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
646
|
+
return await asyncRetry(
|
|
647
|
+
async () => {
|
|
648
|
+
await this.ensureConnection();
|
|
649
|
+
const imageUploaded = inputImage ? await this.uploadImage(inputImage) : null;
|
|
650
|
+
const taskUUID = customTaskUUID || getUUID();
|
|
651
|
+
this.send(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
652
|
+
taskType: "imageBackgroundRemoval" /* IMAGE_BACKGROUND_REMOVAL */,
|
|
653
|
+
taskUUID,
|
|
654
|
+
inputImage: imageUploaded == null ? void 0 : imageUploaded.imageUUID
|
|
655
|
+
}, evaluateNonTrue({ key: "rgba", value: rgba })), evaluateNonTrue({
|
|
656
|
+
key: "postProcessMask",
|
|
657
|
+
value: postProcessMask
|
|
658
|
+
})), evaluateNonTrue({
|
|
659
|
+
key: "returnOnlyMask",
|
|
660
|
+
value: returnOnlyMask
|
|
661
|
+
})), evaluateNonTrue({ key: "alphaMatting", value: alphaMatting })), evaluateNonTrue({ key: "includeCost", value: includeCost })), evaluateNonTrue({
|
|
662
|
+
key: "alphaMattingForegroundThreshold",
|
|
663
|
+
value: alphaMattingForegroundThreshold
|
|
664
|
+
})), evaluateNonTrue({
|
|
665
|
+
key: "alphaMattingBackgroundThreshold",
|
|
666
|
+
value: alphaMattingBackgroundThreshold
|
|
667
|
+
})), evaluateNonTrue({
|
|
668
|
+
key: "alphaMattingErodeSize",
|
|
669
|
+
value: alphaMattingErodeSize
|
|
670
|
+
})), evaluateNonTrue({ key: "outputType", value: outputType })), evaluateNonTrue({ key: "outputFormat", value: outputFormat })));
|
|
671
|
+
lis = this.globalListener({
|
|
672
|
+
taskUUID
|
|
673
|
+
});
|
|
674
|
+
const response = await getIntervalWithPromise(
|
|
675
|
+
({ resolve, reject }) => {
|
|
676
|
+
const newRemoveBackground = this.getSingleMessage({ taskUUID });
|
|
677
|
+
if (!newRemoveBackground)
|
|
678
|
+
return;
|
|
679
|
+
if (newRemoveBackground == null ? void 0 : newRemoveBackground.error) {
|
|
680
|
+
reject(newRemoveBackground);
|
|
681
|
+
return true;
|
|
682
|
+
}
|
|
683
|
+
if (newRemoveBackground) {
|
|
684
|
+
delete this._globalMessages[taskUUID];
|
|
685
|
+
resolve(newRemoveBackground);
|
|
686
|
+
return true;
|
|
687
|
+
}
|
|
688
|
+
},
|
|
689
|
+
{
|
|
690
|
+
debugKey: "remove-image-background",
|
|
691
|
+
timeOutDuration: this._timeOutDuration
|
|
636
692
|
}
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
693
|
+
);
|
|
694
|
+
lis.destroy();
|
|
695
|
+
return response;
|
|
696
|
+
},
|
|
697
|
+
{
|
|
698
|
+
maxRetries: totalRetry,
|
|
699
|
+
callback: () => {
|
|
700
|
+
lis == null ? void 0 : lis.destroy();
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
);
|
|
643
704
|
} catch (e) {
|
|
644
705
|
throw e;
|
|
645
706
|
}
|
|
@@ -650,43 +711,54 @@ var RunwareBase = class {
|
|
|
650
711
|
outputType,
|
|
651
712
|
outputFormat,
|
|
652
713
|
includeCost,
|
|
653
|
-
customTaskUUID
|
|
714
|
+
customTaskUUID,
|
|
715
|
+
retry
|
|
654
716
|
}) => {
|
|
717
|
+
const totalRetry = retry || this._globalMaxRetries;
|
|
718
|
+
let lis = void 0;
|
|
655
719
|
try {
|
|
656
|
-
await
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
720
|
+
return await asyncRetry(
|
|
721
|
+
async () => {
|
|
722
|
+
await this.ensureConnection();
|
|
723
|
+
let imageUploaded;
|
|
724
|
+
imageUploaded = await this.uploadImage(inputImage);
|
|
725
|
+
const taskUUID = customTaskUUID || getUUID();
|
|
726
|
+
this.send(__spreadValues(__spreadValues(__spreadValues({
|
|
727
|
+
taskUUID,
|
|
728
|
+
inputImage: imageUploaded == null ? void 0 : imageUploaded.imageUUID,
|
|
729
|
+
taskType: "imageUpscale" /* IMAGE_UPSCALE */,
|
|
730
|
+
upscaleFactor
|
|
731
|
+
}, evaluateNonTrue({ key: "includeCost", value: includeCost })), outputType ? { outputType } : {}), outputFormat ? { outputFormat } : {}));
|
|
732
|
+
lis = this.globalListener({
|
|
733
|
+
taskUUID
|
|
734
|
+
});
|
|
735
|
+
const response = await getIntervalWithPromise(
|
|
736
|
+
({ resolve, reject }) => {
|
|
737
|
+
const newUpscaleGan = this.getSingleMessage({ taskUUID });
|
|
738
|
+
if (!newUpscaleGan)
|
|
739
|
+
return;
|
|
740
|
+
if (newUpscaleGan == null ? void 0 : newUpscaleGan.error) {
|
|
741
|
+
reject(newUpscaleGan);
|
|
742
|
+
return true;
|
|
743
|
+
}
|
|
744
|
+
if (newUpscaleGan) {
|
|
745
|
+
delete this._globalMessages[taskUUID];
|
|
746
|
+
resolve(newUpscaleGan);
|
|
747
|
+
return true;
|
|
748
|
+
}
|
|
749
|
+
},
|
|
750
|
+
{ debugKey: "upscale-gan", timeOutDuration: this._timeOutDuration }
|
|
751
|
+
);
|
|
752
|
+
lis.destroy();
|
|
753
|
+
return response;
|
|
754
|
+
},
|
|
755
|
+
{
|
|
756
|
+
maxRetries: totalRetry,
|
|
757
|
+
callback: () => {
|
|
758
|
+
lis == null ? void 0 : lis.destroy();
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
);
|
|
690
762
|
} catch (e) {
|
|
691
763
|
throw e;
|
|
692
764
|
}
|
|
@@ -696,41 +768,55 @@ var RunwareBase = class {
|
|
|
696
768
|
promptMaxLength = 380,
|
|
697
769
|
promptVersions = 1,
|
|
698
770
|
includeCost,
|
|
699
|
-
customTaskUUID
|
|
771
|
+
customTaskUUID,
|
|
772
|
+
retry
|
|
700
773
|
}) => {
|
|
774
|
+
const totalRetry = retry || this._globalMaxRetries;
|
|
775
|
+
let lis = void 0;
|
|
701
776
|
try {
|
|
702
|
-
await
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
777
|
+
return await asyncRetry(
|
|
778
|
+
async () => {
|
|
779
|
+
await this.ensureConnection();
|
|
780
|
+
const taskUUID = customTaskUUID || getUUID();
|
|
781
|
+
this.send(__spreadProps(__spreadValues({
|
|
782
|
+
prompt,
|
|
783
|
+
taskUUID,
|
|
784
|
+
promptMaxLength,
|
|
785
|
+
promptVersions
|
|
786
|
+
}, evaluateNonTrue({ key: "includeCost", value: includeCost })), {
|
|
787
|
+
taskType: "promptEnhance" /* PROMPT_ENHANCE */
|
|
788
|
+
}));
|
|
789
|
+
lis = this.globalListener({
|
|
790
|
+
taskUUID
|
|
791
|
+
});
|
|
792
|
+
const response = await getIntervalWithPromise(
|
|
793
|
+
({ resolve, reject }) => {
|
|
794
|
+
const reducedPrompt = this._globalMessages[taskUUID];
|
|
795
|
+
if (reducedPrompt == null ? void 0 : reducedPrompt.error) {
|
|
796
|
+
reject(reducedPrompt);
|
|
797
|
+
return true;
|
|
798
|
+
}
|
|
799
|
+
if ((reducedPrompt == null ? void 0 : reducedPrompt.length) >= promptVersions) {
|
|
800
|
+
delete this._globalMessages[taskUUID];
|
|
801
|
+
resolve(reducedPrompt);
|
|
802
|
+
return true;
|
|
803
|
+
}
|
|
804
|
+
},
|
|
805
|
+
{
|
|
806
|
+
debugKey: "enhance-prompt",
|
|
807
|
+
timeOutDuration: this._timeOutDuration
|
|
727
808
|
}
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
809
|
+
);
|
|
810
|
+
lis.destroy();
|
|
811
|
+
return response;
|
|
812
|
+
},
|
|
813
|
+
{
|
|
814
|
+
maxRetries: totalRetry,
|
|
815
|
+
callback: () => {
|
|
816
|
+
lis == null ? void 0 : lis.destroy();
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
);
|
|
734
820
|
} catch (e) {
|
|
735
821
|
throw e;
|
|
736
822
|
}
|
|
@@ -753,6 +839,8 @@ var RunwareBase = class {
|
|
|
753
839
|
this._url = url;
|
|
754
840
|
this._sdkType = "CLIENT" /* CLIENT */;
|
|
755
841
|
this._shouldReconnect = shouldReconnect;
|
|
842
|
+
this._globalMaxRetries = globalMaxRetries;
|
|
843
|
+
this._timeOutDuration = timeOutDuration;
|
|
756
844
|
}
|
|
757
845
|
// protected addListener({
|
|
758
846
|
// lis,
|
|
@@ -951,13 +1039,13 @@ var RunwareBase = class {
|
|
|
951
1039
|
onPartialImages,
|
|
952
1040
|
includeCost,
|
|
953
1041
|
customTaskUUID,
|
|
954
|
-
retry
|
|
1042
|
+
retry
|
|
955
1043
|
}) {
|
|
956
|
-
await this.ensureConnection();
|
|
957
1044
|
let lis = void 0;
|
|
958
1045
|
let requestObject = void 0;
|
|
959
1046
|
let taskUUIDs = [];
|
|
960
1047
|
let retryCount = 0;
|
|
1048
|
+
const totalRetry = retry || this._globalMaxRetries;
|
|
961
1049
|
try {
|
|
962
1050
|
await this.ensureConnection();
|
|
963
1051
|
let seedImageUUID = null;
|
|
@@ -1047,7 +1135,7 @@ var RunwareBase = class {
|
|
|
1047
1135
|
return promise;
|
|
1048
1136
|
},
|
|
1049
1137
|
{
|
|
1050
|
-
maxRetries:
|
|
1138
|
+
maxRetries: totalRetry,
|
|
1051
1139
|
callback: () => {
|
|
1052
1140
|
lis == null ? void 0 : lis.destroy();
|
|
1053
1141
|
}
|
|
@@ -1057,7 +1145,7 @@ var RunwareBase = class {
|
|
|
1057
1145
|
if (e.taskUUID) {
|
|
1058
1146
|
throw e;
|
|
1059
1147
|
}
|
|
1060
|
-
if (retryCount >=
|
|
1148
|
+
if (retryCount >= totalRetry) {
|
|
1061
1149
|
return this.handleIncompleteImages({ taskUUIDs, error: e });
|
|
1062
1150
|
}
|
|
1063
1151
|
}
|
|
@@ -1152,7 +1240,11 @@ var RunwareBase = class {
|
|
|
1152
1240
|
return true;
|
|
1153
1241
|
}
|
|
1154
1242
|
},
|
|
1155
|
-
{
|
|
1243
|
+
{
|
|
1244
|
+
debugKey: "getting images",
|
|
1245
|
+
shouldThrowError,
|
|
1246
|
+
timeOutDuration: this._timeOutDuration
|
|
1247
|
+
}
|
|
1156
1248
|
);
|
|
1157
1249
|
}
|
|
1158
1250
|
handleIncompleteImages({
|
|
@@ -1177,9 +1269,10 @@ var RunwareBase = class {
|
|
|
1177
1269
|
// Runware/Runware-client.ts
|
|
1178
1270
|
var import_reconnect = __toESM(require_reconnect());
|
|
1179
1271
|
var RunwareClient = class extends RunwareBase {
|
|
1180
|
-
constructor(
|
|
1181
|
-
|
|
1182
|
-
|
|
1272
|
+
constructor(props) {
|
|
1273
|
+
const _a = props, { shouldReconnect } = _a, rest = __objRest(_a, ["shouldReconnect"]);
|
|
1274
|
+
super(rest);
|
|
1275
|
+
if (rest.apiKey) {
|
|
1183
1276
|
this._ws = new import_reconnect.default(
|
|
1184
1277
|
this._url
|
|
1185
1278
|
);
|
|
@@ -1191,8 +1284,8 @@ var RunwareClient = class extends RunwareBase {
|
|
|
1191
1284
|
// Runware/Runware-server.ts
|
|
1192
1285
|
var import_ws = __toESM(require("ws"));
|
|
1193
1286
|
var RunwareServer = class extends RunwareBase {
|
|
1194
|
-
constructor(
|
|
1195
|
-
super(
|
|
1287
|
+
constructor(props) {
|
|
1288
|
+
super(props);
|
|
1196
1289
|
this._instantiated = false;
|
|
1197
1290
|
this._listeners = [];
|
|
1198
1291
|
this._reconnectingIntervalId = null;
|
|
@@ -1213,7 +1306,7 @@ var RunwareServer = class extends RunwareBase {
|
|
|
1213
1306
|
}
|
|
1214
1307
|
};
|
|
1215
1308
|
this._sdkType = "SERVER" /* SERVER */;
|
|
1216
|
-
if (apiKey) {
|
|
1309
|
+
if (props.apiKey) {
|
|
1217
1310
|
this.connect();
|
|
1218
1311
|
}
|
|
1219
1312
|
}
|
|
@@ -1306,9 +1399,7 @@ var RunwareServer = class extends RunwareBase {
|
|
|
1306
1399
|
if (this._reconnectingIntervalId) {
|
|
1307
1400
|
clearInterval(this._reconnectingIntervalId);
|
|
1308
1401
|
}
|
|
1309
|
-
console.log("should reconnect", this._shouldReconnect);
|
|
1310
1402
|
if (this._shouldReconnect) {
|
|
1311
|
-
console.log("reconnecting");
|
|
1312
1403
|
setTimeout(() => this.connect(), 1e3);
|
|
1313
1404
|
}
|
|
1314
1405
|
}
|