@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.
Files changed (71) hide show
  1. package/README.md +23 -150
  2. package/dist/{widget-react-BfPdgAQ-.js → widget-react-A2LiLuw0.js} +1151 -1006
  3. package/dist/{widget-react-DwL_rsx_.js → widget-react-B0fjhAJD.js} +72 -56
  4. package/dist/{widget-react-D-QrEVpv.js → widget-react-BC-2nOW4.js} +1 -1
  5. package/dist/{widget-react-CZs0xRrr.js → widget-react-BMpc2uNT2.js} +1 -1
  6. package/dist/widget-react-BNG2P8TD.js +337 -0
  7. package/dist/widget-react-BcPE3ZoY.js +337 -0
  8. package/dist/widget-react-BdgqHrUV.js +337 -0
  9. package/dist/widget-react-BdohGq4s2.js +337 -0
  10. package/dist/widget-react-BthaWcns.js +337 -0
  11. package/dist/widget-react-C-8yYmmX2.js +337 -0
  12. package/dist/widget-react-C2atp9Wc.js +337 -0
  13. package/dist/widget-react-C7J17SWR.js +337 -0
  14. package/dist/{widget-react-BAOIDvhV.js → widget-react-CB6Jxluy.js} +1362 -1328
  15. package/dist/widget-react-CKZ5tNDZ.js +337 -0
  16. package/dist/widget-react-CLRkytx8.js +337 -0
  17. package/dist/widget-react-CMvMg68M.js +337 -0
  18. package/dist/widget-react-COu0Pgwj2.js +337 -0
  19. package/dist/widget-react-CSqqxBrZ2.js +337 -0
  20. package/dist/widget-react-CVLlTbB_2.js +337 -0
  21. package/dist/{widget-react-DtOeNw5z.js → widget-react-CVx50FQP2.js} +18 -9
  22. package/dist/{widget-react-AgErOR36.js → widget-react-CYlAGnu_2.js} +19 -7
  23. package/dist/{widget-react-CPYwD6FR.js → widget-react-CdjAa7d12.js} +2 -2
  24. package/dist/widget-react-Cfgp7JeP.js +337 -0
  25. package/dist/widget-react-CozbWJT5.js +337 -0
  26. package/dist/widget-react-Crxd4qSM.js +337 -0
  27. package/dist/widget-react-D3ZFysG9.js +337 -0
  28. package/dist/widget-react-DAT3UgdW2.js +285 -0
  29. package/dist/widget-react-DRyfg-bL.js +337 -0
  30. package/dist/widget-react-DhC6mv1r.js +337 -0
  31. package/dist/widget-react-DiF8_rWm.js +337 -0
  32. package/dist/widget-react-DjXlAiu5.js +337 -0
  33. package/dist/widget-react-DkhMvmdX2.js +337 -0
  34. package/dist/{widget-react-CUuKGDZN.js → widget-react-DqRO9d652.js} +2 -2
  35. package/dist/widget-react-Dq_sYldT.js +337 -0
  36. package/dist/{widget-react-Cj_zbk_F.js → widget-react-Dr-NACA0.js} +19 -7
  37. package/dist/widget-react-DviuEPoq.js +337 -0
  38. package/dist/{widget-react-CDPzwV1i.js → widget-react-DxkbC0xE.js} +1823 -1833
  39. package/dist/widget-react-JOt2DXbR.js +337 -0
  40. package/dist/widget-react-L8PMkUr7.js +337 -0
  41. package/dist/widget-react-LWisk9g6.js +337 -0
  42. package/dist/{widget-react-DSw03RG7.js → widget-react-_xdGdTzK.js} +1 -1
  43. package/dist/widget-react-fNts-U3I2.js +337 -0
  44. package/dist/widget-react-iKCOmnGh.js +337 -0
  45. package/dist/{widget-react-C5COLy3m.js → widget-react-wTlmXnex2.js} +1 -1
  46. package/dist/widget-react-xzOjEdXk2.js +337 -0
  47. package/dist/widget-react.d.ts +10 -19
  48. package/dist/widget-react.js +4028 -3450
  49. package/package.json +1 -1
  50. package/dist/widget-react-AgErOR36.js.map +0 -1
  51. package/dist/widget-react-BAOIDvhV.js.map +0 -1
  52. package/dist/widget-react-BfPdgAQ-.js.map +0 -1
  53. package/dist/widget-react-BxvW64LH.js.map +0 -1
  54. package/dist/widget-react-C5COLy3m.js.map +0 -1
  55. package/dist/widget-react-CAWxn8I0.js +0 -247
  56. package/dist/widget-react-CAWxn8I0.js.map +0 -1
  57. package/dist/widget-react-CDPzwV1i.js.map +0 -1
  58. package/dist/widget-react-CPYwD6FR.js.map +0 -1
  59. package/dist/widget-react-CUBFPjaV.js.map +0 -1
  60. package/dist/widget-react-CUuKGDZN.js.map +0 -1
  61. package/dist/widget-react-CZs0xRrr.js.map +0 -1
  62. package/dist/widget-react-Cj_zbk_F.js.map +0 -1
  63. package/dist/widget-react-D-QrEVpv.js.map +0 -1
  64. package/dist/widget-react-D8TPnM9r.js.map +0 -1
  65. package/dist/widget-react-DE7AVrCo.js.map +0 -1
  66. package/dist/widget-react-DOX6j7_Q.js.map +0 -1
  67. package/dist/widget-react-DSw03RG7.js.map +0 -1
  68. package/dist/widget-react-Dew7YaLU.js.map +0 -1
  69. package/dist/widget-react-DtOeNw5z.js.map +0 -1
  70. package/dist/widget-react-DwL_rsx_.js.map +0 -1
  71. 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
- For an **unverified pre-fill** (skip the prechat form when the visitor's email is already known but you can't sign it), use `prefill`:
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 | Type | Description |
86
- | ------------------- | ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
87
- | `publicKey` | `string` | Wexio integration public key (`pk_live_...`). Omit to render in demo mode (bundled mock content for landing pages or Storybook). |
88
- | `locale` | `"en" \| "uk"` | UI locale. Defaults to the visitor's browser language. Extend by contributing a new bundle to the source repo. |
89
- | `user` | [`VisitorIdentity`](#visitoridentity) | Verified identity. See [Identifying users](#identifying-users). |
90
- | `prefill` | [`VisitorPrefill`](#visitorprefill) | Unverified pre-fill for the prechat form. |
91
- | `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. |
92
- | `lightboxViewport` | `boolean` (default `true`) | Render the media lightbox (image / video gallery) as a viewport-fixed overlay. Pass `false` to contain the gallery inside the widget's host box. |
93
- | `onResize` | `(size: { width: number; height: number }) => void` | Fired whenever the widget's intended dimensions change (open ↔ closed ↔ expanded). Use for host-side layout sync. |
94
- | `onClose` | `() => void` | Fired when the visitor taps the close chip. |
95
- | `className` | `string` | Pass-through class on the outer host `<div>`. Style this with normal layout CSS. |
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
- Open or close the messenger panel.
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
- ```ts
107
- window.WexioWidget?.show();
108
- window.WexioWidget?.hide();
109
- window.WexioWidget?.toggle();
110
- ```
94
+ ## Bot protection (Cloudflare Turnstile)
111
95
 
112
- ### update
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
- ### showSpace
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
- ### Future / reserved
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
- The following names are reserved on the public surface for upcoming features and are no-ops today (with a `console.warn` in dev builds): `trackEvent`, `startTour`, `startSurvey`, `startChecklist`, `showTicket`. They'll light up when the corresponding backend features ship.
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 and never meant to ship. Remove them and the build will pass.
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