@primestyleai/tryon 5.10.112 → 5.10.114
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 +2202 -2165
- package/dist/react/index.js.map +1 -1
- package/dist/sizing/fit-compute.d.ts +7 -1
- package/dist/storefront/primestyle-tryon.js +57 -4
- package/package.json +1 -1
|
@@ -49,8 +49,14 @@ export declare function buildSilhouetteContext(sizingResult: {
|
|
|
49
49
|
/** Optional override — when the user manually picks a different size in
|
|
50
50
|
* the result view and hits "Apply this size", we want Gemini to reason
|
|
51
51
|
* about THAT size, not the original recommendation. */
|
|
52
|
-
selectedSizeOverride?: string
|
|
52
|
+
selectedSizeOverride?: string,
|
|
53
|
+
/** Active profile's height/weight, formatted for prompt display (e.g.
|
|
54
|
+
* `"5'6\""` and `"185 lbs"`). Passed straight to the backend so the
|
|
55
|
+
* prime directive can include the model's frame. */
|
|
56
|
+
userHeight?: string, userWeight?: string): {
|
|
53
57
|
recommendedSize?: string;
|
|
54
58
|
sizeChartSummary?: string;
|
|
55
59
|
userMeasurementsText?: string;
|
|
60
|
+
userHeight?: string;
|
|
61
|
+
userWeight?: string;
|
|
56
62
|
} | undefined;
|
|
@@ -10131,11 +10131,13 @@ function buildFitInfo(matchDetails, poseLines, unit) {
|
|
|
10131
10131
|
return info;
|
|
10132
10132
|
});
|
|
10133
10133
|
}
|
|
10134
|
-
function buildSilhouetteContext(sizingResult, sizeGuide, selectedSizeOverride) {
|
|
10135
|
-
if (!sizingResult && !sizeGuide) return void 0;
|
|
10134
|
+
function buildSilhouetteContext(sizingResult, sizeGuide, selectedSizeOverride, userHeight, userWeight) {
|
|
10135
|
+
if (!sizingResult && !sizeGuide && !userHeight && !userWeight) return void 0;
|
|
10136
10136
|
const out = {};
|
|
10137
10137
|
if (selectedSizeOverride) out.recommendedSize = selectedSizeOverride;
|
|
10138
10138
|
else if (sizingResult?.recommendedSize) out.recommendedSize = sizingResult.recommendedSize;
|
|
10139
|
+
if (userHeight) out.userHeight = userHeight;
|
|
10140
|
+
if (userWeight) out.userWeight = userWeight;
|
|
10139
10141
|
const seen = /* @__PURE__ */ new Set();
|
|
10140
10142
|
const userLines = [];
|
|
10141
10143
|
const push = (md2) => {
|
|
@@ -27787,6 +27789,7 @@ function PrimeStyleTryonInner({
|
|
|
27787
27789
|
const selectedFileRef = reactExports.useRef(null);
|
|
27788
27790
|
const modelImageIdRef = reactExports.useRef(null);
|
|
27789
27791
|
const autoTryOnFiredRef = reactExports.useRef(false);
|
|
27792
|
+
const bestGarmentImageRef = reactExports.useRef(null);
|
|
27790
27793
|
reactExports.useEffect(() => {
|
|
27791
27794
|
try {
|
|
27792
27795
|
const key = getApiKey();
|
|
@@ -27801,6 +27804,29 @@ function PrimeStyleTryonInner({
|
|
|
27801
27804
|
if (pollingRef.current) clearInterval(pollingRef.current);
|
|
27802
27805
|
};
|
|
27803
27806
|
}, [apiUrl]);
|
|
27807
|
+
reactExports.useEffect(() => {
|
|
27808
|
+
bestGarmentImageRef.current = null;
|
|
27809
|
+
if (garmentReferenceImage) {
|
|
27810
|
+
bestGarmentImageRef.current = garmentReferenceImage;
|
|
27811
|
+
return;
|
|
27812
|
+
}
|
|
27813
|
+
if (!productImages || productImages.length < 2) return;
|
|
27814
|
+
const baseUrl = getApiUrl(apiUrl);
|
|
27815
|
+
const ctrl = new AbortController();
|
|
27816
|
+
fetch(`${baseUrl}/api/catalog/pick-best-garment-image`, {
|
|
27817
|
+
method: "POST",
|
|
27818
|
+
headers: { "Content-Type": "application/json" },
|
|
27819
|
+
body: JSON.stringify({ images: productImages }),
|
|
27820
|
+
signal: ctrl.signal
|
|
27821
|
+
}).then((r2) => r2.ok ? r2.json() : null).then((j) => {
|
|
27822
|
+
if (j?.bestUrl) {
|
|
27823
|
+
bestGarmentImageRef.current = j.bestUrl;
|
|
27824
|
+
console.log(`[ps-sdk] pre-picked garment reference: ${j.bestUrl}`);
|
|
27825
|
+
}
|
|
27826
|
+
}).catch(() => {
|
|
27827
|
+
});
|
|
27828
|
+
return () => ctrl.abort();
|
|
27829
|
+
}, [productImages, garmentReferenceImage, apiUrl]);
|
|
27804
27830
|
const TARGET_SECONDS2 = 22;
|
|
27805
27831
|
const progressRef = reactExports.useRef(0);
|
|
27806
27832
|
const progressBarRef = reactExports.useRef(null);
|
|
@@ -28823,10 +28849,13 @@ function PrimeStyleTryonInner({
|
|
|
28823
28849
|
let garmentImage = productImage;
|
|
28824
28850
|
if (garmentReferenceImage) {
|
|
28825
28851
|
garmentImage = garmentReferenceImage;
|
|
28852
|
+
} else if (bestGarmentImageRef.current) {
|
|
28853
|
+
garmentImage = bestGarmentImageRef.current;
|
|
28854
|
+
console.log(`[ps-sdk:tryon] using pre-picked garment reference: ${garmentImage}`);
|
|
28826
28855
|
} else if (productImages && productImages.length > 1) {
|
|
28827
28856
|
const best = await pickBestGarmentImage(productImages);
|
|
28828
28857
|
if (best && best !== productImage) {
|
|
28829
|
-
console.log(`[ps-sdk:tryon] auto-picked garment reference: ${best}`);
|
|
28858
|
+
console.log(`[ps-sdk:tryon] auto-picked garment reference (mediapipe): ${best}`);
|
|
28830
28859
|
garmentImage = best;
|
|
28831
28860
|
}
|
|
28832
28861
|
}
|
|
@@ -28840,7 +28869,30 @@ function PrimeStyleTryonInner({
|
|
|
28840
28869
|
productTitle,
|
|
28841
28870
|
productDescription,
|
|
28842
28871
|
productMaterial,
|
|
28843
|
-
silhouetteContext: buildSilhouetteContext(
|
|
28872
|
+
silhouetteContext: buildSilhouetteContext(
|
|
28873
|
+
sizingResult,
|
|
28874
|
+
sizeGuide,
|
|
28875
|
+
override?.displayLabel,
|
|
28876
|
+
(() => {
|
|
28877
|
+
const p2 = profiles.find((x2) => x2.id === activeProfileId);
|
|
28878
|
+
const h = p2?.height ?? p2?.heightCm;
|
|
28879
|
+
const u2 = p2?.heightUnit || "cm";
|
|
28880
|
+
if (!h || h <= 0) return void 0;
|
|
28881
|
+
if (u2 === "ft") {
|
|
28882
|
+
const ft = Math.floor(h);
|
|
28883
|
+
const inches = Math.round((h - ft) * 12);
|
|
28884
|
+
return `${ft}'${inches}"`;
|
|
28885
|
+
}
|
|
28886
|
+
return u2 === "in" ? `${h}"` : `${h} cm`;
|
|
28887
|
+
})(),
|
|
28888
|
+
(() => {
|
|
28889
|
+
const p2 = profiles.find((x2) => x2.id === activeProfileId);
|
|
28890
|
+
const w2 = p2?.weight ?? p2?.weightKg;
|
|
28891
|
+
const u2 = p2?.weightUnit || "kg";
|
|
28892
|
+
if (!w2 || w2 <= 0) return void 0;
|
|
28893
|
+
return `${w2} ${u2}`;
|
|
28894
|
+
})()
|
|
28895
|
+
),
|
|
28844
28896
|
modelImageId: modelImageIdRef.current ?? void 0
|
|
28845
28897
|
}
|
|
28846
28898
|
);
|
|
@@ -29117,6 +29169,7 @@ function PrimeStyleTryonInner({
|
|
|
29117
29169
|
const restoreHistory = reactExports.useCallback((entry) => {
|
|
29118
29170
|
historySavedRef.current = true;
|
|
29119
29171
|
historyTryonSavedRef.current = !!entry.resultImageUrl;
|
|
29172
|
+
autoTryOnFiredRef.current = true;
|
|
29120
29173
|
if (entry.sizingResult) {
|
|
29121
29174
|
setSizingResult(entry.sizingResult);
|
|
29122
29175
|
} else if (entry.recommendedSize) {
|