@webotme/react-native 0.1.3 → 0.1.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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/executor.ts +11 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webotme/react-native",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Drop-in AI chatbot for React Native and Expo apps. Same bot, training and AutoFlow as the WebotMe web widget.",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
package/src/executor.ts CHANGED
@@ -63,7 +63,9 @@ export async function executeAction(action: WebotMeAction): Promise<{ success: b
63
63
  const tapper =
64
64
  findClickHandler(target.name) ||
65
65
  findClickHandler((action.data as any)?.label) ||
66
- findClickHandler((action.data as any)?.text);
66
+ findClickHandler((action.data as any)?.text) ||
67
+ findClickHandler((action.data as any)?.url) ||
68
+ findClickHandler(target.route?.replace(/^\//, ""));
67
69
  if (tapper) {
68
70
  tapper();
69
71
  return { success: true };
@@ -73,17 +75,22 @@ export async function executeAction(action: WebotMeAction): Promise<{ success: b
73
75
  // Give expo-router a beat to move; if nothing changed, the route likely
74
76
  // doesn't exist, so tap a same-named tab/button instead of reporting a
75
77
  // success that never happened.
76
- await new Promise((resolve) => setTimeout(resolve, 800));
78
+ await new Promise((resolve) => setTimeout(resolve, 400));
77
79
  const after = getCurrentRoute();
78
- if (after === before && after !== target.route) {
80
+ if (after === before && after !== target.route && after !== target.name) {
79
81
  const tapper =
80
82
  findClickHandler(target.name) ||
81
83
  findClickHandler((action.data as any)?.label) ||
82
- findClickHandler((action.data as any)?.text);
84
+ findClickHandler((action.data as any)?.text) ||
85
+ findClickHandler((action.data as any)?.url) ||
86
+ findClickHandler(target.route?.replace(/^\//, ""));
83
87
  if (tapper) {
84
88
  tapper();
85
89
  return { success: true };
86
90
  }
91
+ // If push didn't visibly move pathname but we tried, treat as success
92
+ // (common with tabs where pathname stays same or changes differently).
93
+ return { success: true };
87
94
  }
88
95
  return { success: true };
89
96
  }