@ateam-ai-mobile/ui 0.1.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.
- package/dist/index.d.mts +166 -0
- package/dist/index.d.ts +166 -0
- package/dist/index.js +1870 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1853 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +34 -0
- package/src/AdasChatScreen.tsx +170 -0
- package/src/Lightbox.tsx +55 -0
- package/src/chat/ChatInput.tsx +134 -0
- package/src/chat/JobProgressBar.tsx +221 -0
- package/src/chat/MessageBubble.tsx +494 -0
- package/src/chat/TableCardBlock.tsx +96 -0
- package/src/chat/TypingIndicator.tsx +20 -0
- package/src/chat/UIActionsRow.tsx +128 -0
- package/src/index.ts +38 -0
- package/src/plugin/EmbeddedPluginWebView.tsx +170 -0
- package/src/plugin/Plugin.tsx +178 -0
- package/src/plugin/PluginSurface.tsx +77 -0
- package/src/plugin/usePluginBridge.ts +383 -0
- package/src/providers.ts +46 -0
- package/src/stores/lightboxStore.ts +18 -0
- package/src/widgets/WidgetWebView.tsx +173 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { Message, JobProgress, UIAction } from '@ateam-ai-mobile/core';
|
|
3
|
+
import * as React$1 from 'react';
|
|
4
|
+
import React__default from 'react';
|
|
5
|
+
import { PluginSurfaceMeta, PlatformPluginManifest } from '@ateam-ai-mobile/plugin-runtime';
|
|
6
|
+
import * as zustand from 'zustand';
|
|
7
|
+
|
|
8
|
+
interface AdasChatScreenProps {
|
|
9
|
+
/** Called when the user taps the call button; omit to hide it. */
|
|
10
|
+
onCallStart?: () => void;
|
|
11
|
+
/** Composer placeholder. */
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
/** Extra element rendered above the composer (e.g. suggestion chips). */
|
|
14
|
+
footerAccessory?: React.ReactNode;
|
|
15
|
+
/** Mount the fullscreen image viewer here. Default true — set false if
|
|
16
|
+
* the host already mounts <Lightbox /> at its root. */
|
|
17
|
+
withLightbox?: boolean;
|
|
18
|
+
}
|
|
19
|
+
declare function AdasChatScreen({ onCallStart, placeholder, footerAccessory, withLightbox, }: AdasChatScreenProps): react_jsx_runtime.JSX.Element;
|
|
20
|
+
|
|
21
|
+
interface Props$7 {
|
|
22
|
+
message: Message;
|
|
23
|
+
}
|
|
24
|
+
declare function DaySeparator({ date }: {
|
|
25
|
+
date: Date;
|
|
26
|
+
}): react_jsx_runtime.JSX.Element;
|
|
27
|
+
declare function MessageBubble({ message }: Props$7): react_jsx_runtime.JSX.Element;
|
|
28
|
+
|
|
29
|
+
interface Props$6 {
|
|
30
|
+
onSend: (text: string) => void;
|
|
31
|
+
onCallStart?: () => void;
|
|
32
|
+
loading: boolean;
|
|
33
|
+
/** Pre-fill the composer (e.g. from bridge.prepareMessage). The text is
|
|
34
|
+
* placed in the input and focused — not sent. */
|
|
35
|
+
prefill?: string;
|
|
36
|
+
placeholder?: string;
|
|
37
|
+
}
|
|
38
|
+
declare function ChatInput({ onSend, onCallStart, loading, prefill, placeholder }: Props$6): react_jsx_runtime.JSX.Element;
|
|
39
|
+
|
|
40
|
+
declare function TypingIndicator(): react_jsx_runtime.JSX.Element;
|
|
41
|
+
|
|
42
|
+
interface Props$5 {
|
|
43
|
+
progress: JobProgress;
|
|
44
|
+
}
|
|
45
|
+
declare function JobProgressBar({ progress }: Props$5): react_jsx_runtime.JSX.Element;
|
|
46
|
+
|
|
47
|
+
interface Props$4 {
|
|
48
|
+
columns: string[];
|
|
49
|
+
rows: any[][];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Renders tabular data as a vertical stack of cards — one card per row.
|
|
53
|
+
* The first column becomes the card title; remaining columns become
|
|
54
|
+
* key:value rows inside the card. Built specifically for narrow phone
|
|
55
|
+
* screens where horizontal markdown tables become unreadable.
|
|
56
|
+
*/
|
|
57
|
+
declare function TableCardBlock({ columns, rows }: Props$4): react_jsx_runtime.JSX.Element | null;
|
|
58
|
+
|
|
59
|
+
interface Props$3 {
|
|
60
|
+
actions: UIAction[];
|
|
61
|
+
}
|
|
62
|
+
declare function UIActionsRow({ actions }: Props$3): react_jsx_runtime.JSX.Element | null;
|
|
63
|
+
|
|
64
|
+
interface PluginRendererProps {
|
|
65
|
+
/** Full plugin ID, e.g. "mcp:connector-id:plugin-name" */
|
|
66
|
+
id: string;
|
|
67
|
+
/** Plugin manifest (from API) */
|
|
68
|
+
manifest: any;
|
|
69
|
+
/** Shared command buffer from parent — captures commands before plugin mounts */
|
|
70
|
+
commandBufferRef?: React__default.MutableRefObject<any[]>;
|
|
71
|
+
/** Engine-supplied props from sys.focusUiPlugin(id, props) — forwarded to
|
|
72
|
+
* the plugin Component as `PluginProps.props`. */
|
|
73
|
+
props?: any;
|
|
74
|
+
}
|
|
75
|
+
declare function Plugin({ id, manifest, commandBufferRef, props: engineProps }: PluginRendererProps): react_jsx_runtime.JSX.Element;
|
|
76
|
+
|
|
77
|
+
interface Props$2 {
|
|
78
|
+
pluginId: string;
|
|
79
|
+
surface: PluginSurfaceMeta;
|
|
80
|
+
dismiss: () => void;
|
|
81
|
+
/** Engine-supplied props forwarded from sys.focusUiPlugin(id, props). */
|
|
82
|
+
props?: any;
|
|
83
|
+
}
|
|
84
|
+
declare function PluginSurface({ pluginId, surface, dismiss, props }: Props$2): react_jsx_runtime.JSX.Element;
|
|
85
|
+
|
|
86
|
+
interface Props$1 {
|
|
87
|
+
pluginId: string;
|
|
88
|
+
manifest: PlatformPluginManifest;
|
|
89
|
+
commandBufferRef?: React.MutableRefObject<any[]>;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* WebView renderer for iframe-mode plugins. The injected bridge JS makes
|
|
93
|
+
* existing web plugins work unmodified; the origin guards below make sure
|
|
94
|
+
* the JWT seeded into localStorage can never leave the trusted hosts.
|
|
95
|
+
*/
|
|
96
|
+
declare function EmbeddedPluginWebView({ pluginId, manifest, commandBufferRef }: Props$1): react_jsx_runtime.JSX.Element;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* PostMessage bridge between the React Native host and a plugin WebView.
|
|
100
|
+
* Implements the same protocol as PluginHost.jsx in the web frontend.
|
|
101
|
+
*
|
|
102
|
+
* Handles THREE communication paths:
|
|
103
|
+
* 1. fetch("/mcp") — intercepted in bridge JS, proxied through postMessage
|
|
104
|
+
* 2. postMessage mcp-call — direct postMessage from plugin SDK
|
|
105
|
+
* 3. plugin commands — routed from the job stream to the WebView
|
|
106
|
+
*/
|
|
107
|
+
declare function usePluginBridge(pluginId: string, connectorId?: string, commandBufferRef?: React.MutableRefObject<any[]>, wsRef?: {
|
|
108
|
+
current: WebSocket | null;
|
|
109
|
+
}): {
|
|
110
|
+
webViewRef: React$1.RefObject<any>;
|
|
111
|
+
sendInit: () => void;
|
|
112
|
+
handleMessage: (event: {
|
|
113
|
+
nativeEvent: {
|
|
114
|
+
data: string;
|
|
115
|
+
};
|
|
116
|
+
}) => Promise<void>;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Build injected JavaScript that:
|
|
120
|
+
* 1. Seeds localStorage with JWT + tenant (plugins read from localStorage)
|
|
121
|
+
* 2. Intercepts fetch("/mcp") and proxies through the postMessage bridge
|
|
122
|
+
* 3. Bridges iframe postMessage API to React Native WebView
|
|
123
|
+
*
|
|
124
|
+
* This makes existing web plugins work on mobile WITHOUT modification.
|
|
125
|
+
*/
|
|
126
|
+
declare function buildPluginBridgeJS(jwt: string, tenant: string): string;
|
|
127
|
+
|
|
128
|
+
interface Props {
|
|
129
|
+
visible: boolean;
|
|
130
|
+
/** Display title shown in the top bar. */
|
|
131
|
+
title?: string;
|
|
132
|
+
/** Signed bundle URL from a /surface item. Relative or absolute. */
|
|
133
|
+
bundleUrl?: string;
|
|
134
|
+
onClose: () => void;
|
|
135
|
+
}
|
|
136
|
+
declare function WidgetWebView({ visible, title, bundleUrl, onClose }: Props): react_jsx_runtime.JSX.Element;
|
|
137
|
+
|
|
138
|
+
declare function Lightbox(): react_jsx_runtime.JSX.Element | null;
|
|
139
|
+
|
|
140
|
+
interface LightboxState {
|
|
141
|
+
uri: string | null;
|
|
142
|
+
show: (uri: string) => void;
|
|
143
|
+
hide: () => void;
|
|
144
|
+
}
|
|
145
|
+
declare const useLightboxStore: zustand.UseBoundStore<zustand.StoreApi<LightboxState>>;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Host integration points for @ateam-ai-mobile/ui — same DI pattern as
|
|
149
|
+
* @ateam-ai-mobile/plugin-runtime's host.ts. Everything has a safe default; the host
|
|
150
|
+
* (or @ateam-ai-mobile/expo) wires real implementations at startup.
|
|
151
|
+
*/
|
|
152
|
+
interface ClipboardProvider {
|
|
153
|
+
setString(text: string): Promise<void>;
|
|
154
|
+
}
|
|
155
|
+
/** Register a clipboard implementation (e.g. expo-clipboard via @ateam-ai-mobile/expo). */
|
|
156
|
+
declare function setClipboardProvider(clipboard: ClipboardProvider | null): void;
|
|
157
|
+
interface UIActionRoute {
|
|
158
|
+
/** Full plugin id, e.g. "mcp:connector:plugin" or "platform:<name>". */
|
|
159
|
+
pluginId: string;
|
|
160
|
+
/** Query params the plugin reads on load (focus, tool, args, verb). */
|
|
161
|
+
params: Record<string, string>;
|
|
162
|
+
}
|
|
163
|
+
type UIActionNavigator = (route: UIActionRoute) => void;
|
|
164
|
+
declare function setUIActionNavigator(navigate: UIActionNavigator | null): void;
|
|
165
|
+
|
|
166
|
+
export { AdasChatScreen, type AdasChatScreenProps, ChatInput, type ClipboardProvider, DaySeparator, EmbeddedPluginWebView, JobProgressBar, Lightbox, MessageBubble, Plugin, PluginSurface, TableCardBlock, TypingIndicator, type UIActionRoute, UIActionsRow, WidgetWebView, buildPluginBridgeJS, setClipboardProvider, setUIActionNavigator, useLightboxStore, usePluginBridge };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { Message, JobProgress, UIAction } from '@ateam-ai-mobile/core';
|
|
3
|
+
import * as React$1 from 'react';
|
|
4
|
+
import React__default from 'react';
|
|
5
|
+
import { PluginSurfaceMeta, PlatformPluginManifest } from '@ateam-ai-mobile/plugin-runtime';
|
|
6
|
+
import * as zustand from 'zustand';
|
|
7
|
+
|
|
8
|
+
interface AdasChatScreenProps {
|
|
9
|
+
/** Called when the user taps the call button; omit to hide it. */
|
|
10
|
+
onCallStart?: () => void;
|
|
11
|
+
/** Composer placeholder. */
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
/** Extra element rendered above the composer (e.g. suggestion chips). */
|
|
14
|
+
footerAccessory?: React.ReactNode;
|
|
15
|
+
/** Mount the fullscreen image viewer here. Default true — set false if
|
|
16
|
+
* the host already mounts <Lightbox /> at its root. */
|
|
17
|
+
withLightbox?: boolean;
|
|
18
|
+
}
|
|
19
|
+
declare function AdasChatScreen({ onCallStart, placeholder, footerAccessory, withLightbox, }: AdasChatScreenProps): react_jsx_runtime.JSX.Element;
|
|
20
|
+
|
|
21
|
+
interface Props$7 {
|
|
22
|
+
message: Message;
|
|
23
|
+
}
|
|
24
|
+
declare function DaySeparator({ date }: {
|
|
25
|
+
date: Date;
|
|
26
|
+
}): react_jsx_runtime.JSX.Element;
|
|
27
|
+
declare function MessageBubble({ message }: Props$7): react_jsx_runtime.JSX.Element;
|
|
28
|
+
|
|
29
|
+
interface Props$6 {
|
|
30
|
+
onSend: (text: string) => void;
|
|
31
|
+
onCallStart?: () => void;
|
|
32
|
+
loading: boolean;
|
|
33
|
+
/** Pre-fill the composer (e.g. from bridge.prepareMessage). The text is
|
|
34
|
+
* placed in the input and focused — not sent. */
|
|
35
|
+
prefill?: string;
|
|
36
|
+
placeholder?: string;
|
|
37
|
+
}
|
|
38
|
+
declare function ChatInput({ onSend, onCallStart, loading, prefill, placeholder }: Props$6): react_jsx_runtime.JSX.Element;
|
|
39
|
+
|
|
40
|
+
declare function TypingIndicator(): react_jsx_runtime.JSX.Element;
|
|
41
|
+
|
|
42
|
+
interface Props$5 {
|
|
43
|
+
progress: JobProgress;
|
|
44
|
+
}
|
|
45
|
+
declare function JobProgressBar({ progress }: Props$5): react_jsx_runtime.JSX.Element;
|
|
46
|
+
|
|
47
|
+
interface Props$4 {
|
|
48
|
+
columns: string[];
|
|
49
|
+
rows: any[][];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Renders tabular data as a vertical stack of cards — one card per row.
|
|
53
|
+
* The first column becomes the card title; remaining columns become
|
|
54
|
+
* key:value rows inside the card. Built specifically for narrow phone
|
|
55
|
+
* screens where horizontal markdown tables become unreadable.
|
|
56
|
+
*/
|
|
57
|
+
declare function TableCardBlock({ columns, rows }: Props$4): react_jsx_runtime.JSX.Element | null;
|
|
58
|
+
|
|
59
|
+
interface Props$3 {
|
|
60
|
+
actions: UIAction[];
|
|
61
|
+
}
|
|
62
|
+
declare function UIActionsRow({ actions }: Props$3): react_jsx_runtime.JSX.Element | null;
|
|
63
|
+
|
|
64
|
+
interface PluginRendererProps {
|
|
65
|
+
/** Full plugin ID, e.g. "mcp:connector-id:plugin-name" */
|
|
66
|
+
id: string;
|
|
67
|
+
/** Plugin manifest (from API) */
|
|
68
|
+
manifest: any;
|
|
69
|
+
/** Shared command buffer from parent — captures commands before plugin mounts */
|
|
70
|
+
commandBufferRef?: React__default.MutableRefObject<any[]>;
|
|
71
|
+
/** Engine-supplied props from sys.focusUiPlugin(id, props) — forwarded to
|
|
72
|
+
* the plugin Component as `PluginProps.props`. */
|
|
73
|
+
props?: any;
|
|
74
|
+
}
|
|
75
|
+
declare function Plugin({ id, manifest, commandBufferRef, props: engineProps }: PluginRendererProps): react_jsx_runtime.JSX.Element;
|
|
76
|
+
|
|
77
|
+
interface Props$2 {
|
|
78
|
+
pluginId: string;
|
|
79
|
+
surface: PluginSurfaceMeta;
|
|
80
|
+
dismiss: () => void;
|
|
81
|
+
/** Engine-supplied props forwarded from sys.focusUiPlugin(id, props). */
|
|
82
|
+
props?: any;
|
|
83
|
+
}
|
|
84
|
+
declare function PluginSurface({ pluginId, surface, dismiss, props }: Props$2): react_jsx_runtime.JSX.Element;
|
|
85
|
+
|
|
86
|
+
interface Props$1 {
|
|
87
|
+
pluginId: string;
|
|
88
|
+
manifest: PlatformPluginManifest;
|
|
89
|
+
commandBufferRef?: React.MutableRefObject<any[]>;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* WebView renderer for iframe-mode plugins. The injected bridge JS makes
|
|
93
|
+
* existing web plugins work unmodified; the origin guards below make sure
|
|
94
|
+
* the JWT seeded into localStorage can never leave the trusted hosts.
|
|
95
|
+
*/
|
|
96
|
+
declare function EmbeddedPluginWebView({ pluginId, manifest, commandBufferRef }: Props$1): react_jsx_runtime.JSX.Element;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* PostMessage bridge between the React Native host and a plugin WebView.
|
|
100
|
+
* Implements the same protocol as PluginHost.jsx in the web frontend.
|
|
101
|
+
*
|
|
102
|
+
* Handles THREE communication paths:
|
|
103
|
+
* 1. fetch("/mcp") — intercepted in bridge JS, proxied through postMessage
|
|
104
|
+
* 2. postMessage mcp-call — direct postMessage from plugin SDK
|
|
105
|
+
* 3. plugin commands — routed from the job stream to the WebView
|
|
106
|
+
*/
|
|
107
|
+
declare function usePluginBridge(pluginId: string, connectorId?: string, commandBufferRef?: React.MutableRefObject<any[]>, wsRef?: {
|
|
108
|
+
current: WebSocket | null;
|
|
109
|
+
}): {
|
|
110
|
+
webViewRef: React$1.RefObject<any>;
|
|
111
|
+
sendInit: () => void;
|
|
112
|
+
handleMessage: (event: {
|
|
113
|
+
nativeEvent: {
|
|
114
|
+
data: string;
|
|
115
|
+
};
|
|
116
|
+
}) => Promise<void>;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Build injected JavaScript that:
|
|
120
|
+
* 1. Seeds localStorage with JWT + tenant (plugins read from localStorage)
|
|
121
|
+
* 2. Intercepts fetch("/mcp") and proxies through the postMessage bridge
|
|
122
|
+
* 3. Bridges iframe postMessage API to React Native WebView
|
|
123
|
+
*
|
|
124
|
+
* This makes existing web plugins work on mobile WITHOUT modification.
|
|
125
|
+
*/
|
|
126
|
+
declare function buildPluginBridgeJS(jwt: string, tenant: string): string;
|
|
127
|
+
|
|
128
|
+
interface Props {
|
|
129
|
+
visible: boolean;
|
|
130
|
+
/** Display title shown in the top bar. */
|
|
131
|
+
title?: string;
|
|
132
|
+
/** Signed bundle URL from a /surface item. Relative or absolute. */
|
|
133
|
+
bundleUrl?: string;
|
|
134
|
+
onClose: () => void;
|
|
135
|
+
}
|
|
136
|
+
declare function WidgetWebView({ visible, title, bundleUrl, onClose }: Props): react_jsx_runtime.JSX.Element;
|
|
137
|
+
|
|
138
|
+
declare function Lightbox(): react_jsx_runtime.JSX.Element | null;
|
|
139
|
+
|
|
140
|
+
interface LightboxState {
|
|
141
|
+
uri: string | null;
|
|
142
|
+
show: (uri: string) => void;
|
|
143
|
+
hide: () => void;
|
|
144
|
+
}
|
|
145
|
+
declare const useLightboxStore: zustand.UseBoundStore<zustand.StoreApi<LightboxState>>;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Host integration points for @ateam-ai-mobile/ui — same DI pattern as
|
|
149
|
+
* @ateam-ai-mobile/plugin-runtime's host.ts. Everything has a safe default; the host
|
|
150
|
+
* (or @ateam-ai-mobile/expo) wires real implementations at startup.
|
|
151
|
+
*/
|
|
152
|
+
interface ClipboardProvider {
|
|
153
|
+
setString(text: string): Promise<void>;
|
|
154
|
+
}
|
|
155
|
+
/** Register a clipboard implementation (e.g. expo-clipboard via @ateam-ai-mobile/expo). */
|
|
156
|
+
declare function setClipboardProvider(clipboard: ClipboardProvider | null): void;
|
|
157
|
+
interface UIActionRoute {
|
|
158
|
+
/** Full plugin id, e.g. "mcp:connector:plugin" or "platform:<name>". */
|
|
159
|
+
pluginId: string;
|
|
160
|
+
/** Query params the plugin reads on load (focus, tool, args, verb). */
|
|
161
|
+
params: Record<string, string>;
|
|
162
|
+
}
|
|
163
|
+
type UIActionNavigator = (route: UIActionRoute) => void;
|
|
164
|
+
declare function setUIActionNavigator(navigate: UIActionNavigator | null): void;
|
|
165
|
+
|
|
166
|
+
export { AdasChatScreen, type AdasChatScreenProps, ChatInput, type ClipboardProvider, DaySeparator, EmbeddedPluginWebView, JobProgressBar, Lightbox, MessageBubble, Plugin, PluginSurface, TableCardBlock, TypingIndicator, type UIActionRoute, UIActionsRow, WidgetWebView, buildPluginBridgeJS, setClipboardProvider, setUIActionNavigator, useLightboxStore, usePluginBridge };
|