@wexio/messenger-widget-react 1.0.4 → 1.0.5
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 +23 -150
- package/dist/{widget-react-BfPdgAQ-.js → widget-react-A2LiLuw0.js} +1151 -1006
- package/dist/{widget-react-DwL_rsx_.js → widget-react-B0fjhAJD.js} +72 -56
- package/dist/{widget-react-D-QrEVpv.js → widget-react-BC-2nOW4.js} +1 -1
- package/dist/{widget-react-CZs0xRrr.js → widget-react-BMpc2uNT2.js} +1 -1
- package/dist/widget-react-BNG2P8TD.js +337 -0
- package/dist/widget-react-BcPE3ZoY.js +337 -0
- package/dist/widget-react-BdgqHrUV.js +337 -0
- package/dist/widget-react-BdohGq4s2.js +337 -0
- package/dist/widget-react-BthaWcns.js +337 -0
- package/dist/widget-react-C-8yYmmX2.js +337 -0
- package/dist/widget-react-C2atp9Wc.js +337 -0
- package/dist/widget-react-C7J17SWR.js +337 -0
- package/dist/{widget-react-BAOIDvhV.js → widget-react-CB6Jxluy.js} +1362 -1328
- package/dist/widget-react-CKZ5tNDZ.js +337 -0
- package/dist/widget-react-CLRkytx8.js +337 -0
- package/dist/widget-react-CMvMg68M.js +337 -0
- package/dist/widget-react-COu0Pgwj2.js +337 -0
- package/dist/widget-react-CSqqxBrZ2.js +337 -0
- package/dist/widget-react-CVLlTbB_2.js +337 -0
- package/dist/{widget-react-DtOeNw5z.js → widget-react-CVx50FQP2.js} +18 -9
- package/dist/{widget-react-AgErOR36.js → widget-react-CYlAGnu_2.js} +19 -7
- package/dist/{widget-react-CPYwD6FR.js → widget-react-CdjAa7d12.js} +2 -2
- package/dist/widget-react-Cfgp7JeP.js +337 -0
- package/dist/widget-react-CozbWJT5.js +337 -0
- package/dist/widget-react-Crxd4qSM.js +337 -0
- package/dist/widget-react-D3ZFysG9.js +337 -0
- package/dist/widget-react-DAT3UgdW2.js +285 -0
- package/dist/widget-react-DRyfg-bL.js +337 -0
- package/dist/widget-react-DhC6mv1r.js +337 -0
- package/dist/widget-react-DiF8_rWm.js +337 -0
- package/dist/widget-react-DjXlAiu5.js +337 -0
- package/dist/widget-react-DkhMvmdX2.js +337 -0
- package/dist/{widget-react-CUuKGDZN.js → widget-react-DqRO9d652.js} +2 -2
- package/dist/widget-react-Dq_sYldT.js +337 -0
- package/dist/{widget-react-Cj_zbk_F.js → widget-react-Dr-NACA0.js} +19 -7
- package/dist/widget-react-DviuEPoq.js +337 -0
- package/dist/{widget-react-CDPzwV1i.js → widget-react-DxkbC0xE.js} +1823 -1833
- package/dist/widget-react-JOt2DXbR.js +337 -0
- package/dist/widget-react-L8PMkUr7.js +337 -0
- package/dist/widget-react-LWisk9g6.js +337 -0
- package/dist/{widget-react-DSw03RG7.js → widget-react-_xdGdTzK.js} +1 -1
- package/dist/widget-react-fNts-U3I2.js +337 -0
- package/dist/widget-react-iKCOmnGh.js +337 -0
- package/dist/{widget-react-C5COLy3m.js → widget-react-wTlmXnex2.js} +1 -1
- package/dist/widget-react-xzOjEdXk2.js +337 -0
- package/dist/widget-react.d.ts +10 -19
- package/dist/widget-react.js +4028 -3450
- package/package.json +1 -1
- package/dist/widget-react-AgErOR36.js.map +0 -1
- package/dist/widget-react-BAOIDvhV.js.map +0 -1
- package/dist/widget-react-BfPdgAQ-.js.map +0 -1
- package/dist/widget-react-BxvW64LH.js.map +0 -1
- package/dist/widget-react-C5COLy3m.js.map +0 -1
- package/dist/widget-react-CAWxn8I0.js +0 -247
- package/dist/widget-react-CAWxn8I0.js.map +0 -1
- package/dist/widget-react-CDPzwV1i.js.map +0 -1
- package/dist/widget-react-CPYwD6FR.js.map +0 -1
- package/dist/widget-react-CUBFPjaV.js.map +0 -1
- package/dist/widget-react-CUuKGDZN.js.map +0 -1
- package/dist/widget-react-CZs0xRrr.js.map +0 -1
- package/dist/widget-react-Cj_zbk_F.js.map +0 -1
- package/dist/widget-react-D-QrEVpv.js.map +0 -1
- package/dist/widget-react-D8TPnM9r.js.map +0 -1
- package/dist/widget-react-DE7AVrCo.js.map +0 -1
- package/dist/widget-react-DOX6j7_Q.js.map +0 -1
- package/dist/widget-react-DSw03RG7.js.map +0 -1
- package/dist/widget-react-Dew7YaLU.js.map +0 -1
- package/dist/widget-react-DtOeNw5z.js.map +0 -1
- package/dist/widget-react-DwL_rsx_.js.map +0 -1
- package/dist/widget-react.js.map +0 -1
package/README.md
CHANGED
|
@@ -15,6 +15,7 @@ Native React component for the [Wexio](https://wexio.io) web messenger. Renders
|
|
|
15
15
|
- [Quick start](#quick-start)
|
|
16
16
|
- [Identifying users](#identifying-users)
|
|
17
17
|
- [Props](#props)
|
|
18
|
+
- [Bot protection (Cloudflare Turnstile)](#bot-protection-cloudflare-turnstile)
|
|
18
19
|
- [Methods](#methods)
|
|
19
20
|
- [Types](#types)
|
|
20
21
|
- [SSR](#ssr)
|
|
@@ -72,153 +73,33 @@ Pass a verified `user` to log a known visitor in (the Wexio equivalent of Interc
|
|
|
72
73
|
/>
|
|
73
74
|
```
|
|
74
75
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
```tsx
|
|
78
|
-
<WexioWidget publicKey="pk_live_..." prefill={{ email: "ada@example.com" }} />
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
> **Memoise `user` and `prefill`.** Fresh object literals every render churn the env (the handshake is internally guarded against re-firing unless the proof actually changes, but it's tidier to avoid).
|
|
76
|
+
> **Memoise `user`.** Fresh object literals every render churn the env (the handshake is internally guarded against re-firing unless the proof actually changes, but it's tidier to avoid).
|
|
82
77
|
|
|
83
78
|
## Props
|
|
84
79
|
|
|
85
|
-
| Prop
|
|
86
|
-
|
|
|
87
|
-
| `publicKey`
|
|
88
|
-
| `
|
|
89
|
-
| `
|
|
90
|
-
| `
|
|
91
|
-
| `
|
|
92
|
-
| `
|
|
93
|
-
| `
|
|
94
|
-
| `
|
|
95
|
-
| `
|
|
96
|
-
| `style` | `React.CSSProperties` | Pass-through inline styles for the outer host `<div>`. |
|
|
97
|
-
|
|
98
|
-
## Methods
|
|
99
|
-
|
|
100
|
-
The visitor- and operator-facing imperative methods (`show`, `hide`, `update`, `shutdown`, `showSpace`, `showMessages`, `whoami`, `onUnreadCountChange`, etc.) live on `window.WexioWidget` once the component has mounted, mirroring the script loader's surface. A typed React hook (`useWexioWidget()`) ships in a future minor — until then, reach for the global from `useEffect`.
|
|
101
|
-
|
|
102
|
-
### show / hide / toggle
|
|
80
|
+
| Prop | Type | Description |
|
|
81
|
+
| ----------- | --------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
82
|
+
| `publicKey` | `string` | Wexio integration public key (`pk_live_...`). Omit to render in demo mode (bundled mock content for landing pages or Storybook). |
|
|
83
|
+
| `user` | [`VisitorIdentity`](#visitoridentity) | Verified identity. See [Identifying users](#identifying-users). |
|
|
84
|
+
| `mode` | `"production" \| "demo"` | Force a mode. Auto-resolves to `production` when `publicKey` is set, `demo` otherwise. Set `demo` explicitly to render bundled mock content even with a public key (landing previews). |
|
|
85
|
+
| `config` | [`InjectableWidgetConfig`](#injectablewidgetconfig) | Pre-resolved widget config. Set this if you already have the config server-rendered or fetched app-wide — skips the bootstrap fetch. |
|
|
86
|
+
| `onResize` | `(size: { width: number; height: number }) => void` | Fired whenever the widget's intended dimensions change (open ↔ closed ↔ expanded). Use for host-side layout sync. |
|
|
87
|
+
| `onOpen` | `() => void` | Fired when the visitor opens the panel (taps the launcher, peek bubble, etc.). |
|
|
88
|
+
| `onClose` | `() => void` | Fired when the visitor taps the close chip. |
|
|
89
|
+
| `className` | `string` | Pass-through class on the outer host `<div>`. Style this with normal layout CSS. |
|
|
90
|
+
| `style` | `React.CSSProperties` | Pass-through inline styles for the outer host `<div>`. |
|
|
103
91
|
|
|
104
|
-
|
|
92
|
+
> **UI locale is operator-controlled.** The widget ships **33 UI locales** (English, Ukrainian, German, Spanish — incl. `es-MX`, French, Italian, Dutch, Portuguese — incl. `pt-BR`, Swedish, Danish, Norwegian, Finnish, Polish, Czech, Slovak, Turkish, Romanian, Hungarian, Greek, Arabic, Hebrew, Hindi, Thai, Vietnamese, Indonesian, Japanese, Korean, Chinese — `zh` + `zh-TW`, plus regional English variants). The operator's `localeStrategy` (set in the Wexio dashboard) decides whether to follow the visitor's browser (`AUTO`), the host page's `<html lang>` (`WEBSITE`), or pin to a chosen language (`DEFAULT` + `defaultLocale`). The visitor can also override their language from the in-widget Profile tab.
|
|
105
93
|
|
|
106
|
-
|
|
107
|
-
window.WexioWidget?.show();
|
|
108
|
-
window.WexioWidget?.hide();
|
|
109
|
-
window.WexioWidget?.toggle();
|
|
110
|
-
```
|
|
94
|
+
## Bot protection (Cloudflare Turnstile)
|
|
111
95
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
Patch live config (swap identity, switch theme, change locale).
|
|
115
|
-
|
|
116
|
-
```ts
|
|
117
|
-
window.WexioWidget?.update({ locale: "uk" });
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
### shutdown / boot
|
|
121
|
-
|
|
122
|
-
Wipe session (token, sticky visitor id, prechat flags); `boot` re-initialises. Use on logout / shared devices.
|
|
123
|
-
|
|
124
|
-
```ts
|
|
125
|
-
window.WexioWidget?.shutdown();
|
|
126
|
-
window.WexioWidget?.boot({ publicKey: "pk_live_..." });
|
|
127
|
-
```
|
|
96
|
+
When the operator enables [Cloudflare Turnstile](https://developers.cloudflare.com/turnstile/) for the integration (Wexio dashboard → Security), the widget transparently runs an interaction-only challenge before the visitor handshake — no host wiring required. The launcher stays unclickable until the challenge resolves; on failure a small "couldn't verify you're human" popup appears anchored above the launcher with a retry button. The challenge token is attached to the prechat and identified-visitor handshake server-side, so operator-side rate-limiting / abuse rules apply automatically.
|
|
128
97
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
Open the messenger and route to a specific tab.
|
|
132
|
-
|
|
133
|
-
```ts
|
|
134
|
-
window.WexioWidget?.showSpace("home");
|
|
135
|
-
window.WexioWidget?.showSpace("messages");
|
|
136
|
-
window.WexioWidget?.showSpace("help");
|
|
137
|
-
window.WexioWidget?.showSpace("news");
|
|
138
|
-
window.WexioWidget?.showSpace("profile");
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
### showMessages
|
|
142
|
-
|
|
143
|
-
Alias for `showSpace("messages")`.
|
|
144
|
-
|
|
145
|
-
```ts
|
|
146
|
-
window.WexioWidget?.showMessages();
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
### showNewMessage
|
|
150
|
-
|
|
151
|
-
Open ready-to-compose. Optional prefill for the composer.
|
|
152
|
-
|
|
153
|
-
```ts
|
|
154
|
-
window.WexioWidget?.showNewMessage();
|
|
155
|
-
window.WexioWidget?.showNewMessage("Hi, I have a question about...");
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
### showArticle / showNews
|
|
159
|
-
|
|
160
|
-
Deep-link into a help article or news post.
|
|
161
|
-
|
|
162
|
-
```ts
|
|
163
|
-
window.WexioWidget?.showArticle(articleId);
|
|
164
|
-
window.WexioWidget?.showNews(newsItemId);
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
### onShow / onHide
|
|
168
|
-
|
|
169
|
-
Fire a callback when the messenger opens/closes.
|
|
170
|
-
|
|
171
|
-
```ts
|
|
172
|
-
window.WexioWidget?.onShow(() => {
|
|
173
|
-
console.log("messenger opened");
|
|
174
|
-
});
|
|
175
|
-
window.WexioWidget?.onHide(() => {
|
|
176
|
-
console.log("messenger closed");
|
|
177
|
-
});
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
### onUnreadCountChange
|
|
181
|
-
|
|
182
|
-
Fires immediately with the current count, then on every change. Common use: badge the host tab title.
|
|
183
|
-
|
|
184
|
-
```tsx
|
|
185
|
-
useEffect(() => {
|
|
186
|
-
return window.WexioWidget?.onUnreadCountChange?.((count) => {
|
|
187
|
-
document.title = count > 0 ? `(${count}) Inbox` : "Inbox";
|
|
188
|
-
});
|
|
189
|
-
}, []);
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
### hideNotifications
|
|
193
|
-
|
|
194
|
-
Suppress launcher peek bubbles on new operator messages.
|
|
195
|
-
|
|
196
|
-
```ts
|
|
197
|
-
window.WexioWidget?.hideNotifications(true); // suppress
|
|
198
|
-
window.WexioWidget?.hideNotifications(false); // restore
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
### whoami / getVisitorId
|
|
202
|
-
|
|
203
|
-
Read the current session.
|
|
204
|
-
|
|
205
|
-
```ts
|
|
206
|
-
const me = window.WexioWidget?.whoami();
|
|
207
|
-
// → { visitorId, peopleId, displayName, verified } | null
|
|
208
|
-
const visitorId = window.WexioWidget?.getVisitorId();
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
### setLocale
|
|
212
|
-
|
|
213
|
-
Programmatic language switch.
|
|
214
|
-
|
|
215
|
-
```ts
|
|
216
|
-
window.WexioWidget?.setLocale("uk");
|
|
217
|
-
```
|
|
98
|
+
## Methods
|
|
218
99
|
|
|
219
|
-
|
|
100
|
+
The component's open / close lifecycle is driven via the `onOpen` / `onClose` callbacks plus the visitor's tap on the launcher — no host-side imperative call is needed for normal use.
|
|
220
101
|
|
|
221
|
-
|
|
102
|
+
An imperative `window.WexioWidget` surface (`show`, `hide`, `showSpace`, `setLocale`, `onUnreadCountChange`, …) is on the roadmap to mirror the script loader's API, but doesn't ship in the current React package. For deep-link / programmatic control today, mount the widget conditionally from your own host state.
|
|
222
103
|
|
|
223
104
|
## Types
|
|
224
105
|
|
|
@@ -237,24 +118,16 @@ interface VisitorIdentity {
|
|
|
237
118
|
}
|
|
238
119
|
```
|
|
239
120
|
|
|
240
|
-
### VisitorPrefill
|
|
241
|
-
|
|
242
|
-
```ts
|
|
243
|
-
interface VisitorPrefill {
|
|
244
|
-
name?: string;
|
|
245
|
-
email?: string;
|
|
246
|
-
phone?: string;
|
|
247
|
-
}
|
|
248
|
-
```
|
|
249
|
-
|
|
250
121
|
### InjectableWidgetConfig
|
|
251
122
|
|
|
252
|
-
The pre-resolved widget config shape (theme, features, blocks, prechat, messenger chrome, sounds, locale strategy). Pull it from the package:
|
|
123
|
+
The pre-resolved widget config shape (theme, features, blocks, prechat, messenger chrome, sounds, locale strategy, bot protection). Pull it from the package:
|
|
253
124
|
|
|
254
125
|
```ts
|
|
255
126
|
import type { InjectableWidgetConfig } from "@wexio/messenger-widget-react";
|
|
256
127
|
```
|
|
257
128
|
|
|
129
|
+
The integration's [Cloudflare Turnstile](https://developers.cloudflare.com/turnstile/) bot-protection check (when the operator enables it in the Wexio dashboard) is wired automatically — the widget loads the CF script, runs the challenge before the visitor handshake, and shows a retry popup above the launcher if the challenge fails. Hosts don't need to wire anything extra.
|
|
130
|
+
|
|
258
131
|
## SSR
|
|
259
132
|
|
|
260
133
|
The component renders `null` on the server. The Shadow-DOM portal target mounts on the first `useEffect`, so the widget is invisible during SSR/hydration and appears on first paint. Wrap in `<Suspense fallback={null}>` if you need to defer hydration in RSC-heavy apps.
|
|
@@ -278,7 +151,7 @@ Modern evergreen browsers — anything that supports Shadow DOM and ES2020. Inte
|
|
|
278
151
|
|
|
279
152
|
### TypeScript errors after upgrade
|
|
280
153
|
|
|
281
|
-
The public type surface is locked to `entries/public.ts` in the source repo. If you previously relied on undocumented props (`mode: "preview"`, `configOverride`, `useDummyData`, `previewData`), they are no longer exposed — they were dashboard-only
|
|
154
|
+
The public type surface is locked to `entries/public.ts` in the source repo. If you previously relied on undocumented props (`locale`, `prefill`, `lightboxViewport`, `mode: "preview"`, `configOverride`, `useDummyData`, `previewData`), they are no longer exposed — they were either dashboard-only or moved to operator-side config. Remove them and the build will pass. UI locale is now controlled by the operator's `localeStrategy` config and the visitor's Profile-tab language switcher.
|
|
282
155
|
|
|
283
156
|
## Use with other frameworks
|
|
284
157
|
|