@duffel/react-native-components-assistant 0.5.1-canary.5 → 0.5.1
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/lib/module/index.js +33 -66
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.tsx +40 -95
package/lib/module/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import React
|
|
4
|
-
import {
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Linking, Modal, Platform, StyleSheet, View } from 'react-native';
|
|
5
5
|
import { WebView } from 'react-native-webview';
|
|
6
6
|
import { hasJsonWebTokenFormat } from "./lib/hasJsonWebTokenFormat.js";
|
|
7
7
|
import { getClientKeyPayload } from "./lib/getClientKeyPayload.js";
|
|
@@ -22,26 +22,6 @@ export const DuffelAssistant = ({
|
|
|
22
22
|
onNewMessage,
|
|
23
23
|
...properties
|
|
24
24
|
}) => {
|
|
25
|
-
const [androidKeyboardHeight, setAndroidKeyboardHeight] = useState(0);
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
if (Platform.OS !== 'android') {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
if (!isOpen) {
|
|
31
|
-
setAndroidKeyboardHeight(0);
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
const keyboardDidShowSubscription = Keyboard.addListener('keyboardDidShow', event => {
|
|
35
|
-
setAndroidKeyboardHeight(event.endCoordinates?.height ?? 0);
|
|
36
|
-
});
|
|
37
|
-
const keyboardDidHideSubscription = Keyboard.addListener('keyboardDidHide', () => {
|
|
38
|
-
setAndroidKeyboardHeight(0);
|
|
39
|
-
});
|
|
40
|
-
return () => {
|
|
41
|
-
keyboardDidShowSubscription.remove();
|
|
42
|
-
keyboardDidHideSubscription.remove();
|
|
43
|
-
};
|
|
44
|
-
}, [isOpen]);
|
|
45
25
|
if (!hasJsonWebTokenFormat(properties.clientKey)) {
|
|
46
26
|
throw new Error('Duffel Assistant client key format must be a valid JWT.');
|
|
47
27
|
}
|
|
@@ -98,44 +78,13 @@ export const DuffelAssistant = ({
|
|
|
98
78
|
Linking.openURL(request.url).catch(() => {});
|
|
99
79
|
return false;
|
|
100
80
|
};
|
|
101
|
-
if (Platform.OS === 'android') {
|
|
102
|
-
return /*#__PURE__*/_jsx(Modal, {
|
|
103
|
-
visible: isOpen,
|
|
104
|
-
onRequestClose: () => onClose(),
|
|
105
|
-
animationType: "slide",
|
|
106
|
-
children: /*#__PURE__*/_jsx(View, {
|
|
107
|
-
style: [styles.androidContainer, {
|
|
108
|
-
paddingBottom: 15 + androidKeyboardHeight
|
|
109
|
-
}],
|
|
110
|
-
children: /*#__PURE__*/_jsx(WebView
|
|
111
|
-
// Required for Android
|
|
112
|
-
, {
|
|
113
|
-
injectedJavaScript: `
|
|
114
|
-
postMessage(
|
|
115
|
-
{
|
|
116
|
-
type: "duffel-assistant-open",
|
|
117
|
-
properties: ${JSON.stringify(properties)},
|
|
118
|
-
},
|
|
119
|
-
"*",
|
|
120
|
-
);
|
|
121
|
-
true;`,
|
|
122
|
-
source: {
|
|
123
|
-
uri: assistantIframeUrl
|
|
124
|
-
},
|
|
125
|
-
onMessage: handleMessage,
|
|
126
|
-
onShouldStartLoadWithRequest: handleShouldStartLoadWithRequest,
|
|
127
|
-
style: styles.webView
|
|
128
|
-
})
|
|
129
|
-
})
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
81
|
return /*#__PURE__*/_jsx(Modal, {
|
|
133
82
|
visible: isOpen,
|
|
134
83
|
onRequestClose: () => onClose(),
|
|
135
84
|
animationType: "slide",
|
|
136
85
|
children: /*#__PURE__*/_jsx(View, {
|
|
137
86
|
style: styles.container,
|
|
138
|
-
children: /*#__PURE__*/_jsx(WebView, {
|
|
87
|
+
children: Platform.OS === 'ios' ? /*#__PURE__*/_jsx(WebView, {
|
|
139
88
|
injectedJavaScriptObject: properties
|
|
140
89
|
// When you are running this in development iOS doesn't allow request from hosts with invalid https certificates.
|
|
141
90
|
// If you try ngrok with the local esbuild server it will fail because ngrok requests in https and the dev server rejects http requests.
|
|
@@ -146,28 +95,46 @@ export const DuffelAssistant = ({
|
|
|
146
95
|
uri: assistantIframeUrl
|
|
147
96
|
},
|
|
148
97
|
onMessage: handleMessage,
|
|
149
|
-
onShouldStartLoadWithRequest: handleShouldStartLoadWithRequest
|
|
150
|
-
|
|
98
|
+
onShouldStartLoadWithRequest: handleShouldStartLoadWithRequest
|
|
99
|
+
// Always fetch the latest assistant bundle. The iframe.html shell
|
|
100
|
+
// references `./iframe-app.js` by a stable path, so without this
|
|
101
|
+
// the system WebView can serve a stale bundle for a long time.
|
|
102
|
+
,
|
|
103
|
+
cacheEnabled: false
|
|
104
|
+
}) : /*#__PURE__*/_jsx(WebView
|
|
105
|
+
// Required for Android
|
|
106
|
+
, {
|
|
107
|
+
injectedJavaScript: `
|
|
108
|
+
postMessage(
|
|
109
|
+
{
|
|
110
|
+
type: "duffel-assistant-open",
|
|
111
|
+
properties: ${JSON.stringify(properties)},
|
|
112
|
+
},
|
|
113
|
+
"*",
|
|
114
|
+
);
|
|
115
|
+
true;`,
|
|
116
|
+
source: {
|
|
117
|
+
uri: assistantIframeUrl
|
|
118
|
+
},
|
|
119
|
+
onMessage: handleMessage,
|
|
120
|
+
onShouldStartLoadWithRequest: handleShouldStartLoadWithRequest
|
|
121
|
+
// Always fetch the latest assistant bundle. The iframe.html shell
|
|
122
|
+
// references `./iframe-app.js` by a stable path, so without this
|
|
123
|
+
// the system WebView can serve a stale bundle for a long time.
|
|
124
|
+
,
|
|
125
|
+
cacheEnabled: false,
|
|
126
|
+
cacheMode: "LOAD_NO_CACHE"
|
|
151
127
|
})
|
|
152
128
|
})
|
|
153
129
|
});
|
|
154
130
|
};
|
|
155
131
|
const styles = StyleSheet.create({
|
|
156
132
|
container: {
|
|
157
|
-
|
|
133
|
+
height: '100%',
|
|
158
134
|
width: '100%',
|
|
159
135
|
paddingHorizontal: 12,
|
|
160
136
|
paddingTop: 50,
|
|
161
137
|
paddingBottom: 30
|
|
162
|
-
},
|
|
163
|
-
androidContainer: {
|
|
164
|
-
flex: 1,
|
|
165
|
-
width: '100%',
|
|
166
|
-
paddingTop: 45,
|
|
167
|
-
paddingBottom: 15
|
|
168
|
-
},
|
|
169
|
-
webView: {
|
|
170
|
-
flex: 1
|
|
171
138
|
}
|
|
172
139
|
});
|
|
173
140
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","
|
|
1
|
+
{"version":3,"names":["React","Linking","Modal","Platform","StyleSheet","View","WebView","hasJsonWebTokenFormat","getClientKeyPayload","jsx","_jsx","assistantIframeUrl","isHttpUrl","url","test","isAssistantIframeUrl","parsedUrl","URL","origin","pathname","error","DuffelAssistant","isOpen","onClose","onNewMessage","properties","clientKey","Error","clientKeyPayload","clientKeyIncludesResource","order_id","undefined","booking_id","cars_booking_id","issueType","console","warn","context","supportChannels","chat","showMinimiseButton","onMinimise","handleMessage","event","nativeEvent","data","parsedData","JSON","parse","type","userId","resourceId","handleShouldStartLoadWithRequest","request","OS","navigationType","openURL","catch","visible","onRequestClose","animationType","children","style","styles","container","injectedJavaScriptObject","source","uri","onMessage","onShouldStartLoadWithRequest","cacheEnabled","injectedJavaScript","stringify","cacheMode","create","height","width","paddingHorizontal","paddingTop","paddingBottom"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,OAAO,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AACzE,SAASC,OAAO,QAAQ,sBAAsB;AAE9C,SAASC,qBAAqB,QAAQ,gCAA6B;AACnE,SAASC,mBAAmB,QAAQ,8BAA2B;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAIhE,MAAM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MAAMV,MAAM,GAAG3D,UAAU,CAACsE,MAAM,CAAC;EAC/BV,SAAS,EAAE;IACTW,MAAM,EAAE,MAAM;IACdC,KAAK,EAAE,MAAM;IACbC,iBAAiB,EAAE,EAAE;IACrBC,UAAU,EAAE,EAAE;IACdC,aAAa,EAAE;EACjB;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,KAAK,oBAAoB,IAAI,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AAInG,MAAM,MAAM,oBAAoB,GAAG,4BAA4B,CAAC;AA2BhE,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAkK1D,CAAC"}
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import {
|
|
3
|
-
Keyboard,
|
|
4
|
-
Linking,
|
|
5
|
-
Modal,
|
|
6
|
-
Platform,
|
|
7
|
-
StyleSheet,
|
|
8
|
-
View,
|
|
9
|
-
} from 'react-native';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Linking, Modal, Platform, StyleSheet, View } from 'react-native';
|
|
10
3
|
import { WebView } from 'react-native-webview';
|
|
11
4
|
import { type DuffelAssistantProps as DuffelAssistantPropsImported } from './DuffelAssistantProps';
|
|
12
5
|
import { hasJsonWebTokenFormat } from './lib/hasJsonWebTokenFormat';
|
|
@@ -45,37 +38,6 @@ export const DuffelAssistant: React.FC<DuffelAssistantProps> = ({
|
|
|
45
38
|
onNewMessage,
|
|
46
39
|
...properties
|
|
47
40
|
}) => {
|
|
48
|
-
const [androidKeyboardHeight, setAndroidKeyboardHeight] = useState(0);
|
|
49
|
-
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
if (Platform.OS !== 'android') {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (!isOpen) {
|
|
56
|
-
setAndroidKeyboardHeight(0);
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const keyboardDidShowSubscription = Keyboard.addListener(
|
|
61
|
-
'keyboardDidShow',
|
|
62
|
-
(event) => {
|
|
63
|
-
setAndroidKeyboardHeight(event.endCoordinates?.height ?? 0);
|
|
64
|
-
}
|
|
65
|
-
);
|
|
66
|
-
const keyboardDidHideSubscription = Keyboard.addListener(
|
|
67
|
-
'keyboardDidHide',
|
|
68
|
-
() => {
|
|
69
|
-
setAndroidKeyboardHeight(0);
|
|
70
|
-
}
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
return () => {
|
|
74
|
-
keyboardDidShowSubscription.remove();
|
|
75
|
-
keyboardDidHideSubscription.remove();
|
|
76
|
-
};
|
|
77
|
-
}, [isOpen]);
|
|
78
|
-
|
|
79
41
|
if (!hasJsonWebTokenFormat(properties.clientKey)) {
|
|
80
42
|
throw new Error('Duffel Assistant client key format must be a valid JWT.');
|
|
81
43
|
}
|
|
@@ -185,40 +147,6 @@ export const DuffelAssistant: React.FC<DuffelAssistantProps> = ({
|
|
|
185
147
|
return false;
|
|
186
148
|
};
|
|
187
149
|
|
|
188
|
-
if (Platform.OS === 'android') {
|
|
189
|
-
return (
|
|
190
|
-
<Modal
|
|
191
|
-
visible={isOpen}
|
|
192
|
-
onRequestClose={() => onClose()}
|
|
193
|
-
animationType="slide"
|
|
194
|
-
>
|
|
195
|
-
<View
|
|
196
|
-
style={[
|
|
197
|
-
styles.androidContainer,
|
|
198
|
-
{ paddingBottom: 15 + androidKeyboardHeight },
|
|
199
|
-
]}
|
|
200
|
-
>
|
|
201
|
-
<WebView
|
|
202
|
-
// Required for Android
|
|
203
|
-
injectedJavaScript={`
|
|
204
|
-
postMessage(
|
|
205
|
-
{
|
|
206
|
-
type: "duffel-assistant-open",
|
|
207
|
-
properties: ${JSON.stringify(properties)},
|
|
208
|
-
},
|
|
209
|
-
"*",
|
|
210
|
-
);
|
|
211
|
-
true;`}
|
|
212
|
-
source={{ uri: assistantIframeUrl }}
|
|
213
|
-
onMessage={handleMessage}
|
|
214
|
-
onShouldStartLoadWithRequest={handleShouldStartLoadWithRequest}
|
|
215
|
-
style={styles.webView}
|
|
216
|
-
/>
|
|
217
|
-
</View>
|
|
218
|
-
</Modal>
|
|
219
|
-
);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
150
|
return (
|
|
223
151
|
<Modal
|
|
224
152
|
visible={isOpen}
|
|
@@ -226,17 +154,43 @@ export const DuffelAssistant: React.FC<DuffelAssistantProps> = ({
|
|
|
226
154
|
animationType="slide"
|
|
227
155
|
>
|
|
228
156
|
<View style={styles.container}>
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
157
|
+
{Platform.OS === 'ios' ? (
|
|
158
|
+
<WebView
|
|
159
|
+
injectedJavaScriptObject={properties}
|
|
160
|
+
// When you are running this in development iOS doesn't allow request from hosts with invalid https certificates.
|
|
161
|
+
// If you try ngrok with the local esbuild server it will fail because ngrok requests in https and the dev server rejects http requests.
|
|
162
|
+
// Easiest solution is to use the production URL with test data.
|
|
163
|
+
// If that's not possible, you can also upload the assistant built assets to a different folder in assets.duffel and work with that.
|
|
164
|
+
source={{ uri: assistantIframeUrl }}
|
|
165
|
+
onMessage={handleMessage}
|
|
166
|
+
onShouldStartLoadWithRequest={handleShouldStartLoadWithRequest}
|
|
167
|
+
// Always fetch the latest assistant bundle. The iframe.html shell
|
|
168
|
+
// references `./iframe-app.js` by a stable path, so without this
|
|
169
|
+
// the system WebView can serve a stale bundle for a long time.
|
|
170
|
+
cacheEnabled={false}
|
|
171
|
+
/>
|
|
172
|
+
) : (
|
|
173
|
+
<WebView
|
|
174
|
+
// Required for Android
|
|
175
|
+
injectedJavaScript={`
|
|
176
|
+
postMessage(
|
|
177
|
+
{
|
|
178
|
+
type: "duffel-assistant-open",
|
|
179
|
+
properties: ${JSON.stringify(properties)},
|
|
180
|
+
},
|
|
181
|
+
"*",
|
|
182
|
+
);
|
|
183
|
+
true;`}
|
|
184
|
+
source={{ uri: assistantIframeUrl }}
|
|
185
|
+
onMessage={handleMessage}
|
|
186
|
+
onShouldStartLoadWithRequest={handleShouldStartLoadWithRequest}
|
|
187
|
+
// Always fetch the latest assistant bundle. The iframe.html shell
|
|
188
|
+
// references `./iframe-app.js` by a stable path, so without this
|
|
189
|
+
// the system WebView can serve a stale bundle for a long time.
|
|
190
|
+
cacheEnabled={false}
|
|
191
|
+
cacheMode="LOAD_NO_CACHE"
|
|
192
|
+
/>
|
|
193
|
+
)}
|
|
240
194
|
</View>
|
|
241
195
|
</Modal>
|
|
242
196
|
);
|
|
@@ -244,19 +198,10 @@ export const DuffelAssistant: React.FC<DuffelAssistantProps> = ({
|
|
|
244
198
|
|
|
245
199
|
const styles = StyleSheet.create({
|
|
246
200
|
container: {
|
|
247
|
-
|
|
201
|
+
height: '100%',
|
|
248
202
|
width: '100%',
|
|
249
203
|
paddingHorizontal: 12,
|
|
250
204
|
paddingTop: 50,
|
|
251
205
|
paddingBottom: 30,
|
|
252
206
|
},
|
|
253
|
-
androidContainer: {
|
|
254
|
-
flex: 1,
|
|
255
|
-
width: '100%',
|
|
256
|
-
paddingTop: 45,
|
|
257
|
-
paddingBottom: 15,
|
|
258
|
-
},
|
|
259
|
-
webView: {
|
|
260
|
-
flex: 1,
|
|
261
|
-
},
|
|
262
207
|
});
|