@souldi/try-on 0.1.92 → 0.1.94

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/README.md CHANGED
@@ -86,10 +86,13 @@ Call once per page load to configure the widget.
86
86
  | `tenantApiKey` | `string` | Yes | Your publishable API key (from your Souldi dashboard) |
87
87
  | `theme` | `object` | No | Customize the widget appearance ([see Theming](#theming)) |
88
88
  | `onGenerationStart` | `function(info)` | No | Called when AI generation begins |
89
- | `onGenerationSuccess` | `function(resultUrl, info)` | No | Called with the result image URL on success |
89
+ | `onGenerationSuccess` | `function(resultUrl, info)` | No | Called with the result image URL once generation *produces* a result — before the image has loaded or been seen |
90
+ | `onResultShown` | `function(info)` | No | Called once the result image has actually **loaded and is visible** in the widget's dialog. Never fires if the image fails to load, and never fires twice for the same result ([details](#the-info-argument)) |
90
91
  | `onError` | `function(message, info)` | No | Called when something goes wrong |
91
92
  | `onLogout` | `function` | No | Called when the user's session ends — by logout, or by a token the backend no longer honours |
93
+ | `onSignedIn` | `function(info)` | No | Called whenever a session begins for this tab — a code verified here, a session shared from another tab, or a stored session restored ([details](#the-info-argument)) |
92
94
  | `onAuthPrompt` | `function` | No | Called just before the widget takes the screen to ask the user to sign in |
95
+ | `onPhotoReady` | `function(info)` | No | Called once a shopper's base photo clears preprocessing and is promoted — not fired for a rejected photo ([details](#the-info-argument)) |
93
96
  | `onAddToCart` | `async function(intent)` | No | Called when the customer asks to add their recommended size to your cart. Absent, no cart control is drawn anywhere ([details](#onaddtocart)) |
94
97
 
95
98
  #### The `info` argument
@@ -98,8 +101,12 @@ Callbacks about a specific try-on receive a trailing `info` object:
98
101
 
99
102
  | Field | Type | Present on | Description |
100
103
  |-------|------|-----------|-------------|
101
- | `buttonId` | `string` | all three | The `containerId` of the button this callback is about |
102
- | `operation` | `'generate' \| 'refine'` | `onError` | Which operation failed |
104
+ | `buttonId` | `string` | most | The `containerId` of the button this callback is about |
105
+ | `operation` | `'generate' \| 'refine'` | `onError`, `onResultShown` | Which operation this is about |
106
+ | `view` | `string \| null` | `onGenerationSuccess`, `onResultShown` | The Render View this result is (e.g. `'front'`), when the garment offers more than one |
107
+ | `how` | `'verified' \| 'shared' \| 'restored'` | `onSignedIn` | How this tab's session began. Only `'verified'` is a *new* sign-in — `'shared'` and `'restored'` are this tab catching up with a session that began elsewhere |
108
+ | `resolution` | `string` | `onPhotoReady` | The preprocessing outcome, e.g. `'clean'` or `'soft-issue'` |
109
+ | `isRetake` | `boolean` | `onPhotoReady` | Whether this photo replaced an existing one |
103
110
 
104
111
  `buttonId` matters as soon as a page has more than one try-on button: without it
105
112
  you cannot tell which button's job just finished, and a result can only be
@@ -114,15 +121,32 @@ request against an older one is reported here rather than silently dropped.
114
121
  Present it wherever you collected the instruction; the previous result is
115
122
  untouched either way.
116
123
 
124
+ `onResultShown` receives the same `info` `onGenerationSuccess` did for that
125
+ result, minus the image URL — it is about the same render, just reported once
126
+ the pixels are actually on screen. If the image never loads, `onResultShown`
127
+ simply never fires; nothing else changes for the shopper.
128
+
117
129
  `onLogout` deliberately carries no `buttonId` — a session ends for the whole
118
130
  page, and every result surface on it must be torn down. If you render results
119
131
  yourself, this is where you drop them: the result URL is signed, user-specific,
120
132
  and must not outlive the session.
121
133
 
134
+ `onSignedIn` is the mirror of `onLogout`: a session BEGAN for this tab. Use
135
+ `info.how` to tell a shopper's own sign-in (`'verified'`) apart from this tab
136
+ merely adopting a session that already existed (`'shared'`, `'restored'`) —
137
+ only the first is a new sign-in for funnel purposes.
138
+
122
139
  `onAuthPrompt` fires before the widget's own sign-in card opens. Use it to move
123
140
  anything of yours that would cover it (a modal, a lightbox) out of the way. It
124
141
  says nothing about whether the previous session ended — that is `onLogout`.
125
142
 
143
+ `onPhotoReady` fires once per promoted photo — on first upload and on a
144
+ retake, from both the desktop upload and the phone-QR upload paths — and never
145
+ for a rejected photo, since nothing was promoted for it to report.
146
+
147
+ None of the payloads above ever carry an image URL, an auth token, an email
148
+ address, or body measurements.
149
+
126
150
  #### `onAddToCart`
127
151
 
128
152
  The widget knows a customer's size; only you know your cart. Supply