@souldi/try-on 0.1.72 → 0.1.73
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 +36 -4
- package/dist/widget.mjs +1 -1
- package/dist/widget.umd.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -70,10 +70,42 @@ Call once per page load to configure the widget.
|
|
|
70
70
|
|--------|------|----------|-------------|
|
|
71
71
|
| `tenantApiKey` | `string` | Yes | Your publishable API key (from your Souldi dashboard) |
|
|
72
72
|
| `theme` | `object` | No | Customize the widget appearance ([see Theming](#theming)) |
|
|
73
|
-
| `onGenerationStart` | `function` | No | Called when AI generation begins |
|
|
74
|
-
| `onGenerationSuccess` | `function(resultUrl)` | No | Called with the result image URL on success |
|
|
75
|
-
| `onError` | `function(message)` | No | Called when something goes wrong |
|
|
76
|
-
| `onLogout` | `function` | No | Called when the user
|
|
73
|
+
| `onGenerationStart` | `function(info)` | No | Called when AI generation begins |
|
|
74
|
+
| `onGenerationSuccess` | `function(resultUrl, info)` | No | Called with the result image URL on success |
|
|
75
|
+
| `onError` | `function(message, info)` | No | Called when something goes wrong |
|
|
76
|
+
| `onLogout` | `function` | No | Called when the user's session ends — by logout, or by a token the backend no longer honours |
|
|
77
|
+
| `onAuthPrompt` | `function` | No | Called just before the widget takes the screen to ask the user to sign in |
|
|
78
|
+
|
|
79
|
+
#### The `info` argument
|
|
80
|
+
|
|
81
|
+
Callbacks about a specific try-on receive a trailing `info` object:
|
|
82
|
+
|
|
83
|
+
| Field | Type | Present on | Description |
|
|
84
|
+
|-------|------|-----------|-------------|
|
|
85
|
+
| `buttonId` | `string` | all three | The `containerId` of the button this callback is about |
|
|
86
|
+
| `operation` | `'generate' \| 'refine'` | `onError` | Which operation failed |
|
|
87
|
+
|
|
88
|
+
`buttonId` matters as soon as a page has more than one try-on button: without it
|
|
89
|
+
you cannot tell which button's job just finished, and a result can only be
|
|
90
|
+
placed by guessing. Read it whenever you render results yourself.
|
|
91
|
+
|
|
92
|
+
`info` is passed after the existing arguments, so `onGenerationSuccess(url)`
|
|
93
|
+
and `onError(message)` keep working unchanged.
|
|
94
|
+
|
|
95
|
+
Note that `onError` with `operation: 'refine'` also covers a refine the widget
|
|
96
|
+
*declined* — only the most recently generated result can be refined, so a
|
|
97
|
+
request against an older one is reported here rather than silently dropped.
|
|
98
|
+
Present it wherever you collected the instruction; the previous result is
|
|
99
|
+
untouched either way.
|
|
100
|
+
|
|
101
|
+
`onLogout` deliberately carries no `buttonId` — a session ends for the whole
|
|
102
|
+
page, and every result surface on it must be torn down. If you render results
|
|
103
|
+
yourself, this is where you drop them: the result URL is signed, user-specific,
|
|
104
|
+
and must not outlive the session.
|
|
105
|
+
|
|
106
|
+
`onAuthPrompt` fires before the widget's own sign-in card opens. Use it to move
|
|
107
|
+
anything of yours that would cover it (a modal, a lightbox) out of the way. It
|
|
108
|
+
says nothing about whether the previous session ended — that is `onLogout`.
|
|
77
109
|
|
|
78
110
|
### `createButton(options)`
|
|
79
111
|
|