@shotik/react-native 0.1.0 → 0.2.0

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 (46) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/LICENSE +26 -0
  3. package/README.md +39 -3
  4. package/README.ru.md +40 -3
  5. package/dist/analytics/core.d.ts +96 -11
  6. package/dist/analytics/core.js +295 -22
  7. package/dist/analytics/privacy.d.ts +4 -0
  8. package/dist/analytics/privacy.js +46 -0
  9. package/dist/analytics/replay.d.ts +41 -0
  10. package/dist/analytics/replay.js +192 -0
  11. package/dist/analytics/rn.d.ts +52 -2
  12. package/dist/analytics/rn.js +669 -62
  13. package/dist/analytics/wire.d.ts +54 -2
  14. package/dist/analytics/wire.js +44 -4
  15. package/dist/client.d.ts +94 -1
  16. package/dist/client.js +254 -17
  17. package/dist/flow.d.ts +48 -0
  18. package/dist/flow.js +56 -0
  19. package/dist/index.d.ts +4 -4
  20. package/dist/index.js +2 -2
  21. package/dist/parts.d.ts +42 -1
  22. package/dist/parts.js +72 -14
  23. package/dist/react.d.ts +24 -3
  24. package/dist/react.js +42 -15
  25. package/dist/sheet.d.ts +2 -1
  26. package/dist/sheet.js +207 -16
  27. package/dist/support.js +2 -2
  28. package/dist/theme.d.ts +43 -0
  29. package/dist/theme.js +90 -4
  30. package/package.json +15 -2
  31. package/recipe.json +1 -1
  32. package/src/analytics/README.md +10 -6
  33. package/src/analytics/core.ts +314 -25
  34. package/src/analytics/privacy.ts +50 -0
  35. package/src/analytics/recipe.json +1 -1
  36. package/src/analytics/replay.ts +190 -0
  37. package/src/analytics/rn.tsx +620 -63
  38. package/src/analytics/wire.ts +99 -8
  39. package/src/client.ts +344 -19
  40. package/src/flow.ts +100 -0
  41. package/src/index.ts +4 -4
  42. package/src/parts.tsx +102 -14
  43. package/src/react.tsx +57 -16
  44. package/src/sheet.tsx +423 -20
  45. package/src/support.ts +2 -2
  46. package/src/theme.ts +90 -4
package/dist/sheet.js CHANGED
@@ -1,12 +1,16 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  // The chat sheet: a bottom sheet (drag handle, spring open and close, keyboard-avoiding) holding the conversation list
3
- // or one thread with receipts, typing, quick replies, the handoff to a person, attachments and the offline queue.
3
+ // or one thread with receipts, typing, quick replies, action buttons, the handoff to a person, attachments, the offline
4
+ // queue, the AI consent line and the rating; plus the Subscription screens with the honest cancel and refund (§3.10).
4
5
  // Every visual and motion decision is logged in REFS.md.
5
6
  import { memo, useEffect, useMemo, useRef, useState } from 'react';
6
- import { AccessibilityInfo, ActionSheetIOS, Animated, Dimensions, FlatList, Image, Keyboard, LayoutAnimation, Modal, PanResponder, Platform, Pressable, StatusBar, StyleSheet, TextInput, View, useWindowDimensions } from 'react-native';
7
- import { attachmentsOf, receiptOf } from './client';
8
- import { ArrowUp, Avatar, Chevron, Clock, Cross, Dots, Plus, Spark, T, attachPeers, captureScreen, font, motion, pickPhoto, useReduceMotion } from './parts';
7
+ import { AccessibilityInfo, ActionSheetIOS, Animated, Dimensions, FlatList, Image, Keyboard, LayoutAnimation, Modal, PanResponder, Platform, Pressable, ScrollView, StatusBar, StyleSheet, TextInput, View, useWindowDimensions } from 'react-native';
8
+ import { actionsOf, attachmentsOf, receiptOf } from './client';
9
+ import { cancelReasons, canCancel, csatPrompt, runState, startFlow, stepFlow, storeName, subscriptionSummary } from './flow';
10
+ import { Alert, ArrowUp, Avatar, Chevron, Clock, Cross, Dots, Forward, LoadingBar, Plus, Reveal, Spark, T, Thumb, Tick, Trash, attachPeers, captureScreen, font, motion, pickPhoto, useReduceMotion } from './parts';
9
11
  import { fill } from './theme';
12
+ // A host preview may hand in an older api without canRun; nothing then claims it can run.
13
+ const can = (s, kind, value) => s.canRun?.(kind, value) ?? false;
10
14
  function insets() {
11
15
  try {
12
16
  const m = require('react-native-safe-area-context')?.initialWindowMetrics?.insets;
@@ -16,11 +20,12 @@ function insets() {
16
20
  catch { }
17
21
  return Platform.OS === 'ios' ? { top: 50, bottom: 20 } : { top: StatusBar.currentHeight ?? 24, bottom: 0 };
18
22
  }
23
+ const day = (at) => new Date(at).toLocaleDateString([], { month: 'short', day: 'numeric', year: 'numeric' });
19
24
  const clock = (at) => {
20
25
  const d = new Date(at);
21
26
  return new Date().toDateString() === d.toDateString() ? d.toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' }) : d.toLocaleDateString([], { month: 'short', day: 'numeric' });
22
27
  };
23
- export function Sheet({ s, c, t, title, team, quickReplies, presentation = 'modal' }) {
28
+ export function Sheet({ s, c, t, title, team, quickReplies, presentation = 'modal', appName }) {
24
29
  const inline = presentation === 'inline';
25
30
  const { height } = useWindowDimensions();
26
31
  const inset = useMemo(insets, []);
@@ -32,6 +37,60 @@ export function Sheet({ s, c, t, title, team, quickReplies, presentation = 'moda
32
37
  const [composing, setComposing] = useState(false);
33
38
  const [draft, setDraft] = useState('');
34
39
  const [pending, setPending] = useState([]);
40
+ const [flow, setFlow] = useState(startFlow);
41
+ const [runs, setRuns] = useState({});
42
+ const [erase, setErase] = useState(null);
43
+ const run = (key, fn) => {
44
+ if (runs[key] === 'pending')
45
+ return;
46
+ setRuns((p) => ({ ...p, [key]: 'pending' }));
47
+ fn()
48
+ .catch(() => 'failed')
49
+ .then((r) => setRuns((p) => {
50
+ const next = { ...p };
51
+ const state = runState(r);
52
+ if (state)
53
+ next[key] = state;
54
+ else
55
+ delete next[key];
56
+ return next;
57
+ }));
58
+ };
59
+ const store = (kind, label) => run('sub.' + kind, () => s.runAction({ id: 'widget.' + kind, kind, label }));
60
+ const go = (e) => {
61
+ const step = stepFlow(flow, e, s.widget?.offers ?? {});
62
+ for (const [kind, data] of step.track)
63
+ s.track(kind, data);
64
+ setFlow(step.flow);
65
+ if (step.run === 'offer' && flow.reason && flow.offer) {
66
+ s.askForOffer(flow.reason);
67
+ setDraft(fill(t.offerDraft, { label: flow.offer.label }));
68
+ setComposing(true);
69
+ }
70
+ else if (step.run === 'manage_subscription')
71
+ store('manage_subscription', t.manage);
72
+ else if (step.run === 'request_refund')
73
+ store('request_refund', t.refund);
74
+ };
75
+ const chat = () => {
76
+ setFlow(startFlow);
77
+ s.select(null);
78
+ setComposing(true);
79
+ };
80
+ // Delete my data (§3.13): the client wipes the device first, so everything this sheet holds goes with it.
81
+ const deleteAll = () => {
82
+ setErase('working');
83
+ Promise.resolve(s.deleteMyData?.() ?? 'done')
84
+ .catch(() => 'pending')
85
+ .then((r) => {
86
+ setDraft('');
87
+ setPending(() => []);
88
+ setComposing(false);
89
+ setFlow(startFlow);
90
+ setRuns({});
91
+ setErase(r);
92
+ });
93
+ };
35
94
  const animate = (open, done) => {
36
95
  const slide = reduce
37
96
  ? Animated.timing(y, { toValue: open ? 0 : H, duration: 0, useNativeDriver: true })
@@ -48,6 +107,8 @@ export function Sheet({ s, c, t, title, team, quickReplies, presentation = 'moda
48
107
  }
49
108
  else if (shown) {
50
109
  Keyboard.dismiss();
110
+ setFlow(startFlow);
111
+ setErase((e) => (e === 'working' ? e : null));
51
112
  animate(false, () => setShown(false));
52
113
  }
53
114
  }, [s.visible]);
@@ -73,26 +134,27 @@ export function Sheet({ s, c, t, title, team, quickReplies, presentation = 'moda
73
134
  setComposing(false);
74
135
  s.select(null);
75
136
  };
76
- const queued = Object.values(s.messages).reduce((n, l) => n + l.filter((m) => m.pending === 'sending').length, 0);
137
+ const queued = Object.values(s.messages).reduce((n, l) => n + l.filter((m) => m.pending && m.pending !== 'failed').length, 0);
77
138
  const status = s.status === 'live' ? { color: c.ok, text: t.online }
78
139
  : s.status === 'offline' ? { color: c.danger, text: queued ? t.offline + ' · ' + fill(t.queuedN, { n: queued }) : t.offline }
79
140
  : s.status === 'error' ? { color: c.danger, text: t.error + ' · ' + t.retry }
80
141
  : { color: c.faint, text: t.connecting };
81
142
  const bottom = inline ? 0 : inset.bottom;
82
- const body = (_jsxs(_Fragment, { children: [_jsxs(View, { ...(inline ? {} : pan.panHandlers), children: [_jsx(View, { style: [st.grabber, { backgroundColor: c.line }] }), _jsxs(View, { style: st.header, children: [inThread && s.conversations.length > 0 ? (_jsx(Pressable, { onPress: back, hitSlop: 10, accessibilityRole: "button", accessibilityLabel: t.back, style: st.back, children: _jsx(Chevron, { color: c.text }) })) : null, _jsx(Avatar, { c: c, label: title, size: 32 }), _jsxs(View, { style: st.fill, children: [_jsx(T, { c: c, bold: true, style: st.title, numberOfLines: 1, accessibilityRole: "header", children: title }), _jsxs(Pressable, { disabled: s.status !== 'error', onPress: () => s.identify(), style: st.statusRow, accessibilityRole: s.status === 'error' ? 'button' : undefined, accessibilityLiveRegion: "polite", children: [_jsx(View, { style: [st.dot, { backgroundColor: status.color }] }), _jsx(T, { c: c, style: [st.status, { color: c.sub }], numberOfLines: 1, children: status.text })] })] }), _jsx(Pressable, { onPress: s.close, hitSlop: 10, accessibilityRole: "button", accessibilityLabel: t.close, style: [st.close, { backgroundColor: c.raised }], children: _jsx(Cross, { color: c.sub, size: 9 }) })] })] }), _jsx(View, { style: [st.hair, { backgroundColor: c.line }] }), inThread ? (_jsx(Thread, { s: s, c: c, t: t, team: team, conversation: active, quickReplies: quickReplies, reduce: reduce, inset: bottom, draft: draft, setDraft: setDraft, pending: pending, setPending: setPending, onScreenshot: screenshot, onSent: () => setComposing(false) })) : (_jsx(List, { s: s, c: c, t: t, inset: bottom, onNew: () => setComposing(true) }))] }));
143
+ const home = (_jsx(HomeRows, { s: s, c: c, t: t, reduce: reduce, rate: runs['sub.write_review'], appName: appName, onOpen: () => go({ type: 'open' }), onErase: () => setErase('confirm'), onRate: () => store('write_review', appName ? fill(t.rateApp, { app: appName }) : t.rateThisApp) }));
144
+ const body = (_jsxs(_Fragment, { children: [_jsxs(View, { ...(inline ? {} : pan.panHandlers), children: [_jsx(View, { style: [st.grabber, { backgroundColor: c.line }] }), _jsxs(View, { style: st.header, children: [erase === 'confirm' || (!erase && (flow.screen || (inThread && s.conversations.length > 0))) ? (_jsx(Pressable, { onPress: erase ? () => setErase(null) : flow.screen ? () => go({ type: 'back' }) : back, hitSlop: 10, accessibilityRole: "button", accessibilityLabel: t.back, style: st.back, children: _jsx(Chevron, { color: c.text }) })) : null, _jsx(Avatar, { c: c, label: title, size: 32 }), _jsxs(View, { style: st.fill, children: [_jsx(T, { c: c, bold: true, style: st.title, numberOfLines: 1, accessibilityRole: "header", children: title }), _jsxs(Pressable, { disabled: s.status !== 'error', onPress: () => s.identify(), style: st.statusRow, accessibilityRole: s.status === 'error' ? 'button' : undefined, accessibilityLiveRegion: "polite", children: [_jsx(View, { style: [st.dot, { backgroundColor: status.color }] }), _jsx(T, { c: c, style: [st.status, { color: c.sub }], numberOfLines: 1, children: status.text })] })] }), _jsx(Pressable, { onPress: s.close, hitSlop: 10, accessibilityRole: "button", accessibilityLabel: t.close, style: [st.close, { backgroundColor: c.raised }], children: _jsx(Cross, { color: c.sub, size: 9 }) })] })] }), _jsx(View, { style: [st.hair, { backgroundColor: c.line }] }), erase ? (_jsx(Erase, { c: c, t: t, reduce: reduce, phase: erase, inset: bottom, onDelete: deleteAll, onCancel: () => setErase(null), onClose: s.close })) : flow.screen ? (_jsx(Subscription, { s: s, c: c, t: t, flow: flow, go: go, runs: runs, store: store, reduce: reduce, inset: bottom, onChat: chat })) : inThread ? (_jsx(Thread, { s: s, c: c, t: t, team: team, conversation: active, quickReplies: quickReplies, reduce: reduce, inset: bottom, draft: draft, setDraft: setDraft, pending: pending, setPending: setPending, onScreenshot: screenshot, onSent: () => setComposing(false), runs: runs, run: run, home: home })) : (_jsx(List, { s: s, c: c, t: t, inset: bottom, onNew: () => setComposing(true), home: home }))] }));
83
145
  if (inline)
84
146
  return _jsx(View, { style: [st.fill, { backgroundColor: c.bg }], children: body });
85
147
  return (_jsxs(Modal, { visible: shown, transparent: true, animationType: "none", statusBarTranslucent: true, onRequestClose: s.close, children: [_jsx(Animated.View, { style: [StyleSheet.absoluteFill, { backgroundColor: c.backdrop, opacity: fade }], children: _jsx(Pressable, { style: st.fill, onPress: s.close, accessibilityLabel: t.close }) }), _jsx(Animated.View, { accessibilityViewIsModal: true, style: [st.sheet, { height: H, backgroundColor: c.bg, borderTopStartRadius: c.radius + 10, borderTopEndRadius: c.radius + 10, opacity: reduce ? fade : 1, transform: [{ translateY: y }] }], children: body })] }));
86
148
  }
87
- function List({ s, c, t, inset, onNew }) {
88
- return (_jsxs(View, { style: st.fill, children: [_jsx(FlatList, { data: s.conversations, keyExtractor: (x) => x.id, contentContainerStyle: st.listPad, renderItem: ({ item }) => _jsx(ConvRow, { c: c, t: t, conv: item, unread: !!s.unreadBy[item.id], onPress: () => s.select(item.id) }) }), _jsx(View, { style: [st.footer, { paddingBottom: 12 + inset }], children: _jsxs(Pressable, { onPress: onNew, accessibilityRole: "button", style: ({ pressed }) => [st.cta, { backgroundColor: c.accent, opacity: pressed ? 0.85 : 1 }], children: [_jsx(Plus, { color: c.onAccent }), _jsx(T, { c: c, bold: true, style: [st.ctaText, { color: c.onAccent }], children: t.newMessage })] }) })] }));
149
+ function List({ s, c, t, inset, onNew, home }) {
150
+ return (_jsxs(View, { style: st.fill, children: [_jsx(FlatList, { data: s.conversations, ListHeaderComponent: _jsx(_Fragment, { children: home }), keyExtractor: (x) => x.id, contentContainerStyle: st.listPad, renderItem: ({ item }) => _jsx(ConvRow, { c: c, t: t, conv: item, unread: !!s.unreadBy[item.id], onPress: () => s.select(item.id) }) }), _jsx(View, { style: [st.footer, { paddingBottom: 12 + inset }], children: _jsxs(Pressable, { onPress: onNew, accessibilityRole: "button", style: ({ pressed }) => [st.cta, { backgroundColor: c.accent, opacity: pressed ? 0.85 : 1 }], children: [_jsx(Plus, { color: c.onAccent }), _jsx(T, { c: c, bold: true, style: [st.ctaText, { color: c.onAccent }], children: t.newMessage })] }) })] }));
89
151
  }
90
152
  const ConvRow = memo(function ConvRow({ c, t, conv, unread, onPress }) {
91
153
  const pill = conv.status === 'needs_human' ? { text: t.person, color: c.warn } : conv.status === 'resolved' || conv.status === 'closed' ? { text: t.resolved, color: c.ok } : null;
92
154
  const who = conv.lastAuthor === 'user' ? t.you + ': ' : conv.lastAuthor === 'ai' ? t.ai + ': ' : '';
93
155
  return (_jsxs(Pressable, { onPress: onPress, accessibilityRole: "button", style: ({ pressed }) => [st.row, pressed && { backgroundColor: c.raised }], children: [_jsx(Avatar, { c: c, label: conv.subject ?? '?', size: 36, ai: conv.lastAuthor === 'ai' }), _jsxs(View, { style: st.fill, children: [_jsxs(View, { style: st.rowTop, children: [_jsx(T, { c: c, bold: unread, style: st.rowTitle, numberOfLines: 1, children: conv.subject ?? t.newMessage }), _jsx(T, { c: c, style: [st.meta, { color: c.faint }], children: clock(conv.lastMessageAt) })] }), _jsxs(View, { style: st.rowTop, children: [_jsx(T, { c: c, style: [st.preview, { color: unread ? c.text : c.sub }], numberOfLines: 1, children: who + (conv.lastPreview ?? '') }), pill ? (_jsx(View, { style: [st.pill, { backgroundColor: pill.color + '22' }], children: _jsx(T, { c: c, bold: true, style: [st.pillText, { color: pill.color }], children: pill.text }) })) : null, unread ? _jsx(View, { style: [st.unread, { backgroundColor: c.accent }] }) : null] })] })] }));
94
156
  });
95
- function Thread({ s, c, t, team, conversation, quickReplies, reduce, inset, draft, setDraft, pending, setPending, onScreenshot, onSent }) {
157
+ function Thread({ s, c, t, team, conversation, quickReplies, reduce, inset, draft, setDraft, pending, setPending, onScreenshot, onSent, runs, run, home }) {
96
158
  const id = s.activeConversationId;
97
159
  const messages = (id && s.messages[id]) || [];
98
160
  const typing = id ? s.typing[id] : undefined;
@@ -100,6 +162,7 @@ function Thread({ s, c, t, team, conversation, quickReplies, reduce, inset, draf
100
162
  const handed = conversation?.status === 'needs_human';
101
163
  const closed = conversation?.status === 'resolved' || conversation?.status === 'closed';
102
164
  const since = useRef(Date.now()).current;
165
+ const [rated, setRated] = useState(null);
103
166
  const rows = useMemo(() => {
104
167
  const out = [];
105
168
  const lastMine = messages.reduce((at, m, i) => (m.author === 'user' ? i : at), -1);
@@ -117,8 +180,11 @@ function Thread({ s, c, t, team, conversation, quickReplies, reduce, inset, draf
117
180
  const q = Array.isArray(last.meta?.['quickReplies']) ? last.meta['quickReplies'] : [];
118
181
  out.push({ k: 'chips' + last.id, kind: 'chips', items: q.slice(0, 3), talk: true });
119
182
  }
183
+ const csat = csatPrompt(conversation, !!id && rated === id);
184
+ if (csat && id)
185
+ out.push({ k: 'csat' + id, kind: 'csat', phase: csat });
120
186
  return out.reverse();
121
- }, [messages, typing, conversation, offline, handed, closed, t, team]);
187
+ }, [messages, typing, conversation, offline, handed, closed, t, team, rated, id]);
122
188
  const last = messages[messages.length - 1];
123
189
  useEffect(() => {
124
190
  if (last && last.author !== 'user' && last.createdAt > since)
@@ -134,13 +200,18 @@ function Thread({ s, c, t, team, conversation, quickReplies, reduce, inset, draf
134
200
  };
135
201
  const kb = useKeyboardInset();
136
202
  const empty = !messages.length;
137
- return (_jsxs(View, { style: [st.fill, { paddingBottom: kb }], children: [empty ? (_jsxs(View, { style: st.empty, children: [_jsx(Avatar, { c: c, label: team, size: 44 }), _jsx(T, { c: c, bold: true, style: st.greet, accessibilityRole: "header", children: t.greeting }), _jsx(Chips, { c: c, items: quickReplies, reduce: reduce, onPick: (q) => send(q), center: true })] })) : (_jsx(FlatList, { inverted: true, data: rows, keyExtractor: (r) => r.k, contentContainerStyle: st.thread, keyboardShouldPersistTaps: "handled", keyboardDismissMode: "interactive", initialNumToRender: 14, windowSize: 9, removeClippedSubviews: Platform.OS === 'android', renderItem: ({ item }) => item.kind === 'msg' ? (_jsx(Bubble, { r: item, c: c, t: t, fresh: item.m.createdAt > since - 1000, reduce: reduce, url: s.url, onRetry: s.retry })) : item.kind === 'typing' ? (_jsxs(View, { style: [st.theirs, st.typing], accessible: true, accessibilityLabel: fill(t.typing, { who: item.who }), children: [_jsx(T, { c: c, style: [st.label, { color: c.sub }], children: item.who }), _jsx(View, { style: [st.bubble, { backgroundColor: c.raised, borderRadius: c.radius }], children: _jsx(Dots, { color: c.sub, reduce: reduce }) })] })) : (_jsx(Chips, { c: c, items: item.items, reduce: reduce, onPick: (q) => send(q), talk: t.talk, onTalk: () => id && s.handoff(id) })) })), handed ? (_jsxs(View, { style: [st.strip, { borderColor: c.line }], accessibilityLiveRegion: "polite", children: [_jsx(View, { style: [st.stripBar, { backgroundColor: c.warn }] }), _jsx(T, { c: c, style: [st.stripText, { color: c.sub }], children: t.handedOff })] })) : null, _jsx(Composer, { c: c, t: t, inset: inset, draft: draft, setDraft: setDraft, pending: pending, setPending: setPending, onScreenshot: onScreenshot, onSend: () => {
203
+ return (_jsxs(View, { style: [st.fill, { paddingBottom: kb }], children: [empty ? (_jsxs(View, { style: st.empty, children: [_jsx(Avatar, { c: c, label: team, size: 44 }), _jsx(T, { c: c, bold: true, style: st.greet, accessibilityRole: "header", children: t.greeting }), _jsx(Chips, { c: c, items: quickReplies, reduce: reduce, onPick: (q) => send(q), center: true }), _jsx(View, { style: st.emptyHome, children: home })] })) : (_jsx(FlatList, { inverted: true, data: rows, keyExtractor: (r) => r.k, contentContainerStyle: st.thread, keyboardShouldPersistTaps: "handled", keyboardDismissMode: "interactive", initialNumToRender: 14, windowSize: 9, removeClippedSubviews: Platform.OS === 'android', renderItem: ({ item }) => item.kind === 'msg' ? (_jsx(Bubble, { r: item, c: c, t: t, fresh: item.m.createdAt > since - 1000, reduce: reduce, url: s.url, onRetry: s.retry, runs: runs, onRun: (key, a) => run(key, () => s.runAction(a, item.m.conversationId)) })) : item.kind === 'csat' ? (_jsx(Csat, { c: c, t: t, reduce: reduce, phase: item.phase, onRate: (score, comment) => {
204
+ if (!id)
205
+ return;
206
+ s.rate(id, score, comment);
207
+ setRated(id);
208
+ } })) : item.kind === 'typing' ? (_jsxs(View, { style: [st.theirs, st.typing], accessible: true, accessibilityLabel: fill(t.typing, { who: item.who }), children: [_jsx(T, { c: c, style: [st.label, { color: c.sub }], children: item.who }), _jsx(View, { style: [st.bubble, { backgroundColor: c.raised, borderRadius: c.radius }], children: _jsx(Dots, { color: c.sub, reduce: reduce }) })] })) : (_jsx(Chips, { c: c, items: item.items, reduce: reduce, onPick: (q) => send(q), talk: t.talk, onTalk: () => id && s.handoff(id) })) })), handed ? (_jsxs(View, { style: [st.strip, { borderColor: c.line }], accessibilityLiveRegion: "polite", children: [_jsx(View, { style: [st.stripBar, { backgroundColor: c.warn }] }), _jsx(T, { c: c, style: [st.stripText, { color: c.sub }], children: t.handedOff })] })) : null, s.aiConsent === null ? (_jsxs(Reveal, { reduce: reduce, style: [st.consent, { backgroundColor: c.raised, borderRadius: c.radius - 4 }], children: [_jsx(T, { c: c, style: [st.consentText, { color: c.sub }], children: t.consent }), _jsx(View, { style: st.consentRow, children: [{ label: t.consentPerson, allowed: false }, { label: t.consentAllow, allowed: true }].map((o) => (_jsx(Pressable, { onPress: () => s.setAiConsent(o.allowed), hitSlop: 6, accessibilityRole: "button", accessibilityLabel: o.label, style: ({ pressed }) => [st.consentBtn, { borderColor: c.line, backgroundColor: pressed ? c.raised : c.bg }], children: _jsx(T, { c: c, bold: true, style: st.consentBtnText, children: o.label }) }, o.label))) })] })) : null, _jsx(Composer, { c: c, t: t, inset: inset, draft: draft, setDraft: setDraft, pending: pending, setPending: setPending, onScreenshot: onScreenshot, onSend: () => {
138
209
  send(draft, pending);
139
210
  setDraft('');
140
211
  setPending(() => []);
141
212
  } })] }));
142
213
  }
143
- const Bubble = memo(function Bubble({ r, c, t, fresh, reduce, url, onRetry }) {
214
+ const Bubble = memo(function Bubble({ r, c, t, fresh, reduce, url, onRetry, runs, onRun }) {
144
215
  const { m } = r;
145
216
  const v = useRef(new Animated.Value(fresh && !reduce ? 0 : 1)).current;
146
217
  useEffect(() => {
@@ -154,11 +225,17 @@ const Bubble = memo(function Bubble({ r, c, t, fresh, reduce, url, onRetry }) {
154
225
  const rc = r.receipt;
155
226
  const receiptText = rc ? (rc === 'failed' ? t.failed : t[rc] + (rc === 'seen' || rc === 'delivered' || rc === 'sent' ? ' · ' + clock(m.createdAt) : '')) : null;
156
227
  const anim = { opacity: v, transform: [{ translateY: v.interpolate({ inputRange: [0, 1], outputRange: [4, 0] }) }] };
157
- return (_jsxs(Animated.View, { style: [mine ? st.mine : st.theirs, { marginTop: r.gap }, anim], accessible: true, accessibilityLabel: (mine ? t.you : r.label ?? '') + ': ' + (m.body || t.photo) + (receiptText ? '. ' + receiptText : ''), children: [r.label ? (_jsxs(View, { style: st.labelRow, children: [m.author === 'ai' ? _jsx(Spark, { color: c.accent, size: 6 }) : null, _jsx(T, { c: c, style: [st.label, { color: c.sub }], children: r.label })] })) : null, atts.map((a, i) => {
228
+ const acts = mine ? [] : actionsOf(m);
229
+ const label = (mine ? t.you : r.label ?? '') + ': ' + (m.body || t.photo) + (receiptText ? '. ' + receiptText : '');
230
+ return (_jsxs(Animated.View, { style: [mine ? st.mine : st.theirs, { marginTop: r.gap }, anim], accessible: !acts.length, accessibilityLabel: acts.length ? undefined : label, children: [r.label ? (_jsxs(View, { style: st.labelRow, children: [m.author === 'ai' ? _jsx(Spark, { color: c.accent, size: 6 }) : null, _jsx(T, { c: c, style: [st.label, { color: c.sub }], children: r.label })] })) : null, atts.map((a, i) => {
158
231
  const w = 200;
159
232
  const h = a.width && a.height ? Math.min(260, Math.round((w * a.height) / a.width)) : 150;
160
233
  return _jsx(Image, { source: { uri: a.uri ?? url(a.path ?? '') }, style: [st.image, { width: w, height: h, borderRadius: c.radius - 4, backgroundColor: c.raised, opacity: m.pending ? 0.6 : 1 }], accessibilityIgnoresInvertColors: true }, i);
161
- }), m.body ? (_jsx(View, { style: [st.bubble, { backgroundColor: mine ? c.accent : c.raised, borderRadius: c.radius, opacity: m.pending === 'failed' ? 0.6 : 1 }], children: _jsx(T, { c: c, style: [st.body, { color: mine ? c.onAccent : c.text }], children: m.body }) })) : null, receiptText ? (_jsxs(Pressable, { disabled: rc !== 'failed', onPress: () => m.localId && onRetry(m.localId), hitSlop: 8, style: st.receipt, accessibilityRole: rc === 'failed' ? 'button' : undefined, children: [rc === 'queued' ? _jsx(Clock, { color: c.faint }) : null, _jsx(T, { c: c, style: [st.receiptText, { color: rc === 'failed' ? c.danger : c.faint }], children: receiptText })] })) : null] }));
234
+ }), m.body ? (_jsx(View, { accessible: !!acts.length, accessibilityLabel: acts.length ? label : undefined, style: [st.bubble, { backgroundColor: mine ? c.accent : c.raised, borderRadius: c.radius, opacity: m.pending === 'failed' ? 0.6 : 1 }], children: _jsx(T, { c: c, style: [st.body, { color: mine ? c.onAccent : c.text }], children: m.body }) })) : null, acts.length ? (_jsx(View, { style: st.actions, children: acts.map((a) => {
235
+ const key = m.id + ':' + a.id;
236
+ const state = runs[key];
237
+ return (_jsxs(Pressable, { onPress: () => onRun(key, a), disabled: state === 'pending', hitSlop: 5, accessibilityRole: "button", accessibilityLabel: a.label, accessibilityState: { busy: state === 'pending' }, accessibilityValue: state ? { text: stateWord(t, state) } : undefined, style: ({ pressed }) => [st.chip, st.action, { borderColor: state === 'failed' ? c.danger + '66' : c.line, backgroundColor: pressed ? c.raised : c.bg }], children: [_jsx(T, { c: c, style: st.chipText, numberOfLines: 1, children: a.label }), _jsx(StateMark, { c: c, state: state, reduce: reduce })] }, a.id));
238
+ }) })) : null, receiptText ? (_jsxs(Pressable, { disabled: rc !== 'failed', onPress: () => m.localId && onRetry(m.localId), hitSlop: 8, style: st.receipt, accessibilityRole: rc === 'failed' ? 'button' : undefined, children: [rc === 'queued' ? _jsx(Clock, { color: c.faint }) : null, _jsx(T, { c: c, style: [st.receiptText, { color: rc === 'failed' ? c.danger : c.faint }], children: receiptText })] })) : null] }));
162
239
  });
163
240
  function Chips({ c, items, reduce, onPick, talk, onTalk, center }) {
164
241
  const all = talk ? [...items, talk] : items;
@@ -175,6 +252,86 @@ function Chips({ c, items, reduce, onPick, talk, onTalk, center }) {
175
252
  return (_jsx(Animated.View, { style: { opacity: v, transform: [{ translateY: v.interpolate({ inputRange: [0, 1], outputRange: [6, 0] }) }] }, children: _jsx(Pressable, { onPress: () => (isTalk ? onTalk?.() : onPick(q)), accessibilityRole: "button", style: ({ pressed }) => [st.chip, { borderColor: isTalk ? c.accent + '55' : c.line, backgroundColor: pressed ? c.raised : c.bg }], children: _jsx(T, { c: c, style: [st.chipText, { color: isTalk ? c.accent : c.text }], children: q }) }) }, q + i));
176
253
  }) }));
177
254
  }
255
+ const stateWord = (t, state) => (state === 'pending' ? t.actionPending : state === 'done' ? t.actionDone : t.actionFailed);
256
+ // Pending: a sliding bar; done: a tick; failed: an alert mark (dee68144). Idle shows the fallback (a row's chevron).
257
+ function StateMark({ c, state, reduce, fallback = null }) {
258
+ if (state === 'pending')
259
+ return _jsx(LoadingBar, { color: c.sub, reduce: reduce });
260
+ if (state === 'done')
261
+ return _jsx(Tick, { color: c.ok });
262
+ if (state === 'failed')
263
+ return _jsx(Alert, { color: c.danger });
264
+ return _jsx(_Fragment, { children: fallback });
265
+ }
266
+ // "Did this help?" with Yes / No pills (Wolt), a one-line comment after No (WHOOP), then a small thanks line.
267
+ function Csat({ c, t, reduce, phase, onRate }) {
268
+ const [commenting, setCommenting] = useState(false);
269
+ const [text, setText] = useState('');
270
+ if (phase === 'thanks')
271
+ return (_jsx(Reveal, { reduce: reduce, style: [st.system, st.csat], children: _jsx(T, { c: c, style: [st.systemText, { color: c.sub }], children: t.csatThanks }) }));
272
+ const sendNo = () => onRate(-1, text.trim() || undefined);
273
+ return (_jsxs(Reveal, { reduce: reduce, style: st.csat, children: [_jsx(T, { c: c, style: [st.systemText, { color: c.sub }], children: t.csatAsk }), commenting ? (_jsxs(View, { style: [st.field, st.csatField, { borderColor: c.line, borderRadius: c.radius + 4, backgroundColor: c.bg }], children: [_jsx(TextInput, { value: text, onChangeText: setText, placeholder: t.csatComment, placeholderTextColor: c.faint, maxLength: 500, autoFocus: true, returnKeyType: "send", onSubmitEditing: sendNo, maxFontSizeMultiplier: 2, accessibilityLabel: t.csatComment, style: [st.input, st.csatInput, font(c), { color: c.text }] }), _jsx(Pressable, { onPress: sendNo, hitSlop: 6, accessibilityRole: "button", accessibilityLabel: t.send, style: [st.send, { backgroundColor: c.accent }], children: _jsx(ArrowUp, { color: c.onAccent }) })] })) : (_jsx(View, { style: [st.chips, st.chipsCenter, st.csatRow], children: [1, -1].map((score) => {
274
+ const word = score === 1 ? t.csatYes : t.csatNo;
275
+ return (_jsxs(Pressable, { onPress: () => (score === 1 ? onRate(1) : setCommenting(true)), hitSlop: 5, accessibilityRole: "button", accessibilityLabel: t.csatAsk + ' ' + word, style: ({ pressed }) => [st.chip, st.action, { borderColor: c.line, backgroundColor: pressed ? c.raised : c.bg }], children: [_jsx(Thumb, { up: score === 1, color: c.text }), _jsx(T, { c: c, style: st.chipText, children: word })] }, score));
276
+ }) }))] }));
277
+ }
278
+ // Grouped rows with hairlines between them (Stardust / Citi Bike subscription rows, Headspace settings list).
279
+ function Menu({ c, t, reduce, items }) {
280
+ const rows = items.filter((x) => !!x);
281
+ if (!rows.length)
282
+ return null;
283
+ return (_jsx(View, { style: [st.group, { borderColor: c.line, borderRadius: c.radius - 4 }], children: rows.map((x, i) => (_jsxs(Pressable, { onPress: x.onPress, disabled: x.state === 'pending', accessibilityRole: "button", accessibilityLabel: [x.over, x.label, x.detail].filter(Boolean).join(', '), accessibilityState: { busy: x.state === 'pending' }, accessibilityValue: x.state ? { text: stateWord(t, x.state) } : undefined, style: ({ pressed }) => [st.menuRow, i > 0 && { borderTopWidth: StyleSheet.hairlineWidth, borderTopColor: c.line }, pressed && { backgroundColor: c.raised }], children: [_jsxs(View, { style: st.fill, children: [x.over ? _jsx(T, { c: c, style: [st.menuOver, { color: c.sub }], children: x.over }) : null, _jsx(T, { c: c, bold: !!x.over, style: [st.menuLabel, x.danger && { color: c.danger }], numberOfLines: 2, children: x.label }), x.detail ? _jsx(T, { c: c, style: [st.menuDetail, { color: c.sub }], numberOfLines: 1, children: x.detail }) : null] }), _jsx(StateMark, { c: c, state: x.state, reduce: reduce, fallback: _jsx(Forward, { color: c.faint }) })] }, x.key))) }));
284
+ }
285
+ // One pill style for every choice on these screens, so no option outweighs another (b904b978 equal pair).
286
+ function Btn({ c, t, label, state, reduce, onPress, style, danger, disabled }) {
287
+ const off = disabled || state === 'pending';
288
+ return (_jsxs(Pressable, { onPress: onPress, disabled: off, accessibilityRole: "button", accessibilityLabel: label, accessibilityState: { busy: state === 'pending', disabled: off }, accessibilityValue: state ? { text: stateWord(t, state) } : undefined, style: ({ pressed }) => [st.btn, { backgroundColor: danger ? c.danger : pressed ? c.line : c.raised, opacity: danger && pressed ? 0.85 : disabled ? 0.5 : 1 }, style], children: [_jsx(T, { c: c, bold: true, style: [st.btnText, danger && { color: '#FFFFFF' }], numberOfLines: 2, children: label }), _jsx(StateMark, { c: danger ? { ...c, sub: '#FFFFFF' } : c, state: state, reduce: reduce })] }));
289
+ }
290
+ // Delete my data: an inline confirm with Cancel and Delete side by side (Phantom), then one result and a single Close
291
+ // (Fresha for done, Shop for a request that finishes later).
292
+ function Erase({ c, t, reduce, phase, inset, onDelete, onCancel, onClose }) {
293
+ const result = phase === 'done' || phase === 'pending';
294
+ const mark = phase === 'done' ? c.ok : phase === 'pending' ? c.raised : c.danger;
295
+ return (_jsxs(View, { style: [st.fill, st.erase, { paddingBottom: 16 + inset }], children: [_jsxs(Reveal, { reduce: reduce, style: st.eraseBody, children: [_jsx(View, { style: [st.eraseMark, { backgroundColor: mark }], children: phase === 'done' ? _jsx(Tick, { color: "#FFFFFF", size: 26 }) : phase === 'pending' ? _jsx(Clock, { color: c.sub, size: 26 }) : _jsx(Trash, { color: "#FFFFFF", size: 26 }) }), _jsx(T, { c: c, bold: true, style: st.eraseTitle, accessibilityRole: "header", children: phase === 'done' ? t.deleted : phase === 'pending' ? t.deletePending : t.deleteConfirm })] }, result ? 'result' : 'confirm'), result ? (_jsx(Btn, { c: c, t: t, reduce: reduce, label: t.close, onPress: onClose })) : (_jsxs(View, { style: st.pair, children: [_jsx(Btn, { c: c, t: t, reduce: reduce, label: t.cancel, disabled: phase === 'working', onPress: onCancel, style: st.fill }), _jsx(Btn, { c: c, t: t, reduce: reduce, label: t.deleteBtn, danger: true, state: phase === 'working' ? 'pending' : undefined, onPress: onDelete, style: st.fill })] }))] }));
296
+ }
297
+ // Home rows: the Subscription row (plan, price, next date) when the host gave one, and "Rate {app}" (§3.10, §3.11).
298
+ function HomeRows({ s, c, t, reduce, rate, appName, onOpen, onRate, onErase }) {
299
+ const sub = s.subscription && s.subscription.status !== 'none' ? s.subscription : null;
300
+ const sum = sub ? subscriptionSummary(sub, t, day) : null;
301
+ const items = [
302
+ sum ? { key: 'sub', over: t.subscription, label: sum.plan, detail: sum.detail, onPress: onOpen } : null,
303
+ can(s, 'write_review') ? { key: 'rate', label: appName ? fill(t.rateApp, { app: appName }) : t.rateThisApp, state: rate, onPress: onRate } : null,
304
+ { key: 'erase', label: t.deleteData, danger: true, onPress: onErase }
305
+ ];
306
+ return (_jsx(View, { style: st.home, children: _jsx(Menu, { c: c, t: t, reduce: reduce, items: items }) }));
307
+ }
308
+ // Subscription, cancel reason, the one alternative, and the help-first refund screen (§3.10).
309
+ function Subscription({ s, c, t, flow, go, runs, store, reduce, inset, onChat }) {
310
+ const sub = s.subscription;
311
+ const head = (text) => _jsx(T, { c: c, bold: true, style: st.subTitle, accessibilityRole: "header", children: text });
312
+ const row = (kind, label) => (can(s, kind) ? { key: kind, label, state: runs['sub.' + kind], onPress: () => store(kind, label) } : null);
313
+ const toStore = fill(t.cancelIn, { store: storeName(sub, Platform.OS === 'android') });
314
+ const sum = sub ? subscriptionSummary(sub, t, day) : null;
315
+ let body = null;
316
+ if (flow.screen === 'sub')
317
+ body = (_jsxs(_Fragment, { children: [head(t.subscription), sum ? (_jsxs(View, { style: [st.group, st.summary, { borderColor: c.line, borderRadius: c.radius - 4 }], accessible: true, accessibilityLabel: sum.plan + ', ' + sum.detail, children: [_jsx(T, { c: c, bold: true, style: st.plan, children: sum.plan }), sum.detail ? _jsx(T, { c: c, style: [st.menuDetail, { color: c.sub }], children: sum.detail }) : null] })) : null, _jsx(Menu, { c: c, t: t, reduce: reduce, items: [
318
+ row('manage_subscription', t.manage),
319
+ row('restore', t.restore),
320
+ row('redeem_code', t.redeem),
321
+ { key: 'refund', label: t.refund, onPress: () => go({ type: 'refund' }) },
322
+ sub && canCancel(sub) ? { key: 'cancel', label: t.cancelSub, danger: true, onPress: () => go({ type: 'cancel' }) } : null
323
+ ] })] }));
324
+ else if (flow.screen === 'reason')
325
+ body = (_jsxs(_Fragment, { children: [head(t.reasonTitle), _jsx(View, { style: st.options, children: cancelReasons.map((r) => {
326
+ const label = t[('reason_' + r)];
327
+ return (_jsx(Pressable, { onPress: () => go({ type: 'pick', reason: r }), accessibilityRole: "button", accessibilityLabel: label, style: ({ pressed }) => [st.option, { borderColor: c.line, borderRadius: c.radius - 4, backgroundColor: pressed ? c.raised : c.bg }], children: _jsx(T, { c: c, style: st.menuLabel, children: label }) }, r));
328
+ }) }), _jsxs(View, { style: st.pair, children: [_jsx(Btn, { c: c, t: t, reduce: reduce, label: t.skip, onPress: () => go({ type: 'pick', reason: null }), style: st.fill }), _jsx(Btn, { c: c, t: t, reduce: reduce, label: toStore, state: runs['sub.manage_subscription'], onPress: () => go({ type: 'store' }), style: st.fill })] })] }));
329
+ else if (flow.screen === 'offer')
330
+ body = (_jsxs(_Fragment, { children: [head(t.offerTitle), _jsxs(View, { style: st.stack, children: [_jsx(Btn, { c: c, t: t, reduce: reduce, label: flow.offer?.label ?? '', onPress: () => go({ type: 'accept' }) }), _jsx(Btn, { c: c, t: t, reduce: reduce, label: t.continueCancel, state: runs['sub.manage_subscription'], onPress: () => go({ type: 'continue' }) })] })] }));
331
+ else if (flow.screen === 'refund')
332
+ body = (_jsxs(_Fragment, { children: [head(t.refund), _jsx(T, { c: c, style: [st.subLine, { color: c.sub }], children: t.refundHelp }), _jsx(Menu, { c: c, t: t, reduce: reduce, items: [row('restore', t.restore), { key: 'chat', label: t.chatWithUs, onPress: onChat }] }), _jsx(Btn, { c: c, t: t, reduce: reduce, label: t.refund, state: runs['sub.request_refund'], onPress: () => go({ type: 'requestRefund' }), style: st.below })] }));
333
+ return _jsx(ScrollView, { contentContainerStyle: [st.subPad, { paddingBottom: 16 + inset }], children: body });
334
+ }
178
335
  function useKeyboardInset() {
179
336
  const [h, setH] = useState(0);
180
337
  useEffect(() => {
@@ -269,5 +426,39 @@ const st = StyleSheet.create({
269
426
  attach: { width: 38, height: 32, alignItems: 'center', justifyContent: 'center' },
270
427
  attachGap: { width: 12 },
271
428
  input: { flex: 1, minHeight: 32, maxHeight: 132, fontSize: 16, lineHeight: 21, paddingTop: 6, paddingBottom: 5, paddingHorizontal: 0 },
272
- send: { width: 32, height: 32, borderRadius: 16, alignItems: 'center', justifyContent: 'center', marginStart: 6 }
429
+ send: { width: 32, height: 32, borderRadius: 16, alignItems: 'center', justifyContent: 'center', marginStart: 6 },
430
+ emptyHome: { alignSelf: 'stretch', marginTop: 8 },
431
+ actions: { flexDirection: 'row', flexWrap: 'wrap', gap: 6, marginTop: 6 },
432
+ action: { flexDirection: 'row', alignItems: 'center', gap: 6 },
433
+ consent: { marginHorizontal: 12, marginBottom: 6, paddingHorizontal: 12, paddingVertical: 10 },
434
+ consentText: { fontSize: 13, lineHeight: 18 },
435
+ consentRow: { flexDirection: 'row', justifyContent: 'flex-end', gap: 8, marginTop: 8 },
436
+ consentBtn: { minHeight: 32, borderRadius: 16, borderWidth: 1, paddingHorizontal: 14, justifyContent: 'center' },
437
+ consentBtnText: { fontSize: 14, lineHeight: 18 },
438
+ csat: { alignSelf: 'center', alignItems: 'center', marginTop: 16, maxWidth: '100%' },
439
+ csatRow: { marginTop: 8 },
440
+ csatField: { marginTop: 8, alignSelf: 'stretch', minWidth: 280 },
441
+ csatInput: { paddingStart: 14 },
442
+ home: { paddingHorizontal: 12, paddingTop: 8, paddingBottom: 4 },
443
+ group: { borderWidth: 1, overflow: 'hidden' },
444
+ menuRow: { flexDirection: 'row', alignItems: 'center', gap: 12, minHeight: 48, paddingHorizontal: 14, paddingVertical: 10 },
445
+ menuOver: { fontSize: 12, lineHeight: 16 },
446
+ menuLabel: { fontSize: 15, lineHeight: 20 },
447
+ menuDetail: { fontSize: 13, lineHeight: 18 },
448
+ subPad: { paddingHorizontal: 16, paddingTop: 16, gap: 12 },
449
+ subTitle: { fontSize: 20, lineHeight: 26 },
450
+ subLine: { fontSize: 14, lineHeight: 19, marginTop: -6 },
451
+ summary: { paddingHorizontal: 14, paddingVertical: 12, gap: 2 },
452
+ plan: { fontSize: 17, lineHeight: 22 },
453
+ options: { gap: 8 },
454
+ option: { minHeight: 48, borderWidth: 1, paddingHorizontal: 14, justifyContent: 'center' },
455
+ pair: { flexDirection: 'row', gap: 8 },
456
+ stack: { gap: 8 },
457
+ below: { marginTop: 4 },
458
+ btn: { minHeight: 46, borderRadius: 23, flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 8, paddingHorizontal: 18, paddingVertical: 8 },
459
+ btnText: { fontSize: 15, lineHeight: 20, textAlign: 'center', flexShrink: 1 },
460
+ erase: { paddingHorizontal: 16 },
461
+ eraseBody: { flex: 1, alignItems: 'center', justifyContent: 'center', gap: 16, paddingHorizontal: 8 },
462
+ eraseMark: { width: 56, height: 56, borderRadius: 28, alignItems: 'center', justifyContent: 'center' },
463
+ eraseTitle: { fontSize: 20, lineHeight: 26, textAlign: 'center' }
273
464
  });
package/dist/support.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // The app-facing singleton: configure once, identify after sign-in, open the widget from anywhere. Calls made before
2
2
  // configure() (an auth listener at module scope, a push token on launch) are held and applied when it runs.
3
- import { Platform } from 'react-native';
3
+ import { Linking, Platform } from 'react-native';
4
4
  import { SupportClient } from './client';
5
5
  import { nativeDevice, nativeStorage } from './native';
6
6
  let current = null;
@@ -11,7 +11,7 @@ export const ShotikSupport = {
11
11
  if (current && current.config.appKey === config.appKey && current.config.serverUrl === config.serverUrl.replace(/\/+$/, ''))
12
12
  return current;
13
13
  current?.stop();
14
- const c = new SupportClient({ storage: nativeStorage(), device: nativeDevice, ...config });
14
+ const c = new SupportClient({ storage: nativeStorage(), device: nativeDevice, openUrl: (url) => Linking.openURL(url).catch(() => { }), ...config });
15
15
  current = c;
16
16
  if (held.push)
17
17
  c.setPushToken(held.push.token, held.push.platform).catch(() => { });
package/dist/theme.d.ts CHANGED
@@ -64,6 +64,49 @@ declare const en: {
64
64
  typing: string;
65
65
  open: string;
66
66
  unreadN: string;
67
+ consent: string;
68
+ consentAllow: string;
69
+ consentPerson: string;
70
+ actionPending: string;
71
+ actionDone: string;
72
+ actionFailed: string;
73
+ friction: string;
74
+ frictionClose: string;
75
+ csatAsk: string;
76
+ csatYes: string;
77
+ csatNo: string;
78
+ csatComment: string;
79
+ csatThanks: string;
80
+ subscription: string;
81
+ renews: string;
82
+ ends: string;
83
+ trialEnds: string;
84
+ ended: string;
85
+ manage: string;
86
+ restore: string;
87
+ redeem: string;
88
+ refund: string;
89
+ cancelSub: string;
90
+ reasonTitle: string;
91
+ reason_too_expensive: string;
92
+ reason_not_using: string;
93
+ reason_bug: string;
94
+ reason_mistake: string;
95
+ reason_other: string;
96
+ skip: string;
97
+ cancelIn: string;
98
+ offerTitle: string;
99
+ continueCancel: string;
100
+ offerDraft: string;
101
+ refundHelp: string;
102
+ chatWithUs: string;
103
+ rateApp: string;
104
+ rateThisApp: string;
105
+ deleteData: string;
106
+ deleteConfirm: string;
107
+ deleteBtn: string;
108
+ deleted: string;
109
+ deletePending: string;
67
110
  };
68
111
  export type Copy = typeof en;
69
112
  export declare const catalogs: Record<string, Copy>;
package/dist/theme.js CHANGED
@@ -29,7 +29,7 @@ const en = {
29
29
  cancel: 'Cancel',
30
30
  remove: 'Remove',
31
31
  sending: 'Sending',
32
- queued: 'Queued',
32
+ queued: "Will send when you're back online",
33
33
  sent: 'Sent',
34
34
  delivered: 'Delivered',
35
35
  seen: 'Seen',
@@ -43,7 +43,50 @@ const en = {
43
43
  person: 'Person',
44
44
  typing: '{who} is typing',
45
45
  open: 'Open support',
46
- unreadN: '{n} unread'
46
+ unreadN: '{n} unread',
47
+ consent: 'Replies may be drafted by AI and checked by the team.',
48
+ consentAllow: 'Allow',
49
+ consentPerson: 'Only a person',
50
+ actionPending: 'In progress',
51
+ actionDone: 'Done',
52
+ actionFailed: "Didn't work",
53
+ friction: 'Something wrong? Write to us',
54
+ frictionClose: 'Not now',
55
+ csatAsk: 'Did this help?',
56
+ csatYes: 'Yes',
57
+ csatNo: 'No',
58
+ csatComment: 'What went wrong? (optional)',
59
+ csatThanks: 'Thanks for the feedback',
60
+ subscription: 'Subscription',
61
+ renews: 'Renews {date}',
62
+ ends: 'Ends {date}',
63
+ trialEnds: 'Trial ends {date}',
64
+ ended: 'Ended',
65
+ manage: 'Manage subscription',
66
+ restore: 'Restore purchases',
67
+ redeem: 'Redeem code',
68
+ refund: 'Request a refund',
69
+ cancelSub: 'Cancel subscription',
70
+ reasonTitle: 'Why are you cancelling?',
71
+ reason_too_expensive: 'Too expensive',
72
+ reason_not_using: 'Not using it enough',
73
+ reason_bug: "Something doesn't work",
74
+ reason_mistake: 'Subscribed by mistake',
75
+ reason_other: 'Something else',
76
+ skip: 'Skip',
77
+ cancelIn: 'Cancel in {store}',
78
+ offerTitle: 'Another option',
79
+ continueCancel: 'Continue to cancel',
80
+ offerDraft: "I'd like this offer: {label}",
81
+ refundHelp: 'A restore or a quick chat often fixes it.',
82
+ chatWithUs: 'Chat with us',
83
+ rateApp: 'Rate {app}',
84
+ rateThisApp: 'Rate the app',
85
+ deleteData: 'Delete my data',
86
+ deleteConfirm: "Delete your chats and app usage data? This can't be undone.",
87
+ deleteBtn: 'Delete',
88
+ deleted: 'Your data is deleted.',
89
+ deletePending: "We'll finish deleting when you're back online."
47
90
  };
48
91
  const ru = {
49
92
  title: 'Поддержка',
@@ -65,7 +108,7 @@ const ru = {
65
108
  cancel: 'Отмена',
66
109
  remove: 'Убрать',
67
110
  sending: 'Отправляется',
68
- queued: 'В очереди',
111
+ queued: 'Отправим, когда появится связь',
69
112
  sent: 'Отправлено',
70
113
  delivered: 'Доставлено',
71
114
  seen: 'Прочитано',
@@ -79,7 +122,50 @@ const ru = {
79
122
  person: 'Человек',
80
123
  typing: '{who} печатает',
81
124
  open: 'Открыть поддержку',
82
- unreadN: 'Непрочитанных: {n}'
125
+ unreadN: 'Непрочитанных: {n}',
126
+ consent: 'Ответы может готовить ИИ, команда их проверяет.',
127
+ consentAllow: 'Разрешить',
128
+ consentPerson: 'Только человек',
129
+ actionPending: 'Выполняется',
130
+ actionDone: 'Готово',
131
+ actionFailed: 'Не получилось',
132
+ friction: 'Что-то не так? Напишите нам',
133
+ frictionClose: 'Не сейчас',
134
+ csatAsk: 'Это помогло?',
135
+ csatYes: 'Да',
136
+ csatNo: 'Нет',
137
+ csatComment: 'Что пошло не так? (необязательно)',
138
+ csatThanks: 'Спасибо за отзыв',
139
+ subscription: 'Подписка',
140
+ renews: 'Продлится {date}',
141
+ ends: 'Закончится {date}',
142
+ trialEnds: 'Пробный период до {date}',
143
+ ended: 'Закончилась',
144
+ manage: 'Управлять подпиской',
145
+ restore: 'Восстановить покупки',
146
+ redeem: 'Ввести код',
147
+ refund: 'Запросить возврат',
148
+ cancelSub: 'Отменить подписку',
149
+ reasonTitle: 'Почему отменяете?',
150
+ reason_too_expensive: 'Слишком дорого',
151
+ reason_not_using: 'Редко пользуюсь',
152
+ reason_bug: 'Что-то не работает',
153
+ reason_mistake: 'Подписка оформлена по ошибке',
154
+ reason_other: 'Другое',
155
+ skip: 'Пропустить',
156
+ cancelIn: 'Отменить в {store}',
157
+ offerTitle: 'Есть другой вариант',
158
+ continueCancel: 'Продолжить отмену',
159
+ offerDraft: 'Хочу это предложение: {label}',
160
+ refundHelp: 'Часто помогает восстановление покупок или чат с нами.',
161
+ chatWithUs: 'Написать нам',
162
+ rateApp: 'Оценить {app}',
163
+ rateThisApp: 'Оценить приложение',
164
+ deleteData: 'Удалить мои данные',
165
+ deleteConfirm: 'Удалить ваши переписки и данные об использовании приложения? Это нельзя отменить.',
166
+ deleteBtn: 'Удалить',
167
+ deleted: 'Ваши данные удалены.',
168
+ deletePending: 'Удалим, когда появится сеть.'
83
169
  };
84
170
  export const catalogs = { en, ru };
85
171
  export function copyFor(locale) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shotik/react-native",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Shotik SDK for React Native and Expo: in-app support chat answered from Shotik, and product analytics.",
5
5
  "keywords": [
6
6
  "react-native",
@@ -45,6 +45,7 @@
45
45
  "src",
46
46
  "README.md",
47
47
  "README.ru.md",
48
+ "CHANGELOG.md",
48
49
  "LICENSE",
49
50
  "guide.json",
50
51
  "recipe.json"
@@ -54,12 +55,15 @@
54
55
  "react": ">=18",
55
56
  "react-native": ">=0.72",
56
57
  "@react-native-async-storage/async-storage": "*",
58
+ "@react-native-community/netinfo": "*",
57
59
  "expo-application": "*",
58
60
  "expo-device": "*",
59
61
  "expo-image-picker": "*",
60
62
  "expo-localization": "*",
63
+ "expo-network": "*",
61
64
  "expo-router": "*",
62
65
  "expo-secure-store": "*",
66
+ "expo-updates": "*",
63
67
  "react-native-mmkv": "*",
64
68
  "react-native-safe-area-context": "*",
65
69
  "react-native-svg": ">=13",
@@ -69,6 +73,9 @@
69
73
  "@react-native-async-storage/async-storage": {
70
74
  "optional": true
71
75
  },
76
+ "@react-native-community/netinfo": {
77
+ "optional": true
78
+ },
72
79
  "expo-application": {
73
80
  "optional": true
74
81
  },
@@ -81,12 +88,18 @@
81
88
  "expo-localization": {
82
89
  "optional": true
83
90
  },
91
+ "expo-network": {
92
+ "optional": true
93
+ },
84
94
  "expo-router": {
85
95
  "optional": true
86
96
  },
87
97
  "expo-secure-store": {
88
98
  "optional": true
89
99
  },
100
+ "expo-updates": {
101
+ "optional": true
102
+ },
90
103
  "react-native-mmkv": {
91
104
  "optional": true
92
105
  },
@@ -108,7 +121,7 @@
108
121
  "scripts": {
109
122
  "build": "rm -rf dist && tsc -p tsconfig.build.json",
110
123
  "prepack": "npm run build",
111
- "test": "node --disable-warning=ExperimentalWarning --test ../../server/test/support.test.ts"
124
+ "test": "node --disable-warning=ExperimentalWarning --test ../../server/test/support.test.ts test/*.test.ts"
112
125
  },
113
126
  "publishConfig": {
114
127
  "access": "public"
package/recipe.json CHANGED
@@ -110,7 +110,7 @@
110
110
  "dependencies",
111
111
  "@shotik/react-native"
112
112
  ],
113
- "value": "^0.1.0"
113
+ "value": "^0.2.0"
114
114
  }
115
115
  ],
116
116
  "run": {