@primestyleai/tryon 5.7.7 → 5.7.8

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.
@@ -21037,7 +21037,28 @@ function buildPropsFromDataAttrs(data) {
21037
21037
  console.log(`${TAG} built props`, props);
21038
21038
  return props;
21039
21039
  }
21040
- function mount(el2) {
21040
+ async function fetchSizeGuideForProduct(proxyUrl, productId) {
21041
+ try {
21042
+ const url = `${proxyUrl}/api/v1/sizeguide-lookup?productId=${encodeURIComponent(productId)}`;
21043
+ console.log(`${TAG} fetching size guide ${url}`);
21044
+ const res = await fetch(url, { method: "GET" });
21045
+ if (!res.ok) {
21046
+ console.warn(`${TAG} size guide lookup failed: ${res.status}`);
21047
+ return null;
21048
+ }
21049
+ const data = await res.json();
21050
+ if (data.found && data.sizeGuide) {
21051
+ console.log(`${TAG} ✓ size guide loaded for product ${productId}`, data.sizeGuide);
21052
+ return data.sizeGuide;
21053
+ }
21054
+ console.log(`${TAG} no size guide stored for product ${productId}`);
21055
+ return null;
21056
+ } catch (e) {
21057
+ console.warn(`${TAG} size guide fetch threw`, e);
21058
+ return null;
21059
+ }
21060
+ }
21061
+ async function mount(el2) {
21041
21062
  if (MOUNTED.has(el2)) {
21042
21063
  console.log(`${TAG} already mounted on`, el2);
21043
21064
  return;
@@ -21046,6 +21067,12 @@ function mount(el2) {
21046
21067
  const data = readDataAttrs(el2);
21047
21068
  console.log(`${TAG} read data attributes`, data);
21048
21069
  const props = buildPropsFromDataAttrs(data);
21070
+ if (!props.sizeGuideData && props.productId && props.apiUrl) {
21071
+ const fetched = await fetchSizeGuideForProduct(props.apiUrl, props.productId);
21072
+ if (fetched) {
21073
+ props.sizeGuideData = fetched;
21074
+ }
21075
+ }
21049
21076
  try {
21050
21077
  const root = createRoot(el2);
21051
21078
  root.render(reactExports.createElement(PrimeStyleTryon, props));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primestyleai/tryon",
3
- "version": "5.7.7",
3
+ "version": "5.7.8",
4
4
  "description": "PrimeStyle Virtual Try-On SDK — React component & Web Component",
5
5
  "type": "module",
6
6
  "main": "dist/primestyle-tryon.js",