@primestyleai/tryon 2.3.0 → 3.0.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.
@@ -1,5 +1,5 @@
1
1
  import { type CSSProperties } from "react";
2
- import type { ButtonStyles, ModalStyles, PrimeStyleClassNames, SizeGuideData } from "../types";
2
+ import type { ButtonStyles, ModalStyles, PrimeStyleClassNames } from "../types";
3
3
  export interface PrimeStyleTryonProps {
4
4
  productImage: string;
5
5
  productTitle?: string;
@@ -23,27 +23,7 @@ export interface PrimeStyleTryonProps {
23
23
  message: string;
24
24
  code?: string;
25
25
  }) => void;
26
- /** Pre-computed size guide — skips AI extraction if provided */
27
- sizeGuide?: SizeGuideData;
28
- /** Product description HTML for AI size guide extraction */
29
- productDescription?: string;
30
- /** Product vendor/brand for AI extraction */
31
- productVendor?: string;
32
- /** Product type (e.g. "T-Shirt", "Jacket") */
33
- productType?: string;
34
- /** Product tags for AI extraction */
35
- productTags?: string[];
36
- /** Product variants with size options */
37
- productVariants?: Array<{
38
- title: string;
39
- option1?: string | null;
40
- option2?: string | null;
41
- option3?: string | null;
42
- }>;
43
- /** Product options (e.g. [{name: "Size", values: ["S","M","L"]}]) */
44
- productOptions?: Array<{
45
- name: string;
46
- values?: string[];
47
- }>;
26
+ /** Size guide data from your backend pass as-is, any format (HTML, JSON, object, string). Our AI will parse it. */
27
+ sizeGuideData?: unknown;
48
28
  }
49
29
  export declare function PrimeStyleTryon(props: PrimeStyleTryonProps): import("react/jsx-runtime").JSX.Element | null;
@@ -179,13 +179,7 @@ function PrimeStyleTryonInner({
179
179
  onProcessing,
180
180
  onComplete,
181
181
  onError,
182
- sizeGuide: sizeGuideProp,
183
- productDescription,
184
- productVendor,
185
- productType,
186
- productTags,
187
- productVariants,
188
- productOptions
182
+ sizeGuideData
189
183
  }) {
190
184
  const [view, setView] = useState("idle");
191
185
  const [selectedFile, setSelectedFile] = useState(null);
@@ -290,31 +284,22 @@ function PrimeStyleTryonInner({
290
284
  useEffect(() => {
291
285
  if (view !== "sizing-choice" || sizeGuideFetchedRef.current || !apiRef.current) return;
292
286
  sizeGuideFetchedRef.current = true;
293
- if (sizeGuideProp) {
294
- setSizeGuide(sizeGuideProp);
287
+ if (!sizeGuideData) {
288
+ setSizeGuide({ found: false });
295
289
  return;
296
290
  }
297
291
  setSizeGuideFetching(true);
298
292
  const baseUrl = getApiUrl(apiUrl);
299
293
  const key = getApiKey();
300
- const productPayload = {
301
- title: productTitle,
302
- variants: productVariants || []
303
- };
304
- if (productDescription) productPayload.description = productDescription;
305
- if (productVendor) productPayload.vendor = productVendor;
306
- if (productType) productPayload.productType = productType;
307
- if (productTags?.length) productPayload.tags = productTags;
308
- if (productOptions?.length) productPayload.options = productOptions;
309
294
  fetch(`${baseUrl}/api/v1/sizing/sizeguide`, {
310
295
  method: "POST",
311
296
  headers: { "Content-Type": "application/json", Authorization: `Bearer ${key}` },
312
- body: JSON.stringify({ product: productPayload })
297
+ body: JSON.stringify({ product: { title: productTitle }, sizeGuideRaw: sizeGuideData })
313
298
  }).then((r) => r.ok ? r.json() : null).then((data) => {
314
299
  if (data) setSizeGuide(data);
315
300
  else setSizeGuide({ found: false });
316
301
  }).catch(() => setSizeGuide({ found: false })).finally(() => setSizeGuideFetching(false));
317
- }, [view, apiUrl, productTitle, sizeGuideProp]);
302
+ }, [view, apiUrl, productTitle, sizeGuideData]);
318
303
  const stepIndex = useMemo(() => {
319
304
  switch (view) {
320
305
  case "welcome":
@@ -422,14 +407,7 @@ function PrimeStyleTryonInner({
422
407
  const payload = {
423
408
  method: sizingMethod,
424
409
  locale: sizingCountry,
425
- product: {
426
- title: productTitle,
427
- description: productDescription || "",
428
- variants: productVariants || [],
429
- ...productVendor && { vendor: productVendor },
430
- ...productType && { productType },
431
- ...productTags?.length && { tags: productTags }
432
- }
410
+ product: { title: productTitle, description: "", variants: [] }
433
411
  };
434
412
  if (sizeGuide?.found) payload.sizeGuide = sizeGuide;
435
413
  if (sizingMethod === "exact") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primestyleai/tryon",
3
- "version": "2.3.0",
3
+ "version": "3.0.0",
4
4
  "description": "PrimeStyle Virtual Try-On SDK — React component & Web Component",
5
5
  "type": "module",
6
6
  "main": "dist/primestyle-tryon.js",