@primestyleai/tryon 5.10.104 → 5.10.106

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.
@@ -21,6 +21,13 @@ export declare function setLastCompletedProduct(productId: string | null, produc
21
21
  * the size-result view. The cart-hook then fires a SIZE_RECOMMENDATION_ACCEPTED
22
22
  * event when this product gets added to cart — a clearer "user committed"
23
23
  * signal than "user clicked a pill once".
24
+ *
25
+ * Side-effect: proactively stamp the current cart with `attributes[ps_session]`
26
+ * via `/cart/update.js`. This is the primary attribution path now — works
27
+ * regardless of how the buyer eventually checks out (Ajax cart, Buy It Now,
28
+ * Shop Pay), because the attribute is already on the cart object before
29
+ * the buyer adds anything. The legacy fetch/form-submit interception below
30
+ * stays as a defense-in-depth fallback for older themes.
24
31
  */
25
32
  export declare function setLastSizeSelection(input: {
26
33
  productId: string | null;
@@ -19418,14 +19418,6 @@ function ProductPhotoCarouselCard({
19418
19418
  slide.push(photos[(start + slide.length) % photos.length]);
19419
19419
  }
19420
19420
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ps-tryon-photo-strip", role: "group", "aria-label": t2("Product photos"), children: [
19421
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ps-tryon-photo-strip-head", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "ps-tryon-photo-strip-badge", children: [
19422
- /* @__PURE__ */ jsxRuntimeExports.jsxs("svg", { width: "11", height: "11", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
19423
- /* @__PURE__ */ jsxRuntimeExports.jsx("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }),
19424
- /* @__PURE__ */ jsxRuntimeExports.jsx("circle", { cx: "9", cy: "9", r: "2" }),
19425
- /* @__PURE__ */ jsxRuntimeExports.jsx("path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" })
19426
- ] }),
19427
- t2("Gallery")
19428
- ] }) }),
19429
19421
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ps-tryon-photo-strip-row", children: slide.map((src, i) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ps-tryon-photo-strip-cell", children: /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src, alt: productTitle || "", draggable: false }) }, `${groupIdx}-${i}`)) }, groupIdx),
19430
19422
  totalGroups > 1 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ps-tryon-photo-strip-dots", "aria-hidden": "true", children: Array.from({ length: totalGroups }).map((_, i) => /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `ps-tryon-photo-strip-dot${i === groupIdx ? " is-active" : ""}` }, i)) })
19431
19423
  ] });
@@ -20066,103 +20058,26 @@ function SectionDetailView({
20066
20058
  return details.map((m2) => {
20067
20059
  if (isFromLength.has(m2.measurement)) {
20068
20060
  const userNum2 = userMeasurements[m2.measurement.toLowerCase()] || pNumFn(m2.userValue);
20069
- const activeLength = selectedLength || effectiveRecLength || m2.chartRange;
20070
- if (!lengthEntry) {
20071
- return { area: m2.measurement + " (" + activeLength + ")", userNum: userNum2, chartLabel: activeLength, fit: "good", isLength: true };
20072
- }
20073
- const sec = lengthEntry.section;
20074
- const measLc = m2.measurement.toLowerCase();
20075
- const isHeight = measLc === "height";
20076
- const sizeCol = sec.headers.findIndex((h) => /size|length/i.test(h.trim()));
20077
- const userIsInches = unitLbl === "in";
20078
- let targetColIdx = -1;
20079
- let colIsCm = false;
20080
- if (isHeight) {
20081
- const cmColIdx = sec.headers.findIndex((h) => /cm|\(cm\)|height.*cm/i.test(h.toLowerCase()));
20082
- const genericColIdx = sec.headers.findIndex((h) => /height|altezza|estatura/i.test(h.toLowerCase()) && !/cm/i.test(h));
20083
- targetColIdx = cmColIdx >= 0 ? cmColIdx : genericColIdx;
20084
- colIsCm = targetColIdx === cmColIdx;
20085
- } else {
20086
- targetColIdx = sec.headers.findIndex((h) => {
20087
- const hLc = h.toLowerCase().replace(/\s*\(.*?\)\s*/g, "").trim();
20088
- if (!hLc) return false;
20089
- return hLc === measLc || hLc.includes(measLc) || measLc.includes(hLc);
20090
- });
20091
- colIsCm = targetColIdx >= 0 ? /cm/i.test(sec.headers[targetColIdx] || "") : false;
20092
- }
20093
- const sIdx = sizeCol >= 0 ? sizeCol : 0;
20094
- const hIdx = targetColIdx >= 0 ? targetColIdx : -1;
20095
- const activeLengthForLookup = (() => {
20096
- const al2 = (activeLength || "").toLowerCase().trim();
20097
- if (/big.*tall|tall/.test(al2)) return "Long";
20098
- if (/^big$/.test(al2)) return "Regular";
20099
- return activeLength;
20100
- })();
20101
- const alLc = (activeLengthForLookup || "").toLowerCase().trim();
20102
- const matchRow = sec.rows.find((r2) => cellValFn(r2, sIdx, sec.headers[sIdx]) === activeLength) || sec.rows.find((r2) => cellValFn(r2, sIdx, sec.headers[sIdx]).trim().toLowerCase() === alLc) || null;
20103
- let chartLabel2 = activeLength;
20104
- let fit2 = "good";
20105
- if (matchRow && hIdx >= 0) {
20106
- const rangeStr = cellValFn(matchRow, hIdx, sec.headers[hIdx]);
20107
- if (rangeStr) {
20108
- const { min: rMinRaw, max: rMaxRaw } = pRangeFn(rangeStr);
20109
- if (rMinRaw > 0 && rMaxRaw > 0) {
20110
- const userInColUnit = colIsCm && userIsInches ? +(userNum2 * 2.54).toFixed(1) : !colIsCm && !userIsInches ? +(userNum2 * 2.54).toFixed(1) : userNum2;
20111
- const range2 = rMaxRaw - rMinRaw;
20112
- const threshold2 = range2 > 0 ? range2 * 0.5 : rMinRaw * 0.05 || 3;
20113
- const tol = colIsCm ? 2.54 : 1;
20114
- if (userInColUnit > rMinRaw - tol && userInColUnit < rMaxRaw + tol) fit2 = "good";
20115
- else if (userInColUnit < rMinRaw) {
20116
- const diff = rMinRaw - userInColUnit;
20117
- fit2 = diff > threshold2 * 2 ? "too-long" : diff > threshold2 ? "long" : "a-bit-long";
20118
- } else {
20119
- const diff = userInColUnit - rMaxRaw;
20120
- fit2 = diff > threshold2 * 2 ? "too-short" : diff > threshold2 ? "short" : "a-bit-short";
20121
- }
20122
- const needsConvert = colIsCm && userIsInches || !colIsCm && !userIsInches;
20123
- const rMinUser = needsConvert ? colIsCm ? +(rMinRaw / 2.54).toFixed(1) : +(rMinRaw * 2.54).toFixed(1) : rMinRaw;
20124
- const rMaxUser = needsConvert ? colIsCm ? +(rMaxRaw / 2.54).toFixed(1) : +(rMaxRaw * 2.54).toFixed(1) : rMaxRaw;
20125
- chartLabel2 = rMinUser === rMaxUser ? `${rMinUser}` : `${rMinUser}-${rMaxUser}`;
20126
- } else {
20127
- chartLabel2 = rangeStr;
20128
- }
20129
- }
20130
- }
20131
- return { area: m2.measurement + " (" + activeLength + ")", userNum: userNum2, chartLabel: cleanNumFn(chartLabel2), fit: fit2, isLength: true };
20061
+ return {
20062
+ area: m2.measurement,
20063
+ userNum: userNum2,
20064
+ chartLabel: cleanNumFn(m2.chartRange),
20065
+ fit: m2.fit || "good",
20066
+ isLength: true
20067
+ };
20132
20068
  }
20133
20069
  const userNum = userMeasurements[m2.measurement.toLowerCase()] || pNumFn(m2.userValue);
20134
- let { min: rMin, max: rMax } = pRangeFn(m2.chartRange);
20135
- let chartLabel = m2.chartRange;
20136
- const alt = chartRangeFor(m2.measurement, displaySize);
20137
- if (alt) {
20138
- chartLabel = alt.range;
20139
- rMin = alt.min;
20140
- rMax = alt.max;
20141
- }
20142
- const range = rMax - rMin;
20143
- const threshold = range > 0 ? range * 0.5 : rMin * 0.05 || 3;
20144
20070
  const measLower = m2.measurement.toLowerCase();
20145
20071
  const isDirectional = /length|inseam|sleeve|hem|rise/.test(measLower);
20146
- let fit;
20147
- const perfectTol = chartUnit === "cm" ? 2.54 : chartUnit === "mm" ? 25.4 : 1;
20148
- const lowBound = rMin - perfectTol;
20149
- const highBound = rMax + perfectTol;
20150
- if (userNum > lowBound && userNum < highBound) {
20151
- fit = "good";
20152
- } else if (isDirectional) {
20153
- const diff = userNum > rMax ? userNum - rMax : rMin - userNum;
20154
- const bucket = diff > threshold * 2 ? "too-" : diff > threshold ? "" : "a-bit-";
20155
- fit = bucket + (userNum > rMax ? "short" : "long");
20156
- } else if (userNum < rMin) {
20157
- const diff = rMin - userNum;
20158
- fit = diff > threshold * 2 ? "too-loose" : diff > threshold ? "loose" : "a-bit-loose";
20159
- } else {
20160
- const diff = userNum - rMax;
20161
- fit = diff > threshold * 2 ? "too-tight" : diff > threshold ? "tight" : "a-bit-tight";
20162
- }
20163
- return { area: m2.measurement, userNum, chartLabel: cleanNumFn(chartLabel), fit, isLength: isDirectional };
20072
+ return {
20073
+ area: m2.measurement,
20074
+ userNum,
20075
+ chartLabel: cleanNumFn(m2.chartRange),
20076
+ fit: m2.fit || "good",
20077
+ isLength: isDirectional
20078
+ };
20164
20079
  });
20165
- }, [sectionResult, lengthEntry, userMeasurements, displaySize, recSize, chartRangeFor, selectedLength, recLength, renderRaw]);
20080
+ }, [sectionResult, lengthEntry, userMeasurements, renderRaw]);
20166
20081
  const goodCount = fitRows.filter(
20167
20082
  (r2) => r2.fit === "good" || r2.fit === "a-bit-tight" || r2.fit === "a-bit-loose"
20168
20083
  ).length;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primestyleai/tryon",
3
- "version": "5.10.104",
3
+ "version": "5.10.106",
4
4
  "description": "PrimeStyle Virtual Try-On SDK — React component & Web Component",
5
5
  "type": "module",
6
6
  "main": "dist/primestyle-tryon.js",