@primestyleai/tryon 3.1.0 → 3.1.1
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/react/index.js +26 -3
- package/package.json +1 -1
package/dist/react/index.js
CHANGED
|
@@ -189,6 +189,7 @@ function PrimeStyleTryonInner({
|
|
|
189
189
|
const [dragOver, setDragOver] = useState(false);
|
|
190
190
|
const [sizingMethod, setSizingMethod] = useState(null);
|
|
191
191
|
const [sizingResult, setSizingResult] = useState(null);
|
|
192
|
+
const [sizingLoading, setSizingLoading] = useState(false);
|
|
192
193
|
const [sizeGuide, setSizeGuide] = useState(null);
|
|
193
194
|
const [sizeGuideFetching, setSizeGuideFetching] = useState(false);
|
|
194
195
|
const sizeGuideFetchedRef = useRef(false);
|
|
@@ -348,6 +349,7 @@ function PrimeStyleTryonInner({
|
|
|
348
349
|
setErrorMessage(null);
|
|
349
350
|
setSizingMethod(null);
|
|
350
351
|
setSizingResult(null);
|
|
352
|
+
setSizingLoading(false);
|
|
351
353
|
setSizeGuide(null);
|
|
352
354
|
setProfileSaved(false);
|
|
353
355
|
formRef.current = {};
|
|
@@ -459,8 +461,13 @@ function PrimeStyleTryonInner({
|
|
|
459
461
|
if (res.ok) {
|
|
460
462
|
const data = await res.json();
|
|
461
463
|
setSizingResult(data);
|
|
464
|
+
} else {
|
|
465
|
+
console.warn("[PrimeStyle] Sizing API error:", res.status, await res.text().catch(() => ""));
|
|
462
466
|
}
|
|
463
|
-
} catch {
|
|
467
|
+
} catch (err) {
|
|
468
|
+
console.warn("[PrimeStyle] Sizing request failed:", err);
|
|
469
|
+
} finally {
|
|
470
|
+
setSizingLoading(false);
|
|
464
471
|
}
|
|
465
472
|
}, [apiUrl, sizingMethod, sizingCountry, heightUnit, weightUnit, sizingUnit, sizeGuide, productTitle]);
|
|
466
473
|
const handleSubmit = useCallback(async () => {
|
|
@@ -473,7 +480,10 @@ function PrimeStyleTryonInner({
|
|
|
473
480
|
}
|
|
474
481
|
completedRef.current = false;
|
|
475
482
|
setView("processing");
|
|
476
|
-
if (sizingMethod)
|
|
483
|
+
if (sizingMethod) {
|
|
484
|
+
setSizingLoading(true);
|
|
485
|
+
submitSizing();
|
|
486
|
+
}
|
|
477
487
|
try {
|
|
478
488
|
const modelImage = await compressImage(selectedFile);
|
|
479
489
|
const response = await apiRef.current.submitTryOn(modelImage, productImage);
|
|
@@ -536,6 +546,7 @@ function PrimeStyleTryonInner({
|
|
|
536
546
|
setErrorMessage(null);
|
|
537
547
|
setSizingMethod(null);
|
|
538
548
|
setSizingResult(null);
|
|
549
|
+
setSizingLoading(false);
|
|
539
550
|
setProfileSaved(false);
|
|
540
551
|
setView("upload");
|
|
541
552
|
}, [previewUrl, cleanupJob]);
|
|
@@ -934,11 +945,16 @@ function PrimeStyleTryonInner({
|
|
|
934
945
|
] });
|
|
935
946
|
}
|
|
936
947
|
function ResultView() {
|
|
937
|
-
const
|
|
948
|
+
const hasSizing = !!sizingResult || sizingLoading;
|
|
949
|
+
const hasBoth = !!resultImageUrl && hasSizing;
|
|
938
950
|
const [profileName, setProfileName] = useState("");
|
|
939
951
|
return /* @__PURE__ */ jsxs("div", { className: `ps-tryon-result-layout${hasBoth ? " ps-tryon-result-split" : ""}`, children: [
|
|
940
952
|
resultImageUrl && /* @__PURE__ */ jsx("div", { className: "ps-tryon-result-image-col", children: /* @__PURE__ */ jsx("img", { src: resultImageUrl, alt: "Try-on result", className: cn.resultImage }) }),
|
|
941
953
|
/* @__PURE__ */ jsxs("div", { className: "ps-tryon-result-info-col", children: [
|
|
954
|
+
sizingLoading && !sizingResult && /* @__PURE__ */ jsxs("div", { className: "ps-tryon-size-recommend ps-tryon-sizing-loading", children: [
|
|
955
|
+
/* @__PURE__ */ jsx("div", { className: "ps-tryon-size-loading-spinner" }),
|
|
956
|
+
/* @__PURE__ */ jsx("p", { className: "ps-tryon-size-reasoning", children: "Analyzing your size..." })
|
|
957
|
+
] }),
|
|
942
958
|
sizingResult && /* @__PURE__ */ jsxs("div", { className: "ps-tryon-size-recommend", children: [
|
|
943
959
|
/* @__PURE__ */ jsx("div", { className: "ps-tryon-size-badge", children: sizingResult.recommendedSize }),
|
|
944
960
|
/* @__PURE__ */ jsxs("div", { className: "ps-tryon-size-confidence", children: [
|
|
@@ -1431,6 +1447,13 @@ const STYLES = `
|
|
|
1431
1447
|
background: linear-gradient(135deg, #bb945c, #d6ba7d);
|
|
1432
1448
|
color: #111; font-size: 20px; font-weight: 700; margin-bottom: 10px;
|
|
1433
1449
|
}
|
|
1450
|
+
.ps-tryon-sizing-loading { text-align: center; padding: 20px 0; }
|
|
1451
|
+
.ps-tryon-size-loading-spinner {
|
|
1452
|
+
width: 36px; height: 36px; border: 3px solid #333;
|
|
1453
|
+
border-top-color: #bb945c; border-radius: 50%;
|
|
1454
|
+
animation: ps-spin 0.8s linear infinite; margin: 0 auto 12px;
|
|
1455
|
+
}
|
|
1456
|
+
@keyframes ps-spin { to { transform: rotate(360deg); } }
|
|
1434
1457
|
.ps-tryon-size-confidence { font-size: 12px; color: #999; margin-bottom: 8px; }
|
|
1435
1458
|
.ps-conf-high { color: #4ade80; } .ps-conf-medium { color: #bb945c; } .ps-conf-low { color: #ef4444; }
|
|
1436
1459
|
.ps-tryon-size-reasoning { font-size: 13px; color: #ccc; line-height: 1.5; margin-bottom: 12px; }
|