@primestyleai/tryon 5.5.26 → 5.6.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.
@@ -7,14 +7,51 @@ export type HipProfile = "narrow" | "average" | "full";
7
7
  export type MatchDetail = MatchDetailType;
8
8
  export type SizingResult = SizingResultType;
9
9
  export type SizeGuideField = SizeGuideFieldType;
10
+ /** Full body measurements computed by the LLM (cm or in based on measurementsUnit) */
11
+ export interface ProfileMeasurements {
12
+ chest?: number;
13
+ bust?: number;
14
+ waist?: number;
15
+ hips?: number;
16
+ shoulderWidth?: number;
17
+ sleeveLength?: number;
18
+ inseam?: number;
19
+ neckCircumference?: number;
20
+ thighCircumference?: number;
21
+ footLengthCm?: number;
22
+ height?: number;
23
+ /** Allow other fields the backend may return */
24
+ [key: string]: number | undefined;
25
+ }
26
+ /** A cached size recommendation for a specific product */
27
+ export interface SizeHistoryEntry {
28
+ productId: string;
29
+ productTitle: string;
30
+ productImage?: string;
31
+ recommendedSize: string;
32
+ confidence?: string;
33
+ /** For multi-section products: { "Jacket Size": "50", "Pants": "34", ... } */
34
+ sections?: Record<string, string>;
35
+ savedAt: number;
36
+ }
10
37
  export interface Profile {
11
38
  id: string;
12
39
  name: string;
13
40
  gender: "male" | "female";
14
41
  height?: number;
15
42
  weight?: number;
43
+ age?: number;
16
44
  /** @deprecated Use `height` */ heightCm?: number;
17
45
  /** @deprecated Use `weight` */ weightKg?: number;
46
+ chestProfile?: ChestProfile;
47
+ midsectionProfile?: MidsectionProfile;
48
+ hipProfile?: HipProfile;
49
+ bandSize?: string;
50
+ cupSize?: string;
51
+ photoBase64?: string;
52
+ measurements?: ProfileMeasurements;
53
+ measurementsUnit?: "cm" | "in";
54
+ sizeHistory?: SizeHistoryEntry[];
18
55
  chest?: number;
19
56
  bust?: number;
20
57
  waist?: number;
@@ -35,6 +72,8 @@ export interface Profile {
35
72
  customMeasurements?: Record<string, number>;
36
73
  createdAt?: number;
37
74
  lastUsedAt?: number;
75
+ /** Bumped any time measurements/answers change — used to invalidate sizeHistory cache */
76
+ lastEditedAt?: number;
38
77
  }
39
78
  export interface HistoryEntry {
40
79
  id: string;
@@ -70,11 +109,13 @@ export interface SizeGuide {
70
109
  /** Mapping of section name → product image URL (classified by AI) */
71
110
  sectionImages?: Record<string, string>;
72
111
  }
73
- export type ViewState = "idle" | "welcome" | "body-profile" | "estimation-review" | "size-result" | "upload" | "processing" | "result" | "error";
112
+ export type ViewState = "idle" | "welcome" | "body-profile" | "estimation-review" | "size-result" | "upload" | "processing" | "result" | "error" | "profiles";
74
113
  export type DrawerType = "profiles" | "history" | null;
75
114
  export interface PrimeStyleTryonProps {
76
115
  productImage: string;
77
116
  productTitle?: string;
117
+ /** Stable product identifier — used to cache size recommendations per (profile, product) */
118
+ productId?: string;
78
119
  buttonText?: string;
79
120
  apiUrl?: string;
80
121
  showPoweredBy?: boolean;
@@ -0,0 +1,21 @@
1
+ import { type RecommendForProductInput, type RecommendForProductResult } from "./recommendForProduct";
2
+ export interface UsePrimeStyleSizeState {
3
+ /** The recommended size (e.g. "M", "42") — null while loading or if no profile */
4
+ recommendedSize: string | null;
5
+ /** Per-section sizes for multi-section products */
6
+ sections: Record<string, string> | null;
7
+ /** True while the recommendation is being fetched */
8
+ loading: boolean;
9
+ /** True if the user has no profile yet — host should show its existing "Find Your Size" CTA */
10
+ noProfile: boolean;
11
+ /** The full result if you need confidence/sections/etc. */
12
+ result: RecommendForProductResult | null;
13
+ /** Manually re-run the recommendation (e.g. after the user edits their profile) */
14
+ refetch: () => void;
15
+ }
16
+ /**
17
+ * React hook wrapper around recommendForProduct(). Calls the headless API
18
+ * on mount, returns the recommended size + loading state. Re-runs whenever
19
+ * productId changes.
20
+ */
21
+ export declare function usePrimeStyleSize(input: RecommendForProductInput): UsePrimeStyleSizeState;
@@ -1,3 +1,18 @@
1
+ import type { Profile, ProfileMeasurements, SizeHistoryEntry } from "../types";
1
2
  export declare const LS_PREFIX = "primestyle_";
2
3
  export declare function lsGet<T>(key: string, fallback: T): T;
3
4
  export declare function lsSet(key: string, value: unknown): void;
5
+ export declare function getProfiles(): Profile[];
6
+ export declare function saveProfiles(profiles: Profile[]): void;
7
+ export declare function getActiveProfileId(): string | null;
8
+ export declare function setActiveProfileId(id: string | null): void;
9
+ /** Returns the active profile, or the most recently used one, or null. */
10
+ export declare function getActiveProfile(): Profile | null;
11
+ /** Mutate a single profile in storage by id. */
12
+ export declare function updateProfile(id: string, patch: Partial<Profile>): Profile | null;
13
+ /** Save the LLM-computed body measurements onto a profile. */
14
+ export declare function updateProfileMeasurements(id: string, measurements: ProfileMeasurements, unit?: "cm" | "in"): Profile | null;
15
+ /** Append (or replace) a per-product size recommendation in the profile's history. */
16
+ export declare function addSizeToHistory(profileId: string, entry: SizeHistoryEntry): Profile | null;
17
+ /** Look up a cached size recommendation for a specific product on a profile. */
18
+ export declare function getCachedSize(profile: Profile, productId: string): SizeHistoryEntry | null;
@@ -0,0 +1,23 @@
1
+ import type { TranslateFn } from "../../i18n";
2
+ import type { Profile } from "../types";
3
+ /**
4
+ * Replaces the old DrawerPanel "My Profiles" view. Shows a grid of profile
5
+ * cards with avatar/name/height/weight/select+edit, a "Create New Profile"
6
+ * empty card, and a list of recently calculated sizes (the sizeHistory[]
7
+ * entries from across all profiles).
8
+ *
9
+ * Layout matches the reference: ATELIER-style minimal cards with status
10
+ * pills, big black call-to-action buttons.
11
+ */
12
+ interface MySizingProfilesViewProps {
13
+ profiles: Profile[];
14
+ activeProfileId: string | null;
15
+ onSelectProfile: (id: string) => void;
16
+ onEditProfile: (p: Profile) => void;
17
+ onCreateProfile: () => void;
18
+ onDeleteProfile: (id: string) => void;
19
+ onClose: () => void;
20
+ t: TranslateFn;
21
+ }
22
+ export declare function MySizingProfilesView({ profiles, activeProfileId, onSelectProfile, onEditProfile, onCreateProfile, onDeleteProfile, onClose, t, }: MySizingProfilesViewProps): import("react/jsx-runtime").JSX.Element;
23
+ export {};
@@ -2,7 +2,8 @@ import type { TranslateFn } from "../../i18n";
2
2
  import type { FitAreaInfo } from "../../types";
3
3
  import type { ViewState, SizeGuide, SizingResult } from "../types";
4
4
  import type { BodyLandmarks } from "../../pose-detect";
5
- export declare function SizeResultView({ sizingLoading, sizingResult, sizeGuide, resultImageUrl, productImage, productTitle, sizingUnit, setView, handleDownload, onRetryWithFit, retryLoading, selectedFile, previewUrl, handleFileSelect, handleRemovePreview, handleTryOnSubmit, tryOnProcessing, bodyLandmarks, activeSection, setActiveSection, t, }: {
5
+ export declare function SizeResultView({ sizingLoading, sizingResult, sizeGuide, resultImageUrl, productImage, productTitle, sizingUnit, setView, handleDownload, onRetryWithFit, retryLoading, selectedFile, previewUrl, handleFileSelect, handleRemovePreview, handleTryOnSubmit, tryOnProcessing, bodyLandmarks, estimationDone, activeSection, setActiveSection, t, }: {
6
+ estimationDone?: boolean;
6
7
  sizingLoading: boolean;
7
8
  sizingResult: SizingResult | null;
8
9
  sizeGuide: SizeGuide | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primestyleai/tryon",
3
- "version": "5.5.26",
3
+ "version": "5.6.0",
4
4
  "description": "PrimeStyle Virtual Try-On SDK — React component & Web Component",
5
5
  "type": "module",
6
6
  "main": "dist/primestyle-tryon.js",