@robono/messaging-react-native 0.23.0 → 0.25.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 (132) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +157 -4
  3. package/RobonoMessagingRuntime.podspec +16 -0
  4. package/SBOM.spdx.json +2709 -813
  5. package/android/build.gradle +10 -0
  6. package/android/src/main/AndroidManifest.xml +1 -0
  7. package/android/src/main/java/com/robono/messaging/RobonoBackupCrypto.java +27 -0
  8. package/android/src/main/java/com/robono/messaging/RobonoBackupGoogle.java +76 -0
  9. package/android/src/main/java/com/robono/messaging/RobonoHistoryStore.java +173 -0
  10. package/android/src/main/java/com/robono/messaging/RobonoMessagingPackage.java +11 -0
  11. package/app.plugin.cjs +22 -3
  12. package/cloudkit/backup-schema.ckdb +13 -0
  13. package/dist/account-pages.d.ts +51 -0
  14. package/dist/account-pages.js +65 -0
  15. package/dist/account.d.ts +6 -2
  16. package/dist/account.js +37 -11
  17. package/dist/attachment-preview.d.ts +11 -10
  18. package/dist/attachment-preview.js +15 -12
  19. package/dist/backup-background.d.ts +25 -0
  20. package/dist/backup-background.js +71 -0
  21. package/dist/backup-base64.d.ts +3 -0
  22. package/dist/backup-base64.js +41 -0
  23. package/dist/backup-google-authorization.d.ts +23 -0
  24. package/dist/backup-google-authorization.js +95 -0
  25. package/dist/backup.d.ts +24 -0
  26. package/dist/backup.js +202 -0
  27. package/dist/brand.js +4 -4
  28. package/dist/bubble-design.d.ts +1 -1
  29. package/dist/bubble-design.js +5 -3
  30. package/dist/cloudkit-backup.d.ts +14 -0
  31. package/dist/cloudkit-backup.js +193 -0
  32. package/dist/contact-directory.d.ts +3 -1
  33. package/dist/contact-directory.js +3 -3
  34. package/dist/conversation-details.js +2 -2
  35. package/dist/customization.d.ts +1 -0
  36. package/dist/delivery-bar.d.ts +3 -2
  37. package/dist/delivery-bar.js +7 -4
  38. package/dist/delivery-notice.d.ts +9 -0
  39. package/dist/delivery-notice.js +15 -0
  40. package/dist/directory-navigation.d.ts +25 -0
  41. package/dist/directory-navigation.js +69 -0
  42. package/dist/expo-backup-background.d.ts +17 -0
  43. package/dist/expo-backup-background.js +57 -0
  44. package/dist/expo-backup-cloudkit.d.ts +6 -0
  45. package/dist/expo-backup-cloudkit.js +11 -0
  46. package/dist/expo-backup-crypto.d.ts +3 -0
  47. package/dist/expo-backup-crypto.js +17 -0
  48. package/dist/expo-backup-google.d.ts +7 -0
  49. package/dist/expo-backup-google.js +16 -0
  50. package/dist/expo-backup-network.d.ts +8 -0
  51. package/dist/expo-backup-network.js +18 -0
  52. package/dist/expo-backup-passkeys.d.ts +14 -0
  53. package/dist/expo-backup-passkeys.js +46 -0
  54. package/dist/expo-backup-settings.d.ts +4 -0
  55. package/dist/expo-backup-settings.js +59 -0
  56. package/dist/expo-backup.d.ts +14 -0
  57. package/dist/expo-backup.js +22 -0
  58. package/dist/expo-bridge.d.ts +2 -0
  59. package/dist/expo-bridge.js +3 -1
  60. package/dist/expo-cache.js +20 -1
  61. package/dist/expo-device-history.d.ts +24 -0
  62. package/dist/expo-device-history.js +88 -0
  63. package/dist/expo-durable-history.d.ts +26 -0
  64. package/dist/expo-durable-history.js +56 -0
  65. package/dist/expo-history-backup.d.ts +3 -0
  66. package/dist/expo-history-backup.js +79 -0
  67. package/dist/expo-history-maintenance.d.ts +4 -0
  68. package/dist/expo-history-maintenance.js +23 -0
  69. package/dist/expo-history-previews.d.ts +5 -0
  70. package/dist/expo-history-previews.js +57 -0
  71. package/dist/expo-history.d.ts +1 -1
  72. package/dist/expo-history.js +2 -2
  73. package/dist/expo-inbox-preferences.d.ts +3 -0
  74. package/dist/expo-inbox-preferences.js +9 -0
  75. package/dist/expo-media.d.ts +2 -0
  76. package/dist/expo-media.js +18 -24
  77. package/dist/expo-messenger.d.ts +8 -0
  78. package/dist/expo-messenger.js +27 -11
  79. package/dist/expo-notifications.d.ts +17 -1
  80. package/dist/expo-notifications.js +36 -16
  81. package/dist/expo-outbox.d.ts +2 -0
  82. package/dist/expo-outbox.js +1 -1
  83. package/dist/expo-oversight.d.ts +15 -0
  84. package/dist/expo-oversight.js +15 -0
  85. package/dist/expo-reviews.d.ts +6 -0
  86. package/dist/expo-reviews.js +145 -0
  87. package/dist/expo-screen.js +62 -28
  88. package/dist/expo-thumbnails.d.ts +6 -2
  89. package/dist/expo-thumbnails.js +73 -8
  90. package/dist/expo.d.ts +14 -0
  91. package/dist/expo.js +12 -0
  92. package/dist/forward.js +2 -2
  93. package/dist/header-calls.js +1 -1
  94. package/dist/header-colors.d.ts +5 -0
  95. package/dist/header-colors.js +7 -0
  96. package/dist/inbox-search.d.ts +1 -1
  97. package/dist/inbox-search.js +7 -3
  98. package/dist/inbox.d.ts +6 -2
  99. package/dist/inbox.js +27 -55
  100. package/dist/index.d.ts +14 -6
  101. package/dist/index.js +195 -78
  102. package/dist/linked-apps.d.ts +45 -0
  103. package/dist/linked-apps.js +40 -0
  104. package/dist/loading-messages.d.ts +5 -0
  105. package/dist/loading-messages.js +10 -0
  106. package/dist/media-access.d.ts +8 -0
  107. package/dist/media-access.js +6 -1
  108. package/dist/media-controller.d.ts +2 -0
  109. package/dist/native-history-authorization.d.ts +4 -0
  110. package/dist/native-history-authorization.js +69 -0
  111. package/dist/native-history-backup.d.ts +16 -0
  112. package/dist/native-history-backup.js +144 -0
  113. package/dist/native-history.d.ts +14 -0
  114. package/dist/native-history.js +186 -0
  115. package/dist/native-outbox.d.ts +2 -0
  116. package/dist/oversight-session.d.ts +4 -0
  117. package/dist/oversight-session.js +14 -0
  118. package/dist/popup.d.ts +6 -3
  119. package/dist/popup.js +6 -6
  120. package/dist/preview-layout.d.ts +12 -0
  121. package/dist/preview-layout.js +102 -0
  122. package/dist/recent-media.js +2 -1
  123. package/dist/reviews.d.ts +19 -0
  124. package/dist/reviews.js +231 -0
  125. package/dist/scheduled.js +6 -6
  126. package/dist/search.js +18 -8
  127. package/ios/RobonoBackupCloudKit.m +96 -0
  128. package/ios/RobonoBackupCrypto.m +30 -0
  129. package/ios/RobonoHistoryStore.m +170 -0
  130. package/package.json +34 -7
  131. package/plugin/backup-expiration.cjs +23 -0
  132. package/plugin/prepare-native.cjs +12 -0
@@ -0,0 +1,4 @@
1
+ import { type MessagingClient, type MessagingRequest } from '@robono/messaging';
2
+ /** Own clients inside the effect lifecycle, including React Strict Mode's
3
+ * setup/cleanup/setup cycle. Never reuse a disposed reviewer session. */
4
+ export declare function useMessagingOversightSession(request: MessagingRequest, reviewerId: string, subjectId: string, conversationId: string): MessagingClient | null;
@@ -0,0 +1,14 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { createMessagingOversightClient } from '@robono/messaging';
3
+ /** Own clients inside the effect lifecycle, including React Strict Mode's
4
+ * setup/cleanup/setup cycle. Never reuse a disposed reviewer session. */
5
+ export function useMessagingOversightSession(request, reviewerId, subjectId, conversationId) {
6
+ const [session, setSession] = useState(null);
7
+ useEffect(() => {
8
+ const client = createMessagingOversightClient({ request, reviewerId, subjectId, pollIntervalMs: 5000 });
9
+ setSession({ request, reviewerId, subjectId, conversationId, client });
10
+ void client.open(conversationId).catch(() => { });
11
+ return () => client.dispose();
12
+ }, [request, reviewerId, subjectId, conversationId]);
13
+ return session?.request === request && session.reviewerId === reviewerId && session.subjectId === subjectId && session.conversationId === conversationId ? session.client : null;
14
+ }
package/dist/popup.d.ts CHANGED
@@ -19,8 +19,10 @@ export declare const messagingPopupColors: {
19
19
  incoming: string;
20
20
  };
21
21
  /** One title/close row for forms, menus and expanded content. */
22
- export declare function MessagingPopupHeader({ title, foreground, onClose, closeLabel, disabled, back }: {
22
+ export declare function MessagingPopupHeader({ title, description, secondary, foreground, onClose, closeLabel, disabled, back }: {
23
23
  title: string;
24
+ description?: string;
25
+ secondary?: string;
24
26
  foreground: string;
25
27
  onClose: () => void;
26
28
  closeLabel?: string;
@@ -56,8 +58,8 @@ export declare function MessagingMenuSurface({ visible, onClose, onDismiss, chil
56
58
  onDismiss?: () => void;
57
59
  children: (rect: MenuRect) => React.ReactNode;
58
60
  }): React.JSX.Element;
59
- /** Content panels occupy the area below the persistent header; confirmations stay compact. */
60
- export declare function MessagingPopup({ screen, children, onClose, background, form, visible, onDismiss, expanded, bottomPadding, title, foreground, closeLabel, closeDisabled, contentWidth, headerBack, withinChat, compact, mediaSurface }: {
61
+ /** Content panels start directly below the Messenger header; confirmations stay compact. */
62
+ export declare function MessagingPopup({ screen, children, onClose, background, form, visible, onDismiss, expanded, bottomPadding, title, description, foreground, closeLabel, closeDisabled, contentWidth, headerBack, withinChat, compact, mediaSurface }: {
61
63
  screen?: MessagingStyleScreen;
62
64
  mediaSurface?: boolean;
63
65
  compact?: boolean;
@@ -71,6 +73,7 @@ export declare function MessagingPopup({ screen, children, onClose, background,
71
73
  expanded?: boolean;
72
74
  bottomPadding?: number;
73
75
  title?: string;
76
+ description?: string;
74
77
  foreground?: string;
75
78
  closeLabel?: string;
76
79
  closeDisabled?: boolean;
package/dist/popup.js CHANGED
@@ -12,9 +12,9 @@ export const messagingPopupBackdrop = '#000000d9';
12
12
  export { useMessagingPopupColors } from './appearance-context.js';
13
13
  export const messagingPopupColors = { background: '#000000', foreground: '#ffffff', secondary: '#aaaaaa', incoming: '#202020' };
14
14
  /** One title/close row for forms, menus and expanded content. */
15
- export function MessagingPopupHeader({ title, foreground, onClose, closeLabel, disabled = false, back = false }) {
15
+ export function MessagingPopupHeader({ title, description, secondary, foreground, onClose, closeLabel, disabled = false, back = false }) {
16
16
  const { text: uiText } = useRobonoLocale();
17
- return _jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', gap: 8, minHeight: 44, borderBottomWidth: 1, borderBottomColor: foreground + '18' }, children: [_jsx(Text, { accessibilityRole: "header", style: { flex: 1, color: foreground, fontSize: 17, lineHeight: 23, fontWeight: '600' }, children: title }), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: closeLabel ?? uiText('Close {name}', { name: title }), disabled: disabled, accessibilityState: { disabled }, onPress: onClose, style: { width: 44, height: 44, alignItems: 'center', justifyContent: 'center', opacity: disabled ? 0.45 : 1 }, children: _jsx(MessageIcon, { name: back ? 'back' : 'close', color: foreground, size: 24 }) })] });
17
+ return _jsxs(View, { testID: "messaging-popup-header", style: { flexShrink: 0, borderBottomWidth: 1, borderBottomColor: foreground + '18' }, children: [_jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', gap: 8, minHeight: 44 }, children: [_jsx(Text, { accessibilityRole: "header", style: { flex: 1, color: foreground, fontSize: 17, lineHeight: 23, fontWeight: '600' }, children: title }), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: closeLabel ?? uiText('Close {name}', { name: title }), disabled: disabled, accessibilityState: { disabled }, onPress: onClose, style: { width: 44, height: 44, alignItems: 'center', justifyContent: 'center', opacity: disabled ? 0.45 : 1 }, children: _jsx(MessageIcon, { name: back ? 'back' : 'close', color: foreground, size: 24 }) })] }), description && _jsx(Text, { testID: "messaging-popup-description", style: { color: secondary ?? foreground, fontSize: 13, lineHeight: 18, paddingBottom: 8 }, children: description })] });
18
18
  }
19
19
  // Measure the host and its persistent header, including embedded native layouts.
20
20
  const PopupBounds = createContext(null);
@@ -98,8 +98,8 @@ export function MessagingMenuSurface({ visible, onClose, onDismiss, children })
98
98
  return _jsx(Modal, { visible: visible, transparent: true, animationType: "none", onRequestClose: onClose, onDismiss: onDismiss, children: visible ? children({ left: 0, top: 0, width: viewport.width, height: viewport.height }) : null });
99
99
  return _jsx(MessagingPopupLayer, { children: visible && rect ? _jsx(View, { ref: panel, testID: "messaging-menu-surface", style: { position: 'absolute', inset: 0, zIndex: 1000, overflow: 'hidden' }, children: children(rect) }) : null });
100
100
  }
101
- /** Content panels occupy the area below the persistent header; confirmations stay compact. */
102
- export function MessagingPopup({ screen = 'panels', children, onClose, background, form = false, visible = true, onDismiss, expanded = true, bottomPadding, title, foreground, closeLabel, closeDisabled = false, contentWidth, headerBack = false, withinChat = false, compact = false, mediaSurface = false }) {
101
+ /** Content panels start directly below the Messenger header; confirmations stay compact. */
102
+ export function MessagingPopup({ screen = 'panels', children, onClose, background, form = false, visible = true, onDismiss, expanded = true, bottomPadding, title, description, foreground, closeLabel, closeDisabled = false, contentWidth, headerBack = false, withinChat = false, compact = false, mediaSurface = false }) {
103
103
  const appearance = useMessagingAppearance(), panelStyle = appearance?.panels, themeColors = useMessagingPopupColors(undefined, screen);
104
104
  const colors = mediaSurface ? messagingPopupColors : themeColors;
105
105
  const panelRadius = panelStyle?.corners === 'square' ? 0 : panelStyle?.corners === 'soft' ? 8 : undefined, panelPadding = panelStyle?.spacing === 'compact' ? 8 : panelStyle?.spacing === 'relaxed' ? 20 : undefined;
@@ -111,7 +111,7 @@ export function MessagingPopup({ screen = 'panels', children, onClose, backgroun
111
111
  let active = true;
112
112
  // Fabric's Android measureInWindow subtracts the activity's system inset,
113
113
  // while the edge-to-edge modal starts at the screen origin. Page coordinates
114
- // retain that inset and keep the popup below the actual visible header.
114
+ // retain that inset and keep the popup inside the safe Messenger area.
115
115
  const measure = (view, done) => {
116
116
  if (Platform.OS === 'android')
117
117
  view.measure((_x, _y, width, height, x, y) => done(x, y, width, height));
@@ -145,7 +145,7 @@ export function MessagingPopup({ screen = 'panels', children, onClose, backgroun
145
145
  } }; document.addEventListener('keydown', escape, true); return () => document.removeEventListener('keydown', escape, true); }, [visible]);
146
146
  const bounded = Platform.OS !== 'web' && !!bounds;
147
147
  const Frame = Platform.OS === 'ios' && !bounded ? SafeAreaView : View;
148
- const content = _jsx(Frame, { style: [{ flex: 1, backgroundColor: messagingPopupBackdrop }, bounded ? { position: 'absolute', ...(rect ?? { left: 0, top: 0, width: 0, height: 0 }) } : Platform.OS === 'android' ? { paddingTop: safeInsets?.top ?? StatusBar.currentHeight ?? 0, paddingBottom: safeInsets?.bottom ?? 0 } : undefined], children: _jsxs(KeyboardAvoidingView, { testID: "messaging-popup-backdrop", behavior: Platform.OS === 'ios' ? 'padding' : undefined, style: { flex: 1, justifyContent: 'center', alignItems: 'center', padding: compact ? 24 : 8 }, children: [_jsx(Pressable, { accessible: false, onPress: onClose, style: { position: 'absolute', inset: 0 } }), _jsxs(View, { testID: "messaging-popup-panel", accessibilityViewIsModal: true, onAccessibilityEscape: onClose, style: { width: '100%', ...(compact ? { maxWidth: 360, maxHeight: '100%', flexShrink: 1 } : { flex: 1, minHeight: 0 }), backgroundColor: compact && !panelStyle?.background && !appearance?.defaultStyle?.colors?.background && !(screen !== 'main' && appearance?.screenStyles?.[screen]?.colors?.background) ? '#111111' : colors.background, borderRadius: panelRadius ?? (compact ? 20 : 18), paddingHorizontal: panelPadding ?? (compact ? 20 : 8), paddingTop: compact ? 8 : 0, paddingBottom: bottomPadding ?? (compact ? 20 : 4), overflow: 'hidden' }, children: [title && _jsx(MessagingPopupHeader, { title: title, foreground: colors.foreground, onClose: onClose, closeLabel: closeLabel, disabled: closeDisabled, back: headerBack }), contentWidth ? _jsx(View, { style: { ...(compact ? { flexShrink: 1 } : { flex: 1, minHeight: 0 }), width: '100%', maxWidth: contentWidth, alignSelf: 'center', paddingTop: 12 }, children: children }) : children] })] }) });
148
+ const content = _jsx(Frame, { style: [{ flex: 1, backgroundColor: messagingPopupBackdrop }, bounded ? { position: 'absolute', ...(rect ?? { left: 0, top: 0, width: 0, height: 0 }) } : Platform.OS === 'android' ? { paddingTop: safeInsets?.top ?? StatusBar.currentHeight ?? 0, paddingBottom: safeInsets?.bottom ?? 0 } : undefined], children: _jsxs(KeyboardAvoidingView, { testID: "messaging-popup-backdrop", behavior: Platform.OS === 'ios' ? 'padding' : undefined, style: { flex: 1, justifyContent: 'center', alignItems: 'center', paddingHorizontal: compact ? 24 : 8, paddingTop: compact ? 24 : 0, paddingBottom: compact ? 24 : 8 }, children: [_jsx(Pressable, { accessible: false, onPress: onClose, style: { position: 'absolute', inset: 0 } }), _jsxs(View, { testID: "messaging-popup-panel", accessibilityViewIsModal: true, onAccessibilityEscape: onClose, style: { width: '100%', ...(compact ? { maxWidth: 360, maxHeight: '100%', flexShrink: 1 } : { flex: 1, minHeight: 0 }), backgroundColor: compact && !panelStyle?.background && !appearance?.defaultStyle?.colors?.background && !(screen !== 'main' && appearance?.screenStyles?.[screen]?.colors?.background) ? '#111111' : colors.background, borderRadius: panelRadius ?? (compact ? 20 : 18), paddingHorizontal: panelPadding ?? (compact ? 20 : 8), paddingTop: compact ? 8 : 0, paddingBottom: bottomPadding ?? (compact ? 20 : 4), overflow: 'hidden' }, children: [title && _jsx(MessagingPopupHeader, { title: title, description: description, secondary: colors.secondary, foreground: colors.foreground, onClose: onClose, closeLabel: closeLabel, disabled: closeDisabled, back: headerBack }), contentWidth ? _jsx(View, { style: { ...(compact ? { flexShrink: 1 } : { flex: 1, minHeight: 0 }), width: '100%', maxWidth: contentWidth, alignSelf: 'center', paddingTop: 8 }, children: children }) : children] })] }) });
149
149
  const styledContent = appearance ? _jsx(MessagingTypography, { appearance: appearance, screen: screen, children: content }) : content;
150
150
  if (Platform.OS === 'web' && ChatSurface)
151
151
  return _jsx(ChatSurface, { visible: visible, title: title, onDismiss: onDismiss, onClose: onClose, children: styledContent });
@@ -0,0 +1,12 @@
1
+ type Size = {
2
+ width: number;
3
+ height: number;
4
+ };
5
+ /** Read only JPEG header bytes already present in an authorized local preview.
6
+ * No fetch, native decode, Buffer or atob is needed for the first rendered frame.
7
+ * Smaller disk previews can have a different URI from the earlier display copy.
8
+ */
9
+ export declare function localPreviewSize(uri: string): Size | undefined;
10
+ export declare function readPreviewSize(scope: object, key: string, uri: string | undefined, now?: number): Size | undefined;
11
+ export declare function rememberPreviewSize(scope: object, key: string, uri: string, width: number, height: number, now?: number): Size | undefined;
12
+ export {};
@@ -0,0 +1,102 @@
1
+ const scopes = new WeakMap();
2
+ /** Read only JPEG header bytes already present in an authorized local preview.
3
+ * No fetch, native decode, Buffer or atob is needed for the first rendered frame.
4
+ * Smaller disk previews can have a different URI from the earlier display copy.
5
+ */
6
+ export function localPreviewSize(uri) {
7
+ const prefix = 'data:image/jpeg;base64,';
8
+ if (!uri.startsWith(prefix) || uri.length > 300000)
9
+ return;
10
+ const text = uri.slice(prefix.length);
11
+ if (text.length % 4 !== 0 || text.length < 12)
12
+ return;
13
+ const length = text.length / 4 * 3 - (text.endsWith('==') ? 2 : text.endsWith('=') ? 1 : 0);
14
+ const digit = (i) => {
15
+ const c = text.charCodeAt(i);
16
+ return c >= 65 && c <= 90 ? c - 65 : c >= 97 && c <= 122 ? c - 71 : c >= 48 && c <= 57 ? c + 4 : c === 43 ? 62 : c === 47 ? 63 : -1;
17
+ };
18
+ const byte = (i) => {
19
+ if (i < 0 || i >= length)
20
+ return -1;
21
+ const p = Math.floor(i / 3) * 4, r = i % 3, a = digit(p + r), b = digit(p + r + 1);
22
+ if (a < 0 || b < 0)
23
+ return -1;
24
+ return r === 0 ? (a << 2) | (b >> 4) : r === 1 ? ((a & 15) << 4) | (b >> 2) : ((a & 3) << 6) | b;
25
+ };
26
+ const word = (i) => { const a = byte(i), b = byte(i + 1); return a < 0 || b < 0 ? -1 : (a << 8) | b; };
27
+ if (byte(0) !== 255 || byte(1) !== 216)
28
+ return;
29
+ let orientation = 1, size;
30
+ for (let offset = 2, segments = 0; offset + 3 < length && segments++ < 128;) {
31
+ if (byte(offset++) !== 255)
32
+ return;
33
+ while (byte(offset) === 255)
34
+ offset++;
35
+ const marker = byte(offset++);
36
+ if (marker === 217 || marker === 218)
37
+ break;
38
+ const count = word(offset);
39
+ if (count < 2 || offset + count > length)
40
+ return;
41
+ if (marker === 225 && count >= 16 && [69, 120, 105, 102, 0, 0].every((v, i) => byte(offset + 2 + i) === v)) {
42
+ const base = offset + 8, end = offset + count, little = byte(base) === 73 && byte(base + 1) === 73;
43
+ const big = byte(base) === 77 && byte(base + 1) === 77;
44
+ const u16 = (p) => p >= base && p + 2 <= end ? (little ? (byte(p + 1) << 8) | byte(p) : word(p)) : -1;
45
+ const u32 = (p) => p >= base && p + 4 <= end ? (little ? u16(p) + u16(p + 2) * 65536 : u16(p) * 65536 + u16(p + 2)) : -1;
46
+ if ((little || big) && u16(base + 2) === 42) {
47
+ const dir = base + u32(base + 4), entries = u16(dir);
48
+ for (let i = 0; i < Math.min(entries, 128); i++) {
49
+ const p = dir + 2 + i * 12;
50
+ if (p + 12 > end)
51
+ break;
52
+ if (u16(p) === 274 && u16(p + 2) === 3 && u32(p + 4) === 1) {
53
+ const value = u16(p + 8);
54
+ if (value >= 1 && value <= 8)
55
+ orientation = value;
56
+ break;
57
+ }
58
+ }
59
+ }
60
+ }
61
+ if ([192, 193, 194, 195, 197, 198, 199, 201, 202, 203, 205, 206, 207].includes(marker)) {
62
+ if (count < 8)
63
+ return;
64
+ const height = word(offset + 3), width = word(offset + 5);
65
+ if (width <= 0 || height <= 0)
66
+ return;
67
+ size = { width, height };
68
+ }
69
+ offset += count;
70
+ }
71
+ return size && (orientation >= 5 ? { width: size.height, height: size.width } : size);
72
+ }
73
+ // Match the short-lived preview cache. These are layout hints, never media
74
+ // access grants: callers must already have the current authorized preview URI.
75
+ export function readPreviewSize(scope, key, uri, now = Date.now()) {
76
+ if (!uri)
77
+ return;
78
+ const rows = scopes.get(scope), entry = rows?.get(key);
79
+ if (entry && entry.expires <= now)
80
+ rows.delete(key);
81
+ else if (entry?.uri === uri)
82
+ return { width: entry.width, height: entry.height };
83
+ const size = localPreviewSize(uri);
84
+ return size ? rememberPreviewSize(scope, key, uri, size.width, size.height, now) : undefined;
85
+ }
86
+ export function rememberPreviewSize(scope, key, uri, width, height, now = Date.now()) {
87
+ if (!uri || !Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0 || width > 100000 || height > 100000)
88
+ return;
89
+ let rows = scopes.get(scope);
90
+ if (!rows) {
91
+ rows = new Map();
92
+ scopes.set(scope, rows);
93
+ }
94
+ for (const [id, entry] of rows)
95
+ if (entry.expires <= now)
96
+ rows.delete(id);
97
+ rows.delete(key);
98
+ rows.set(key, { uri, width, height, expires: now + 60000 });
99
+ while (rows.size > 60)
100
+ rows.delete(rows.keys().next().value);
101
+ return { width, height };
102
+ }
@@ -39,7 +39,8 @@ export class RecentMessagingMedia {
39
39
  download: async (message, context) => {
40
40
  if (context.signal.aborted)
41
41
  throw Error('Cancelled.');
42
- this.prioritize(context.signal, key(message));
42
+ if (context.purpose !== 'preview')
43
+ this.prioritize(context.signal, key(message));
43
44
  if (context.reauthorize)
44
45
  return this.source.download(message, context);
45
46
  const id = key(message), entry = this.entries.get(id);
@@ -0,0 +1,19 @@
1
+ import { type MessagingAppearance } from '@robono/messaging';
2
+ import React from "react";
3
+ import { MessageReviewClient } from "@robono/messaging";
4
+ export interface MessagingReviewInboxProps {
5
+ client: MessageReviewClient;
6
+ /** Optional notification/deep-link target. It is fetched with current reviewer authorization. */
7
+ reviewId?: string;
8
+ appearance?: MessagingAppearance;
9
+ name?: (id: string) => string;
10
+ conversationName: (conversationId: string, subjectId: string) => string;
11
+ renderMedia?: (input: {
12
+ url: string;
13
+ kind: string;
14
+ label: string;
15
+ foreground: string;
16
+ file?: import('@robono/messaging').MessageMedia;
17
+ }) => React.ReactNode;
18
+ }
19
+ export declare function MessagingReviewInbox(props: MessagingReviewInboxProps): React.JSX.Element;
@@ -0,0 +1,231 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { messageReviewSubject, messageReviewSender, messagingContrastInk, defaultMessagingSettings } from '@robono/messaging';
3
+ import { useMessagingPopupColors, useMessagingAppearance } from './appearance-context.js';
4
+ import { Text, MessagingTypography } from './typography.js';
5
+ import { useEffect, useRef, useState } from "react";
6
+ import { AppState, ActivityIndicator, Image, Pressable, ScrollView, View, } from "react-native";
7
+ const reviewStateLabel = (state) => ({
8
+ pending: "Waiting for review",
9
+ approved: "Approved — waiting for delivery",
10
+ delivered: "Delivered",
11
+ rejected: "Not approved",
12
+ expired: "Expired",
13
+ cancelled: "Cancelled",
14
+ })[state];
15
+ /** Shared authorized-review inbox. Completed decisions have no approve/reject controls.
16
+ * Media URLs live only while the selected review remains open. */
17
+ const defaultAppearance = defaultMessagingSettings().appearance;
18
+ export function MessagingReviewInbox(props) {
19
+ const inherited = useMessagingAppearance(), appearance = props.appearance ?? inherited ?? defaultAppearance;
20
+ return _jsx(MessagingTypography, { appearance: appearance, screen: "panels", children: _jsx(MessageReviewInboxContent, { ...props, appearance: appearance }) });
21
+ }
22
+ function MessageReviewInboxContent({ client, reviewId, appearance, name = (id) => id, conversationName, renderMedia }) {
23
+ const colors = useMessagingPopupColors(appearance);
24
+ const [imageReady, setImageReady] = useState(false);
25
+ const [items, setItems] = useState([]), [selected, setSelected] = useState(null), [completed, setCompleted] = useState(false), [media, setMedia] = useState(null), [error, setError] = useState(""), [busy, setBusy] = useState(false), [nextCursor, setNextCursor] = useState(null);
26
+ const generation = useRef(0), activeClient = useRef(client);
27
+ const load = async (history = completed, append = false) => {
28
+ const g = ++generation.current;
29
+ setBusy(true);
30
+ setError("");
31
+ setMedia(null);
32
+ setSelected(null);
33
+ try {
34
+ const page = await client.list(history, append ? nextCursor ?? undefined : undefined);
35
+ if (g === generation.current) {
36
+ setItems((old) => append ? [...old, ...page.items] : page.items);
37
+ setNextCursor(page.nextCursor ??
38
+ (page.items.length === 50 ? page.items.at(-1).id : null));
39
+ }
40
+ }
41
+ catch {
42
+ if (g === generation.current) {
43
+ setItems([]);
44
+ setNextCursor(null);
45
+ setError("Reviews could not be loaded. Refresh and try again.");
46
+ }
47
+ }
48
+ finally {
49
+ if (g === generation.current)
50
+ setBusy(false);
51
+ }
52
+ };
53
+ useEffect(() => {
54
+ activeClient.current = client;
55
+ setItems([]);
56
+ setNextCursor(null);
57
+ if (reviewId)
58
+ void open({ id: reviewId });
59
+ else
60
+ void load();
61
+ return () => {
62
+ generation.current++;
63
+ };
64
+ }, [client, reviewId]);
65
+ useEffect(() => {
66
+ if (!selected)
67
+ return;
68
+ const id = selected.id, g = generation.current;
69
+ const refresh = setInterval(() => {
70
+ void client.get(id).then((latest) => {
71
+ if (g !== generation.current)
72
+ return;
73
+ if (latest.revision !== selected.revision ||
74
+ latest.state !== selected.state) {
75
+ setSelected(latest);
76
+ setMedia(null);
77
+ }
78
+ }).catch(() => {
79
+ if (g === generation.current) {
80
+ setSelected(null);
81
+ setMedia(null);
82
+ setItems([]);
83
+ setNextCursor(null);
84
+ setError("This review is no longer available to you.");
85
+ }
86
+ });
87
+ }, 5000);
88
+ const background = AppState.addEventListener("change", (state) => {
89
+ if (state !== "active")
90
+ setMedia(null);
91
+ });
92
+ return () => {
93
+ clearInterval(refresh);
94
+ background.remove();
95
+ };
96
+ }, [client, selected]);
97
+ const open = async (item) => {
98
+ const g = ++generation.current;
99
+ setSelected(null);
100
+ setMedia(null);
101
+ setBusy(true);
102
+ setError("");
103
+ try {
104
+ const latest = await client.get(item.id);
105
+ if (g !== generation.current)
106
+ return;
107
+ setSelected(latest);
108
+ }
109
+ catch {
110
+ if (g === generation.current) {
111
+ setItems([]);
112
+ setNextCursor(null);
113
+ setError("This review is no longer available to you.");
114
+ }
115
+ }
116
+ finally {
117
+ if (g === generation.current)
118
+ setBusy(false);
119
+ }
120
+ };
121
+ const preview = async () => {
122
+ if (!selected)
123
+ return;
124
+ const g = generation.current;
125
+ setBusy(true);
126
+ setError("");
127
+ try {
128
+ const result = await client.media(selected.id);
129
+ if (g !== generation.current)
130
+ return;
131
+ if (result.revision !== selected.revision ||
132
+ result.digest !== selected.digest)
133
+ throw Error("Changed");
134
+ setMedia(result);
135
+ setImageReady(false);
136
+ }
137
+ catch {
138
+ if (g === generation.current) {
139
+ setError("This attachment could not be opened. Refresh the review before deciding.");
140
+ }
141
+ }
142
+ finally {
143
+ if (g === generation.current)
144
+ setBusy(false);
145
+ }
146
+ };
147
+ const decide = async (decision) => {
148
+ if (!selected)
149
+ return;
150
+ setBusy(true);
151
+ setError("");
152
+ const g = generation.current;
153
+ try {
154
+ let result = decision === "release"
155
+ ? selected
156
+ : await client.decide(selected, decision);
157
+ if (g !== generation.current)
158
+ return;
159
+ setSelected(result);
160
+ setMedia(null);
161
+ if (decision !== "reject") {
162
+ result = await client.release(result.id);
163
+ if (g !== generation.current)
164
+ return;
165
+ setSelected(result);
166
+ }
167
+ setItems((old) => old.map((x) => x.id === result.id ? result : x));
168
+ }
169
+ catch {
170
+ if (g === generation.current) {
171
+ setError(decision === "reject"
172
+ ? "The decision could not be confirmed. Refresh before trying again."
173
+ : "The message was not confirmed delivered. Refresh to see its current state before trying again.");
174
+ }
175
+ }
176
+ finally {
177
+ if (g === generation.current)
178
+ setBusy(false);
179
+ }
180
+ };
181
+ const button = (label, onPress, primary = false) => (_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: label, disabled: busy, onPress: onPress, style: {
182
+ padding: 12,
183
+ minHeight: 44,
184
+ borderWidth: 1,
185
+ borderColor: primary ? colors.accent : colors.secondary,
186
+ backgroundColor: primary ? colors.accent : 'transparent',
187
+ borderRadius: 8,
188
+ margin: 4,
189
+ opacity: busy ? .5 : 1,
190
+ }, children: _jsx(Text, { style: { color: primary ? messagingContrastInk(colors.accent) : colors.foreground, fontWeight: primary ? '700' : '400' }, children: label }) }));
191
+ // A new authenticated client must never render the previous account's list
192
+ // during the effect/loading transition.
193
+ if (activeClient.current !== client)
194
+ return null;
195
+ return (_jsxs(ScrollView, { testID: "message-review-inbox", style: { backgroundColor: colors.background }, contentContainerStyle: { padding: 16, gap: 12 }, children: [_jsx(Text, { accessibilityRole: "header", style: { fontSize: 22, fontWeight: "700", color: colors.foreground }, children: selected ? 'Review message' : 'Message reviews' }), !selected && _jsx(Text, { style: { color: colors.secondary }, children: "Messages stay private until an authorized reviewer approves delivery." }), !selected && _jsxs(View, { style: { flexDirection: "row", flexWrap: "wrap" }, children: [button("Pending", () => {
196
+ setCompleted(false);
197
+ void load(false);
198
+ }, !completed), button("Completed", () => {
199
+ setCompleted(true);
200
+ void load(true);
201
+ }, completed), button("Refresh", () => void load())] }), !!error && (_jsx(Text, { accessibilityRole: "alert", style: { color: colors.danger }, children: error })), selected
202
+ ? (_jsxs(View, { testID: "selected-message-review", style: { gap: 12 }, children: [button("Back to reviews", () => {
203
+ void load();
204
+ }), _jsxs(Text, { style: { color: colors.foreground, fontWeight: "700" }, children: ["Message from ", name(messageReviewSender(selected))] }), _jsxs(Text, { style: { color: colors.secondary }, children: ["To ", selected.direction === 'incoming' ? name(messageReviewSubject(selected)) : conversationName(selected.conversationId, messageReviewSubject(selected))] }), !!selected.content.text && _jsx(Text, { selectable: true, style: { color: colors.foreground }, children: selected.content.text }), selected.content.media && (_jsxs(_Fragment, { children: [_jsx(Text, { style: { color: colors.secondary }, children: selected.content.media.fileName }), ["pending", "approved"].includes(selected.state) &&
205
+ button("Open attachment", () => void preview())] })), media && (media.kind === "image"
206
+ ? (_jsxs(View, { style: { height: 240, width: '100%' }, children: [_jsx(Image, { accessibilityLabel: "Held photo", accessibilityState: { busy: !imageReady }, onLoad: () => setImageReady(true), onError: () => { setImageReady(true); setError('This photo could not be displayed. Reopen the attachment to try again.'); }, source: { uri: media.url }, style: { height: 240, width: "100%", resizeMode: "contain" } }), !imageReady && _jsx(ActivityIndicator, { color: colors.accent, style: { position: 'absolute', alignSelf: 'center', top: 100 } })] }))
207
+ : renderMedia?.({
208
+ ...media,
209
+ file: selected.content.media,
210
+ label: selected.content.media?.fileName ?? "Held attachment", foreground: colors.foreground,
211
+ }) ?? (_jsx(Text, { children: "Open this review in a supported media viewer before approving." }))), _jsx(Text, { testID: "review-state", style: { color: colors.secondary }, children: selected.state === "pending"
212
+ ? "Waiting for your decision"
213
+ : selected.state === "approved"
214
+ ? "Approved — waiting for delivery"
215
+ : selected.state === "delivered"
216
+ ? "Delivered"
217
+ : selected.state === "rejected"
218
+ ? "Not approved"
219
+ : "Expired" }), selected.state === "pending" && (_jsxs(View, { style: { flexDirection: "row", flexWrap: "wrap" }, children: [button("Approve", () => void decide("approve"), true), button("Reject", () => void decide("reject"))] })), selected.state === "approved" &&
220
+ button("Retry delivery", () => void decide("release"))] }))
221
+ : (_jsxs(_Fragment, { children: [items.map((item) => (_jsxs(Pressable, { testID: "review-item-" + item.id, accessibilityRole: "button", accessibilityLabel: "Review message from " + name(messageReviewSender(item)), disabled: busy, onPress: () => void open(item), style: {
222
+ padding: 16,
223
+ borderWidth: 1,
224
+ borderColor: colors.foreground + "22",
225
+ backgroundColor: colors.background,
226
+ borderRadius: 8,
227
+ gap: 5,
228
+ }, children: [_jsxs(Text, { style: { color: colors.foreground, fontWeight: "600" }, children: [name(messageReviewSender(item)), " \u2192", " ", item.direction === 'incoming' ? name(messageReviewSubject(item)) : conversationName(item.conversationId, messageReviewSubject(item))] }), _jsx(Text, { numberOfLines: 2, style: { color: colors.secondary }, children: item.content.text ?? item.content.media?.fileName ??
229
+ "Message" }), _jsx(Text, { style: { color: colors.secondary }, children: reviewStateLabel(item.state) })] }, item.id))), !busy && !items.length && (_jsxs(Text, { style: { color: colors.secondary }, children: ["No ", completed ? "completed" : "pending", " reviews."] })), nextCursor &&
230
+ button("Load more", () => void load(completed, true))] }))] }));
231
+ }
package/dist/scheduled.js CHANGED
@@ -3,7 +3,7 @@ import { messagingContrastInk } from '@robono/messaging';
3
3
  import { Text, TextInput } from './typography.js';
4
4
  import { useRobonoLocale } from './localization.js';
5
5
  import { useEffect, useRef, useState } from 'react';
6
- import { Pressable, ScrollView, View } from 'react-native';
6
+ import { ActivityIndicator, Pressable, ScrollView, View } from 'react-native';
7
7
  import { MessagingPopup, useMessagingPopupColors } from './popup.js';
8
8
  const pad = (n) => String(n).padStart(2, '0');
9
9
  /** Same bounded popup as the other Messenger tools; all dates are shown locally. */
@@ -38,10 +38,10 @@ export function ScheduleTimePicker({ initial, retryAt, onSave, onClose, accent,
38
38
  onSave(value.toISOString());
39
39
  };
40
40
  if (retryAt)
41
- return _jsx(MessagingPopup, { screen: "schedule", title: uiText("Confirm scheduled message"), onClose: () => { if (!busy)
42
- onClose(); }, closeDisabled: busy, background: colors.background, contentWidth: 420, children: _jsxs(View, { style: { padding: 12, gap: 16 }, children: [_jsx(Text, { style: { color: colors.foreground, fontSize: 17 }, children: uiText("The last attempt could not be confirmed. Retry to check it without creating another message.") }), _jsx(Text, { style: { color: colors.secondary, fontSize: 16 }, children: new Date(retryAt).toLocaleString(uiLocale) }), !!error && _jsx(Text, { accessibilityRole: "alert", style: { color: colors.foreground }, children: error }), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Retry scheduling"), disabled: busy, onPress: () => onSave(retryAt), style: { minHeight: 46, borderRadius: 12, justifyContent: 'center', alignItems: 'center', backgroundColor: accent, opacity: busy ? .5 : 1 }, children: _jsx(Text, { style: { fontSize: 16, color: messagingContrastInk(accent), fontWeight: '600' }, children: busy ? uiText("Checking…") : uiText("Retry scheduling") }) })] }) });
43
- return _jsxs(MessagingPopup, { screen: "schedule", title: title, onClose: () => { if (!busy)
44
- onClose(); }, closeDisabled: busy, background: colors.background, contentWidth: 420, children: [_jsxs(ScrollView, { keyboardShouldPersistTaps: "handled", contentContainerStyle: { padding: 12, gap: 12 }, children: [_jsx(Text, { style: { color: colors.foreground, fontSize: 17 }, children: uiText("Choose when this message should be sent.") }), _jsxs(View, { style: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }, children: [_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Previous month"), disabled: busy || first <= today, onPress: () => setMonth(new Date(month.getFullYear(), month.getMonth() - 1, 1)), style: { padding: 12 }, children: _jsx(Text, { style: { color: accent, fontSize: 24 }, children: "\u2039" }) }), _jsx(Text, { style: { color: colors.foreground, fontSize: 18, fontWeight: '600' }, children: month.toLocaleDateString(uiLocale, { month: 'long', year: 'numeric' }) }), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Next month"), disabled: busy || new Date(month.getFullYear(), month.getMonth() + 1, 1) > end, onPress: () => setMonth(new Date(month.getFullYear(), month.getMonth() + 1, 1)), style: { padding: 12 }, children: _jsx(Text, { style: { color: accent, fontSize: 24 }, children: "\u203A" }) })] }), _jsxs(View, { style: { flexDirection: 'row', flexWrap: 'wrap' }, children: [Array.from({ length: 7 }, (_, i) => new Intl.DateTimeFormat(uiLocale, { weekday: 'narrow' }).format(new Date(2026, 0, 4 + i))).map((day, i) => _jsx(Text, { style: { width: '14.285%', textAlign: 'center', color: colors.secondary, paddingBottom: 8 }, children: day }, 'week' + i)), Array.from({ length: first.getDay() }, (_, i) => _jsx(View, { style: { width: '14.285%' } }, 'blank' + i)), Array.from({ length: days }, (_, i) => { const d = new Date(month.getFullYear(), month.getMonth(), i + 1), selected = d.toDateString() === date.toDateString(), disabled = busy || d < today || d > end; return _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: d.toLocaleDateString(uiLocale, { weekday: 'long', month: 'long', day: 'numeric' }), accessibilityState: { selected, disabled }, disabled: disabled, onPress: () => choose(d), style: { width: '14.285%', height: 44, alignItems: 'center', justifyContent: 'center', borderRadius: 22, backgroundColor: selected ? accent + '30' : 'transparent', opacity: disabled ? .3 : 1 }, children: _jsx(Text, { style: { fontSize: 17, color: selected ? accent : colors.foreground, fontWeight: selected ? '700' : '400' }, children: i + 1 }) }, i); })] }), _jsxs(View, { style: { flexDirection: 'row', gap: 12, alignItems: 'center' }, children: [_jsx(Text, { style: { color: colors.foreground, fontSize: 16 }, children: twelveHour ? uiText("Time") : uiText("Time (24-hour)") }), [[hour, setHour, 'Hour'], [minute, setMinute, 'Minute']].map(([value, set, label]) => _jsx(TextInput, { accessibilityLabel: uiText(label), value: value, onChangeText: (text) => { set(text.replace(/\D/g, '').slice(0, 2)); setError(''); }, editable: !busy, keyboardType: "number-pad", maxLength: 2, selectTextOnFocus: true, style: { backgroundColor: colors.incoming, borderWidth: 1, borderColor: colors.secondary, borderRadius: 10, width: 56, padding: 10, color: colors.foreground, fontSize: 20, textAlign: 'center' } }, label)), twelveHour && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: period + ', switch to ' + (period === 'AM' ? 'PM' : 'AM'), onPress: () => setPeriod(period === 'AM' ? 'PM' : 'AM'), disabled: busy, style: { minHeight: 44, justifyContent: 'center', padding: 4 }, children: _jsx(Text, { style: { color: accent, fontSize: 17, fontWeight: '600' }, children: period }) })] }), _jsx(Text, { style: { color: colors.secondary, fontSize: 14 }, children: uiText('{zone}. The app can be closed when it is time to send.', { zone }) }), !!(error || localError) && _jsx(Text, { accessibilityRole: "alert", style: { color: colors.foreground }, children: error || localError })] }), _jsx(View, { style: { paddingHorizontal: 12, paddingTop: 8, paddingBottom: 8, gap: 8 }, children: _jsx(Pressable, { accessibilityRole: "button", disabled: busy, onPress: submit, style: { minHeight: 46, borderRadius: 12, justifyContent: 'center', alignItems: 'center', backgroundColor: accent, opacity: busy ? .5 : 1 }, children: _jsx(Text, { style: { fontSize: 16, color: messagingContrastInk(accent), fontWeight: '600' }, children: busy ? uiText("Saving…") : uiText("Schedule message") }) }) })] });
41
+ return _jsx(MessagingPopup, { screen: "schedule", title: uiText("Confirm scheduled message"), description: uiText("The last attempt could not be confirmed. Retry to check it without creating another message."), onClose: () => { if (!busy)
42
+ onClose(); }, closeDisabled: busy, background: colors.background, contentWidth: 420, children: _jsxs(View, { style: { padding: 12, gap: 16 }, children: [_jsx(Text, { style: { color: colors.secondary, fontSize: 16 }, children: new Date(retryAt).toLocaleString(uiLocale) }), !!error && _jsx(Text, { accessibilityRole: "alert", style: { color: colors.foreground }, children: error }), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Retry scheduling"), disabled: busy, onPress: () => onSave(retryAt), style: { minHeight: 46, borderRadius: 12, justifyContent: 'center', alignItems: 'center', backgroundColor: accent, opacity: busy ? .5 : 1 }, children: _jsx(Text, { style: { fontSize: 16, color: messagingContrastInk(accent), fontWeight: '600' }, children: busy ? uiText("Checking…") : uiText("Retry scheduling") }) })] }) });
43
+ return _jsxs(MessagingPopup, { screen: "schedule", title: title, description: uiText("Choose when this message should be sent."), onClose: () => { if (!busy)
44
+ onClose(); }, closeDisabled: busy, background: colors.background, contentWidth: 420, children: [_jsxs(ScrollView, { keyboardShouldPersistTaps: "handled", contentContainerStyle: { padding: 12, gap: 12 }, children: [_jsxs(View, { style: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }, children: [_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Previous month"), disabled: busy || first <= today, onPress: () => setMonth(new Date(month.getFullYear(), month.getMonth() - 1, 1)), style: { padding: 12 }, children: _jsx(Text, { style: { color: accent, fontSize: 24 }, children: "\u2039" }) }), _jsx(Text, { style: { color: colors.foreground, fontSize: 18, fontWeight: '600' }, children: month.toLocaleDateString(uiLocale, { month: 'long', year: 'numeric' }) }), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Next month"), disabled: busy || new Date(month.getFullYear(), month.getMonth() + 1, 1) > end, onPress: () => setMonth(new Date(month.getFullYear(), month.getMonth() + 1, 1)), style: { padding: 12 }, children: _jsx(Text, { style: { color: accent, fontSize: 24 }, children: "\u203A" }) })] }), _jsxs(View, { style: { flexDirection: 'row', flexWrap: 'wrap' }, children: [Array.from({ length: 7 }, (_, i) => new Intl.DateTimeFormat(uiLocale, { weekday: 'narrow' }).format(new Date(2026, 0, 4 + i))).map((day, i) => _jsx(Text, { style: { width: '14.285%', textAlign: 'center', color: colors.secondary, paddingBottom: 8 }, children: day }, 'week' + i)), Array.from({ length: first.getDay() }, (_, i) => _jsx(View, { style: { width: '14.285%' } }, 'blank' + i)), Array.from({ length: days }, (_, i) => { const d = new Date(month.getFullYear(), month.getMonth(), i + 1), selected = d.toDateString() === date.toDateString(), disabled = busy || d < today || d > end; return _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: d.toLocaleDateString(uiLocale, { weekday: 'long', month: 'long', day: 'numeric' }), accessibilityState: { selected, disabled }, disabled: disabled, onPress: () => choose(d), style: { width: '14.285%', height: 44, alignItems: 'center', justifyContent: 'center', borderRadius: 22, backgroundColor: selected ? accent + '30' : 'transparent', opacity: disabled ? .3 : 1 }, children: _jsx(Text, { style: { fontSize: 17, color: selected ? accent : colors.foreground, fontWeight: selected ? '700' : '400' }, children: i + 1 }) }, i); })] }), _jsxs(View, { style: { flexDirection: 'row', gap: 12, alignItems: 'center' }, children: [_jsx(Text, { style: { color: colors.foreground, fontSize: 16 }, children: twelveHour ? uiText("Time") : uiText("Time (24-hour)") }), [[hour, setHour, 'Hour'], [minute, setMinute, 'Minute']].map(([value, set, label]) => _jsx(TextInput, { accessibilityLabel: uiText(label), value: value, onChangeText: (text) => { set(text.replace(/\D/g, '').slice(0, 2)); setError(''); }, editable: !busy, keyboardType: "number-pad", maxLength: 2, selectTextOnFocus: true, style: { backgroundColor: colors.incoming, borderWidth: 1, borderColor: colors.secondary, borderRadius: 10, width: 56, padding: 10, color: colors.foreground, fontSize: 20, textAlign: 'center' } }, label)), twelveHour && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: period + ', switch to ' + (period === 'AM' ? 'PM' : 'AM'), onPress: () => setPeriod(period === 'AM' ? 'PM' : 'AM'), disabled: busy, style: { minHeight: 44, justifyContent: 'center', padding: 4 }, children: _jsx(Text, { style: { color: accent, fontSize: 17, fontWeight: '600' }, children: period }) })] }), _jsx(Text, { style: { color: colors.secondary, fontSize: 14 }, children: uiText('{zone}. The app can be closed when it is time to send.', { zone }) }), !!(error || localError) && _jsx(Text, { accessibilityRole: "alert", style: { color: colors.foreground }, children: error || localError })] }), _jsx(View, { style: { paddingHorizontal: 12, paddingTop: 8, paddingBottom: 8, gap: 8 }, children: _jsx(Pressable, { accessibilityRole: "button", disabled: busy, onPress: submit, style: { minHeight: 46, borderRadius: 12, justifyContent: 'center', alignItems: 'center', backgroundColor: accent, opacity: busy ? .5 : 1 }, children: _jsx(Text, { style: { fontSize: 16, color: messagingContrastInk(accent), fontWeight: '600' }, children: busy ? uiText("Saving…") : uiText("Schedule message") }) }) })] });
45
45
  }
46
46
  export function ScheduledMessages({ client, accent, onClose }) {
47
47
  const colors = useMessagingPopupColors(undefined, 'scheduled');
@@ -81,5 +81,5 @@ export function ScheduledMessages({ client, accent, onClose }) {
81
81
  } };
82
82
  if (editing)
83
83
  return _jsx(ScheduleTimePicker, { initial: editing.sendAt, title: uiText("Reschedule message"), accent: accent, busy: busy, error: error, onSave: time => void change(editing, time), onClose: () => setEditing(null) });
84
- return _jsx(MessagingPopup, { screen: "scheduled", title: uiText("Scheduled messages"), background: colors.background, onClose: onClose, contentWidth: 640, children: _jsxs(ScrollView, { contentContainerStyle: { padding: 12, gap: 12 }, children: [_jsx(Text, { style: { color: colors.secondary, fontSize: 15 }, children: uiText("Only you can see these until they are sent.") }), loading && _jsx(Text, { style: { color: colors.foreground }, children: uiText("Loading…") }), !loading && !items.length && !error && _jsx(Text, { style: { color: colors.foreground, fontSize: 17 }, children: uiText("No scheduled messages. Hold Send after writing a message to choose a time.") }), !!error && _jsx(Pressable, { onPress: () => void load(), accessibilityRole: "button", accessibilityLabel: uiText("Retry scheduled messages"), children: _jsxs(Text, { accessibilityRole: "alert", style: { color: colors.foreground }, children: [error, ' ', uiText("Tap to refresh.")] }) }), items.map(item => _jsxs(View, { style: { borderRadius: 12, backgroundColor: colors.incoming, padding: 12, gap: 8 }, children: [_jsxs(Text, { style: { color: colors.foreground, fontWeight: '600', fontSize: 16 }, children: [new Date(item.sendAt).toLocaleString(uiLocale, { month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }), " \u00B7 ", item.state === 'pending' ? uiText("Scheduled") : item.state === 'failed' ? uiText("Not sent") : item.state === 'sent' ? uiText("Sent") : uiText("Cancelled")] }), item.content && _jsx(Text, { numberOfLines: 4, style: { color: colors.foreground, fontSize: 16 }, children: item.content.text || item.content.media?.fileName || item.content.poll?.question || item.content.kind }), item.state === 'failed' && _jsxs(Text, { style: { color: colors.secondary }, children: [uiText("Not sent."), ' ', item.errorCode === 'schedule_expired' ? uiText("The sending window passed.") : item.errorCode?.includes('screening') ? uiText("The app’s safety check did not allow delivery.") : item.errorCode?.includes('billing') || item.errorCode?.includes('spending') ? uiText("The app’s spending limit or billing stopped delivery.") : uiText("Access, message rules or service availability changed.")] }), item.state === 'pending' && _jsxs(View, { style: { flexDirection: 'row', gap: 12 }, children: [_jsx(Pressable, { disabled: busy, onPress: () => setEditing(item), style: { minHeight: 44, justifyContent: 'center' }, children: _jsx(Text, { style: { color: accent, fontSize: 16 }, children: uiText("Reschedule") }) }), _jsx(Pressable, { disabled: busy, onPress: () => void change(item), style: { minHeight: 44, justifyContent: 'center' }, children: _jsx(Text, { style: { color: accent, fontSize: 16 }, children: uiText("Cancel message") }) })] })] }, item.id))] }) });
84
+ return _jsx(MessagingPopup, { screen: "scheduled", title: uiText("Scheduled messages"), description: uiText("Only you can see these until they are sent."), background: colors.background, onClose: onClose, contentWidth: 640, children: _jsxs(ScrollView, { contentContainerStyle: { padding: 12, gap: 12, minHeight: 100 }, children: [loading && _jsx(View, { pointerEvents: "none", style: { position: 'absolute', top: 12, left: 12, right: 12, height: 48, alignItems: 'center', justifyContent: 'center' }, children: _jsx(ActivityIndicator, { accessibilityLabel: uiText("Loading…"), color: colors.foreground }) }), !loading && !items.length && !error && _jsx(Text, { style: { color: colors.foreground, fontSize: 17 }, children: uiText("No scheduled messages. Hold Send after writing a message to choose a time.") }), !!error && _jsx(Pressable, { onPress: () => void load(), accessibilityRole: "button", accessibilityLabel: uiText("Retry scheduled messages"), children: _jsxs(Text, { accessibilityRole: "alert", style: { color: colors.foreground }, children: [error, ' ', uiText("Tap to refresh.")] }) }), items.map(item => _jsxs(View, { style: { borderRadius: 12, backgroundColor: colors.incoming, padding: 12, gap: 8 }, children: [_jsxs(Text, { style: { color: colors.foreground, fontWeight: '600', fontSize: 16 }, children: [new Date(item.sendAt).toLocaleString(uiLocale, { month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }), " \u00B7 ", item.state === 'pending' ? uiText("Scheduled") : item.state === 'failed' ? uiText("Not sent") : item.state === 'sent' ? uiText("Sent") : uiText("Cancelled")] }), item.content && _jsx(Text, { numberOfLines: 4, style: { color: colors.foreground, fontSize: 16 }, children: item.content.text || item.content.media?.fileName || item.content.poll?.question || item.content.kind }), item.state === 'failed' && _jsxs(Text, { style: { color: colors.secondary }, children: [uiText("Not sent."), ' ', item.errorCode === 'schedule_expired' ? uiText("The sending window passed.") : item.errorCode?.includes('screening') ? uiText("The app’s safety check did not allow delivery.") : item.errorCode?.includes('billing') || item.errorCode?.includes('spending') ? uiText("The app’s spending limit or billing stopped delivery.") : uiText("Access, message rules or service availability changed.")] }), item.state === 'pending' && _jsxs(View, { style: { flexDirection: 'row', gap: 12 }, children: [_jsx(Pressable, { disabled: busy, onPress: () => setEditing(item), style: { minHeight: 44, justifyContent: 'center' }, children: _jsx(Text, { style: { color: accent, fontSize: 16 }, children: uiText("Reschedule") }) }), _jsx(Pressable, { disabled: busy, onPress: () => void change(item), style: { minHeight: 44, justifyContent: 'center' }, children: _jsx(Text, { style: { color: accent, fontSize: 16 }, children: uiText("Cancel message") }) })] })] }, item.id))] }) });
85
85
  }
package/dist/search.js CHANGED
@@ -31,9 +31,18 @@ export function MessagingSearch({ client, appearance, onClose }) {
31
31
  setBusy(true);
32
32
  setError('');
33
33
  try {
34
- const result = await client.search(term, { ...(more && next ? { before: next } : {}), signal: control.signal });
35
- if (id !== generation.current)
36
- return;
34
+ let cursor = more ? next : null, result = { messages: [], hasMore: false, nextCursor: null };
35
+ // Permission filtering may produce an empty page with older matches still
36
+ // available. Advance bounded pages automatically; keep Next usable if the
37
+ // remaining range is larger, rather than incorrectly showing a final zero.
38
+ for (let page = 0; page < 5; page++) {
39
+ result = await client.search(term, { ...(cursor ? { before: cursor } : {}), signal: control.signal });
40
+ if (id !== generation.current)
41
+ return;
42
+ if (result.messages.length || !result.hasMore || !result.nextCursor || result.nextCursor === cursor)
43
+ break;
44
+ cursor = result.nextCursor;
45
+ }
37
46
  const rows = more ? [...messages, ...result.messages.filter(m => !messages.some(old => old.id === m.id))] : result.messages;
38
47
  const target = more ? Math.min(index + 1, Math.max(0, rows.length - 1)) : 0;
39
48
  setMessages(rows);
@@ -54,11 +63,12 @@ export function MessagingSearch({ client, appearance, onClose }) {
54
63
  useEffect(() => { if (query.trim())
55
64
  timer.current = setTimeout(() => void search(), 300); return () => clearTimeout(timer.current); }, [query]);
56
65
  function change(value) { generation.current++; request.current?.abort(); clearTimeout(timer.current); setBusy(Boolean(value.trim())); setQuery(value); setMessages([]); setIndex(0); setNext(null); setError(''); }
57
- async function move(direction) { if (busy || !messages.length)
58
- return; if (direction > 0 && index === messages.length - 1 && next) {
66
+ async function move(direction) { if (busy)
67
+ return; if (direction > 0 && (!messages.length || index === messages.length - 1) && next) {
59
68
  await search(true);
60
69
  return;
61
- } const target = (index + direction + messages.length) % messages.length; setIndex(target); await focus(messages[target], generation.current); }
62
- const nav = (label, icon, direction) => _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: label, disabled: busy || !messages.length, onPress: () => void move(direction), style: { width: 36, height: 44, alignItems: 'center', justifyContent: 'center', opacity: (busy || !messages.length) ? 0.4 : 1 }, children: _jsx(MessageIcon, { name: icon, size: 20, color: c.foreground }) });
63
- return _jsx(MessagingTypography, { appearance: appearance, screen: "search", children: _jsxs(View, { testID: "conversation-search", style: { backgroundColor: c.background, borderBottomWidth: 1, borderBottomColor: c.foreground + '20' }, children: [_jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', paddingLeft: 10, gap: 4 }, children: [_jsx(MessageIcon, { name: "search", size: 18, color: c.secondary }), _jsx(TextInput, { accessibilityLabel: uiText("Search this chat"), placeholder: uiText("Search this chat"), value: query, onChangeText: change, onSubmitEditing: () => void search(), autoFocus: true, autoCapitalize: "none", autoCorrect: false, maxLength: 200, returnKeyType: "search", placeholderTextColor: c.secondary, style: { flex: 1, minWidth: 0, minHeight: 44, color: c.foreground, fontSize: 15 } }), busy ? _jsx(ActivityIndicator, { accessibilityLabel: uiText("Searching messages"), color: c.accent }) : !!query.trim() && _jsx(Text, { accessibilityLiveRegion: "polite", style: { color: c.secondary, fontSize: 12 }, children: messages.length ? `${index + 1}/${messages.length}${next ? '+' : ''}` : '0' }), nav('Previous search result', 'chevron-up', -1), nav('Next search result', 'chevron-down', 1), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Close search"), onPress: onClose, style: { width: 44, height: 44, alignItems: 'center', justifyContent: 'center' }, children: _jsx(MessageIcon, { name: "close", size: 20, color: c.foreground }) })] }), !!error && _jsx(Text, { accessibilityRole: "alert", style: { color: c.foreground, paddingHorizontal: 12, paddingBottom: 8, fontSize: 13 }, children: error })] }) });
70
+ } if (!messages.length)
71
+ return; const target = (index + direction + messages.length) % messages.length; setIndex(target); await focus(messages[target], generation.current); }
72
+ const nav = (label, icon, direction) => { const disabled = busy || !messages.length && !(direction > 0 && next); return _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: label, disabled: disabled, onPress: () => void move(direction), style: { width: 36, height: 44, alignItems: 'center', justifyContent: 'center', opacity: disabled ? 0.4 : 1 }, children: _jsx(MessageIcon, { name: icon, size: 20, color: c.foreground }) }); };
73
+ return _jsx(MessagingTypography, { appearance: appearance, screen: "search", children: _jsxs(View, { testID: "conversation-search", style: { backgroundColor: c.background, borderBottomWidth: 1, borderBottomColor: c.foreground + '20' }, children: [_jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', paddingLeft: 10, gap: 4 }, children: [_jsx(MessageIcon, { name: "search", size: 18, color: c.secondary }), _jsx(TextInput, { accessibilityLabel: uiText("Search this chat"), placeholder: uiText("Search this chat"), value: query, onChangeText: change, onSubmitEditing: () => void search(), autoFocus: true, autoCapitalize: "none", autoCorrect: false, maxLength: 200, returnKeyType: "search", placeholderTextColor: c.secondary, style: { flex: 1, minWidth: 0, minHeight: 44, color: c.foreground, fontSize: 15 } }), busy ? _jsx(ActivityIndicator, { accessibilityLabel: uiText("Searching messages"), color: c.accent }) : !!query.trim() && _jsx(Text, { accessibilityLiveRegion: "polite", style: { color: c.secondary, fontSize: 12 }, children: messages.length ? `${index + 1}/${messages.length}${next ? '+' : ''}` : next ? '0+' : '0' }), nav('Previous search result', 'chevron-up', -1), nav('Next search result', 'chevron-down', 1), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Close search"), onPress: onClose, style: { width: 44, height: 44, alignItems: 'center', justifyContent: 'center' }, children: _jsx(MessageIcon, { name: "close", size: 20, color: c.foreground }) })] }), !!error && _jsx(Text, { accessibilityRole: "alert", style: { color: c.foreground, paddingHorizontal: 12, paddingBottom: 8, fontSize: 13 }, children: error })] }) });
64
74
  }