@runware/sdk-js 1.0.30 → 1.1.0
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 +117 -61
- package/dist/index.d.ts +117 -61
- package/dist/index.js +276 -340
- package/dist/index.mjs +275 -340
- package/package.json +2 -2
- package/readme.md +192 -72
package/dist/index.js
CHANGED
|
@@ -224,6 +224,7 @@ __export(Runware_exports, {
|
|
|
224
224
|
EOpenPosePreProcessor: () => EOpenPosePreProcessor,
|
|
225
225
|
EPreProcessor: () => EPreProcessor,
|
|
226
226
|
EPreProcessorGroup: () => EPreProcessorGroup,
|
|
227
|
+
ETaskType: () => ETaskType,
|
|
227
228
|
Environment: () => Environment,
|
|
228
229
|
Runware: () => Runware,
|
|
229
230
|
RunwareServer: () => RunwareServer,
|
|
@@ -243,6 +244,17 @@ var SdkType = /* @__PURE__ */ ((SdkType2) => {
|
|
|
243
244
|
SdkType2["SERVER"] = "SERVER";
|
|
244
245
|
return SdkType2;
|
|
245
246
|
})(SdkType || {});
|
|
247
|
+
var ETaskType = /* @__PURE__ */ ((ETaskType2) => {
|
|
248
|
+
ETaskType2["IMAGE_INFERENCE"] = "imageInference";
|
|
249
|
+
ETaskType2["IMAGE_UPLOAD"] = "imageUpload";
|
|
250
|
+
ETaskType2["IMAGE_UPSCALE"] = "imageUpscale";
|
|
251
|
+
ETaskType2["IMAGE_BACKGROUND_REMOVAL"] = "imageBackgroundRemoval";
|
|
252
|
+
ETaskType2["IMAGE_CAPTION"] = "imageCaption";
|
|
253
|
+
ETaskType2["IMAGE_CONTROL_NET_PRE_PROCESS"] = "imageControlNetPreProcess";
|
|
254
|
+
ETaskType2["PROMPT_ENHANCE"] = "promptEnhance";
|
|
255
|
+
ETaskType2["AUTHENTICATION"] = "authentication";
|
|
256
|
+
return ETaskType2;
|
|
257
|
+
})(ETaskType || {});
|
|
246
258
|
var EControlMode = /* @__PURE__ */ ((EControlMode2) => {
|
|
247
259
|
EControlMode2["BALANCED"] = "balanced";
|
|
248
260
|
EControlMode2["PROMPT"] = "prompt";
|
|
@@ -355,82 +367,6 @@ var fileToBase64 = (file) => new Promise((resolve) => {
|
|
|
355
367
|
});
|
|
356
368
|
var getUUID = () => (0, import_uuid.v4)();
|
|
357
369
|
var isValidUUID = (uuid) => (0, import_uuid.validate)(uuid);
|
|
358
|
-
var getTaskType = ({
|
|
359
|
-
prompt,
|
|
360
|
-
controlNet,
|
|
361
|
-
imageMaskInitiator,
|
|
362
|
-
imageInitiator
|
|
363
|
-
}) => {
|
|
364
|
-
if (evaluateToBoolean(prompt, !controlNet, !imageMaskInitiator, !imageInitiator)) {
|
|
365
|
-
return 1;
|
|
366
|
-
}
|
|
367
|
-
if (evaluateToBoolean(prompt, !controlNet, !imageMaskInitiator, imageInitiator)) {
|
|
368
|
-
return 2;
|
|
369
|
-
}
|
|
370
|
-
if (evaluateToBoolean(prompt, !controlNet, imageMaskInitiator, imageInitiator)) {
|
|
371
|
-
return 3;
|
|
372
|
-
}
|
|
373
|
-
if (evaluateToBoolean(prompt, controlNet, !imageMaskInitiator, !imageInitiator)) {
|
|
374
|
-
return 9;
|
|
375
|
-
}
|
|
376
|
-
if (evaluateToBoolean(prompt, controlNet, !imageMaskInitiator, imageInitiator)) {
|
|
377
|
-
return 10;
|
|
378
|
-
}
|
|
379
|
-
if (evaluateToBoolean(prompt, controlNet, imageMaskInitiator, imageInitiator)) {
|
|
380
|
-
return 10;
|
|
381
|
-
}
|
|
382
|
-
};
|
|
383
|
-
var evaluateToBoolean = (...args) => [...args].every((e) => !!e);
|
|
384
|
-
var compact = (value, data) => !!value ? data : {};
|
|
385
|
-
var getPreprocessorType = (processor) => {
|
|
386
|
-
const processorGroup = Object.keys(
|
|
387
|
-
EPreProcessorGroup
|
|
388
|
-
);
|
|
389
|
-
switch (processor) {
|
|
390
|
-
case "canny" /* canny */:
|
|
391
|
-
return "canny" /* canny */;
|
|
392
|
-
case "depth_leres" /* depth_leres */:
|
|
393
|
-
case "depth_midas" /* depth_midas */:
|
|
394
|
-
case "depth_zoe" /* depth_zoe */:
|
|
395
|
-
return "depth" /* depth */;
|
|
396
|
-
case "inpaint_global_harmonious" /* inpaint_global_harmonious */:
|
|
397
|
-
return "depth" /* depth */;
|
|
398
|
-
case "lineart_anime" /* lineart_anime */:
|
|
399
|
-
return "lineart_anime" /* lineart_anime */;
|
|
400
|
-
case "lineart_coarse" /* lineart_coarse */:
|
|
401
|
-
case "lineart_realistic" /* lineart_realistic */:
|
|
402
|
-
case "lineart_standard" /* lineart_standard */:
|
|
403
|
-
return "lineart" /* lineart */;
|
|
404
|
-
case "mlsd" /* mlsd */:
|
|
405
|
-
return "mlsd" /* mlsd */;
|
|
406
|
-
case "normal_bae" /* normal_bae */:
|
|
407
|
-
return "normalbae" /* normalbae */;
|
|
408
|
-
case "openpose_face" /* openpose_face */:
|
|
409
|
-
case "openpose_faceonly" /* openpose_faceonly */:
|
|
410
|
-
case "openpose_full" /* openpose_full */:
|
|
411
|
-
case "openpose_hand" /* openpose_hand */:
|
|
412
|
-
case "openpose" /* openpose */:
|
|
413
|
-
return "openpose" /* openpose */;
|
|
414
|
-
case "scribble_hed" /* scribble_hed */:
|
|
415
|
-
case "scribble_pidinet" /* scribble_pidinet */:
|
|
416
|
-
return "scribble" /* scribble */;
|
|
417
|
-
case "seg_ofade20k" /* seg_ofade20k */:
|
|
418
|
-
case "seg_ofcoco" /* seg_ofcoco */:
|
|
419
|
-
case "seg_ufade20k" /* seg_ufade20k */:
|
|
420
|
-
return "seg" /* seg */;
|
|
421
|
-
case "shuffle" /* shuffle */:
|
|
422
|
-
return "shuffle" /* shuffle */;
|
|
423
|
-
case "softedge_hed" /* softedge_hed */:
|
|
424
|
-
case "softedge_hedsafe" /* softedge_hedsafe */:
|
|
425
|
-
case "softedge_pidinet" /* softedge_pidinet */:
|
|
426
|
-
case "softedge_pidisafe" /* softedge_pidisafe */:
|
|
427
|
-
return "softedge" /* softedge */;
|
|
428
|
-
case "tile_gaussian" /* tile_gaussian */:
|
|
429
|
-
return "tile" /* tile */;
|
|
430
|
-
default:
|
|
431
|
-
return "canny" /* canny */;
|
|
432
|
-
}
|
|
433
|
-
};
|
|
434
370
|
var accessDeepObject = ({
|
|
435
371
|
key,
|
|
436
372
|
data,
|
|
@@ -508,34 +444,36 @@ var RunwareBase = class {
|
|
|
508
444
|
var _a;
|
|
509
445
|
return ((_a = this._ws) == null ? void 0 : _a.readyState) === 1;
|
|
510
446
|
};
|
|
511
|
-
|
|
447
|
+
// We moving to an array format, it make sense to consolidate all request to an array here
|
|
448
|
+
this.send = (msg) => this._ws.send(JSON.stringify([msg]));
|
|
512
449
|
this.uploadImage = async (file) => {
|
|
513
450
|
try {
|
|
514
451
|
return await asyncRetry(async () => {
|
|
515
452
|
const taskUUID = getUUID();
|
|
516
453
|
if (typeof file === "string" && isValidUUID(file)) {
|
|
517
454
|
return {
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
taskUUID
|
|
455
|
+
imageURL: file,
|
|
456
|
+
imageUUID: file,
|
|
457
|
+
taskUUID,
|
|
458
|
+
taskType: "imageUpload" /* IMAGE_UPLOAD */
|
|
521
459
|
};
|
|
522
460
|
}
|
|
523
461
|
const imageBase64 = typeof file === "string" ? file : await fileToBase64(file);
|
|
524
462
|
this.send({
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
taskType: 7
|
|
529
|
-
}
|
|
463
|
+
taskType: "imageUpload" /* IMAGE_UPLOAD */,
|
|
464
|
+
image: imageBase64,
|
|
465
|
+
taskUUID
|
|
530
466
|
});
|
|
531
467
|
const lis = this.globalListener({
|
|
532
|
-
responseKey: "newUploadedImageUUID",
|
|
533
|
-
taskKey: "newUploadedImageUUID",
|
|
534
468
|
taskUUID
|
|
535
469
|
});
|
|
536
470
|
const image = await getIntervalWithPromise(
|
|
537
471
|
({ resolve, reject }) => {
|
|
538
|
-
const uploadedImage = this.
|
|
472
|
+
const uploadedImage = this.getSingleMessage({
|
|
473
|
+
taskUUID
|
|
474
|
+
});
|
|
475
|
+
if (!uploadedImage)
|
|
476
|
+
return;
|
|
539
477
|
if (uploadedImage == null ? void 0 : uploadedImage.error) {
|
|
540
478
|
reject(uploadedImage);
|
|
541
479
|
return true;
|
|
@@ -555,44 +493,54 @@ var RunwareBase = class {
|
|
|
555
493
|
throw e;
|
|
556
494
|
}
|
|
557
495
|
};
|
|
558
|
-
this.
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
width,
|
|
496
|
+
this.controlNetPreProcess = async ({
|
|
497
|
+
inputImage,
|
|
498
|
+
preProcessor,
|
|
562
499
|
height,
|
|
563
|
-
|
|
500
|
+
width,
|
|
501
|
+
outputType,
|
|
502
|
+
outputFormat,
|
|
564
503
|
highThresholdCanny,
|
|
565
|
-
|
|
566
|
-
|
|
504
|
+
lowThresholdCanny,
|
|
505
|
+
includeHandsAndFaceOpenPose,
|
|
506
|
+
includeCost
|
|
567
507
|
}) => {
|
|
568
508
|
try {
|
|
569
|
-
const image = await this.uploadImage(
|
|
570
|
-
if (!image)
|
|
509
|
+
const image = await this.uploadImage(inputImage);
|
|
510
|
+
if (!(image == null ? void 0 : image.imageUUID))
|
|
571
511
|
return null;
|
|
572
512
|
const taskUUID = getUUID();
|
|
573
|
-
this.send({
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
513
|
+
this.send(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
514
|
+
inputImage: image.imageUUID,
|
|
515
|
+
taskType: "imageControlNetPreProcess" /* IMAGE_CONTROL_NET_PRE_PROCESS */,
|
|
516
|
+
taskUUID,
|
|
517
|
+
preProcessor
|
|
518
|
+
}, 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({
|
|
519
|
+
key: "highThresholdCanny",
|
|
520
|
+
value: highThresholdCanny
|
|
521
|
+
})), evaluateNonTrue({
|
|
522
|
+
key: "lowThresholdCanny",
|
|
523
|
+
value: lowThresholdCanny
|
|
524
|
+
})), evaluateNonTrue({
|
|
525
|
+
key: "includeHandsAndFaceOpenPose",
|
|
526
|
+
value: includeHandsAndFaceOpenPose
|
|
527
|
+
})));
|
|
581
528
|
const lis = this.globalListener({
|
|
582
|
-
responseKey: "newPreProcessControlNet",
|
|
583
|
-
taskKey: "newPreProcessControlNet",
|
|
584
529
|
taskUUID
|
|
585
530
|
});
|
|
586
531
|
const guideImage = await getIntervalWithPromise(
|
|
587
532
|
({ resolve, reject }) => {
|
|
588
|
-
const uploadedImage = this.
|
|
533
|
+
const uploadedImage = this.getSingleMessage({
|
|
534
|
+
taskUUID
|
|
535
|
+
});
|
|
536
|
+
if (!uploadedImage)
|
|
537
|
+
return;
|
|
589
538
|
if (uploadedImage == null ? void 0 : uploadedImage.error) {
|
|
590
539
|
reject(uploadedImage);
|
|
591
540
|
return true;
|
|
592
541
|
}
|
|
593
542
|
if (uploadedImage) {
|
|
594
|
-
|
|
595
|
-
resolve(uploadedImage == null ? void 0 : uploadedImage.newPreProcessControlNet);
|
|
543
|
+
resolve(uploadedImage);
|
|
596
544
|
return true;
|
|
597
545
|
}
|
|
598
546
|
},
|
|
@@ -605,38 +553,40 @@ var RunwareBase = class {
|
|
|
605
553
|
}
|
|
606
554
|
};
|
|
607
555
|
this.requestImageToText = async ({
|
|
608
|
-
|
|
556
|
+
inputImage,
|
|
557
|
+
includeCost
|
|
609
558
|
}) => {
|
|
610
559
|
try {
|
|
611
560
|
await this.ensureConnection();
|
|
612
561
|
return await asyncRetry(async () => {
|
|
613
562
|
const imageUploaded = await this.uploadImage(
|
|
614
|
-
|
|
563
|
+
inputImage
|
|
615
564
|
);
|
|
616
|
-
if (!(imageUploaded == null ? void 0 : imageUploaded.
|
|
565
|
+
if (!(imageUploaded == null ? void 0 : imageUploaded.imageUUID))
|
|
617
566
|
return null;
|
|
618
567
|
const taskUUID = getUUID();
|
|
619
|
-
this.send({
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
});
|
|
568
|
+
this.send(__spreadValues({
|
|
569
|
+
taskUUID,
|
|
570
|
+
taskType: "imageCaption" /* IMAGE_CAPTION */,
|
|
571
|
+
inputImage: imageUploaded.imageUUID
|
|
572
|
+
}, evaluateNonTrue({ key: "includeCost", value: includeCost })));
|
|
625
573
|
const lis = this.globalListener({
|
|
626
|
-
responseKey: "newReverseClip",
|
|
627
|
-
taskKey: "newReverseClip.texts",
|
|
628
574
|
taskUUID
|
|
629
575
|
});
|
|
630
576
|
const response = await getIntervalWithPromise(
|
|
631
577
|
({ resolve, reject }) => {
|
|
632
|
-
const newReverseClip = this.
|
|
578
|
+
const newReverseClip = this.getSingleMessage({
|
|
579
|
+
taskUUID
|
|
580
|
+
});
|
|
581
|
+
if (!newReverseClip)
|
|
582
|
+
return;
|
|
633
583
|
if (newReverseClip == null ? void 0 : newReverseClip.error) {
|
|
634
584
|
reject(newReverseClip);
|
|
635
585
|
return true;
|
|
636
586
|
}
|
|
637
587
|
if (newReverseClip) {
|
|
638
588
|
delete this._globalMessages[taskUUID];
|
|
639
|
-
resolve(newReverseClip
|
|
589
|
+
resolve(newReverseClip);
|
|
640
590
|
return true;
|
|
641
591
|
}
|
|
642
592
|
},
|
|
@@ -650,39 +600,59 @@ var RunwareBase = class {
|
|
|
650
600
|
}
|
|
651
601
|
};
|
|
652
602
|
this.removeImageBackground = async ({
|
|
653
|
-
|
|
603
|
+
inputImage,
|
|
604
|
+
outputType,
|
|
605
|
+
outputFormat,
|
|
606
|
+
rgba,
|
|
607
|
+
postProcessMask,
|
|
608
|
+
returnOnlyMask,
|
|
609
|
+
alphaMatting,
|
|
610
|
+
alphaMattingForegroundThreshold,
|
|
611
|
+
alphaMattingBackgroundThreshold,
|
|
612
|
+
alphaMattingErodeSize,
|
|
613
|
+
includeCost
|
|
654
614
|
}) => {
|
|
655
615
|
try {
|
|
656
616
|
await this.ensureConnection();
|
|
657
617
|
return await asyncRetry(async () => {
|
|
658
618
|
const imageUploaded = await this.uploadImage(
|
|
659
|
-
|
|
619
|
+
inputImage
|
|
660
620
|
);
|
|
661
|
-
if (!(imageUploaded == null ? void 0 : imageUploaded.
|
|
621
|
+
if (!(imageUploaded == null ? void 0 : imageUploaded.imageUUID))
|
|
662
622
|
return null;
|
|
663
623
|
const taskUUID = getUUID();
|
|
664
|
-
this.send({
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
624
|
+
this.send(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
625
|
+
taskType: "imageBackgroundRemoval" /* IMAGE_BACKGROUND_REMOVAL */,
|
|
626
|
+
taskUUID,
|
|
627
|
+
inputImage: imageUploaded.imageUUID
|
|
628
|
+
}, evaluateNonTrue({ key: "rgba", value: rgba })), evaluateNonTrue({
|
|
629
|
+
key: "postProcessMask",
|
|
630
|
+
value: postProcessMask
|
|
631
|
+
})), evaluateNonTrue({ key: "returnOnlyMask", value: returnOnlyMask })), evaluateNonTrue({ key: "alphaMatting", value: alphaMatting })), evaluateNonTrue({ key: "includeCost", value: includeCost })), evaluateNonTrue({
|
|
632
|
+
key: "alphaMattingForegroundThreshold",
|
|
633
|
+
value: alphaMattingForegroundThreshold
|
|
634
|
+
})), evaluateNonTrue({
|
|
635
|
+
key: "alphaMattingBackgroundThreshold",
|
|
636
|
+
value: alphaMattingBackgroundThreshold
|
|
637
|
+
})), evaluateNonTrue({
|
|
638
|
+
key: "alphaMattingErodeSize",
|
|
639
|
+
value: alphaMattingErodeSize
|
|
640
|
+
})), evaluateNonTrue({ key: "outputType", value: outputType })), evaluateNonTrue({ key: "outputFormat", value: outputFormat })));
|
|
671
641
|
const lis = this.globalListener({
|
|
672
|
-
responseKey: "newRemoveBackground",
|
|
673
|
-
taskKey: "newRemoveBackground.images",
|
|
674
642
|
taskUUID
|
|
675
643
|
});
|
|
676
644
|
const response = await getIntervalWithPromise(
|
|
677
645
|
({ resolve, reject }) => {
|
|
678
|
-
const newRemoveBackground = this.
|
|
646
|
+
const newRemoveBackground = this.getSingleMessage({ taskUUID });
|
|
647
|
+
if (!newRemoveBackground)
|
|
648
|
+
return;
|
|
679
649
|
if (newRemoveBackground == null ? void 0 : newRemoveBackground.error) {
|
|
680
650
|
reject(newRemoveBackground);
|
|
681
651
|
return true;
|
|
682
652
|
}
|
|
683
653
|
if (newRemoveBackground) {
|
|
684
654
|
delete this._globalMessages[taskUUID];
|
|
685
|
-
resolve(newRemoveBackground);
|
|
655
|
+
resolve([newRemoveBackground]);
|
|
686
656
|
return true;
|
|
687
657
|
}
|
|
688
658
|
},
|
|
@@ -696,39 +666,41 @@ var RunwareBase = class {
|
|
|
696
666
|
}
|
|
697
667
|
};
|
|
698
668
|
this.upscaleGan = async ({
|
|
699
|
-
|
|
700
|
-
upscaleFactor
|
|
669
|
+
inputImage,
|
|
670
|
+
upscaleFactor,
|
|
671
|
+
outputType,
|
|
672
|
+
outputFormat,
|
|
673
|
+
includeCost
|
|
701
674
|
}) => {
|
|
702
675
|
try {
|
|
703
676
|
await this.ensureConnection();
|
|
704
677
|
return await asyncRetry(async () => {
|
|
705
678
|
let imageUploaded;
|
|
706
|
-
imageUploaded = await this.uploadImage(
|
|
707
|
-
if (!(imageUploaded == null ? void 0 : imageUploaded.
|
|
679
|
+
imageUploaded = await this.uploadImage(inputImage);
|
|
680
|
+
if (!(imageUploaded == null ? void 0 : imageUploaded.imageUUID))
|
|
708
681
|
return null;
|
|
709
682
|
const taskUUID = getUUID();
|
|
710
|
-
this.send({
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
});
|
|
683
|
+
this.send(__spreadValues(__spreadValues(__spreadValues({
|
|
684
|
+
taskUUID,
|
|
685
|
+
inputImage: imageUploaded == null ? void 0 : imageUploaded.imageUUID,
|
|
686
|
+
taskType: "imageUpscale" /* IMAGE_UPSCALE */,
|
|
687
|
+
upscaleFactor
|
|
688
|
+
}, evaluateNonTrue({ key: "includeCost", value: includeCost })), outputType ? { outputType } : {}), outputFormat ? { outputFormat } : {}));
|
|
717
689
|
const lis = this.globalListener({
|
|
718
|
-
responseKey: "newUpscaleGan",
|
|
719
|
-
taskKey: "newUpscaleGan.images",
|
|
720
690
|
taskUUID
|
|
721
691
|
});
|
|
722
692
|
const response = await getIntervalWithPromise(
|
|
723
693
|
({ resolve, reject }) => {
|
|
724
|
-
const newUpscaleGan = this.
|
|
694
|
+
const newUpscaleGan = this.getSingleMessage({ taskUUID });
|
|
695
|
+
if (!newUpscaleGan)
|
|
696
|
+
return;
|
|
725
697
|
if (newUpscaleGan == null ? void 0 : newUpscaleGan.error) {
|
|
726
698
|
reject(newUpscaleGan);
|
|
727
699
|
return true;
|
|
728
700
|
}
|
|
729
701
|
if (newUpscaleGan) {
|
|
730
702
|
delete this._globalMessages[taskUUID];
|
|
731
|
-
resolve(newUpscaleGan);
|
|
703
|
+
resolve([newUpscaleGan]);
|
|
732
704
|
return true;
|
|
733
705
|
}
|
|
734
706
|
},
|
|
@@ -744,25 +716,22 @@ var RunwareBase = class {
|
|
|
744
716
|
this.enhancePrompt = async ({
|
|
745
717
|
prompt,
|
|
746
718
|
promptMaxLength = 380,
|
|
747
|
-
|
|
748
|
-
|
|
719
|
+
promptVersions = 1,
|
|
720
|
+
includeCost
|
|
749
721
|
}) => {
|
|
750
722
|
try {
|
|
751
723
|
await this.ensureConnection();
|
|
752
724
|
return await asyncRetry(async () => {
|
|
753
725
|
const taskUUID = getUUID();
|
|
754
|
-
this.send({
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
});
|
|
726
|
+
this.send(__spreadProps(__spreadValues({
|
|
727
|
+
prompt,
|
|
728
|
+
taskUUID,
|
|
729
|
+
promptMaxLength,
|
|
730
|
+
promptVersions
|
|
731
|
+
}, evaluateNonTrue({ key: "includeCost", value: includeCost })), {
|
|
732
|
+
taskType: "promptEnhance" /* PROMPT_ENHANCE */
|
|
733
|
+
}));
|
|
763
734
|
const lis = this.globalListener({
|
|
764
|
-
responseKey: "newPromptEnhancer",
|
|
765
|
-
taskKey: "newPromptEnhancer.texts",
|
|
766
735
|
taskUUID
|
|
767
736
|
});
|
|
768
737
|
const response = await getIntervalWithPromise(
|
|
@@ -787,6 +756,12 @@ var RunwareBase = class {
|
|
|
787
756
|
throw e;
|
|
788
757
|
}
|
|
789
758
|
};
|
|
759
|
+
this.getSingleMessage = ({ taskUUID }) => {
|
|
760
|
+
var _a, _b;
|
|
761
|
+
if (!((_a = this._globalMessages[taskUUID]) == null ? void 0 : _a[0]))
|
|
762
|
+
return null;
|
|
763
|
+
return (_b = this._globalMessages[taskUUID]) == null ? void 0 : _b[0];
|
|
764
|
+
};
|
|
790
765
|
this.connected = () => this.isWebsocketReadyState() && !!this._connectionSessionUUID;
|
|
791
766
|
this._apiKey = apiKey;
|
|
792
767
|
this._url = url;
|
|
@@ -814,14 +789,27 @@ var RunwareBase = class {
|
|
|
814
789
|
// }
|
|
815
790
|
addListener({
|
|
816
791
|
lis,
|
|
817
|
-
check,
|
|
818
|
-
groupKey
|
|
792
|
+
// check,
|
|
793
|
+
groupKey,
|
|
794
|
+
taskUUID
|
|
819
795
|
}) {
|
|
820
796
|
const listener = (msg) => {
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
797
|
+
var _a;
|
|
798
|
+
const arrayMessage = Array.isArray(msg == null ? void 0 : msg.data) ? msg.data : [msg.data];
|
|
799
|
+
const arrayErrors = Array.isArray(msg == null ? void 0 : msg.errors) ? msg.errors : [msg.errors];
|
|
800
|
+
const filteredMessage = arrayMessage.filter(
|
|
801
|
+
(v) => (v == null ? void 0 : v.taskUUID) === taskUUID
|
|
802
|
+
);
|
|
803
|
+
const filteredErrors = arrayErrors.filter(
|
|
804
|
+
(v) => (v == null ? void 0 : v.taskUUID) === taskUUID
|
|
805
|
+
);
|
|
806
|
+
if (filteredErrors.length) {
|
|
807
|
+
lis({ error: __spreadValues({}, (_a = arrayErrors[0]) != null ? _a : {}) });
|
|
808
|
+
return;
|
|
809
|
+
}
|
|
810
|
+
if (filteredMessage.length) {
|
|
811
|
+
lis({ [taskUUID]: arrayMessage });
|
|
812
|
+
return;
|
|
825
813
|
}
|
|
826
814
|
};
|
|
827
815
|
const groupListener = { key: getUUID(), listener, groupKey };
|
|
@@ -837,28 +825,24 @@ var RunwareBase = class {
|
|
|
837
825
|
this._ws.onopen = (e) => {
|
|
838
826
|
if (this._connectionSessionUUID) {
|
|
839
827
|
this.send({
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
}
|
|
828
|
+
taskType: "authentication" /* AUTHENTICATION */,
|
|
829
|
+
apiKey: this._apiKey,
|
|
830
|
+
connectionSessionUUID: this._connectionSessionUUID
|
|
844
831
|
});
|
|
845
832
|
} else {
|
|
846
|
-
this.send({
|
|
833
|
+
this.send({ apiKey: this._apiKey, taskType: "authentication" /* AUTHENTICATION */ });
|
|
847
834
|
}
|
|
848
835
|
this.addListener({
|
|
849
|
-
|
|
850
|
-
var _a;
|
|
851
|
-
return (_a = m == null ? void 0 : m.newConnectionSessionUUID) == null ? void 0 : _a.connectionSessionUUID;
|
|
852
|
-
},
|
|
836
|
+
taskUUID: "authentication" /* AUTHENTICATION */,
|
|
853
837
|
lis: (m) => {
|
|
854
|
-
var _a;
|
|
838
|
+
var _a, _b;
|
|
855
839
|
if (m == null ? void 0 : m.error) {
|
|
856
840
|
if (m.errorId === 19) {
|
|
857
841
|
this._invalidAPIkey = "Invalid API key";
|
|
858
842
|
}
|
|
859
843
|
return;
|
|
860
844
|
}
|
|
861
|
-
this._connectionSessionUUID = (_a = m == null ? void 0 : m
|
|
845
|
+
this._connectionSessionUUID = (_b = (_a = m == null ? void 0 : m["authentication" /* AUTHENTICATION */]) == null ? void 0 : _a[0]) == null ? void 0 : _b.connectionSessionUUID;
|
|
862
846
|
this._invalidAPIkey = void 0;
|
|
863
847
|
}
|
|
864
848
|
});
|
|
@@ -888,13 +872,10 @@ var RunwareBase = class {
|
|
|
888
872
|
groupKey
|
|
889
873
|
}) {
|
|
890
874
|
return this.addListener({
|
|
891
|
-
|
|
892
|
-
var _a;
|
|
893
|
-
return (_a = m.newImages) == null ? void 0 : _a.images;
|
|
894
|
-
},
|
|
875
|
+
taskUUID,
|
|
895
876
|
lis: (m) => {
|
|
896
|
-
var _a, _b
|
|
897
|
-
const images = (
|
|
877
|
+
var _a, _b;
|
|
878
|
+
const images = (_a = m == null ? void 0 : m[taskUUID]) == null ? void 0 : _a.filter(
|
|
898
879
|
(img) => img.taskUUID === taskUUID
|
|
899
880
|
);
|
|
900
881
|
onPartialImages == null ? void 0 : onPartialImages(images, (m == null ? void 0 : m.error) && m);
|
|
@@ -904,7 +885,7 @@ var RunwareBase = class {
|
|
|
904
885
|
if (this._sdkType === "CLIENT" /* CLIENT */) {
|
|
905
886
|
this._globalImages = [
|
|
906
887
|
...this._globalImages,
|
|
907
|
-
...(
|
|
888
|
+
...(_b = m == null ? void 0 : m[taskUUID]) != null ? _b : []
|
|
908
889
|
];
|
|
909
890
|
} else {
|
|
910
891
|
this._globalImages = [...this._globalImages, ...images];
|
|
@@ -914,27 +895,25 @@ var RunwareBase = class {
|
|
|
914
895
|
groupKey
|
|
915
896
|
});
|
|
916
897
|
}
|
|
917
|
-
globalListener({
|
|
918
|
-
responseKey,
|
|
919
|
-
taskKey,
|
|
920
|
-
taskUUID
|
|
921
|
-
}) {
|
|
898
|
+
globalListener({ taskUUID }) {
|
|
922
899
|
return this.addListener({
|
|
923
|
-
check: (m) => {
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
},
|
|
900
|
+
// check: (m) => {
|
|
901
|
+
// const value = accessDeepObject({
|
|
902
|
+
// key: responseKey,
|
|
903
|
+
// data: m,
|
|
904
|
+
// useZero: false,
|
|
905
|
+
// });
|
|
906
|
+
// return !!value;
|
|
907
|
+
// },
|
|
908
|
+
// check: responseKey,
|
|
909
|
+
taskUUID,
|
|
931
910
|
lis: (m) => {
|
|
932
911
|
if (m.error) {
|
|
933
912
|
this._globalMessages[taskUUID] = m;
|
|
934
913
|
return;
|
|
935
914
|
}
|
|
936
915
|
const value = accessDeepObject({
|
|
937
|
-
key:
|
|
916
|
+
key: taskUUID,
|
|
938
917
|
data: m,
|
|
939
918
|
useZero: false
|
|
940
919
|
});
|
|
@@ -953,24 +932,30 @@ var RunwareBase = class {
|
|
|
953
932
|
});
|
|
954
933
|
}
|
|
955
934
|
async requestImages({
|
|
956
|
-
|
|
935
|
+
outputType,
|
|
936
|
+
outputFormat,
|
|
937
|
+
uploadEndpoint,
|
|
938
|
+
checkNsfw,
|
|
957
939
|
positivePrompt,
|
|
958
|
-
imageSize,
|
|
959
940
|
negativePrompt,
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
941
|
+
seedImage,
|
|
942
|
+
maskImage,
|
|
943
|
+
strength,
|
|
944
|
+
height,
|
|
945
|
+
width,
|
|
946
|
+
model,
|
|
965
947
|
steps,
|
|
966
|
-
onPartialImages,
|
|
967
|
-
lora,
|
|
968
|
-
seed,
|
|
969
|
-
gScale,
|
|
970
|
-
checkNsfw,
|
|
971
|
-
returnBase64Image,
|
|
972
948
|
scheduler,
|
|
973
|
-
|
|
949
|
+
seed,
|
|
950
|
+
CFGScale,
|
|
951
|
+
clipSkip,
|
|
952
|
+
usePromptWeighting,
|
|
953
|
+
numberResults = 1,
|
|
954
|
+
controlNet,
|
|
955
|
+
lora,
|
|
956
|
+
useCache,
|
|
957
|
+
onPartialImages,
|
|
958
|
+
includeCost
|
|
974
959
|
}) {
|
|
975
960
|
let lis = void 0;
|
|
976
961
|
let requestObject = void 0;
|
|
@@ -978,86 +963,68 @@ var RunwareBase = class {
|
|
|
978
963
|
let retryCount = 0;
|
|
979
964
|
try {
|
|
980
965
|
await this.ensureConnection();
|
|
981
|
-
let
|
|
982
|
-
let
|
|
966
|
+
let seedImageUUID = null;
|
|
967
|
+
let maskImageUUID = null;
|
|
983
968
|
let controlNetData = [];
|
|
984
|
-
if (
|
|
985
|
-
const uploadedImage = await this.uploadImage(
|
|
969
|
+
if (seedImage) {
|
|
970
|
+
const uploadedImage = await this.uploadImage(seedImage);
|
|
986
971
|
if (!uploadedImage)
|
|
987
972
|
return [];
|
|
988
|
-
|
|
973
|
+
seedImageUUID = uploadedImage.imageUUID;
|
|
989
974
|
}
|
|
990
|
-
if (
|
|
991
|
-
const uploadedMaskInitiator = await this.uploadImage(
|
|
992
|
-
imageMaskInitiator
|
|
993
|
-
);
|
|
975
|
+
if (maskImage) {
|
|
976
|
+
const uploadedMaskInitiator = await this.uploadImage(maskImage);
|
|
994
977
|
if (!uploadedMaskInitiator)
|
|
995
978
|
return [];
|
|
996
|
-
|
|
979
|
+
maskImageUUID = uploadedMaskInitiator.imageUUID;
|
|
997
980
|
}
|
|
998
981
|
if (controlNet == null ? void 0 : controlNet.length) {
|
|
999
982
|
for (let i = 0; i < controlNet.length; i++) {
|
|
1000
983
|
const controlData = controlNet[i];
|
|
1001
|
-
const anyControlData = controlData;
|
|
1002
984
|
const {
|
|
1003
985
|
endStep,
|
|
1004
|
-
preprocessor,
|
|
1005
986
|
startStep,
|
|
1006
987
|
weight,
|
|
1007
988
|
guideImage,
|
|
1008
|
-
guideImageUnprocessed,
|
|
1009
989
|
controlMode,
|
|
1010
|
-
|
|
990
|
+
startStepPercentage,
|
|
991
|
+
endStepPercentage,
|
|
992
|
+
model: controlNetModel
|
|
1011
993
|
} = controlData;
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
};
|
|
1018
|
-
} else
|
|
1019
|
-
return {};
|
|
1020
|
-
};
|
|
1021
|
-
const imageUploaded = await (guideImageUnprocessed ? this.uploadUnprocessedImage(__spreadProps(__spreadValues({
|
|
1022
|
-
file: guideImageUnprocessed,
|
|
1023
|
-
preProcessorType: getPreprocessorType(
|
|
1024
|
-
preprocessor
|
|
1025
|
-
),
|
|
1026
|
-
includeHandsAndFaceOpenPose: anyControlData.includeHandsAndFaceOpenPose
|
|
1027
|
-
}, getCannyObject()), {
|
|
1028
|
-
returnBase64Image: returnBase64Image2
|
|
1029
|
-
})) : this.uploadImage(guideImage));
|
|
994
|
+
if (!guideImage)
|
|
995
|
+
return;
|
|
996
|
+
const imageUploaded = await this.uploadImage(
|
|
997
|
+
guideImage
|
|
998
|
+
);
|
|
1030
999
|
if (!imageUploaded)
|
|
1031
|
-
return
|
|
1032
|
-
controlNetData.push(__spreadValues({
|
|
1033
|
-
|
|
1000
|
+
return;
|
|
1001
|
+
controlNetData.push(__spreadProps(__spreadValues(__spreadValues({
|
|
1002
|
+
guideImage: imageUploaded.imageUUID,
|
|
1003
|
+
model: controlNetModel,
|
|
1034
1004
|
endStep,
|
|
1035
|
-
preprocessor,
|
|
1036
1005
|
startStep,
|
|
1037
|
-
weight
|
|
1006
|
+
weight
|
|
1007
|
+
}, evaluateNonTrue({
|
|
1008
|
+
key: "startStepPercentage",
|
|
1009
|
+
value: startStepPercentage
|
|
1010
|
+
})), evaluateNonTrue({
|
|
1011
|
+
key: "endStepPercentage",
|
|
1012
|
+
value: endStepPercentage
|
|
1013
|
+
})), {
|
|
1038
1014
|
controlMode: controlMode || "controlnet" /* CONTROL_NET */
|
|
1039
|
-
}
|
|
1015
|
+
}));
|
|
1040
1016
|
}
|
|
1041
1017
|
}
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
sizeId: imageSize,
|
|
1050
|
-
taskType: getTaskType({
|
|
1051
|
-
prompt,
|
|
1052
|
-
controlNet,
|
|
1053
|
-
imageInitiator,
|
|
1054
|
-
imageMaskInitiator
|
|
1055
|
-
}),
|
|
1056
|
-
useCache
|
|
1057
|
-
}, scheduler ? { scheduler } : {}), returnBase64Image ? { returnBase64Image } : {}), evaluateNonTrue({ key: "checkNsfw", value: checkNsfw })), evaluateNonTrue({ key: "gScale", value: gScale })), evaluateNonTrue({ key: "steps", value: steps })), evaluateNonTrue({
|
|
1018
|
+
requestObject = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadProps(__spreadValues(__spreadValues(__spreadValues({
|
|
1019
|
+
taskType: "imageInference" /* IMAGE_INFERENCE */,
|
|
1020
|
+
model,
|
|
1021
|
+
positivePrompt
|
|
1022
|
+
}, negativePrompt ? { negativePrompt } : {}), height ? { height } : {}), width ? { width } : {}), {
|
|
1023
|
+
numberResults
|
|
1024
|
+
}), (lora == null ? void 0 : lora.length) ? { lora } : {}), outputType ? { outputType } : {}), outputFormat ? { outputFormat } : {}), uploadEndpoint ? { uploadEndpoint } : {}), evaluateNonTrue({ key: "checkNsfw", value: checkNsfw })), evaluateNonTrue({ key: "strength", value: strength })), evaluateNonTrue({ key: "CFGScale", value: CFGScale })), evaluateNonTrue({ key: "clipSkip", value: clipSkip })), evaluateNonTrue({
|
|
1058
1025
|
key: "usePromptWeighting",
|
|
1059
1026
|
value: usePromptWeighting
|
|
1060
|
-
})),
|
|
1027
|
+
})), evaluateNonTrue({ key: "steps", value: steps })), controlNetData.length ? { controlNet: controlNetData } : {}), seed ? { seed } : {}), scheduler ? { scheduler } : {}), evaluateNonTrue({ key: "includeCost", value: includeCost })), evaluateNonTrue({ key: "useCache", value: useCache })), seedImageUUID ? { seedImage: seedImageUUID } : {}), maskImageUUID ? { maskImage: maskImageUUID } : {});
|
|
1061
1028
|
return await asyncRetry(
|
|
1062
1029
|
async () => {
|
|
1063
1030
|
retryCount++;
|
|
@@ -1067,22 +1034,20 @@ var RunwareBase = class {
|
|
|
1067
1034
|
);
|
|
1068
1035
|
const taskUUID = getUUID();
|
|
1069
1036
|
taskUUIDs.push(taskUUID);
|
|
1070
|
-
const imageRemaining =
|
|
1071
|
-
const newRequestObject = {
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
})
|
|
1076
|
-
};
|
|
1037
|
+
const imageRemaining = numberResults - imagesWithSimilarTask.length;
|
|
1038
|
+
const newRequestObject = __spreadProps(__spreadValues({}, requestObject), {
|
|
1039
|
+
taskUUID,
|
|
1040
|
+
numberResults: imageRemaining
|
|
1041
|
+
});
|
|
1077
1042
|
this.send(newRequestObject);
|
|
1078
1043
|
lis = this.listenToImages({
|
|
1079
1044
|
onPartialImages,
|
|
1080
1045
|
taskUUID,
|
|
1081
1046
|
groupKey: "REQUEST_IMAGES" /* REQUEST_IMAGES */
|
|
1082
1047
|
});
|
|
1083
|
-
const promise = await this.
|
|
1048
|
+
const promise = await this.getSimilarImages({
|
|
1084
1049
|
taskUUID: taskUUIDs,
|
|
1085
|
-
|
|
1050
|
+
numberResults,
|
|
1086
1051
|
lis
|
|
1087
1052
|
});
|
|
1088
1053
|
return promise;
|
|
@@ -1100,25 +1065,9 @@ var RunwareBase = class {
|
|
|
1100
1065
|
}
|
|
1101
1066
|
}
|
|
1102
1067
|
}
|
|
1103
|
-
handleIncompleteImages({
|
|
1104
|
-
taskUUIDs,
|
|
1105
|
-
error
|
|
1106
|
-
}) {
|
|
1107
|
-
const imagesWithSimilarTask = this._globalImages.filter(
|
|
1108
|
-
(img) => taskUUIDs.includes(img.taskUUID)
|
|
1109
|
-
);
|
|
1110
|
-
if (imagesWithSimilarTask.length > 1) {
|
|
1111
|
-
this._globalImages = this._globalImages.filter(
|
|
1112
|
-
(img) => !taskUUIDs.includes(img.taskUUID)
|
|
1113
|
-
);
|
|
1114
|
-
return imagesWithSimilarTask;
|
|
1115
|
-
} else {
|
|
1116
|
-
throw error;
|
|
1117
|
-
}
|
|
1118
|
-
}
|
|
1119
1068
|
async ensureConnection() {
|
|
1120
1069
|
var _a;
|
|
1121
|
-
let isConnected = this.connected()
|
|
1070
|
+
let isConnected = this.connected();
|
|
1122
1071
|
try {
|
|
1123
1072
|
if (this._invalidAPIkey)
|
|
1124
1073
|
throw this._invalidAPIkey;
|
|
@@ -1130,9 +1079,9 @@ var RunwareBase = class {
|
|
|
1130
1079
|
throw (_a = this._invalidAPIkey) != null ? _a : "Could not connect to server. Ensure your API key is correct";
|
|
1131
1080
|
}
|
|
1132
1081
|
}
|
|
1133
|
-
async
|
|
1082
|
+
async getSimilarImages({
|
|
1134
1083
|
taskUUID,
|
|
1135
|
-
|
|
1084
|
+
numberResults,
|
|
1136
1085
|
shouldThrowError,
|
|
1137
1086
|
lis
|
|
1138
1087
|
}) {
|
|
@@ -1148,20 +1097,34 @@ var RunwareBase = class {
|
|
|
1148
1097
|
clearInterval(intervalId);
|
|
1149
1098
|
reject == null ? void 0 : reject(newData);
|
|
1150
1099
|
return true;
|
|
1151
|
-
} else if (imagesWithSimilarTask.length >=
|
|
1100
|
+
} else if (imagesWithSimilarTask.length >= numberResults) {
|
|
1152
1101
|
clearInterval(intervalId);
|
|
1153
1102
|
this._globalImages = this._globalImages.filter(
|
|
1154
1103
|
(img) => !taskUUIDs.includes(img.taskUUID)
|
|
1155
1104
|
);
|
|
1156
|
-
resolve(
|
|
1157
|
-
[...imagesWithSimilarTask].slice(0, numberOfImages)
|
|
1158
|
-
);
|
|
1105
|
+
resolve([...imagesWithSimilarTask].slice(0, numberResults));
|
|
1159
1106
|
return true;
|
|
1160
1107
|
}
|
|
1161
1108
|
},
|
|
1162
1109
|
{ debugKey: "getting images", shouldThrowError }
|
|
1163
1110
|
);
|
|
1164
1111
|
}
|
|
1112
|
+
handleIncompleteImages({
|
|
1113
|
+
taskUUIDs,
|
|
1114
|
+
error
|
|
1115
|
+
}) {
|
|
1116
|
+
const imagesWithSimilarTask = this._globalImages.filter(
|
|
1117
|
+
(img) => taskUUIDs.includes(img.taskUUID)
|
|
1118
|
+
);
|
|
1119
|
+
if (imagesWithSimilarTask.length > 1) {
|
|
1120
|
+
this._globalImages = this._globalImages.filter(
|
|
1121
|
+
(img) => !taskUUIDs.includes(img.taskUUID)
|
|
1122
|
+
);
|
|
1123
|
+
return imagesWithSimilarTask;
|
|
1124
|
+
} else {
|
|
1125
|
+
throw error;
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1165
1128
|
//end of data
|
|
1166
1129
|
};
|
|
1167
1130
|
|
|
@@ -1188,7 +1151,7 @@ var RunwareServer = class extends RunwareBase {
|
|
|
1188
1151
|
this._listeners = [];
|
|
1189
1152
|
this._reconnectingIntervalId = null;
|
|
1190
1153
|
this.send = (msg) => {
|
|
1191
|
-
this._ws.send(JSON.stringify(msg));
|
|
1154
|
+
this._ws.send(JSON.stringify([msg]));
|
|
1192
1155
|
};
|
|
1193
1156
|
this._sdkType = "SERVER" /* SERVER */;
|
|
1194
1157
|
if (apiKey) {
|
|
@@ -1231,51 +1194,23 @@ var RunwareServer = class extends RunwareBase {
|
|
|
1231
1194
|
});
|
|
1232
1195
|
this._ws.on("close", () => this.handleClose());
|
|
1233
1196
|
this._ws.on("open", () => {
|
|
1234
|
-
var _a;
|
|
1235
1197
|
if (this._reconnectingIntervalId) {
|
|
1236
1198
|
clearInterval(this._reconnectingIntervalId);
|
|
1237
1199
|
}
|
|
1238
1200
|
if (this._connectionSessionUUID && this.isWebsocketReadyState()) {
|
|
1239
1201
|
this.send({
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
}
|
|
1202
|
+
taskType: "authentication" /* AUTHENTICATION */,
|
|
1203
|
+
apiKey: this._apiKey,
|
|
1204
|
+
connectionSessionUUID: this._connectionSessionUUID
|
|
1244
1205
|
});
|
|
1245
1206
|
} else {
|
|
1246
1207
|
if (this.isWebsocketReadyState()) {
|
|
1247
|
-
this.send({
|
|
1208
|
+
this.send({
|
|
1209
|
+
apiKey: this._apiKey,
|
|
1210
|
+
taskType: "authentication" /* AUTHENTICATION */
|
|
1211
|
+
});
|
|
1248
1212
|
}
|
|
1249
1213
|
}
|
|
1250
|
-
this.addListener({
|
|
1251
|
-
check: (m) => {
|
|
1252
|
-
var _a2;
|
|
1253
|
-
return (_a2 = m == null ? void 0 : m.newConnectionSessionUUID) == null ? void 0 : _a2.connectionSessionUUID;
|
|
1254
|
-
},
|
|
1255
|
-
lis: (m) => {
|
|
1256
|
-
var _a2;
|
|
1257
|
-
if (m == null ? void 0 : m.error) {
|
|
1258
|
-
if (m.errorId === 19) {
|
|
1259
|
-
this._invalidAPIkey = "Invalid API key";
|
|
1260
|
-
} else {
|
|
1261
|
-
this._invalidAPIkey = "Error connection ";
|
|
1262
|
-
}
|
|
1263
|
-
return;
|
|
1264
|
-
}
|
|
1265
|
-
this._connectionSessionUUID = (_a2 = m == null ? void 0 : m.newConnectionSessionUUID) == null ? void 0 : _a2.connectionSessionUUID;
|
|
1266
|
-
this._invalidAPIkey = void 0;
|
|
1267
|
-
this.heartBeat();
|
|
1268
|
-
}
|
|
1269
|
-
});
|
|
1270
|
-
(_a = this._pongListener) == null ? void 0 : _a.destroy();
|
|
1271
|
-
this._pongListener = this.addListener({
|
|
1272
|
-
check: (m) => m == null ? void 0 : m.pong,
|
|
1273
|
-
lis: (m) => {
|
|
1274
|
-
if (m.pong) {
|
|
1275
|
-
this.heartBeat();
|
|
1276
|
-
}
|
|
1277
|
-
}
|
|
1278
|
-
});
|
|
1279
1214
|
});
|
|
1280
1215
|
this._ws.on("message", (e, isBinary) => {
|
|
1281
1216
|
const data = isBinary ? e : e == null ? void 0 : e.toString();
|
|
@@ -1316,6 +1251,7 @@ var RunwareServer = class extends RunwareBase {
|
|
|
1316
1251
|
EOpenPosePreProcessor,
|
|
1317
1252
|
EPreProcessor,
|
|
1318
1253
|
EPreProcessorGroup,
|
|
1254
|
+
ETaskType,
|
|
1319
1255
|
Environment,
|
|
1320
1256
|
Runware,
|
|
1321
1257
|
RunwareServer,
|