@primestyleai/tryon 5.10.113 → 5.10.115

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.
@@ -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,28 @@ function PrimeStyleTryonInner({
28840
28869
  productTitle,
28841
28870
  productDescription,
28842
28871
  productMaterial,
28843
- silhouetteContext: buildSilhouetteContext(sizingResult, sizeGuide, override?.displayLabel),
28872
+ silhouetteContext: buildSilhouetteContext(
28873
+ sizingResult,
28874
+ sizeGuide,
28875
+ override?.displayLabel,
28876
+ (() => {
28877
+ const h = parseFloat(formRef.current.height || "0");
28878
+ if (!h || h <= 0) return void 0;
28879
+ const u2 = formRef.current.heightUnit || heightUnit || "cm";
28880
+ if (u2 === "ft") {
28881
+ const ft = Math.floor(h);
28882
+ const inches = Math.round((h - ft) * 12);
28883
+ return `${ft}'${inches}"`;
28884
+ }
28885
+ return u2 === "in" ? `${h}"` : `${h} cm`;
28886
+ })(),
28887
+ (() => {
28888
+ const w2 = parseFloat(formRef.current.weight || "0");
28889
+ if (!w2 || w2 <= 0) return void 0;
28890
+ const u2 = formRef.current.weightUnit || weightUnit || "kg";
28891
+ return `${w2} ${u2}`;
28892
+ })()
28893
+ ),
28844
28894
  modelImageId: modelImageIdRef.current ?? void 0
28845
28895
  }
28846
28896
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primestyleai/tryon",
3
- "version": "5.10.113",
3
+ "version": "5.10.115",
4
4
  "description": "PrimeStyle Virtual Try-On SDK — React component & Web Component",
5
5
  "type": "module",
6
6
  "main": "dist/primestyle-tryon.js",