@lorikeetai/react-native-sdk 2.0.0-alpha.1 → 2.0.0-alpha.3
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 +97 -5
- package/dist/index.cjs +228 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +441 -15
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +441 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +229 -46
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,81 +1,476 @@
|
|
|
1
1
|
import { StyleProp, TextStyle } from "react-native";
|
|
2
2
|
import { WebView, WebViewMessageEvent, WebViewProps } from "react-native-webview";
|
|
3
|
-
import { Customisations } from "@lorikeetai/web-sdk/types";
|
|
4
3
|
//#region src/conversation-metadata.d.ts
|
|
5
4
|
type ConversationMetadata = Record<string, unknown>;
|
|
6
5
|
//#endregion
|
|
6
|
+
//#region src/customisations.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* What the chat page accepts as `customisations`, as the SDK's own types.
|
|
9
|
+
*
|
|
10
|
+
* A copy of the web SDK's shape rather than an import of it. The web SDK is a
|
|
11
|
+
* browser bundle an app has no reason to install, and importing a type from it
|
|
12
|
+
* left the published `dist/index.d.ts` referencing a module consumers do not
|
|
13
|
+
* have: `Customisations` then degraded to `any` and typed nothing.
|
|
14
|
+
* `ConversationMetadata` is duplicated here for the same reason.
|
|
15
|
+
*
|
|
16
|
+
* `src/customisations.web-sdk-parity.ts` fails the build if the two drift.
|
|
17
|
+
*
|
|
18
|
+
* Fields that only mean something on a web page, the viewport sizes and the
|
|
19
|
+
* launcher button, are kept so the page's behaviour is unchanged and so a host
|
|
20
|
+
* sharing one configuration object with its web widget still type-checks.
|
|
21
|
+
*/
|
|
22
|
+
/** Sizing for one viewport. Desktop only: the page is full-screen on mobile. */
|
|
23
|
+
interface ViewportCustomisations {
|
|
24
|
+
/** Clamped to a 2rem maximum. */
|
|
25
|
+
borderRadius?: string;
|
|
26
|
+
default_open?: boolean;
|
|
27
|
+
/** Clamped to the viewport minus `topClearance`, and to a 20rem minimum. */
|
|
28
|
+
height?: string;
|
|
29
|
+
/** Reserved space above the widget. Desktop default 6.5rem. */
|
|
30
|
+
topClearance?: string;
|
|
31
|
+
width?: string;
|
|
32
|
+
}
|
|
33
|
+
interface Customisations {
|
|
34
|
+
/** Falls back to the logo image. */
|
|
35
|
+
avatarUrl?: string;
|
|
36
|
+
botName?: string;
|
|
37
|
+
desktop?: ViewportCustomisations;
|
|
38
|
+
/**
|
|
39
|
+
* Which header the customer gets, not whether there is one. `true` hides the
|
|
40
|
+
* page's own; `false` keeps it, and it carries Close and End chat.
|
|
41
|
+
*
|
|
42
|
+
* What replaces a hidden one is the host's business, so there is no one
|
|
43
|
+
* default to quote. `LorikeetWidgetView` substitutes its own header, a title
|
|
44
|
+
* and new chat, and does so when this is omitted. `LorikeetClient` only
|
|
45
|
+
* serialises the flag and renders nothing, so a composed host keeps the page's
|
|
46
|
+
* header unless it asks for it to go, and must render `LorikeetWidgetHeader`
|
|
47
|
+
* itself when it does.
|
|
48
|
+
*/
|
|
49
|
+
hideHeader?: boolean;
|
|
50
|
+
/** @default '_blank' */
|
|
51
|
+
linkTarget?: '_blank' | '_parent';
|
|
52
|
+
logoUrl?: string;
|
|
53
|
+
messages?: {
|
|
54
|
+
/** Shown when the widget is in an unexpectedly failed state. */
|
|
55
|
+
failOver?: string;
|
|
56
|
+
/** Shown when live chat has been switched off deliberately. */
|
|
57
|
+
unavailable?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Replaces the line under "Someone is taking a look", for a conversation
|
|
60
|
+
* handed to a person. Say where the reply will come from when the default
|
|
61
|
+
* should not promise it.
|
|
62
|
+
*/
|
|
63
|
+
escalated?: string;
|
|
64
|
+
};
|
|
65
|
+
mobile?: ViewportCustomisations;
|
|
66
|
+
mode?: 'controlled' | 'uncontrolled';
|
|
67
|
+
/**
|
|
68
|
+
* Styling for the launcher button the web widget renders. The React Native
|
|
69
|
+
* SDK renders no launcher, so this reaches the page and does nothing.
|
|
70
|
+
*
|
|
71
|
+
* @danger Experimental and may change.
|
|
72
|
+
*/
|
|
73
|
+
rootElement?: {
|
|
74
|
+
border?: string;
|
|
75
|
+
borderRadius?: string;
|
|
76
|
+
zIndex?: number;
|
|
77
|
+
bottom?: string;
|
|
78
|
+
right?: string;
|
|
79
|
+
/** Any CSS size value. Defaults to 3rem. */
|
|
80
|
+
size?: string;
|
|
81
|
+
};
|
|
82
|
+
/** Show dates as well as times, on every message. */
|
|
83
|
+
showVerboseTimestamps?: boolean;
|
|
84
|
+
theme?: CustomisationTheme;
|
|
85
|
+
title?: string;
|
|
86
|
+
/** @default false */
|
|
87
|
+
useSubtleBranding?: boolean;
|
|
88
|
+
}
|
|
89
|
+
interface CustomisationTheme {
|
|
90
|
+
/**
|
|
91
|
+
* Colour or gradient for the main area. Any colour value, and any gradient
|
|
92
|
+
* function including multiple layers. Image-based backgrounds are not
|
|
93
|
+
* supported. Takes precedence over `backgroundColor`.
|
|
94
|
+
*/
|
|
95
|
+
background?: string;
|
|
96
|
+
backgroundColor?: string;
|
|
97
|
+
/** Accent fill, currently the header. Resolves to a neutral when unset. */
|
|
98
|
+
brandAccentColor?: string;
|
|
99
|
+
brandColor?: string;
|
|
100
|
+
/** @default 'light' */
|
|
101
|
+
colorMode?: 'light' | 'dark';
|
|
102
|
+
fontFamily?: string;
|
|
103
|
+
/**
|
|
104
|
+
* Google Fonts CSS URL declaring the `@font-face` rules for `fontFamily`.
|
|
105
|
+
* The page ships Inter only, so a brand font the device lacks falls back
|
|
106
|
+
* unless its files are loaded. Host must be `fonts.googleapis.com`, path
|
|
107
|
+
* `/css` or `/css2`, and only `family` and `display` params; anything else is
|
|
108
|
+
* ignored.
|
|
109
|
+
*/
|
|
110
|
+
fontUrl?: string;
|
|
111
|
+
/**
|
|
112
|
+
* Colour or gradient for the header, on the same terms as `background`.
|
|
113
|
+
* Takes precedence over `brandAccentColor`.
|
|
114
|
+
*/
|
|
115
|
+
headerBackground?: string;
|
|
116
|
+
/** For text on a dark background. */
|
|
117
|
+
inverseTextColor?: string;
|
|
118
|
+
/** Falls back to the brand colour. */
|
|
119
|
+
linkColor?: string;
|
|
120
|
+
linkHoverColor?: string;
|
|
121
|
+
secondaryBrandColor?: string;
|
|
122
|
+
subtleBrandColor?: string;
|
|
123
|
+
textColor?: string;
|
|
124
|
+
}
|
|
125
|
+
//#endregion
|
|
7
126
|
//#region src/events.d.ts
|
|
8
|
-
|
|
127
|
+
/**
|
|
128
|
+
* What the page reports, as events rather than as raw bridge messages.
|
|
129
|
+
*
|
|
130
|
+
* Names follow the web SDK's (`LorikeetEvent` in `@lorikeetai/web-sdk/types`)
|
|
131
|
+
* wherever it has one, because a host that integrates both should not have to
|
|
132
|
+
* learn two vocabularies. The rest cover what the page tells a host that owns
|
|
133
|
+
* its own layout and storage, which on web the SDK handles internally and never
|
|
134
|
+
* surfaces: the close handshake, the persistence messages, the logout
|
|
135
|
+
* confirmation, and error codes. `logout_failed` is the one the SDK reports
|
|
136
|
+
* itself, for a page that said nothing when it had to.
|
|
137
|
+
*
|
|
138
|
+
* `token_expiry` is deliberately absent. The credential model it belongs to is
|
|
139
|
+
* being rewritten, and an event is the hardest thing to take back. Nothing
|
|
140
|
+
* carrying a credential is translated at all, for the same reason.
|
|
141
|
+
*/
|
|
142
|
+
type LorikeetWidgetEvent =
|
|
143
|
+
/** The page is up and the conversation is usable. */
|
|
144
|
+
{
|
|
9
145
|
type: 'ready';
|
|
10
|
-
} |
|
|
146
|
+
} |
|
|
147
|
+
/**
|
|
148
|
+
* A ticket that did not exist before this page loaded. Once per ticket, and
|
|
149
|
+
* never for a resume, matching the web SDK.
|
|
150
|
+
*/
|
|
151
|
+
{
|
|
11
152
|
type: 'ticket_created';
|
|
12
153
|
ticketId: string;
|
|
13
|
-
} |
|
|
154
|
+
} |
|
|
155
|
+
/** The customer sent something. */
|
|
156
|
+
{
|
|
14
157
|
type: 'customer_message';
|
|
15
|
-
} |
|
|
158
|
+
} |
|
|
159
|
+
/**
|
|
160
|
+
* The agent sent something. `markUnread` is the page asking for an unread
|
|
161
|
+
* indicator, which it only does where its live chat experience is on; the web
|
|
162
|
+
* SDK's launcher dot is driven by it, and it badges only while the widget is
|
|
163
|
+
* out of sight.
|
|
164
|
+
*
|
|
165
|
+
* Absent from a page older than the release that added it, which is not the
|
|
166
|
+
* same as `false`.
|
|
167
|
+
*/
|
|
168
|
+
{
|
|
16
169
|
type: 'agent_message';
|
|
17
|
-
|
|
170
|
+
markUnread?: boolean;
|
|
171
|
+
} |
|
|
172
|
+
/**
|
|
173
|
+
* The page closed itself, and why. `ended_by_customer` is followed by a
|
|
174
|
+
* `new_chat`, seconds later, so a host that tears down here never sees the
|
|
175
|
+
* rest of the handshake. `minimised` has nothing behind it: the conversation
|
|
176
|
+
* is intact and hiding it is enough.
|
|
177
|
+
*
|
|
178
|
+
* `reason` is absent from a page older than the release that added it.
|
|
179
|
+
*/
|
|
180
|
+
{
|
|
18
181
|
type: 'close';
|
|
19
182
|
reason?: 'ended_by_customer' | 'minimised';
|
|
20
|
-
} |
|
|
183
|
+
} |
|
|
184
|
+
/**
|
|
185
|
+
* The conversation ended without the customer ending it: an agent closed it,
|
|
186
|
+
* or it timed out. Nothing follows, and nothing is asking the host to hide
|
|
187
|
+
* anything. Left unhandled, this is the customer stranded on a conversation
|
|
188
|
+
* that can no longer be used.
|
|
189
|
+
*/
|
|
190
|
+
{
|
|
21
191
|
type: 'conversation_ended';
|
|
22
|
-
} |
|
|
192
|
+
} |
|
|
193
|
+
/**
|
|
194
|
+
* The page asking for a replacement conversation. It cannot navigate itself,
|
|
195
|
+
* so acting on this is the host's half of End chat.
|
|
196
|
+
*/
|
|
197
|
+
{
|
|
23
198
|
type: 'new_chat';
|
|
24
|
-
} |
|
|
199
|
+
} |
|
|
200
|
+
/**
|
|
201
|
+
* Store this against the customer, alongside the session. A resume needs both:
|
|
202
|
+
* the ticket alone fails with `CUSTOMER_ID_MISSING`.
|
|
203
|
+
*/
|
|
204
|
+
{
|
|
25
205
|
type: 'persist_ticket_id';
|
|
26
206
|
ticketId: string;
|
|
27
|
-
} |
|
|
207
|
+
} |
|
|
208
|
+
/** The other half of the stored pair. Arrives separately and in no order. */
|
|
209
|
+
{
|
|
28
210
|
type: 'persist_session';
|
|
29
211
|
session: string;
|
|
30
|
-
} |
|
|
212
|
+
} |
|
|
213
|
+
/**
|
|
214
|
+
* `/logout` cleared the frame: the chat's cookies for this key, server-side,
|
|
215
|
+
* and the storage the page kept. Reached by navigating the WebView to
|
|
216
|
+
* `LorikeetClient.getLogoutUrl()`, and the only confirmation that the
|
|
217
|
+
* clearing happened. The page's load event is not: an error page fires that
|
|
218
|
+
* too.
|
|
219
|
+
*
|
|
220
|
+
* `persistAnonymousSessionToken` is deliberately not translated. It carries a
|
|
221
|
+
* 365-day identity credential, this SDK offers no way to use one, and the web
|
|
222
|
+
* SDK keeps the same message inside the frame rather than handing it to its
|
|
223
|
+
* host. A typed event would be a published commitment to storing it, days
|
|
224
|
+
* before the hand-off protocol is meant to stop putting it in a URL at all.
|
|
225
|
+
*/
|
|
226
|
+
{
|
|
227
|
+
type: 'logged_out';
|
|
228
|
+
} |
|
|
229
|
+
/**
|
|
230
|
+
* The SDK's own report, not the page's: `/logout` did not confirm inside
|
|
231
|
+
* `LOGOUT_CONFIRMATION_TIMEOUT_MS`, so the previous customer may still be
|
|
232
|
+
* signed in on this device.
|
|
233
|
+
*
|
|
234
|
+
* The widget stays unavailable rather than starting the next customer's chat,
|
|
235
|
+
* because the alternative is handing them a device the last one's credentials
|
|
236
|
+
* still open. Call `logout()` again to retry.
|
|
237
|
+
*/
|
|
238
|
+
{
|
|
239
|
+
type: 'logout_failed';
|
|
240
|
+
} |
|
|
241
|
+
/** A page-level failure. `LORIKEET_ERROR_CODES` lists the codes. */
|
|
242
|
+
{
|
|
31
243
|
type: 'error';
|
|
32
244
|
error: string;
|
|
33
|
-
} |
|
|
245
|
+
} |
|
|
246
|
+
/**
|
|
247
|
+
* The preload page finished warming, and what the server said about it.
|
|
248
|
+
*
|
|
249
|
+
* Unreachable from React Native, and published in error. The preload page
|
|
250
|
+
* posts straight to `window.parent` behind a `window.parent !== window`
|
|
251
|
+
* guard, which is false in a WebView, so it never takes the native bridge the
|
|
252
|
+
* page's other messages go through. Kept because removing a published union
|
|
253
|
+
* member is a breaking change; retire it when 2.x leaves alpha, or when the
|
|
254
|
+
* page learns to post it natively.
|
|
255
|
+
*/
|
|
256
|
+
{
|
|
34
257
|
type: 'preload_complete';
|
|
35
258
|
clientStart: boolean;
|
|
36
259
|
lazyTicketCreationEnabled: boolean;
|
|
37
260
|
};
|
|
38
|
-
|
|
261
|
+
/** The names, spelled out rather than derived, so callers import a real type. */
|
|
262
|
+
type LorikeetWidgetEventType = 'agent_message' | 'close' | 'conversation_ended' | 'customer_message' | 'error' | 'logged_out' | 'logout_failed' | 'new_chat' | 'persist_session' | 'persist_ticket_id' | 'preload_complete' | 'ready' | 'ticket_created';
|
|
39
263
|
//#endregion
|
|
40
264
|
//#region src/types.d.ts
|
|
41
265
|
interface LorikeetInitOptions {
|
|
266
|
+
/**
|
|
267
|
+
* The base URL of the Lorikeet API for the widget to interact with.
|
|
268
|
+
*/
|
|
42
269
|
api_base?: string;
|
|
270
|
+
/**
|
|
271
|
+
* The options available to customise the widget.
|
|
272
|
+
*/
|
|
43
273
|
customisations?: Customisations;
|
|
274
|
+
/**
|
|
275
|
+
* Arbitrary context to attach to the conversation. Sent as JSON, not base64,
|
|
276
|
+
* which is what both the widget route and the resume route expect.
|
|
277
|
+
*/
|
|
44
278
|
metadata?: ConversationMetadata;
|
|
279
|
+
/**
|
|
280
|
+
* The public key to use.
|
|
281
|
+
*/
|
|
45
282
|
public_key: string;
|
|
46
283
|
}
|
|
47
284
|
type LorikeetWidgetWebViewProps = {
|
|
285
|
+
/**
|
|
286
|
+
* The URI of the widget.
|
|
287
|
+
*/
|
|
48
288
|
uri: string;
|
|
289
|
+
/**
|
|
290
|
+
* The base URL of the Lorikeet API for the widget to interact with.
|
|
291
|
+
*/
|
|
49
292
|
baseUrl?: string;
|
|
293
|
+
/**
|
|
294
|
+
* The props for the react-native-webview component
|
|
295
|
+
*/
|
|
50
296
|
webviewProps?: WebViewProps;
|
|
297
|
+
/**
|
|
298
|
+
* What the page reported, as typed events rather than raw bridge messages.
|
|
299
|
+
*
|
|
300
|
+
* This component reports; it does not act. A host composing it owns its own
|
|
301
|
+
* URL, layout and storage, so hiding on a close, rebuilding a resume URL or
|
|
302
|
+
* recovering from process loss are all theirs to do. `LorikeetWidgetView`
|
|
303
|
+
* consumes this same path and acts on top of it, because it owns the URL.
|
|
304
|
+
*/
|
|
51
305
|
onEvent?: (event: LorikeetWidgetEvent) => void;
|
|
52
306
|
};
|
|
53
307
|
type LorikeetWidgetHeaderProps = {
|
|
308
|
+
/**
|
|
309
|
+
* The title of the widget.
|
|
310
|
+
*/
|
|
54
311
|
title: string;
|
|
312
|
+
/**
|
|
313
|
+
* The style of the header text.
|
|
314
|
+
*/
|
|
55
315
|
style?: StyleProp<TextStyle>;
|
|
316
|
+
/**
|
|
317
|
+
* The icon to display in the header.
|
|
318
|
+
*/
|
|
56
319
|
icon?: React.ReactNode;
|
|
320
|
+
/**
|
|
321
|
+
* The function to call when the icon is pressed.
|
|
322
|
+
*/
|
|
57
323
|
onIconPress?: () => void;
|
|
58
324
|
};
|
|
325
|
+
/**
|
|
326
|
+
* What a host can ask `LorikeetWidgetView` to do, through a ref. Imperative
|
|
327
|
+
* because logging out and reopening are events on the host's side rather than
|
|
328
|
+
* states the widget can read off its props.
|
|
329
|
+
*/
|
|
330
|
+
type LorikeetWidgetHandle = {
|
|
331
|
+
/**
|
|
332
|
+
* The conversation the widget would resume right now, or `null` when it has
|
|
333
|
+
* none to resume.
|
|
334
|
+
*
|
|
335
|
+
* The pull half of `persist_ticket_id` and `persist_session`. Those report a
|
|
336
|
+
* conversation as the page names it; this answers what the widget is on after
|
|
337
|
+
* it has acted, which is not always the same thing. A resume the server
|
|
338
|
+
* refuses is replaced, and a new chat replaces whatever came before it, so a
|
|
339
|
+
* host holding what it passed at mount can be holding a conversation that no
|
|
340
|
+
* longer exists.
|
|
341
|
+
*
|
|
342
|
+
* `null` means exactly that the widget has nothing to resume: no conversation
|
|
343
|
+
* reported yet, only half of one, the credentials have moved on, or the
|
|
344
|
+
* customer has been logged out. It does not mean the conversation is over. A
|
|
345
|
+
* conversation the customer ended is still reported, because that is still
|
|
346
|
+
* what the widget is on and what its own recovery would resume; `close` and
|
|
347
|
+
* its `reason` are how you hear that it ended.
|
|
348
|
+
*
|
|
349
|
+
* Reports what is on screen, so inside an `onEvent` handler it is still what
|
|
350
|
+
* was on screen before that event: read `reason` on the `close` rather than
|
|
351
|
+
* calling this from the handler. Read it again after a change rather than
|
|
352
|
+
* caching what it said.
|
|
353
|
+
*/
|
|
354
|
+
getConversation: () => {
|
|
355
|
+
minimised: boolean;
|
|
356
|
+
session?: string;
|
|
357
|
+
ticketId?: string;
|
|
358
|
+
} | null;
|
|
359
|
+
/**
|
|
360
|
+
* Clear this customer's chat from the device, for the credentials currently in
|
|
361
|
+
* props. Navigates the WebView to the page's own `/logout`, which drops the
|
|
362
|
+
* chat's cookies and the storage the page keeps; neither is reachable from
|
|
363
|
+
* native code, so clearing your stored `ticketId` and `session` alone leaves
|
|
364
|
+
* the conversation reopenable by the next person on the device.
|
|
365
|
+
*
|
|
366
|
+
* The widget renders nothing but that page until it confirms, and changing
|
|
367
|
+
* `publicKey`, `baseUrl` or `authToken` does not cut it short: signing the
|
|
368
|
+
* next customer in mid-clear would leave the previous one's cookies on the
|
|
369
|
+
* device. Wait for `logged_out` on `onEvent`, then pass the next credentials.
|
|
370
|
+
*
|
|
371
|
+
* A page that does not confirm within ten seconds reports `logout_failed` and
|
|
372
|
+
* leaves the widget unavailable rather than opening a chat on a device the
|
|
373
|
+
* previous customer's credentials still unlock. Call this again to retry; a
|
|
374
|
+
* retry while one is pending retries that customer, not whoever is in props
|
|
375
|
+
* by then.
|
|
376
|
+
*
|
|
377
|
+
* `logout_failed` outlives this component, and the obligation with it. The
|
|
378
|
+
* SDK stores nothing, so a widget unmounted before the clear confirmed, by a
|
|
379
|
+
* screen change or an app restart, comes back with no memory of it and will
|
|
380
|
+
* open a chat normally. Record the failure where you record the conversation,
|
|
381
|
+
* and call `logout()` again before you mount a chat for anyone else.
|
|
382
|
+
*
|
|
383
|
+
* Clear your own stored `ticketId` and `session` as well.
|
|
384
|
+
*/
|
|
385
|
+
logout: () => void;
|
|
386
|
+
/**
|
|
387
|
+
* Show a minimised conversation again, exactly as the customer left it.
|
|
388
|
+
* Nothing reloads and nothing is reported, so the conversation keeps its
|
|
389
|
+
* place, its draft and its stream.
|
|
390
|
+
*
|
|
391
|
+
* For a host with its own launcher. The widget already offers a control of
|
|
392
|
+
* its own while minimised, and it does the same thing.
|
|
393
|
+
*
|
|
394
|
+
* A no-op unless the widget is minimised. A conversation the customer ended
|
|
395
|
+
* is left alone, because it only reopens read-only, and so is one the
|
|
396
|
+
* credentials have moved on from.
|
|
397
|
+
*/
|
|
398
|
+
reopen: () => void;
|
|
399
|
+
};
|
|
59
400
|
type LorikeetWidgetViewProps = {
|
|
401
|
+
/**
|
|
402
|
+
* The public key to use.
|
|
403
|
+
*/
|
|
60
404
|
publicKey: string;
|
|
405
|
+
/**
|
|
406
|
+
* The base URL of the Lorikeet API for the widget to interact with.
|
|
407
|
+
*/
|
|
61
408
|
baseUrl?: string;
|
|
409
|
+
/**
|
|
410
|
+
* The auth token to use when retrieving the widget URL.
|
|
411
|
+
*/
|
|
62
412
|
authToken: string;
|
|
413
|
+
/**
|
|
414
|
+
* The function to call when a message is received from the webview.
|
|
415
|
+
*
|
|
416
|
+
* @deprecated Prefer `onEvent`, which reports the page's messages as typed
|
|
417
|
+
* events rather than raw JSON a host has to match on by string. Still called,
|
|
418
|
+
* and still additive with `webviewProps.onMessage`.
|
|
419
|
+
*
|
|
420
|
+
* `onEvent` is not a superset. Messages the SDK deliberately leaves
|
|
421
|
+
* untranslated, `persistAnonymousSessionToken` among them, arrive on the raw
|
|
422
|
+
* bridge only. Read those through `webviewProps.onMessage`, which carries the
|
|
423
|
+
* same stream and is not deprecated, rather than taking this prop for them.
|
|
424
|
+
*/
|
|
63
425
|
onWebViewMessage?: (event: WebViewMessageEvent) => void;
|
|
426
|
+
/**
|
|
427
|
+
* What the page reported, as typed events. The same stream
|
|
428
|
+
* `LorikeetWidgetWebView` emits, after the widget has acted on it.
|
|
429
|
+
*/
|
|
64
430
|
onEvent?: (event: LorikeetWidgetEvent) => void;
|
|
431
|
+
/**
|
|
432
|
+
* The options available to customise the widget.
|
|
433
|
+
*/
|
|
65
434
|
customisations?: Customisations;
|
|
435
|
+
/**
|
|
436
|
+
* The style of the components - limited to header text
|
|
437
|
+
*/
|
|
66
438
|
styles?: {
|
|
67
439
|
header?: StyleProp<TextStyle>;
|
|
68
440
|
};
|
|
441
|
+
/**
|
|
442
|
+
* Resume this conversation instead of starting a new one. Without it the
|
|
443
|
+
* widget boots `/widget`, which mints a fresh ticket on every mount.
|
|
444
|
+
*
|
|
445
|
+
* Take it from the `persistLorikeetTicketId` message and store it yourself;
|
|
446
|
+
* the SDK has no storage of its own.
|
|
447
|
+
*/
|
|
69
448
|
ticketId?: string;
|
|
449
|
+
/**
|
|
450
|
+
* The session token last reported by `persistLorikeetSession`, stored
|
|
451
|
+
* alongside `ticketId`. The ticket route needs it to authorise a WebView that
|
|
452
|
+
* has no cookie yet, so a resume without it fails with CUSTOMER_ID_MISSING.
|
|
453
|
+
*/
|
|
70
454
|
session?: string;
|
|
455
|
+
/**
|
|
456
|
+
* Arbitrary context to attach to the conversation, for routing or for the
|
|
457
|
+
* agent to read. Survives a resume: the ticket route forwards it into the
|
|
458
|
+
* re-init URL.
|
|
459
|
+
*/
|
|
71
460
|
metadata?: ConversationMetadata;
|
|
461
|
+
/**
|
|
462
|
+
* Props forwarded to the underlying react-native-webview. The SDK supplies
|
|
463
|
+
* defaults for media playback, scaling and the loading state, and any of them
|
|
464
|
+
* can be overridden here. `onMessage` is additive rather than an override:
|
|
465
|
+
* the SDK reads the bridge first and then calls yours.
|
|
466
|
+
*/
|
|
72
467
|
webviewProps?: WebViewProps;
|
|
73
468
|
};
|
|
74
469
|
//#endregion
|
|
75
470
|
//#region src/widget.d.ts
|
|
76
471
|
declare const LorikeetWidgetWebView: import("react").ForwardRefExoticComponent<LorikeetWidgetWebViewProps & import("react").RefAttributes<WebView<{}>>>;
|
|
77
472
|
declare const LorikeetWidgetHeader: ({ title, style, icon, onIconPress }: LorikeetWidgetHeaderProps) => import("react").JSX.Element;
|
|
78
|
-
declare
|
|
473
|
+
declare const LorikeetWidgetView: import("react").ForwardRefExoticComponent<LorikeetWidgetViewProps & import("react").RefAttributes<LorikeetWidgetHandle>>;
|
|
79
474
|
//#endregion
|
|
80
475
|
//#region src/client.d.ts
|
|
81
476
|
declare class LorikeetClient {
|
|
@@ -91,13 +486,44 @@ declare class LorikeetClient {
|
|
|
91
486
|
ticket_id?: string;
|
|
92
487
|
token: string;
|
|
93
488
|
}) => string;
|
|
489
|
+
/**
|
|
490
|
+
* The page that clears this key's credentials from the WebView: its cookies,
|
|
491
|
+
* server-side, and the storage the frame keeps. Navigating a WebView here is
|
|
492
|
+
* the only way to reach either, so a host that only drops its own copy of
|
|
493
|
+
* `ticketId` and `session` leaves the next person on the device able to
|
|
494
|
+
* reopen the conversation.
|
|
495
|
+
*
|
|
496
|
+
* The page confirms with a `loggedOut` message, which the SDK reports as
|
|
497
|
+
* `logged_out`. The load event does not: an error page fires that too.
|
|
498
|
+
*/
|
|
499
|
+
getLogoutUrl: () => string;
|
|
94
500
|
}
|
|
95
501
|
//#endregion
|
|
96
502
|
//#region src/errors.d.ts
|
|
503
|
+
/**
|
|
504
|
+
* Codes the chat page posts to the host as `{ type: 'error', error: CODE }`.
|
|
505
|
+
* Mirrored here because the page publishes them nowhere else, so a host would
|
|
506
|
+
* otherwise be matching on strings it discovered by observation.
|
|
507
|
+
*/
|
|
97
508
|
declare const LORIKEET_ERROR_CODES: readonly ["MISSING_TOKEN", "CORRUPT_TOKEN_DATA", "DECRYPT_FAILED", "EXPIRED_TOKEN", "MALFORMED_TOKEN", "MISSING_PUBLIC_KEY", "UNKNOWN_PUBLIC_KEY", "CUSTOMER_ID_CONFLICT", "CUSTOMER_ID_MISSING", "FATAL_ERROR", "INVALID_SESSION", "DOMAIN_NOT_ALLOWED", "TICKET_NOT_FOUND"];
|
|
98
509
|
type LorikeetErrorCode = (typeof LORIKEET_ERROR_CODES)[number];
|
|
510
|
+
/** Whether an error code means the stored conversation cannot be reopened. */
|
|
99
511
|
declare function isUnusableConversationCode(code: string): boolean;
|
|
100
512
|
declare function isUnusableConversation(message: unknown): boolean;
|
|
101
513
|
//#endregion
|
|
102
|
-
|
|
514
|
+
//#region src/lifecycle.d.ts
|
|
515
|
+
/**
|
|
516
|
+
* How long `/logout` gets to confirm it cleared the frame before the host is
|
|
517
|
+
* told it did not. Matches the web SDK's own budget, and like it, a logout that
|
|
518
|
+
* misses the deadline leaves the widget unavailable rather than letting the next
|
|
519
|
+
* customer start a chat on a device the previous one's credentials still open.
|
|
520
|
+
*
|
|
521
|
+
* `LorikeetWidgetView` applies this to its own `logout()`. Exported because a
|
|
522
|
+
* composed host has to run the timer itself and nothing else will report
|
|
523
|
+
* `logout_failed` for it, and two hosts choosing their own budgets is how one
|
|
524
|
+
* app calls a clear failed that the other never does.
|
|
525
|
+
*/
|
|
526
|
+
declare const LOGOUT_CONFIRMATION_TIMEOUT_MS = 10000;
|
|
527
|
+
//#endregion
|
|
528
|
+
export { type CustomisationTheme, type Customisations, LOGOUT_CONFIRMATION_TIMEOUT_MS, LORIKEET_ERROR_CODES, LorikeetClient, type LorikeetErrorCode, type LorikeetInitOptions, type LorikeetWidgetEvent, type LorikeetWidgetEventType, type LorikeetWidgetHandle, LorikeetWidgetHeader, type LorikeetWidgetHeaderProps, LorikeetWidgetView, type LorikeetWidgetViewProps, LorikeetWidgetWebView, type LorikeetWidgetWebViewProps, isUnusableConversation, isUnusableConversationCode };
|
|
103
529
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/conversation-metadata.ts","../src/events.ts","../src/types.ts","../src/widget.tsx","../src/client.ts","../src/errors.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/conversation-metadata.ts","../src/customisations.ts","../src/events.ts","../src/types.ts","../src/widget.tsx","../src/client.ts","../src/errors.ts","../src/lifecycle.ts"],"mappings":";;;KAEY,uBAAuB;;;;;;;;;;;;;;;;;;;UCezB;;EAER;EACA;;EAEA;;EAEA;EACA;;UAGe;;EAEf;EACA;EACA,UAAU;;;;;;;;;;;;EAYV;;EAEA;EACA;EACA;;IAEE;;IAEA;;;;;;IAMA;;EAEF,SAAS;EACT;;;;;;;EAOA;IACE;IACA;IACA;IACA;IACA;;IAEA;;;EAGF;EACA,QAAQ;EACR;;EAEA;;UAGe;;;;;;EAMf;EACA;;EAEA;EACA;;EAEA;EACA;;;;;;;;EAQA;;;;;EAKA;;EAEA;;EAEA;EACA;EACA;EACA;EACA;;;;;;;;;;;;;;;;;;;KCxGU;;;EAEN;;;;;;;EAKA;EAAwB;;;;EAExB;;;;;;;;;;;;EAUA;EAAuB;;;;;;;;;;;EASvB;EAAe;;;;;;;;;EAOf;;;;;;;EAKA;;;;;;;EAKA;EAA2B;;;;EAE3B;EAAyB;;;;;;;;;;;;;;;;EAczB;;;;;;;;;;;;EAUA;;;;EAEA;EAAe;;;;;;;;;;;;;EAYf;EACA;EACA;;;KAIM;;;UCnGK;;;;EAIf;;;;EAIA,iBAAiB;;;;;EAKjB,WAAW;;;;EAIX;;KAGU;;;;EAIV;;;;EAIA;;;;EAIA,eAAe;;;;;;;;;EASf,WAAW,OAAO;;KAGR;;;;EAIV;;;;EAIA,QAAQ,UAAU;;;;EAIlB,OAAO,MAAM;;;;EAIb;;;;;;;KAQU;;;;;;;;;;;;;;;;;;;;;;;;EAwBV;IACE;IACA;IACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4BF;;;;;;;;;;;;;EAaA;;KAGU;;;;EAIV;;;;EAIA;;;;EAIA;;;;;;;;;;;;;EAaA,oBAAoB,OAAO;;;;;EAK3B,WAAW,OAAO;;;;EAIlB,iBAAiB;;;;EAIjB;IACE,SAAS,UAAU;;;;;;;;;EASrB;;;;;;EAMA;;;;;;EAMA,WAAW;;;;;;;EAOX,eAAe;;;;cC3HJ,uCAAqB,0BAAA,6CAAA,cAAA;cA2HrB,yBAAwB,OAAA,OAAA,MAAA,eAKlC,8CAAyB,IAAA;cAYf,oCAAkB,0BAAA,0CAAA,cAAA;;;cCjOlB;EACX;EACA,gBAAgB;EAChB,UAAU;EACV;EAEY,cACV,gBACA,UACA,UACA,cACC;EAeH,kBAAiB,gBAAA,eAAA,OAAA,WAAA;IAOf;IACA;IACA;IACA;IACA;;;;;;;;;;;;EAmDF;;;;;;;;;cCxFW;KAgBD,4BAA4B;;iBAexB,2BAA2B;iBAK3B,uBAAuB;;;;;;;;;;;;;;cCjB1B"}
|