@primestyleai/tryon 5.4.7 → 5.5.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.
Files changed (2) hide show
  1. package/dist/react/index.js +26 -68
  2. package/package.json +1 -1
@@ -6261,6 +6261,8 @@ function PrimeStyleTryonInner({
6261
6261
  if (chestProfile) formRef.current.chestProfile = chestProfile;
6262
6262
  if (midsectionProfile) formRef.current.midsectionProfile = midsectionProfile;
6263
6263
  if (hipProfile) formRef.current.hipProfile = hipProfile;
6264
+ setSizingResult(null);
6265
+ setResultImageUrl(null);
6264
6266
  setSizingMethod("quick");
6265
6267
  setSizingLoading(true);
6266
6268
  setView("size-result");
@@ -6276,6 +6278,8 @@ function PrimeStyleTryonInner({
6276
6278
  setPreviewUrl(objUrl);
6277
6279
  completedRef.current = false;
6278
6280
  setTryOnProcessing(false);
6281
+ setSizingResult(null);
6282
+ setResultImageUrl(null);
6279
6283
  setSizingLoading(true);
6280
6284
  setView("size-result");
6281
6285
  modelPoseRef.current = null;
@@ -6288,80 +6292,34 @@ function PrimeStyleTryonInner({
6288
6292
  setBodyLandmarks(lm);
6289
6293
  }).catch(() => {
6290
6294
  });
6291
- const SKIP_ESTIMATE_KEYS = /* @__PURE__ */ new Set(["weight", "weightKg", "height", "heightCm"]);
6292
- const allFieldKeys = /* @__PURE__ */ new Set();
6293
- if (sizeGuide?.sections) {
6294
- for (const sec of Object.values(sizeGuide.sections)) {
6295
- if (sec.requiredFields) {
6296
- for (const f of sec.requiredFields) {
6297
- if (f.required && f.unit === "cm" && !SKIP_ESTIMATE_KEYS.has(f.key)) allFieldKeys.add(f.key);
6298
- }
6299
- }
6295
+ const payload = {
6296
+ method: "photo",
6297
+ locale: sizingCountry,
6298
+ sizingUnit,
6299
+ product: { title: productTitle, description: "", variants: [] },
6300
+ bodyImage: data.photoBase64,
6301
+ measurements: {
6302
+ gender: data.gender,
6303
+ height: data.height,
6304
+ weight: data.weight,
6305
+ heightUnit: data.heightUnit,
6306
+ weightUnit: data.weightUnit,
6307
+ sizingUnit,
6308
+ ...data.age && { age: data.age }
6300
6309
  }
6301
- }
6302
- for (const f of dynamicFields) {
6303
- if (f.required && f.unit === "cm" && !SKIP_ESTIMATE_KEYS.has(f.key)) allFieldKeys.add(f.key);
6304
- }
6305
- const requiredFieldKeys = Array.from(allFieldKeys);
6306
- let estData = null;
6310
+ };
6311
+ if (sizeGuide?.found) payload.sizeGuide = sizeGuide;
6307
6312
  try {
6308
- const estRes = await fetch(`${baseUrl}/api/v1/sizing/estimate`, {
6313
+ const recRes = await fetch(`${baseUrl}/api/v1/sizing/recommend`, {
6309
6314
  method: "POST",
6310
6315
  headers: { "Content-Type": "application/json", Authorization: `Bearer ${key}` },
6311
- body: JSON.stringify(data.snapMode ? {
6312
- snapMode: true,
6313
- bodyImage: data.photoBase64,
6314
- requiredFields: requiredFieldKeys.length > 0 ? requiredFieldKeys : void 0
6315
- } : {
6316
- height: data.height,
6317
- weight: data.weight,
6318
- heightUnit: data.heightUnit,
6319
- weightUnit: data.weightUnit,
6320
- gender: data.gender,
6321
- requiredFields: requiredFieldKeys,
6322
- bodyImage: data.photoBase64,
6323
- ...data.age && { age: data.age }
6324
- })
6316
+ body: JSON.stringify(payload)
6325
6317
  });
6326
- if (estRes.ok) estData = await estRes.json();
6327
- } catch {
6328
- }
6329
- if (estData?.estimates) {
6330
- for (const [k, v] of Object.entries(estData.estimates)) {
6331
- formRef.current[k] = String(v);
6332
- }
6333
- const isSnap = !!data.snapMode;
6334
- const resolvedGender = estData.detectedGender || data.gender;
6335
- formRef.current.gender = resolvedGender;
6336
- formRef.current.height = String(data.height);
6337
- formRef.current.weight = String(data.weight);
6338
- formRef.current.heightUnit = data.heightUnit;
6339
- formRef.current.weightUnit = data.weightUnit;
6340
- const m = isSnap ? { gender: resolvedGender, sizingUnit: "in" } : { gender: resolvedGender, sizingUnit, heightUnit: data.heightUnit, weightUnit: data.weightUnit };
6341
- for (const [k, v] of Object.entries(estData.estimates)) {
6342
- m[k] = v;
6343
- }
6344
- if (!isSnap) m.height = data.height;
6345
- const payload = {
6346
- method: "exact",
6347
- locale: sizingCountry,
6348
- sizingUnit: isSnap ? "in" : sizingUnit,
6349
- product: { title: productTitle, description: "", variants: [] },
6350
- measurements: m
6351
- };
6352
- if (sizeGuide?.found) payload.sizeGuide = sizeGuide;
6353
- try {
6354
- const recRes = await fetch(`${baseUrl}/api/v1/sizing/recommend`, {
6355
- method: "POST",
6356
- headers: { "Content-Type": "application/json", Authorization: `Bearer ${key}` },
6357
- body: JSON.stringify(payload)
6358
- });
6359
- if (recRes.ok) {
6360
- const recData = await recRes.json();
6361
- setSizingResult(recData);
6362
- }
6363
- } catch {
6318
+ if (recRes.ok) {
6319
+ const recData = await recRes.json();
6320
+ setSizingResult(recData);
6364
6321
  }
6322
+ } catch {
6365
6323
  }
6366
6324
  setSizingLoading(false);
6367
6325
  }, [apiUrl, productImage, productTitle, sizingUnit, weightUnit, sizingCountry, sizeGuide, dynamicFields]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primestyleai/tryon",
3
- "version": "5.4.7",
3
+ "version": "5.5.0",
4
4
  "description": "PrimeStyle Virtual Try-On SDK — React component & Web Component",
5
5
  "type": "module",
6
6
  "main": "dist/primestyle-tryon.js",