@zean-chat/react-native 0.1.7 → 0.1.9
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/dist/components/AppMark.d.ts +1 -1
- package/dist/components/ChatHeader.d.ts +1 -1
- package/dist/components/ChatModal.d.ts +1 -1
- package/dist/components/ChatNotice.d.ts +1 -1
- package/dist/components/ChatScreen.d.ts +1 -1
- package/dist/components/Composer.d.ts +1 -1
- package/dist/components/ContactCodeCard.d.ts +3 -3
- package/dist/components/EmailForm.d.ts +1 -1
- package/dist/components/Icon.d.ts +1 -1
- package/dist/components/ImageViewer.d.ts +1 -1
- package/dist/components/MessageBubble.d.ts +1 -1
- package/dist/components/MessageFiles.d.ts +1 -1
- package/dist/components/MessageList.d.ts +1 -1
- package/dist/components/MessageMeta.d.ts +1 -1
- package/dist/components/PendingPhotos.d.ts +1 -1
- package/dist/components/PoweredBy.d.ts +1 -1
- package/dist/components/Skeleton.d.ts +1 -1
- package/dist/components/TeamAvatar.d.ts +1 -1
- package/dist/components/TypingBubble.d.ts +1 -1
- package/dist/components/ZeanChat.d.ts +1 -1
- package/dist/i18n/en.d.ts +2 -0
- package/dist/i18n/fr.d.ts +2 -0
- package/dist/index.js +63 -19
- package/package.json +6 -6
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { AppMarkProps } from '../models/sdk.interface';
|
|
2
2
|
/** The App in the header: its logo in a circle, as the dashboard shows it, else a chat bubble in its colour. */
|
|
3
|
-
export declare function AppMark({ app }: AppMarkProps): import("react
|
|
3
|
+
export declare function AppMark({ app }: AppMarkProps): import("react").JSX.Element;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ChatHeaderProps } from '../models/sdk.interface';
|
|
2
2
|
/** The App's name and whether the team is there: one short row, so the Conversation keeps the room, even on a small phone. */
|
|
3
|
-
export declare function ChatHeader({ app, online, topInset, onClose }: ChatHeaderProps): import("react
|
|
3
|
+
export declare function ChatHeader({ app, online, topInset, onClose }: ChatHeaderProps): import("react").JSX.Element;
|
|
@@ -4,4 +4,4 @@ import type { ChatModalProps } from '../models/sdk.interface';
|
|
|
4
4
|
* screen on Android, closed with back, and on an iPad. It shows once the App and the Conversation are loaded, in the
|
|
5
5
|
* App's colour and the Contact's language.
|
|
6
6
|
*/
|
|
7
|
-
export declare function ChatModal({ chat, colorScheme, maxPhotos }: ChatModalProps): import("react
|
|
7
|
+
export declare function ChatModal({ chat, colorScheme, maxPhotos }: ChatModalProps): import("react").JSX.Element;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ChatNoticeProps } from '../models/sdk.interface';
|
|
2
2
|
/** A card from the chat itself: offline, blocked, unavailable. */
|
|
3
|
-
export declare function ChatNotice({ children }: ChatNoticeProps): import("react
|
|
3
|
+
export declare function ChatNotice({ children }: ChatNoticeProps): import("react").JSX.Element;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ChatScreenProps } from '../models/sdk.interface';
|
|
2
2
|
/** The open chat: the header, the Conversation, and the message field above the keyboard. */
|
|
3
|
-
export declare function ChatScreen({ state, insets, onClose }: ChatScreenProps): import("react
|
|
3
|
+
export declare function ChatScreen({ state, insets, onClose }: ChatScreenProps): import("react").JSX.Element;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* in the App's colour. 16 point text; the field grows with the text up to five lines. Emoji come from the phone's keyboard.
|
|
4
4
|
* Picked photos show above the field and upload when the message is sent.
|
|
5
5
|
*/
|
|
6
|
-
export declare function Composer(): import("react
|
|
6
|
+
export declare function Composer(): import("react").JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ContactCodeCardProps } from '../models/sdk.interface';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* A Contact code to the person's email: it joins this device to their Conversation (ADR 0010), or brings in what they
|
|
4
|
+
* wrote before signing in (ADR 0014). The code field takes the code the phone offers from the email.
|
|
5
5
|
*/
|
|
6
|
-
export declare function ContactCodeCard({ code, onDismiss }: ContactCodeCardProps): import("react
|
|
6
|
+
export declare function ContactCodeCard({ code, onDismiss }: ContactCodeCardProps): import("react").JSX.Element;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { EmailFormProps } from '../models/sdk.interface';
|
|
2
2
|
/** Asked once the Contact has written, until they leave an email: where the team reaches them back. */
|
|
3
|
-
export declare function EmailForm({ onSubmit }: EmailFormProps): import("react
|
|
3
|
+
export declare function EmailForm({ onSubmit }: EmailFormProps): import("react").JSX.Element;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { IconProps } from '../models/sdk.interface';
|
|
2
2
|
/** One of the chat's icons, in a colour. Decorative: the button around it carries the name. */
|
|
3
|
-
export declare function Icon({ name, color, size }: IconProps): import("react
|
|
3
|
+
export declare function Icon({ name, color, size }: IconProps): import("react").JSX.Element;
|
|
@@ -3,4 +3,4 @@ import type { ImageViewerProps } from '../models/sdk.interface';
|
|
|
3
3
|
* A message's images at full size over the chat, swiped from one to the next, pinched to zoom on iOS. The close button,
|
|
4
4
|
* or Android's back, goes back to the chat.
|
|
5
5
|
*/
|
|
6
|
-
export declare function ImageViewer({ gallery, topInset, onClose }: ImageViewerProps): import("react
|
|
6
|
+
export declare function ImageViewer({ gallery, topInset, onClose }: ImageViewerProps): import("react").JSX.Element;
|
|
@@ -3,4 +3,4 @@ import type { MessageBubbleProps } from '../models/sdk.interface';
|
|
|
3
3
|
* One message: the Contact's on the right in the App's colour, the team's on the left beside the sender's avatar.
|
|
4
4
|
* Messages of a run sit close, with tight corners where they meet; the run's last one carries the time.
|
|
5
5
|
*/
|
|
6
|
-
export declare function MessageBubble({ row, app, onRetry }: MessageBubbleProps): import("react
|
|
6
|
+
export declare function MessageBubble({ row, app, onRetry }: MessageBubbleProps): import("react").JSX.Element;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { MessageFilesProps } from '../models/sdk.interface';
|
|
2
2
|
/** A message's files: images that open in the viewer, a bone while each one's link is signed, other files to open. */
|
|
3
|
-
export declare function MessageFiles({ attachments, own, stored }: MessageFilesProps): import("react
|
|
3
|
+
export declare function MessageFiles({ attachments, own, stored }: MessageFilesProps): import("react").JSX.Element | null;
|
|
@@ -4,4 +4,4 @@ import type { MessageListProps } from '../models/sdk.interface';
|
|
|
4
4
|
* new messages stay in view, and older ones loaded at the top keep the reader's place. Scrolled up, a button goes back
|
|
5
5
|
* to the latest message; the Contact's own message brings them back too.
|
|
6
6
|
*/
|
|
7
|
-
export declare function MessageList({ state }: MessageListProps): import("react
|
|
7
|
+
export declare function MessageList({ state }: MessageListProps): import("react").JSX.Element;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { MessageMetaProps } from '../models/sdk.interface';
|
|
2
2
|
/** Under the last message of a run: its time, and for the Contact's own how far it went, or why it did not go. */
|
|
3
|
-
export declare function MessageMeta({ row, onRetry }: MessageMetaProps): import("react
|
|
3
|
+
export declare function MessageMeta({ row, onRetry }: MessageMetaProps): import("react").JSX.Element;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { PendingPhotosProps } from '../models/sdk.interface';
|
|
2
2
|
/** The photos going with the next message, above the field: a spinner while each uploads, red when it did not. */
|
|
3
|
-
export declare function PendingPhotos({ photos, locked, onRemove }: PendingPhotosProps): import("react
|
|
3
|
+
export declare function PendingPhotos({ photos, locked, onRemove }: PendingPhotosProps): import("react").JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** The badge the Plan shows, in the product's own colour. Opens the public site. */
|
|
2
|
-
export declare function PoweredBy(): import("react
|
|
2
|
+
export declare function PoweredBy(): import("react").JSX.Element;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { SkeletonProps } from '../models/sdk.interface';
|
|
2
2
|
/** A bone that breathes where something is loading. Its size and shape come from `style`. */
|
|
3
|
-
export declare function Skeleton({ style }: SkeletonProps): import("react
|
|
3
|
+
export declare function Skeleton({ style }: SkeletonProps): import("react").JSX.Element;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { TeamAvatarProps } from '../models/sdk.interface';
|
|
2
2
|
/** Beside the team's messages: the Member's photo or initials, else the App's logo or initial. */
|
|
3
|
-
export declare function TeamAvatar({ app, sender }: TeamAvatarProps): import("react
|
|
3
|
+
export declare function TeamAvatar({ app, sender }: TeamAvatarProps): import("react").JSX.Element;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { TypingBubbleProps } from '../models/sdk.interface';
|
|
2
2
|
/** Three dots that bounce in turn while a Member writes a reply. */
|
|
3
|
-
export declare function TypingBubble({ app, sender }: TypingBubbleProps): import("react
|
|
3
|
+
export declare function TypingBubble({ app, sender }: TypingBubbleProps): import("react").JSX.Element;
|
|
@@ -3,4 +3,4 @@ import type { ZeanChatProps } from '../interfaces';
|
|
|
3
3
|
* The chat. Render it once, near the root of the app, inside or outside any navigator: it opens in its own modal when
|
|
4
4
|
* `open()` from `useZean()` is called, and shows nothing until then.
|
|
5
5
|
*/
|
|
6
|
-
export declare function ZeanChat({ appKey, storage, user, attributes, locale, colorScheme, maxPhotos, backendUrl }: ZeanChatProps): import("react
|
|
6
|
+
export declare function ZeanChat({ appKey, storage, user, attributes, locale, colorScheme, maxPhotos, backendUrl }: ZeanChatProps): import("react").JSX.Element | null;
|
package/dist/i18n/en.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export declare const en: {
|
|
|
24
24
|
email_saved: string;
|
|
25
25
|
error: string;
|
|
26
26
|
code_prompt: string;
|
|
27
|
+
code_prompt_earlier: string;
|
|
27
28
|
code_send: string;
|
|
28
29
|
code_label: string;
|
|
29
30
|
code_submit: string;
|
|
@@ -32,6 +33,7 @@ export declare const en: {
|
|
|
32
33
|
code_expired: string;
|
|
33
34
|
code_rate_limited: string;
|
|
34
35
|
code_dismiss: string;
|
|
36
|
+
code_not_me: string;
|
|
35
37
|
attach: string;
|
|
36
38
|
uploading: string;
|
|
37
39
|
ready: string;
|
package/dist/i18n/fr.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export declare const fr: {
|
|
|
25
25
|
email_saved: string;
|
|
26
26
|
error: string;
|
|
27
27
|
code_prompt: string;
|
|
28
|
+
code_prompt_earlier: string;
|
|
28
29
|
code_send: string;
|
|
29
30
|
code_label: string;
|
|
30
31
|
code_submit: string;
|
|
@@ -33,6 +34,7 @@ export declare const fr: {
|
|
|
33
34
|
code_expired: string;
|
|
34
35
|
code_rate_limited: string;
|
|
35
36
|
code_dismiss: string;
|
|
37
|
+
code_not_me: string;
|
|
36
38
|
attach: string;
|
|
37
39
|
uploading: string;
|
|
38
40
|
ready: string;
|
package/dist/index.js
CHANGED
|
@@ -208,6 +208,9 @@ var KEPT_MESSAGES = 100;
|
|
|
208
208
|
var KEPT_VERSION = 1;
|
|
209
209
|
var LIVE_AFTER_CLOSE_MS = 2 * 6e4;
|
|
210
210
|
var ADVANCE_AFTER = WIDGET_PAGE_SIZE / 2;
|
|
211
|
+
function emailKey(offer) {
|
|
212
|
+
return `${offer.kind}:${offer.email}`;
|
|
213
|
+
}
|
|
211
214
|
function createChatStore(backend, options) {
|
|
212
215
|
const secretKey = `zean:${options.appKey}:device`;
|
|
213
216
|
const outboxKey = `zean:${options.appKey}:outbox`;
|
|
@@ -241,7 +244,10 @@ function createChatStore(backend, options) {
|
|
|
241
244
|
let started = false;
|
|
242
245
|
let reported = false;
|
|
243
246
|
let user = null;
|
|
244
|
-
let
|
|
247
|
+
let idCode = null;
|
|
248
|
+
let idCodeDismissed = false;
|
|
249
|
+
let emailCodeSent = null;
|
|
250
|
+
let emailCodeDismissed = null;
|
|
245
251
|
let emailGiven = false;
|
|
246
252
|
let wroteHere = false;
|
|
247
253
|
let emailAskWanted = false;
|
|
@@ -292,7 +298,6 @@ function createChatStore(backend, options) {
|
|
|
292
298
|
stops.push(() => clearInterval(clock));
|
|
293
299
|
})();
|
|
294
300
|
function watchAll() {
|
|
295
|
-
for (const stop of watchers) stop();
|
|
296
301
|
watchers = [
|
|
297
302
|
backend.watch("session", args(), handleSession, () => {
|
|
298
303
|
failedToLoad = true;
|
|
@@ -353,7 +358,7 @@ function createChatStore(backend, options) {
|
|
|
353
358
|
try {
|
|
354
359
|
const result = await backend.call("identify", { ...args(), user: person, device: device() });
|
|
355
360
|
if (mine !== generation) return;
|
|
356
|
-
|
|
361
|
+
idCode = result.state === "code_available" ? { email: result.email, sent: idCode?.sent ?? false } : null;
|
|
357
362
|
identified = true;
|
|
358
363
|
emit2();
|
|
359
364
|
} catch (error) {
|
|
@@ -479,7 +484,7 @@ function createChatStore(backend, options) {
|
|
|
479
484
|
function wantsEmail() {
|
|
480
485
|
const app = session && "app" in session ? session.app : null;
|
|
481
486
|
const contact = session && "contact" in session ? session.contact : null;
|
|
482
|
-
return statusOf() === "ready" && !!contact && contact.email === null && !emailGiven &&
|
|
487
|
+
return statusOf() === "ready" && !!contact && contact.email === null && !emailGiven && app?.askEmail === true;
|
|
483
488
|
}
|
|
484
489
|
function holdEmailAsk() {
|
|
485
490
|
const wanted = wantsEmail();
|
|
@@ -532,10 +537,16 @@ function createChatStore(backend, options) {
|
|
|
532
537
|
askEmail: emailAskWanted && !emailAskTimer,
|
|
533
538
|
emailGiven,
|
|
534
539
|
verified,
|
|
535
|
-
contactCode: verified
|
|
540
|
+
contactCode: codeOffer(verified),
|
|
536
541
|
connected
|
|
537
542
|
};
|
|
538
543
|
}
|
|
544
|
+
function codeOffer(verified) {
|
|
545
|
+
if (idCode && !verified) return idCodeDismissed ? null : { kind: "id", ...idCode };
|
|
546
|
+
const offer = session && "emailCode" in session ? session.emailCode : null;
|
|
547
|
+
if (!offer || emailKey(offer) === emailCodeDismissed) return null;
|
|
548
|
+
return { ...offer, sent: emailKey(offer) === emailCodeSent };
|
|
549
|
+
}
|
|
539
550
|
function checkKept(result) {
|
|
540
551
|
const history = "contact" in result ? result.contact?.historyKey ?? null : null;
|
|
541
552
|
if (history !== keptHistory) {
|
|
@@ -545,7 +556,7 @@ function createChatStore(backend, options) {
|
|
|
545
556
|
if (hidesChat(result)) forgetKept();
|
|
546
557
|
else if (history !== null && !stopMessages && serverMessages().length === 0 && deviceSecret) {
|
|
547
558
|
watchLive();
|
|
548
|
-
|
|
559
|
+
stopLiveLater();
|
|
549
560
|
} else saveKept();
|
|
550
561
|
}
|
|
551
562
|
async function loadKept() {
|
|
@@ -744,7 +755,8 @@ function createChatStore(backend, options) {
|
|
|
744
755
|
}
|
|
745
756
|
if (user?.id !== person.id) {
|
|
746
757
|
generation += 1;
|
|
747
|
-
|
|
758
|
+
idCode = null;
|
|
759
|
+
idCodeDismissed = false;
|
|
748
760
|
emailGiven = false;
|
|
749
761
|
}
|
|
750
762
|
user = person;
|
|
@@ -752,12 +764,17 @@ function createChatStore(backend, options) {
|
|
|
752
764
|
await sendIdentity();
|
|
753
765
|
},
|
|
754
766
|
async requestCode() {
|
|
767
|
+
const offer = state.contactCode;
|
|
755
768
|
const person = user;
|
|
756
|
-
if (!
|
|
769
|
+
if (!deviceSecret || !offer || offer.kind === "id" && !person) return { ok: false, code: "not_found" };
|
|
757
770
|
try {
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
771
|
+
if (offer.kind !== "id") {
|
|
772
|
+
await backend.call("requestEmailCode", args());
|
|
773
|
+
emailCodeSent = emailKey(offer);
|
|
774
|
+
} else {
|
|
775
|
+
await backend.call("requestCode", { ...args(), userId: person.id });
|
|
776
|
+
if (idCode && user === person) idCode = { ...idCode, sent: true };
|
|
777
|
+
}
|
|
761
778
|
emit2();
|
|
762
779
|
return { ok: true };
|
|
763
780
|
} catch (error) {
|
|
@@ -765,12 +782,20 @@ function createChatStore(backend, options) {
|
|
|
765
782
|
}
|
|
766
783
|
},
|
|
767
784
|
async confirmCode(code2) {
|
|
785
|
+
const offer = state.contactCode;
|
|
768
786
|
const person = user;
|
|
769
|
-
if (!
|
|
787
|
+
if (!deviceSecret || !offer || offer.kind === "id" && !person) return { ok: false, code: "not_found" };
|
|
770
788
|
try {
|
|
789
|
+
if (offer.kind !== "id") {
|
|
790
|
+
const result2 = await backend.call("confirmEmailCode", { ...args(), code: code2 });
|
|
791
|
+
if (!result2.ok) return result2;
|
|
792
|
+
emailCodeSent = null;
|
|
793
|
+
emit2();
|
|
794
|
+
return { ok: true };
|
|
795
|
+
}
|
|
771
796
|
const result = await backend.call("confirmCode", { ...args(), userId: person.id, code: code2 });
|
|
772
797
|
if (!result.ok) return result;
|
|
773
|
-
|
|
798
|
+
idCode = null;
|
|
774
799
|
emit2();
|
|
775
800
|
void sendIdentity();
|
|
776
801
|
return { ok: true };
|
|
@@ -778,6 +803,17 @@ function createChatStore(backend, options) {
|
|
|
778
803
|
return { ok: false, code: codeOf(error) };
|
|
779
804
|
}
|
|
780
805
|
},
|
|
806
|
+
dismissCode() {
|
|
807
|
+
const offer = state.contactCode;
|
|
808
|
+
if (!offer) return;
|
|
809
|
+
if (offer.kind === "id") idCodeDismissed = true;
|
|
810
|
+
else {
|
|
811
|
+
emailCodeDismissed = emailKey(offer);
|
|
812
|
+
backend.call("dismissEmailCode", args()).catch(() => {
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
emit2();
|
|
816
|
+
},
|
|
781
817
|
async signOut() {
|
|
782
818
|
generation += 1;
|
|
783
819
|
const mine = generation;
|
|
@@ -785,7 +821,10 @@ function createChatStore(backend, options) {
|
|
|
785
821
|
if (mine !== generation) return;
|
|
786
822
|
user = null;
|
|
787
823
|
identified = false;
|
|
788
|
-
|
|
824
|
+
idCode = null;
|
|
825
|
+
idCodeDismissed = false;
|
|
826
|
+
emailCodeSent = null;
|
|
827
|
+
emailCodeDismissed = null;
|
|
789
828
|
emailGiven = false;
|
|
790
829
|
identifying = null;
|
|
791
830
|
identifiedKnown = false;
|
|
@@ -6623,6 +6662,7 @@ var en = {
|
|
|
6623
6662
|
email_saved: "Thanks, we will write to {email}.",
|
|
6624
6663
|
error: "Something went wrong. Try again.",
|
|
6625
6664
|
code_prompt: "Chatted with us on another device? Get a code at {email} to see your conversation here.",
|
|
6665
|
+
code_prompt_earlier: "Wrote to us before signing in? Get a code at {email} to bring that conversation here.",
|
|
6626
6666
|
code_send: "Get the code",
|
|
6627
6667
|
code_label: "Enter the 6-digit code sent to {email}.",
|
|
6628
6668
|
code_submit: "Confirm",
|
|
@@ -6631,6 +6671,7 @@ var en = {
|
|
|
6631
6671
|
code_expired: "This code no longer works. Ask for a new one.",
|
|
6632
6672
|
code_rate_limited: "Too many codes asked for. Try again in an hour.",
|
|
6633
6673
|
code_dismiss: "Not now",
|
|
6674
|
+
code_not_me: "Not me",
|
|
6634
6675
|
attach: "Send a photo",
|
|
6635
6676
|
uploading: "Uploading\u2026",
|
|
6636
6677
|
ready: "Ready",
|
|
@@ -6675,6 +6716,7 @@ var fr = {
|
|
|
6675
6716
|
email_saved: "Merci, nous vous \xE9crirons \xE0 {email}.",
|
|
6676
6717
|
error: "Une erreur est survenue. R\xE9essayez.",
|
|
6677
6718
|
code_prompt: "D\xE9j\xE0 \xE9chang\xE9 avec nous sur un autre appareil ? Recevez un code \xE0 {email} pour retrouver votre conversation ici.",
|
|
6719
|
+
code_prompt_earlier: "Vous nous avez \xE9crit avant de vous connecter ? Recevez un code \xE0 {email} pour retrouver cette conversation ici.",
|
|
6678
6720
|
code_send: "Recevoir le code",
|
|
6679
6721
|
code_label: "Saisissez le code \xE0 6 chiffres envoy\xE9 \xE0 {email}.",
|
|
6680
6722
|
code_submit: "Valider",
|
|
@@ -6683,6 +6725,7 @@ var fr = {
|
|
|
6683
6725
|
code_expired: "Ce code ne fonctionne plus. Demandez-en un nouveau.",
|
|
6684
6726
|
code_rate_limited: "Trop de codes demand\xE9s. R\xE9essayez dans une heure.",
|
|
6685
6727
|
code_dismiss: "Plus tard",
|
|
6728
|
+
code_not_me: "Ce n\u2019est pas moi",
|
|
6686
6729
|
attach: "Envoyer une photo",
|
|
6687
6730
|
uploading: "Envoi\u2026",
|
|
6688
6731
|
ready: "Pr\xEAt",
|
|
@@ -6947,6 +6990,7 @@ var CODE_LENGTH = 6;
|
|
|
6947
6990
|
var CODE_MAX_AGE_SECONDS = 15 * 60;
|
|
6948
6991
|
var TEST_EMAIL_DOMAIN = "zean-test.local";
|
|
6949
6992
|
var DEV_OPERATOR_EMAIL = `operator@${TEST_EMAIL_DOMAIN}`;
|
|
6993
|
+
var MOBILE_AUTH_CODE_TTL_MS = 2 * 6e4;
|
|
6950
6994
|
|
|
6951
6995
|
// src/components/ContactCodeCard.tsx
|
|
6952
6996
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
@@ -6976,7 +7020,8 @@ function ContactCodeCard({ code: code2, onDismiss }) {
|
|
|
6976
7020
|
setBusy(false);
|
|
6977
7021
|
if (!result.ok) setError(errorOf(result.code));
|
|
6978
7022
|
};
|
|
6979
|
-
const
|
|
7023
|
+
const prompt = code2.kind === "earlier" ? t.code_prompt_earlier : t.code_prompt;
|
|
7024
|
+
const label = format(code2.sent ? t.code_label : prompt, { email: code2.email });
|
|
6980
7025
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react_native9.View, { style: [styles5.card, { backgroundColor: colors.surface }], children: [
|
|
6981
7026
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Text, { style: [styles5.prompt, { color: colors.text }], children: label }),
|
|
6982
7027
|
code2.sent ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react_native9.View, { style: styles5.row, children: [
|
|
@@ -7021,7 +7066,7 @@ function ContactCodeCard({ code: code2, onDismiss }) {
|
|
|
7021
7066
|
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Text, { style: [styles5.buttonText, { color: colors.primaryForeground }], children: t.code_send })
|
|
7022
7067
|
}
|
|
7023
7068
|
),
|
|
7024
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Pressable, { onPress: onDismiss, accessibilityRole: "button", hitSlop: 8, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Text, { style: [styles5.link, { color: colors.muted }], children: t.code_dismiss }) })
|
|
7069
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Pressable, { onPress: onDismiss, accessibilityRole: "button", hitSlop: 8, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Text, { style: [styles5.link, { color: colors.muted }], children: code2.kind === "id" ? t.code_dismiss : t.code_not_me }) })
|
|
7025
7070
|
] }),
|
|
7026
7071
|
error && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Text, { accessibilityLiveRegion: "polite", style: [styles5.error, { color: colors.danger }], children: error }),
|
|
7027
7072
|
code2.sent && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Pressable, { onPress: () => void handleSend(), disabled: busy, accessibilityRole: "button", hitSlop: 8, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native9.Text, { style: [styles5.link, { color: colors.primaryText }, busy && styles5.dim], children: t.code_resend }) })
|
|
@@ -8032,18 +8077,17 @@ var styles15 = import_react_native21.StyleSheet.create({
|
|
|
8032
8077
|
// src/components/ChatScreen.tsx
|
|
8033
8078
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
8034
8079
|
function ChatScreen({ state, insets, onClose }) {
|
|
8035
|
-
const { t, colors } = useChatContext();
|
|
8080
|
+
const { chat: chat2, t, colors } = useChatContext();
|
|
8036
8081
|
const rootRef = (0, import_react15.useRef)(null);
|
|
8037
8082
|
const keyboard = useKeyboardOverlap(rootRef);
|
|
8038
8083
|
const connectionLost = useConnectionLost(state.connected);
|
|
8039
|
-
const [codeDismissed, setCodeDismissed] = (0, import_react15.useState)(false);
|
|
8040
8084
|
const app = state.app;
|
|
8041
8085
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_react_native22.View, { ref: rootRef, style: [styles16.screen, { backgroundColor: colors.background, paddingBottom: keyboard }], children: [
|
|
8042
8086
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ChatHeader, { app, online: state.online, topInset: insets.top, onClose }),
|
|
8043
8087
|
connectionLost && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_native22.View, { style: styles16.notice, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ChatNotice, { children: t.reconnecting }) }),
|
|
8044
8088
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(MessageList, { state }),
|
|
8045
8089
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_react_native22.View, { style: [styles16.footer, { paddingBottom: 8 + (keyboard > 0 ? 0 : insets.bottom) }], children: [
|
|
8046
|
-
state.contactCode &&
|
|
8090
|
+
state.contactCode && state.status === "ready" && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ContactCodeCard, { code: state.contactCode, onDismiss: chat2.dismissCode }),
|
|
8047
8091
|
state.status === "blocked" ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ChatNotice, { children: t.blocked }) : state.status === "unavailable" ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ChatNotice, { children: t.unavailable }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Composer, {}),
|
|
8048
8092
|
app.showBadge && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(PoweredBy, {})
|
|
8049
8093
|
] })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zean-chat/react-native",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "In-app support chat for React Native and Expo, iOS and Android. Pure JS, no native module. A free Intercom, Crisp and Zendesk mobile SDK alternative.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
|
@@ -91,18 +91,18 @@
|
|
|
91
91
|
},
|
|
92
92
|
"devDependencies": {
|
|
93
93
|
"@jest/globals": "29.7.0",
|
|
94
|
-
"@react-native/babel-preset": "0.
|
|
95
|
-
"@react-native/jest-preset": "0.
|
|
94
|
+
"@react-native/babel-preset": "0.88.0",
|
|
95
|
+
"@react-native/jest-preset": "0.88.0",
|
|
96
96
|
"@testing-library/react-native": "14.1.0",
|
|
97
|
-
"@types/react": "19.
|
|
97
|
+
"@types/react": "19.3.0",
|
|
98
98
|
"@zean/config": "*",
|
|
99
99
|
"@zean/sdk-core": "*",
|
|
100
100
|
"@zean/shared": "*",
|
|
101
101
|
"babel-jest": "29.7.0",
|
|
102
102
|
"convex": "1.46.0",
|
|
103
103
|
"jest": "29.7.0",
|
|
104
|
-
"react": "19.
|
|
105
|
-
"react-native": "0.
|
|
104
|
+
"react": "19.3.0",
|
|
105
|
+
"react-native": "0.88.0",
|
|
106
106
|
"test-renderer": "1.3.1",
|
|
107
107
|
"typescript": "6.0.3",
|
|
108
108
|
"vitest": "4.1.11"
|