@primestyleai/tryon 5.6.17 → 5.6.19
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 +68 -29
- package/dist/react/styles.d.ts +1 -1
- package/dist/react/types.d.ts +12 -0
- package/package.json +1 -1
package/dist/react/index.js
CHANGED
|
@@ -330,12 +330,30 @@ async function recommendForProduct(input) {
|
|
|
330
330
|
if (!input.skipCache) {
|
|
331
331
|
const cached = getCachedSize(profile, input.productId);
|
|
332
332
|
if (cached) {
|
|
333
|
+
const reconstructedRaw = cached.sectionsFull ? {
|
|
334
|
+
recommendedSize: cached.recommendedSize,
|
|
335
|
+
confidence: cached.confidence || "high",
|
|
336
|
+
reasoning: "",
|
|
337
|
+
recommendedLength: cached.recommendedLength,
|
|
338
|
+
sections: Object.fromEntries(
|
|
339
|
+
Object.entries(cached.sectionsFull).map(([name, sec]) => [
|
|
340
|
+
name,
|
|
341
|
+
{ ...sec, matchDetails: [] }
|
|
342
|
+
])
|
|
343
|
+
)
|
|
344
|
+
} : {
|
|
345
|
+
recommendedSize: cached.recommendedSize,
|
|
346
|
+
confidence: cached.confidence || "high",
|
|
347
|
+
reasoning: "",
|
|
348
|
+
recommendedLength: cached.recommendedLength
|
|
349
|
+
};
|
|
333
350
|
return {
|
|
334
351
|
recommendedSize: cached.recommendedSize,
|
|
335
352
|
confidence: cached.confidence,
|
|
336
353
|
sections: cached.sections,
|
|
337
354
|
profileId: profile.id,
|
|
338
|
-
fromCache: true
|
|
355
|
+
fromCache: true,
|
|
356
|
+
raw: reconstructedRaw
|
|
339
357
|
};
|
|
340
358
|
}
|
|
341
359
|
}
|
|
@@ -405,6 +423,19 @@ async function recommendForProduct(input) {
|
|
|
405
423
|
const sectionsMap = result.sections ? Object.fromEntries(
|
|
406
424
|
Object.entries(result.sections).map(([name, sec]) => [name, sec.recommendedSize])
|
|
407
425
|
) : void 0;
|
|
426
|
+
const sectionsFull = result.sections ? Object.fromEntries(
|
|
427
|
+
Object.entries(result.sections).map(([name, sec]) => [
|
|
428
|
+
name,
|
|
429
|
+
{
|
|
430
|
+
recommendedSize: sec.recommendedSize,
|
|
431
|
+
// Backend may include these on merged Jacket/Pants entries
|
|
432
|
+
size: sec.size,
|
|
433
|
+
length: sec.length,
|
|
434
|
+
availableSizes: sec.availableSizes,
|
|
435
|
+
availableLengths: sec.availableLengths
|
|
436
|
+
}
|
|
437
|
+
])
|
|
438
|
+
) : void 0;
|
|
408
439
|
addSizeToHistory(profile.id, {
|
|
409
440
|
productId: input.productId,
|
|
410
441
|
productTitle: input.productTitle,
|
|
@@ -412,6 +443,8 @@ async function recommendForProduct(input) {
|
|
|
412
443
|
recommendedSize: result.recommendedSize,
|
|
413
444
|
confidence: result.confidence,
|
|
414
445
|
sections: sectionsMap,
|
|
446
|
+
sectionsFull,
|
|
447
|
+
recommendedLength: result.recommendedLength || void 0,
|
|
415
448
|
savedAt: Date.now()
|
|
416
449
|
});
|
|
417
450
|
return {
|
|
@@ -3647,13 +3680,10 @@ const STYLES = `
|
|
|
3647
3680
|
background: var(--ps-bg-secondary);
|
|
3648
3681
|
display: flex; align-items: center; justify-content: center;
|
|
3649
3682
|
}
|
|
3650
|
-
/*
|
|
3651
|
-
.
|
|
3652
|
-
background: #0F0F10;
|
|
3653
|
-
}
|
|
3683
|
+
/* Try-on result keeps the same neutral background as the product hero —
|
|
3684
|
+
* no dark backdrop on mobile. */
|
|
3654
3685
|
.ps-msr-product-img {
|
|
3655
|
-
|
|
3656
|
-
width: auto; height: 100%;
|
|
3686
|
+
width: 100%; height: 100%;
|
|
3657
3687
|
object-fit: contain; display: block;
|
|
3658
3688
|
}
|
|
3659
3689
|
/* Show-Fit / mediapipe overlay toggle pill — bottom-left of try-on hero */
|
|
@@ -3814,6 +3844,12 @@ const STYLES = `
|
|
|
3814
3844
|
letter-spacing: -0.01em;
|
|
3815
3845
|
margin: 0 0 6px;
|
|
3816
3846
|
}
|
|
3847
|
+
/* Wrapper that vertically centers the cards in whatever space is left
|
|
3848
|
+
* between the title at the top and the bottom navigation. */
|
|
3849
|
+
.ps-bsm-options-center {
|
|
3850
|
+
flex: 1 1 auto; min-height: 0;
|
|
3851
|
+
display: flex; flex-direction: column; justify-content: center;
|
|
3852
|
+
}
|
|
3817
3853
|
.ps-bsm-options {
|
|
3818
3854
|
display: flex; flex-direction: column; gap: 12px;
|
|
3819
3855
|
}
|
|
@@ -4860,8 +4896,7 @@ const STYLES = `
|
|
|
4860
4896
|
flex-shrink: 0;
|
|
4861
4897
|
}
|
|
4862
4898
|
.ps-msd-image-img {
|
|
4863
|
-
|
|
4864
|
-
width: auto; height: 100%;
|
|
4899
|
+
width: 100%; height: 100%;
|
|
4865
4900
|
object-fit: contain; display: block;
|
|
4866
4901
|
}
|
|
4867
4902
|
|
|
@@ -6168,23 +6203,17 @@ function MobileScanningView({
|
|
|
6168
6203
|
};
|
|
6169
6204
|
const [stageIdx, setStageIdx] = useState(0);
|
|
6170
6205
|
useEffect(() => {
|
|
6171
|
-
|
|
6206
|
+
const id = setInterval(() => {
|
|
6207
|
+
setStageIdx((i) => (i + 1) % stages.length);
|
|
6208
|
+
}, 1500);
|
|
6209
|
+
return () => clearInterval(id);
|
|
6210
|
+
}, [stages.length]);
|
|
6211
|
+
useEffect(() => {
|
|
6172
6212
|
if (isPhotoMode && bodyLandmarks && stageIdx === 0) {
|
|
6173
6213
|
setStageIdx(1);
|
|
6174
|
-
return;
|
|
6175
6214
|
}
|
|
6176
|
-
|
|
6177
|
-
setStageIdx((i) => Math.min(i + 1, stages.length - 1));
|
|
6178
|
-
}, 1600);
|
|
6179
|
-
return () => clearInterval(id);
|
|
6180
|
-
}, [bodyLandmarks, sizingDone, stageIdx, stages.length, isPhotoMode]);
|
|
6215
|
+
}, [bodyLandmarks]);
|
|
6181
6216
|
const current = stages[stageIdx] ?? stages[0];
|
|
6182
|
-
const [feedTick, setFeedTick] = useState(1);
|
|
6183
|
-
useEffect(() => {
|
|
6184
|
-
if (sizingDone) return;
|
|
6185
|
-
const id = setInterval(() => setFeedTick((n) => n + 1), 850);
|
|
6186
|
-
return () => clearInterval(id);
|
|
6187
|
-
}, [sizingDone]);
|
|
6188
6217
|
return /* @__PURE__ */ jsxs("div", { className: "ps-msc-root", children: [
|
|
6189
6218
|
/* @__PURE__ */ jsxs("div", { className: "ps-msc-viewfinder", children: [
|
|
6190
6219
|
displayImage && /* @__PURE__ */ jsx(
|
|
@@ -6484,6 +6513,15 @@ function MeasurementOverlay({ lines, fitRows, show, imgWidth, imgHeight }) {
|
|
|
6484
6513
|
const delay = i * 0.35;
|
|
6485
6514
|
const curvePath = `M ${x1} ${cy} Q ${midX} ${cy + curveDepth} ${x2} ${cy}`;
|
|
6486
6515
|
const lineLen = width * 1.05;
|
|
6516
|
+
const labelText = fitRow ? fitRow.fit === "good" ? "✓ Fit" : fitRow.fit.includes("tight") ? "Tight" : "Loose" : label;
|
|
6517
|
+
const labelFont = Math.round(14 * scale);
|
|
6518
|
+
const labelWidthEst = labelText.length * labelFont * 0.62;
|
|
6519
|
+
const rightSpace = W - x2 - 12 * scale;
|
|
6520
|
+
const flipLeft = rightSpace < labelWidthEst;
|
|
6521
|
+
const labelX = flipLeft ? x1 - 10 * scale : x2 + 10 * scale;
|
|
6522
|
+
const labelAnchor = flipLeft ? "end" : "start";
|
|
6523
|
+
const tickX1 = flipLeft ? x1 : x2;
|
|
6524
|
+
const tickX2 = flipLeft ? x1 - 6 * scale : x2 + 6 * scale;
|
|
6487
6525
|
return /* @__PURE__ */ jsxs("g", { children: [
|
|
6488
6526
|
/* @__PURE__ */ jsx(
|
|
6489
6527
|
"path",
|
|
@@ -6524,9 +6562,9 @@ function MeasurementOverlay({ lines, fitRows, show, imgWidth, imgHeight }) {
|
|
|
6524
6562
|
/* @__PURE__ */ jsx(
|
|
6525
6563
|
"line",
|
|
6526
6564
|
{
|
|
6527
|
-
x1:
|
|
6565
|
+
x1: tickX1,
|
|
6528
6566
|
y1: cy,
|
|
6529
|
-
x2:
|
|
6567
|
+
x2: tickX2,
|
|
6530
6568
|
y2: cy,
|
|
6531
6569
|
stroke: color,
|
|
6532
6570
|
strokeWidth: 2 * scale
|
|
@@ -6535,14 +6573,15 @@ function MeasurementOverlay({ lines, fitRows, show, imgWidth, imgHeight }) {
|
|
|
6535
6573
|
/* @__PURE__ */ jsx(
|
|
6536
6574
|
"text",
|
|
6537
6575
|
{
|
|
6538
|
-
x:
|
|
6576
|
+
x: labelX,
|
|
6539
6577
|
y: cy + 1 * scale,
|
|
6540
6578
|
fill: color,
|
|
6541
|
-
fontSize:
|
|
6579
|
+
fontSize: labelFont,
|
|
6542
6580
|
fontWeight: "700",
|
|
6543
6581
|
fontFamily: "system-ui, -apple-system, sans-serif",
|
|
6544
6582
|
dominantBaseline: "middle",
|
|
6545
|
-
|
|
6583
|
+
textAnchor: labelAnchor,
|
|
6584
|
+
children: labelText
|
|
6546
6585
|
}
|
|
6547
6586
|
)
|
|
6548
6587
|
] })
|
|
@@ -9232,7 +9271,7 @@ function BodyShapeStepMobile({
|
|
|
9232
9271
|
String(totalSteps).padStart(2, "0")
|
|
9233
9272
|
] }),
|
|
9234
9273
|
/* @__PURE__ */ jsx("h2", { className: "ps-bsm-question", children: title }),
|
|
9235
|
-
/* @__PURE__ */ jsx("div", { className: "ps-bsm-options", children: options.map((opt, idx) => {
|
|
9274
|
+
/* @__PURE__ */ jsx("div", { className: "ps-bsm-options-center", children: /* @__PURE__ */ jsx("div", { className: "ps-bsm-options", children: options.map((opt, idx) => {
|
|
9236
9275
|
const isActive = selected === opt.value;
|
|
9237
9276
|
const profileLetter = String.fromCharCode(65 + idx);
|
|
9238
9277
|
return /* @__PURE__ */ jsxs(
|
|
@@ -9255,7 +9294,7 @@ function BodyShapeStepMobile({
|
|
|
9255
9294
|
},
|
|
9256
9295
|
opt.value
|
|
9257
9296
|
);
|
|
9258
|
-
}) })
|
|
9297
|
+
}) }) })
|
|
9259
9298
|
] });
|
|
9260
9299
|
}
|
|
9261
9300
|
function CameraUploadIcon() {
|