@primestyleai/tryon 5.8.43 → 5.8.45

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.
@@ -12620,23 +12620,7 @@ function AccessorySizeView({
12620
12620
  ] }) });
12621
12621
  }
12622
12622
  return /* @__PURE__ */ jsxs("div", { className: "ps-bp-layout", children: [
12623
- /* @__PURE__ */ jsx("div", { className: "ps-bp-image", style: { position: "relative", display: step === "photo" && !photoPreview ? "none" : void 0 }, children: step === "photo" ? (
12624
- /* Photo step: show preview if uploaded, otherwise empty */
12625
- photoPreview ? /* @__PURE__ */ jsxs(Fragment, { children: [
12626
- /* @__PURE__ */ jsx("img", { src: photoPreview, alt: "preview", className: "ps-bp-image-img" }),
12627
- /* @__PURE__ */ jsx(
12628
- "button",
12629
- {
12630
- onClick: handleRemovePhoto,
12631
- style: { position: "absolute", top: "0.5vw", right: "0.5vw", width: "1.6vw", height: "1.6vw", borderRadius: "50%", background: "rgba(0,0,0,0.55)", border: "none", color: "#fff", fontSize: "0.9vw", cursor: "pointer", display: "flex", alignItems: "center", justifyContent: "center" },
12632
- children: "×"
12633
- }
12634
- )
12635
- ] }) : null
12636
- ) : (
12637
- /* Manual step: product image */
12638
- /* @__PURE__ */ jsx("img", { src: productImage, alt: productTitle, className: "ps-bp-image-img" })
12639
- ) }),
12623
+ step !== "photo" && /* @__PURE__ */ jsx("div", { className: "ps-bp-image", style: { position: "relative" }, children: /* @__PURE__ */ jsx("img", { src: productImage, alt: productTitle, className: "ps-bp-image-img" }) }),
12640
12624
  /* @__PURE__ */ jsx("div", { className: "ps-bp-root", children: step === "photo" ? (
12641
12625
  /* ── Photo step — identical to BodyProfileView photo step ── */
12642
12626
  /* @__PURE__ */ jsxs("div", { className: "ps-bp-wrapper", style: { display: "flex", flexDirection: "column", width: "100%", height: "100%" }, children: [
@@ -13438,6 +13422,69 @@ function PrimeStyleTryonInner({
13438
13422
  const method = methodOverride || sizingMethod;
13439
13423
  const baseUrl = getApiUrl(apiUrl);
13440
13424
  const key = getApiKey();
13425
+ const measurementType = detectMeasurementType(productTitle);
13426
+ if (measurementType === "face" || measurementType === "head") {
13427
+ const f = formRef.current;
13428
+ const toNum = (v) => {
13429
+ if (!v) return void 0;
13430
+ const n = parseFloat(v);
13431
+ return Number.isFinite(n) && n > 0 ? n : void 0;
13432
+ };
13433
+ const inputUnit = f.sizingUnit || sizingUnit || (measurementType === "head" ? "cm" : "mm");
13434
+ const toMm = (n) => {
13435
+ if (n == null) return void 0;
13436
+ if (inputUnit === "mm") return n;
13437
+ if (inputUnit === "cm") return n * 10;
13438
+ if (inputUnit === "in") return n * 25.4;
13439
+ return n;
13440
+ };
13441
+ const faceMm = {};
13442
+ const src = {
13443
+ bridgeWidth: toMm(toNum(f.bridgeWidth)),
13444
+ templeLength: toMm(toNum(f.templeLength) ?? toNum(f.armLength)),
13445
+ lensWidth: toMm(toNum(f.lensWidth)),
13446
+ lensHeight: toMm(toNum(f.lensHeight)),
13447
+ faceWidth: toMm(toNum(f.faceWidth) ?? toNum(f.frameWidth)),
13448
+ pd: toMm(toNum(f.pd)),
13449
+ // Headwear — circumference usually typed in cm; keep as mm internally.
13450
+ headCircumference: toMm(toNum(f.headCircumference)),
13451
+ headWidth: toMm(toNum(f.headWidth))
13452
+ };
13453
+ for (const [k, v] of Object.entries(src)) if (typeof v === "number") faceMm[k] = v;
13454
+ const facePayload = {
13455
+ product: { title: productTitle, productId },
13456
+ sizeGuide: sizeGuide?.found ? sizeGuide : { found: false },
13457
+ sizingUnit: measurementType === "head" ? "cm" : "mm",
13458
+ category: measurementType,
13459
+ ...Object.keys(faceMm).length > 0 && { faceMeasurementsMm: faceMm, irisConfidence: 1 }
13460
+ };
13461
+ try {
13462
+ const resp = await fetch(`${baseUrl}/api/v1/sizing/face-recommend`, {
13463
+ method: "POST",
13464
+ headers: { "Content-Type": "application/json", Authorization: `Bearer ${key}` },
13465
+ body: JSON.stringify(facePayload)
13466
+ });
13467
+ if (resp.ok) {
13468
+ const data = await resp.json();
13469
+ setSizingResult(data);
13470
+ onComplete?.(data);
13471
+ } else {
13472
+ const body = await resp.text().catch(() => "");
13473
+ console.error("[PS-SDK] face-recommend failed:", resp.status, body);
13474
+ setErrorMessage(t("Unable to get size recommendation. Please try again."));
13475
+ setView("error");
13476
+ setEstimationDone(true);
13477
+ }
13478
+ } catch (err) {
13479
+ console.error("[PS-SDK] face-recommend network error:", err);
13480
+ setErrorMessage(t("Unable to connect to sizing service. Please try again."));
13481
+ setView("error");
13482
+ setEstimationDone(true);
13483
+ } finally {
13484
+ setSizingLoading(false);
13485
+ }
13486
+ return;
13487
+ }
13441
13488
  const payload = {
13442
13489
  method,
13443
13490
  locale: sizingCountry,
@@ -22044,23 +22044,7 @@ function AccessorySizeView({
22044
22044
  ] }) });
22045
22045
  }
22046
22046
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ps-bp-layout", children: [
22047
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ps-bp-image", style: { position: "relative", display: step === "photo" && !photoPreview ? "none" : void 0 }, children: step === "photo" ? (
22048
- /* Photo step: show preview if uploaded, otherwise empty */
22049
- photoPreview ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
22050
- /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: photoPreview, alt: "preview", className: "ps-bp-image-img" }),
22051
- /* @__PURE__ */ jsxRuntimeExports.jsx(
22052
- "button",
22053
- {
22054
- onClick: handleRemovePhoto,
22055
- style: { position: "absolute", top: "0.5vw", right: "0.5vw", width: "1.6vw", height: "1.6vw", borderRadius: "50%", background: "rgba(0,0,0,0.55)", border: "none", color: "#fff", fontSize: "0.9vw", cursor: "pointer", display: "flex", alignItems: "center", justifyContent: "center" },
22056
- children: "×"
22057
- }
22058
- )
22059
- ] }) : null
22060
- ) : (
22061
- /* Manual step: product image */
22062
- /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: productImage, alt: productTitle, className: "ps-bp-image-img" })
22063
- ) }),
22047
+ step !== "photo" && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ps-bp-image", style: { position: "relative" }, children: /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: productImage, alt: productTitle, className: "ps-bp-image-img" }) }),
22064
22048
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ps-bp-root", children: step === "photo" ? (
22065
22049
  /* ── Photo step — identical to BodyProfileView photo step ── */
22066
22050
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ps-bp-wrapper", style: { display: "flex", flexDirection: "column", width: "100%", height: "100%" }, children: [
@@ -22862,6 +22846,69 @@ function PrimeStyleTryonInner({
22862
22846
  const method = methodOverride || sizingMethod;
22863
22847
  const baseUrl = getApiUrl(apiUrl);
22864
22848
  const key = getApiKey();
22849
+ const measurementType = detectMeasurementType(productTitle);
22850
+ if (measurementType === "face" || measurementType === "head") {
22851
+ const f2 = formRef.current;
22852
+ const toNum = (v2) => {
22853
+ if (!v2) return void 0;
22854
+ const n2 = parseFloat(v2);
22855
+ return Number.isFinite(n2) && n2 > 0 ? n2 : void 0;
22856
+ };
22857
+ const inputUnit = f2.sizingUnit || sizingUnit || (measurementType === "head" ? "cm" : "mm");
22858
+ const toMm = (n2) => {
22859
+ if (n2 == null) return void 0;
22860
+ if (inputUnit === "mm") return n2;
22861
+ if (inputUnit === "cm") return n2 * 10;
22862
+ if (inputUnit === "in") return n2 * 25.4;
22863
+ return n2;
22864
+ };
22865
+ const faceMm = {};
22866
+ const src = {
22867
+ bridgeWidth: toMm(toNum(f2.bridgeWidth)),
22868
+ templeLength: toMm(toNum(f2.templeLength) ?? toNum(f2.armLength)),
22869
+ lensWidth: toMm(toNum(f2.lensWidth)),
22870
+ lensHeight: toMm(toNum(f2.lensHeight)),
22871
+ faceWidth: toMm(toNum(f2.faceWidth) ?? toNum(f2.frameWidth)),
22872
+ pd: toMm(toNum(f2.pd)),
22873
+ // Headwear — circumference usually typed in cm; keep as mm internally.
22874
+ headCircumference: toMm(toNum(f2.headCircumference)),
22875
+ headWidth: toMm(toNum(f2.headWidth))
22876
+ };
22877
+ for (const [k2, v2] of Object.entries(src)) if (typeof v2 === "number") faceMm[k2] = v2;
22878
+ const facePayload = {
22879
+ product: { title: productTitle, productId },
22880
+ sizeGuide: sizeGuide?.found ? sizeGuide : { found: false },
22881
+ sizingUnit: measurementType === "head" ? "cm" : "mm",
22882
+ category: measurementType,
22883
+ ...Object.keys(faceMm).length > 0 && { faceMeasurementsMm: faceMm, irisConfidence: 1 }
22884
+ };
22885
+ try {
22886
+ const resp = await fetch(`${baseUrl}/api/v1/sizing/face-recommend`, {
22887
+ method: "POST",
22888
+ headers: { "Content-Type": "application/json", Authorization: `Bearer ${key}` },
22889
+ body: JSON.stringify(facePayload)
22890
+ });
22891
+ if (resp.ok) {
22892
+ const data = await resp.json();
22893
+ setSizingResult(data);
22894
+ onComplete?.(data);
22895
+ } else {
22896
+ const body = await resp.text().catch(() => "");
22897
+ console.error("[PS-SDK] face-recommend failed:", resp.status, body);
22898
+ setErrorMessage(t2("Unable to get size recommendation. Please try again."));
22899
+ setView("error");
22900
+ setEstimationDone(true);
22901
+ }
22902
+ } catch (err) {
22903
+ console.error("[PS-SDK] face-recommend network error:", err);
22904
+ setErrorMessage(t2("Unable to connect to sizing service. Please try again."));
22905
+ setView("error");
22906
+ setEstimationDone(true);
22907
+ } finally {
22908
+ setSizingLoading(false);
22909
+ }
22910
+ return;
22911
+ }
22865
22912
  const payload = {
22866
22913
  method,
22867
22914
  locale: sizingCountry,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primestyleai/tryon",
3
- "version": "5.8.43",
3
+ "version": "5.8.45",
4
4
  "description": "PrimeStyle Virtual Try-On SDK — React component & Web Component",
5
5
  "type": "module",
6
6
  "main": "dist/primestyle-tryon.js",