@mcp-native/react-native 0.2.0 → 0.4.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/README.md +161 -28
- package/dist/component-adapters.d.ts +86 -0
- package/dist/component-adapters.d.ts.map +1 -0
- package/dist/component-adapters.js +26 -0
- package/dist/component-adapters.js.map +1 -0
- package/dist/index.d.ts +44 -31
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +519 -20
- package/dist/index.js.map +1 -1
- package/dist/iso-4217.d.ts +8 -0
- package/dist/iso-4217.d.ts.map +1 -0
- package/dist/iso-4217.js +187 -0
- package/dist/iso-4217.js.map +1 -0
- package/dist/v1.d.ts +39 -1
- package/dist/v1.d.ts.map +1 -1
- package/dist/v1.js +1068 -64
- package/dist/v1.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
`@mcp-native/react-native` converts a surface already validated by `@mcp-native/a2ui` into a trusted render plan and mounts it with components supplied by the host application. Servers provide data and declared actions—not JavaScript modules, component implementations, or arbitrary component names.
|
|
18
18
|
|
|
19
|
-
The renderer is an internal platform layer, not proof of complete A2UI v1.0 conformance. The custom `0.1` surface remains
|
|
19
|
+
The renderer is an internal platform layer, not proof of complete A2UI v1.0 conformance. The custom `0.1` surface remains available only through deprecated migration APIs, while the v1.0 adapter converts the documented component subset, including bounded dynamic lists, into the same host-owned `NativeElement` boundary. See the [feature-scoped conformance profile](https://github.com/pablospaniard/mcp-native/blob/main/docs/a2ui-v1-conformance.md).
|
|
20
20
|
|
|
21
21
|
## Install
|
|
22
22
|
|
|
@@ -79,7 +79,7 @@ The renderer uses only the currently allowed component names:
|
|
|
79
79
|
type NativeComponentName = "Button" | "Text" | "TextInput" | "View";
|
|
80
80
|
```
|
|
81
81
|
|
|
82
|
-
The application host decides how each name maps to a locally bundled component and how declared button actions reach `McpNativeRuntime`. `onBindingChange` reports a validated binding name and the next text value
|
|
82
|
+
This example uses deprecated custom `0.1` APIs. The application host decides how each name maps to a locally bundled component and how declared button actions reach `McpNativeRuntime`. `onBindingChange` reports a validated binding name and the next text value for that legacy proof surface. New hosts should use `A2uiV1NativeSurface`.
|
|
83
83
|
|
|
84
84
|
## A2UI v1 render-plan adapter
|
|
85
85
|
|
|
@@ -101,36 +101,167 @@ const surface = store.get("profile");
|
|
|
101
101
|
const plan = surface && createA2uiV1NativeRenderPlan(surface, policy);
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
-
The adapter maps `Row`, `Column`, static `List`, and `Card` to `View`; `Text` to `Text`; `Button` with a `Text` child to `Button`; and `TextField` to `TextInput`.
|
|
104
|
+
The adapter maps `Row`, `Column`, static or dynamic `List`, and `Card` to `View`; `Text` to `Text`; `Button` with a `Text` child to `Button`; and `TextField` to `TextInput`. Dynamic lists expand one validated template component per bound array item and remain inside the 1,024-node plan limit. The adapter resolves absolute and item-relative JSON Pointer values, translates relative `TextField` bindings into absolute renderer-local pointers, evaluates bounded literal `formatString`, host-localized `formatNumber`, `formatCurrency`, `formatDate`, and `pluralize`, pure `and`, `or`, and `not`, `required`, bounded `regex`, `length`, `numeric`, and `email`, and `@index` with optional offsets, maps supported container direction and alignment to owned React Native flex styles, applies component weight through a host-owned `View` wrapper with `flexGrow`, maps `TextField` variants to explicit native input behavior (including `secureTextEntry` for `obscured`), and preserves event context and explicit accessibility fields. At the mounted boundary, text and buttons receive closed native roles, button accessibility state mirrors the derived disabled state, hidden text and controls are not accessibility elements, and text plus text inputs explicitly allow font scaling. Supported `TextField` checks set explicit `invalid` and `validationMessages` props on the host component and append declared failures to its accessibility hint; supported `Button` checks set `disabled`, expose declared messages, and cannot resolve or dispatch the event or local URL action until current renderer-local state passes. Main-axis `stretch` and negative weight, which React Native flex layout cannot represent faithfully, fail closed.
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
These mappings have automated host-boundary coverage plus passing Android 17 TalkBack and iOS 26.5
|
|
107
|
+
XCUITest evidence. The [native accessibility test
|
|
108
|
+
plan](../../docs/native-accessibility-testing.md) defines the verified platform matrix, shared
|
|
109
|
+
fixture, WCAG inspection, and strict evidence gate. The [automated robustness
|
|
110
|
+
gates](../../docs/a2ui-v1-performance.md) define repeatable Node.js render-plan budgets and
|
|
111
|
+
fixed-seed generated-input coverage.
|
|
112
|
+
|
|
113
|
+
For release/platform testing, `npm run native:host:prepare` generates an official temporary React
|
|
114
|
+
Native `0.87.1` or `0.86.3` host from local package tarballs and the pinned accessibility fixture.
|
|
115
|
+
The [native accessibility test plan](../../docs/native-accessibility-testing.md) documents Metro and
|
|
116
|
+
native build preflight, Android TalkBack and iOS XCUITest rows, verified WCAG outcomes, and the
|
|
117
|
+
strict evidence gate.
|
|
118
|
+
|
|
119
|
+
### Host component adapters
|
|
120
|
+
|
|
121
|
+
The catalog may use React Native primitives directly or typed adapters around any locally bundled design system. The adapter helpers receive only the trusted primitive props selected by MCP Native and map them into the host component's API:
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
import { createNativeButtonAdapter, type NativeComponentCatalog } from "@mcp-native/react-native";
|
|
125
|
+
import { Text, TextInput, View } from "react-native";
|
|
126
|
+
import { DesignButton } from "your-design-system";
|
|
127
|
+
|
|
128
|
+
const components: NativeComponentCatalog = {
|
|
129
|
+
View,
|
|
130
|
+
Text,
|
|
131
|
+
TextInput,
|
|
132
|
+
Button: createNativeButtonAdapter(
|
|
133
|
+
DesignButton,
|
|
134
|
+
({
|
|
135
|
+
title,
|
|
136
|
+
onPress,
|
|
137
|
+
disabled,
|
|
138
|
+
accessibilityLabel,
|
|
139
|
+
accessibilityRole,
|
|
140
|
+
accessibilityState,
|
|
141
|
+
accessible,
|
|
142
|
+
validationMessages,
|
|
143
|
+
}) => ({
|
|
144
|
+
label: title,
|
|
145
|
+
onActivate: onPress,
|
|
146
|
+
inactive: disabled === true,
|
|
147
|
+
assistiveLabel: accessibilityLabel,
|
|
148
|
+
assistiveElement: accessible,
|
|
149
|
+
assistiveRole: accessibilityRole,
|
|
150
|
+
assistiveState: accessibilityState,
|
|
151
|
+
...(validationMessages === undefined ? {} : { errors: validationMessages }),
|
|
152
|
+
}),
|
|
153
|
+
),
|
|
154
|
+
};
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
`createNativeViewAdapter`, `createNativeTextAdapter`, and `createNativeTextInputAdapter` provide the same typed boundary for the other primitives. This supports wrappers around libraries such as Expo UI or Gluestack without coupling MCP Native to them. These helpers do not create new wire-level components: the supported semantic names remain the closed `View`, `Text`, `Button`, and `TextInput` render-plan catalog, and the A2UI adapter continues to reject components outside its explicit host allowlist. Mapper functions and target components are trusted application code; server input never selects an import, mapper, or unchecked target prop.
|
|
158
|
+
|
|
159
|
+
For richer local presentation, provide optional closed variant slots alongside the base primitives:
|
|
160
|
+
|
|
161
|
+
```tsx
|
|
162
|
+
const components: NativeComponentCatalog = {
|
|
163
|
+
View,
|
|
164
|
+
Text,
|
|
165
|
+
Button,
|
|
166
|
+
TextInput,
|
|
167
|
+
variants: {
|
|
168
|
+
View: { row: HorizontalStack, column: VerticalStack, card: SurfaceCard, list: ItemList },
|
|
169
|
+
Text: { body: BodyText, caption: CaptionText },
|
|
170
|
+
Button: { default: DefaultButton, primary: PrimaryButton, borderless: LinkButton },
|
|
171
|
+
TextInput: {
|
|
172
|
+
shortText: ShortInput,
|
|
173
|
+
longText: MultilineInput,
|
|
174
|
+
number: NumericInput,
|
|
175
|
+
obscured: PasswordInput,
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Each override receives the same explicitly selected primitive props as its base component. Missing
|
|
182
|
+
entries fall back to `View`, `Text`, `Button`, or `TextInput`; omitted A2UI hints select their pinned
|
|
183
|
+
defaults (`body`, `default`, and `shortText`). The renderer consumes structural and style hints while
|
|
184
|
+
choosing a local component and never forwards `variant`, a server-provided style object, or an
|
|
185
|
+
arbitrary native prop. Hosts can combine variant slots with the typed adapter helpers when a design
|
|
186
|
+
system uses a different prop API. Variant slots apply only to `A2uiV1NativeSurface`; the custom `0.1`
|
|
187
|
+
`McpNativeSurface` always uses the four base primitives, even when the same host catalog is reused.
|
|
188
|
+
|
|
189
|
+
Create adapter components and the catalog at module scope, as above, or memoize them with stable dependencies. Each factory call intentionally creates a new React component type; calling one during every host render would remount that catalog entry and discard its component-local state. Generated adapters include descriptive React DevTools display names.
|
|
190
|
+
|
|
191
|
+
Use `A2uiV1NativeSurface` to mount that subset with renderer-local string state and official action envelopes:
|
|
192
|
+
|
|
193
|
+
```tsx
|
|
194
|
+
import { A2uiV1NativeSurface } from "@mcp-native/react-native";
|
|
195
|
+
import { Linking } from "react-native";
|
|
196
|
+
|
|
197
|
+
<A2uiV1NativeSurface
|
|
198
|
+
surface={surface}
|
|
199
|
+
policy={policy}
|
|
200
|
+
components={{ Button, Text, TextInput, View }}
|
|
201
|
+
onAction={(envelope, dataModel) => {
|
|
202
|
+
// dataModel is present only when the surface explicitly enables sendDataModel.
|
|
203
|
+
if (dataModel === undefined) {
|
|
204
|
+
sendToAgent(envelope);
|
|
205
|
+
} else {
|
|
206
|
+
sendToAgent(envelope, { dataModel });
|
|
207
|
+
}
|
|
208
|
+
}}
|
|
209
|
+
openUrlPolicy={({ url }) => new URL(url).origin === "https://docs.example.com"}
|
|
210
|
+
onOpenUrl={({ url }) => {
|
|
211
|
+
void Linking.openURL(url).catch(reportOpenUrlError);
|
|
212
|
+
}}
|
|
213
|
+
/>;
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Bound `TextField` changes update an owned local data model and rerender absolute or dynamic-list-relative bindings and formatted output immediately; they do not call the agent on each keystroke. Equivalent fresh store snapshots preserve those edits, while accepted agent data-model updates reset them. Repeated template buttons retain a renderer-only instance key, so pressing one resolves its user message, supported renderer functions, `@index`, and context again against the correct item in the latest local model while the official wire `sourceComponentId` remains the catalog component ID. The action is timestamped, reconstructed as finite JSON, and validated against the pinned official renderer-to-agent action schema. The callback receives the local data model only when the surface explicitly sets `sendDataModel: true`; otherwise its second argument is omitted. The host callback owns transport delivery and permission or consent boundaries.
|
|
217
|
+
|
|
218
|
+
`openUrl` is a local Button action, not an agent event. The host must allow the function name in the catalog policy and provide both `openUrlPolicy` and `onOpenUrl`. The adapter re-resolves the URL against current local state during the originating press, canonicalizes it, rejects non-HTTP(S), relative, credential-bearing, whitespace-containing, control-containing, Unicode-format-containing, or oversized values, and invokes the opener only when the synchronous policy returns exactly `true`. Invalid initial server values reject the surface; temporary invalid renderer-local text edits instead disable the affected Button until the value becomes valid, and strict resolution runs again before an enabled press can reach host policy. No URL handler is imported or called by this package. Each URL is capped at 8,192 UTF-16 code units and one expanded pass is capped at 1,048,576 URL code units.
|
|
219
|
+
|
|
220
|
+
Renderer functions other than `formatString`, `formatNumber`, `formatCurrency`, `formatDate`, `pluralize`, `required`, `regex`, `length`, `numeric`, `email`, `and`, `or`, `not`, template-scoped `@index`, and local Button action `openUrl`, nested inline catalogs, and every other basic-catalog component fail closed. Number and currency formatting uses `Intl.NumberFormat`, date formatting uses `Intl.DateTimeFormat`, and cardinal plural selection uses `Intl.PluralRules` with the required `other` fallback. `required` follows the pinned reference behavior for null, empty strings, and empty arrays. `length` and `numeric` use inclusive, ordered bounds, and `email` uses the pinned basic check with a 320-code-unit input cap. Agent-supplied `regex` is limited to 256 UTF-16 code units, a 4,096-code-unit input, repeats no larger than 4,096, no groups, alternation, backreferences, or Unicode property escapes, and at most one variable repeat; inputs over the cap fail the check, while unsupported or malformed patterns reject the surface. Expanded plans evaluate at most 10,000 renderer checks per pass. Each combined validation accessibility output is capped at 65,536 UTF-16 code units before construction, with at most 1,048,576 such output code units across one expanded pass. `formatDate` accepts finite Unix seconds or milliseconds, their numeric string forms, RFC 3339 timestamps, and strict `yyyy-MM-dd` dates. Absolute numeric magnitudes greater than `10,000,000,000` are milliseconds; all others are seconds. It supports the pinned catalog's `yy`, `yyyy`, `M`, `MM`, `MMM`, `MMMM`, `d`, `dd`, `E`, `EEEE`, `h`, `hh`, `H`, `HH`, `mm`, `ss`, and `a` token subset plus quoted literals; `h` and `hh` require `a`, other pattern letters fail closed, and one pattern may contain at most 128 tokens. The host may supply one validated, runtime-supported BCP 47 `locale` to the mounted surface, render-plan options, event-resolution options, and URL-resolution options, or omit it to use the runtime locale. A date-only `yyyy-MM-dd` value is a calendar date interpreted at midnight in the runtime time zone. An RFC 3339 value is an instant whose declared offset is applied before it is formatted in that runtime time zone. Agent-controlled decimal precision is restricted to an integer from 0 through 100, currency must appear in ISO 4217 List One published 2026-01-01, dynamic values resolve with strict types, formatter construction failures are controlled parse errors, and formatter caches live only for one bounded render, event-resolution, or URL-resolution pass. Expanded plans are capped at 1,024 nodes, 10,000 interpolations, and 1,048,576 formatted UTF-16 code units so repeated references or large bound arrays cannot amplify a small component graph into unbounded work; each formatted result also retains the shared 65,536-code-unit string limit.
|
|
107
221
|
|
|
108
222
|
## Public API
|
|
109
223
|
|
|
110
|
-
| Export | Purpose
|
|
111
|
-
| --------------------------------------- |
|
|
112
|
-
| `McpNativeSurface` | Mounts a validated surface using the host's component catalog.
|
|
113
|
-
| `
|
|
114
|
-
| `
|
|
115
|
-
| `
|
|
116
|
-
| `
|
|
117
|
-
| `
|
|
118
|
-
| `
|
|
119
|
-
| `
|
|
120
|
-
| `
|
|
121
|
-
| `
|
|
122
|
-
| `
|
|
123
|
-
| `
|
|
124
|
-
| `
|
|
224
|
+
| Export | Purpose |
|
|
225
|
+
| --------------------------------------- | -------------------------------------------------------------------------------------------------------- |
|
|
226
|
+
| `McpNativeSurface` | Mounts a validated surface using the host's component catalog. |
|
|
227
|
+
| `A2uiV1NativeSurface` | Mounts the supported v1 subset with local bindings and official action-envelope callbacks. |
|
|
228
|
+
| `useMcpNativeActionDispatcher` | Adapts asynchronous runtime dispatch into a stable event callback with required error handling. |
|
|
229
|
+
| `useNativeRenderPlan` | Memoizes a trusted render plan for a validated surface identity. |
|
|
230
|
+
| `createNativeRenderPlan` | Converts a validated `A2uiSurface` into a `NativeElement` tree. |
|
|
231
|
+
| `createA2uiV1NativeRenderPlan` | Revalidates and adapts the supported v1 subset into a trusted `NativeElement` tree. |
|
|
232
|
+
| `resolveA2uiV1NativeEvent` | Revalidates and resolves one reachable static or template-instance event against the latest local model. |
|
|
233
|
+
| `resolveA2uiV1NativeOpenUrl` | Revalidates and resolves one reachable HTTP(S) URL action against the latest local model. |
|
|
234
|
+
| `A2UI_V1_NATIVE_COMPONENT_NAMES` | Exact basic-catalog component names implemented by the current native adapter. |
|
|
235
|
+
| `A2UI_V1_NATIVE_MAX_RENDER_NODES` | Bound on expanded v1 render-plan nodes. |
|
|
236
|
+
| `A2UI_V1_NATIVE_MAX_OPEN_URL_LENGTH` | Per-action bound on canonical HTTP(S) URL length. |
|
|
237
|
+
| `A2uiV1NativeEventDescriptor` | Resolved trusted-plan event data used by mounted dispatch or custom hosts. |
|
|
238
|
+
| `A2uiV1NativeOpenUrlDescriptor` | Canonical URL plus surface, component, and optional template-instance identity. |
|
|
239
|
+
| `A2uiV1NativeRenderPlanOptions` | Optional renderer-local model and host-owned BCP 47 locale. |
|
|
240
|
+
| `A2uiV1NativeEventResolutionOptions` | Optional template instance key and matching host-owned BCP 47 locale. |
|
|
241
|
+
| `A2uiV1NativeOpenUrlResolutionOptions` | Optional template instance key and matching host-owned BCP 47 locale for URL resolution. |
|
|
242
|
+
| `A2uiV1NativeActionHandler` | Host callback receiving the validated action envelope and, when opted in, the local data model. |
|
|
243
|
+
| `A2uiV1NativeOpenUrlPolicy` | Synchronous host predicate authorizing one canonical URL during its Button press. |
|
|
244
|
+
| `A2uiV1NativeOpenUrlHandler` | Host-owned callback that opens an authorized URL through a platform API. |
|
|
245
|
+
| `NativeComponentCatalog` | Base primitives plus optional closed host-owned component variants. |
|
|
246
|
+
| `NativeComponentVariants` | Optional overrides for supported structure and pinned style hints, with primitive fallbacks. |
|
|
247
|
+
| `Native*Variant` types | Closed view, text, button, and text-input variant keys. |
|
|
248
|
+
| `NativeAccessibilityRole` | Renderer-derived closed role union for supported text and button primitives. |
|
|
249
|
+
| `NativeAccessibilityState` | Renderer-derived state currently exposing only the supported button disabled flag. |
|
|
250
|
+
| `createNative*Adapter` helpers | Typed mappings from trusted primitive props into locally bundled component-library APIs. |
|
|
251
|
+
| `NativeComponentPropMapper` | Generic mapper type used by the four host component adapter helpers. |
|
|
252
|
+
| `NativeActionHandler` | Synchronous handler for a validated declared action. |
|
|
253
|
+
| `NativeBindingChangeHandler` | Handler receiving a validated binding name and the next text value. |
|
|
254
|
+
| `McpNativeActionDispatcherOptions` | Required action error callback and optional result callback. |
|
|
255
|
+
| `NativeElement` / `NativeComponentName` | Serializable trusted-plan node and its fixed component-name union. |
|
|
125
256
|
|
|
126
257
|
## Current mappings
|
|
127
258
|
|
|
128
|
-
| Surface node | Native component | Host props and event behavior
|
|
129
|
-
| ------------ | ---------------- |
|
|
130
|
-
| `container` | `View` | Nested trusted children
|
|
131
|
-
| `text` | `Text` | Validated
|
|
132
|
-
| `button` | `Button` | `title`,
|
|
133
|
-
| `text-input` | `TextInput` | Label
|
|
259
|
+
| Surface node | Native component | Host props and event behavior |
|
|
260
|
+
| ------------ | ---------------- | ----------------------------------------------------------------------------------------- |
|
|
261
|
+
| `container` | `View` | Nested trusted children |
|
|
262
|
+
| `text` | `Text` | Validated `children`, closed `text` role, and enabled font scaling |
|
|
263
|
+
| `button` | `Button` | `title`, label, closed `button` role/state, and `onPress` for its validated action |
|
|
264
|
+
| `text-input` | `TextInput` | Label/placeholder, enabled font scaling, optional value, and binding-aware `onChangeText` |
|
|
134
265
|
|
|
135
266
|
## Trust boundary
|
|
136
267
|
|
|
@@ -138,12 +269,14 @@ Dynamic list templates, relative bindings, renderer functions, renderer-side che
|
|
|
138
269
|
- The server cannot send executable React Native code.
|
|
139
270
|
- Render plans should only be created from a successfully validated surface.
|
|
140
271
|
- The v1 adapter performs policy validation again at its public boundary.
|
|
141
|
-
-
|
|
272
|
+
- The mounted v1 surface owns local binding state and revalidates action context at dispatch time.
|
|
273
|
+
- Unsupported v1 components and arbitrary executable functions fail closed.
|
|
142
274
|
- Declared actions and their complete JSON arguments are validated again immediately before emission.
|
|
143
275
|
- Rendered component props are selected explicitly; unchecked server props are never spread into host components.
|
|
144
|
-
-
|
|
276
|
+
- Accessibility roles, native state, focus eligibility, and font scaling are renderer-derived; server data cannot replace them.
|
|
277
|
+
- The host must explicitly map components, enforce permissions, and choose the renderer-to-agent transport; emitting an envelope does not grant network or device access.
|
|
145
278
|
- Asynchronous action failures cannot become unhandled rejections because `useMcpNativeActionDispatcher` requires an error callback.
|
|
146
|
-
-
|
|
279
|
+
- Styling variants preserve pinned allowlists and never spread unchecked server props; future component expansion must retain the same boundary.
|
|
147
280
|
|
|
148
281
|
See [`@mcp-native/a2ui`](https://www.npmjs.com/package/@mcp-native/a2ui) for parsing and [`@mcp-native/core`](https://www.npmjs.com/package/@mcp-native/core) for action dispatch. Install [`mcp-native`](https://www.npmjs.com/package/mcp-native) for the combined runtime and UI APIs.
|
|
149
282
|
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { type ComponentType, type ReactNode } from "react";
|
|
2
|
+
export type NativeAccessibilityRole = "button" | "text";
|
|
3
|
+
export interface NativeAccessibilityState {
|
|
4
|
+
readonly disabled: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface NativeAccessibilityProps {
|
|
7
|
+
readonly accessible?: boolean;
|
|
8
|
+
readonly accessibilityElementsHidden?: boolean;
|
|
9
|
+
readonly accessibilityHint?: string;
|
|
10
|
+
readonly accessibilityLabel?: string;
|
|
11
|
+
readonly accessibilityLiveRegion?: "assertive" | "none" | "polite";
|
|
12
|
+
readonly importantForAccessibility?: "auto" | "no-hide-descendants";
|
|
13
|
+
}
|
|
14
|
+
export interface NativeViewStyle {
|
|
15
|
+
readonly alignItems?: "center" | "flex-end" | "flex-start" | "stretch";
|
|
16
|
+
readonly flexDirection?: "column" | "row";
|
|
17
|
+
readonly flexGrow?: number;
|
|
18
|
+
readonly justifyContent?: "center" | "flex-end" | "flex-start" | "space-around" | "space-between" | "space-evenly";
|
|
19
|
+
}
|
|
20
|
+
export interface NativeViewComponentProps extends NativeAccessibilityProps {
|
|
21
|
+
readonly children?: ReactNode;
|
|
22
|
+
readonly style?: NativeViewStyle;
|
|
23
|
+
}
|
|
24
|
+
export interface NativeTextComponentProps extends NativeAccessibilityProps {
|
|
25
|
+
readonly accessible: boolean;
|
|
26
|
+
readonly accessibilityRole: "text";
|
|
27
|
+
readonly allowFontScaling: true;
|
|
28
|
+
readonly children: string;
|
|
29
|
+
}
|
|
30
|
+
export interface NativeButtonComponentProps extends NativeAccessibilityProps {
|
|
31
|
+
readonly accessible: boolean;
|
|
32
|
+
readonly accessibilityLabel: string;
|
|
33
|
+
readonly accessibilityRole: "button";
|
|
34
|
+
readonly accessibilityState: NativeAccessibilityState;
|
|
35
|
+
readonly disabled?: boolean;
|
|
36
|
+
readonly onPress: () => void;
|
|
37
|
+
readonly title: string;
|
|
38
|
+
readonly validationMessages?: readonly string[];
|
|
39
|
+
}
|
|
40
|
+
export interface NativeTextInputComponentProps extends NativeAccessibilityProps {
|
|
41
|
+
readonly accessible: boolean;
|
|
42
|
+
readonly accessibilityLabel: string;
|
|
43
|
+
readonly allowFontScaling: true;
|
|
44
|
+
readonly invalid?: boolean;
|
|
45
|
+
readonly keyboardType?: "numeric";
|
|
46
|
+
readonly multiline?: boolean;
|
|
47
|
+
readonly onChangeText?: (value: string) => void;
|
|
48
|
+
readonly placeholder: string;
|
|
49
|
+
readonly secureTextEntry?: boolean;
|
|
50
|
+
readonly validationMessages?: readonly string[];
|
|
51
|
+
readonly value?: string;
|
|
52
|
+
}
|
|
53
|
+
export type NativeViewVariant = "card" | "column" | "list" | "row";
|
|
54
|
+
export type NativeTextVariant = "body" | "caption";
|
|
55
|
+
export type NativeButtonVariant = "borderless" | "default" | "primary";
|
|
56
|
+
export type NativeTextInputVariant = "longText" | "number" | "obscured" | "shortText";
|
|
57
|
+
/**
|
|
58
|
+
* Optional locally bundled component overrides for the pinned A2UI style hints.
|
|
59
|
+
* The renderer selects only these closed keys and still supplies primitive props.
|
|
60
|
+
*/
|
|
61
|
+
export interface NativeComponentVariants {
|
|
62
|
+
readonly View?: Partial<Record<NativeViewVariant, ComponentType<NativeViewComponentProps>>>;
|
|
63
|
+
readonly Text?: Partial<Record<NativeTextVariant, ComponentType<NativeTextComponentProps>>>;
|
|
64
|
+
readonly Button?: Partial<Record<NativeButtonVariant, ComponentType<NativeButtonComponentProps>>>;
|
|
65
|
+
readonly TextInput?: Partial<Record<NativeTextInputVariant, ComponentType<NativeTextInputComponentProps>>>;
|
|
66
|
+
}
|
|
67
|
+
/** Locally bundled components chosen by the host application. */
|
|
68
|
+
export interface NativeComponentCatalog {
|
|
69
|
+
readonly View: ComponentType<NativeViewComponentProps>;
|
|
70
|
+
readonly Text: ComponentType<NativeTextComponentProps>;
|
|
71
|
+
readonly Button: ComponentType<NativeButtonComponentProps>;
|
|
72
|
+
readonly TextInput: ComponentType<NativeTextInputComponentProps>;
|
|
73
|
+
/** Optional semantic/style variants; omitted entries fall back to the base primitive. */
|
|
74
|
+
readonly variants?: NativeComponentVariants;
|
|
75
|
+
}
|
|
76
|
+
/** Maps renderer-selected primitive props into one locally bundled host component. */
|
|
77
|
+
export type NativeComponentPropMapper<TrustedProps extends object, HostProps extends object> = (props: TrustedProps) => HostProps;
|
|
78
|
+
/** Adapts trusted MCP Native view props to a host design-system component. */
|
|
79
|
+
export declare function createNativeViewAdapter<HostProps extends object>(component: ComponentType<HostProps>, mapProps: NativeComponentPropMapper<NativeViewComponentProps, HostProps>): ComponentType<NativeViewComponentProps>;
|
|
80
|
+
/** Adapts trusted MCP Native text props to a host design-system component. */
|
|
81
|
+
export declare function createNativeTextAdapter<HostProps extends object>(component: ComponentType<HostProps>, mapProps: NativeComponentPropMapper<NativeTextComponentProps, HostProps>): ComponentType<NativeTextComponentProps>;
|
|
82
|
+
/** Adapts trusted MCP Native button props to a host design-system component. */
|
|
83
|
+
export declare function createNativeButtonAdapter<HostProps extends object>(component: ComponentType<HostProps>, mapProps: NativeComponentPropMapper<NativeButtonComponentProps, HostProps>): ComponentType<NativeButtonComponentProps>;
|
|
84
|
+
/** Adapts trusted MCP Native text-input props to a host design-system component. */
|
|
85
|
+
export declare function createNativeTextInputAdapter<HostProps extends object>(component: ComponentType<HostProps>, mapProps: NativeComponentPropMapper<NativeTextInputComponentProps, HostProps>): ComponentType<NativeTextInputComponentProps>;
|
|
86
|
+
//# sourceMappingURL=component-adapters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-adapters.d.ts","sourceRoot":"","sources":["../src/component-adapters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE1E,MAAM,MAAM,uBAAuB,GAAG,QAAQ,GAAG,MAAM,CAAC;AAExD,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,2BAA2B,CAAC,EAAE,OAAO,CAAC;IAC/C,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,uBAAuB,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,QAAQ,CAAC;IACnE,QAAQ,CAAC,yBAAyB,CAAC,EAAE,MAAM,GAAG,qBAAqB,CAAC;CACrE;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,UAAU,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,YAAY,GAAG,SAAS,CAAC;IACvE,QAAQ,CAAC,aAAa,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;IAC1C,QAAQ,CAAC,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aAAa,CAAC,6BAA6B,CAAC,CAE9C"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createElement } from "react";
|
|
2
|
+
function createComponentAdapter(primitiveName, component, mapProps) {
|
|
3
|
+
function NativeComponentAdapter(props) {
|
|
4
|
+
return createElement(component, mapProps(props));
|
|
5
|
+
}
|
|
6
|
+
const componentName = component.displayName ?? component.name ?? "Component";
|
|
7
|
+
NativeComponentAdapter.displayName = `McpNative${primitiveName}Adapter(${componentName})`;
|
|
8
|
+
return NativeComponentAdapter;
|
|
9
|
+
}
|
|
10
|
+
/** Adapts trusted MCP Native view props to a host design-system component. */
|
|
11
|
+
export function createNativeViewAdapter(component, mapProps) {
|
|
12
|
+
return createComponentAdapter("View", component, mapProps);
|
|
13
|
+
}
|
|
14
|
+
/** Adapts trusted MCP Native text props to a host design-system component. */
|
|
15
|
+
export function createNativeTextAdapter(component, mapProps) {
|
|
16
|
+
return createComponentAdapter("Text", component, mapProps);
|
|
17
|
+
}
|
|
18
|
+
/** Adapts trusted MCP Native button props to a host design-system component. */
|
|
19
|
+
export function createNativeButtonAdapter(component, mapProps) {
|
|
20
|
+
return createComponentAdapter("Button", component, mapProps);
|
|
21
|
+
}
|
|
22
|
+
/** Adapts trusted MCP Native text-input props to a host design-system component. */
|
|
23
|
+
export function createNativeTextInputAdapter(component, mapProps) {
|
|
24
|
+
return createComponentAdapter("TextInput", component, mapProps);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=component-adapters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-adapters.js","sourceRoot":"","sources":["../src/component-adapters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAsC,MAAM,OAAO,CAAC;AAuG1E,SAAS,sBAAsB,CAC7B,aAAuD,EACvD,SAAmC,EACnC,QAA4D;IAE5D,SAAS,sBAAsB,CAAC,KAAmB;QACjD,OAAO,aAAa,CAAC,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IACnD,CAAC;IACD,MAAM,aAAa,GAAG,SAAS,CAAC,WAAW,IAAI,SAAS,CAAC,IAAI,IAAI,WAAW,CAAC;IAC7E,sBAAsB,CAAC,WAAW,GAAG,YAAY,aAAa,WAAW,aAAa,GAAG,CAAC;IAC1F,OAAO,sBAAsB,CAAC;AAChC,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,uBAAuB,CACrC,SAAmC,EACnC,QAAwE;IAExE,OAAO,sBAAsB,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;AAC7D,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,uBAAuB,CACrC,SAAmC,EACnC,QAAwE;IAExE,OAAO,sBAAsB,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;AAC7D,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,yBAAyB,CACvC,SAAmC,EACnC,QAA0E;IAE1E,OAAO,sBAAsB,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;AAC/D,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,4BAA4B,CAC1C,SAAmC,EACnC,QAA6E;IAE7E,OAAO,sBAAsB,CAAC,WAAW,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;AAClE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import type { A2uiSurface } from "@mcp-native/a2ui";
|
|
2
|
-
import type { McpNativeAction, McpToolCallResult } from "@mcp-native/core";
|
|
3
|
-
import { type
|
|
1
|
+
import type { A2uiSurface, A2uiV1ActionEnvelope, A2uiV1SurfaceState, A2uiV1SurfaceValidationPolicy } from "@mcp-native/a2ui";
|
|
2
|
+
import type { JsonObject, McpNativeAction, McpToolCallResult } from "@mcp-native/core";
|
|
3
|
+
import { type ReactElement } from "react";
|
|
4
|
+
import type { NativeComponentCatalog } from "./component-adapters.js";
|
|
5
|
+
import { type A2uiV1NativeOpenUrlDescriptor } from "./v1.js";
|
|
6
|
+
export { createNativeButtonAdapter, createNativeTextAdapter, createNativeTextInputAdapter, createNativeViewAdapter, } from "./component-adapters.js";
|
|
7
|
+
export type { NativeComponentPropMapper } from "./component-adapters.js";
|
|
8
|
+
export type { NativeAccessibilityProps, NativeAccessibilityRole, NativeAccessibilityState, NativeButtonComponentProps, NativeButtonVariant, NativeComponentCatalog, NativeComponentVariants, NativeTextComponentProps, NativeTextInputComponentProps, NativeTextInputVariant, NativeTextVariant, NativeViewComponentProps, NativeViewStyle, NativeViewVariant, } from "./component-adapters.js";
|
|
4
9
|
export type NativeComponentName = "Button" | "Text" | "TextInput" | "View";
|
|
5
10
|
/**
|
|
6
11
|
* A serializable render plan. A React Native host maps these trusted component
|
|
@@ -12,38 +17,40 @@ export interface NativeElement {
|
|
|
12
17
|
readonly props: Readonly<Record<string, unknown>>;
|
|
13
18
|
readonly children?: readonly NativeElement[];
|
|
14
19
|
}
|
|
15
|
-
|
|
16
|
-
readonly children?: ReactNode;
|
|
17
|
-
}
|
|
18
|
-
export interface NativeTextComponentProps {
|
|
19
|
-
readonly children: string;
|
|
20
|
-
}
|
|
21
|
-
export interface NativeButtonComponentProps {
|
|
22
|
-
readonly accessibilityLabel: string;
|
|
23
|
-
readonly onPress: () => void;
|
|
24
|
-
readonly title: string;
|
|
25
|
-
}
|
|
26
|
-
export interface NativeTextInputComponentProps {
|
|
27
|
-
readonly accessibilityLabel: string;
|
|
28
|
-
readonly onChangeText?: (value: string) => void;
|
|
29
|
-
readonly placeholder: string;
|
|
30
|
-
readonly value?: string;
|
|
31
|
-
}
|
|
32
|
-
/** Locally bundled components chosen by the host application. */
|
|
33
|
-
export interface NativeComponentCatalog {
|
|
34
|
-
readonly View: ComponentType<NativeViewComponentProps>;
|
|
35
|
-
readonly Text: ComponentType<NativeTextComponentProps>;
|
|
36
|
-
readonly Button: ComponentType<NativeButtonComponentProps>;
|
|
37
|
-
readonly TextInput: ComponentType<NativeTextInputComponentProps>;
|
|
38
|
-
}
|
|
20
|
+
/** @deprecated Use `A2uiV1NativeSurface` and its official action envelope handler. */
|
|
39
21
|
export type NativeActionHandler = (action: McpNativeAction) => void;
|
|
22
|
+
/** @deprecated Use `A2uiV1NativeSurface` renderer-local data-model handling. */
|
|
40
23
|
export type NativeBindingChangeHandler = (binding: string, value: string) => void;
|
|
24
|
+
/** @deprecated Use `A2uiV1NativeSurfaceProps`. */
|
|
41
25
|
export interface McpNativeSurfaceProps {
|
|
42
26
|
readonly surface: A2uiSurface;
|
|
43
27
|
readonly components: NativeComponentCatalog;
|
|
44
28
|
readonly onAction: NativeActionHandler;
|
|
45
29
|
readonly onBindingChange?: NativeBindingChangeHandler;
|
|
46
30
|
}
|
|
31
|
+
export type A2uiV1NativeActionHandler = (envelope: A2uiV1ActionEnvelope, dataModel?: JsonObject) => void;
|
|
32
|
+
/** Synchronous host authorization checked during the originating Button press. */
|
|
33
|
+
export type A2uiV1NativeOpenUrlPolicy = (request: A2uiV1NativeOpenUrlDescriptor) => boolean;
|
|
34
|
+
/** Host-owned platform opener. The library never invokes a browser or URL handler directly. */
|
|
35
|
+
export type A2uiV1NativeOpenUrlHandler = (request: A2uiV1NativeOpenUrlDescriptor) => void;
|
|
36
|
+
export interface A2uiV1NativeSurfaceProps {
|
|
37
|
+
readonly surface: A2uiV1SurfaceState;
|
|
38
|
+
readonly policy: A2uiV1SurfaceValidationPolicy;
|
|
39
|
+
readonly components: NativeComponentCatalog;
|
|
40
|
+
/** Receives an official envelope and, only after explicit surface opt-in, the local model. */
|
|
41
|
+
readonly onAction: A2uiV1NativeActionHandler;
|
|
42
|
+
/** Required with `onOpenUrl` when this surface is allowed to use the local `openUrl` function. */
|
|
43
|
+
readonly openUrlPolicy?: A2uiV1NativeOpenUrlPolicy;
|
|
44
|
+
/** Executes an authorized URL while the originating Button press is still active. */
|
|
45
|
+
readonly onOpenUrl?: A2uiV1NativeOpenUrlHandler;
|
|
46
|
+
/** Observes renderer-local state changes without turning keystrokes into network calls. */
|
|
47
|
+
readonly onDataModelChange?: (dataModel: JsonObject) => void;
|
|
48
|
+
readonly actionMetadata?: JsonObject;
|
|
49
|
+
/** Host-selected BCP 47 locale for renderer-side number, currency, date, and plural formatting. */
|
|
50
|
+
readonly locale?: string;
|
|
51
|
+
/** Injectable RFC 3339 timestamp source for host clocks and deterministic tests. */
|
|
52
|
+
readonly now?: () => string;
|
|
53
|
+
}
|
|
47
54
|
export interface McpNativeDispatcher {
|
|
48
55
|
dispatch(action: McpNativeAction): Promise<McpToolCallResult>;
|
|
49
56
|
}
|
|
@@ -51,8 +58,9 @@ export interface McpNativeActionDispatcherOptions {
|
|
|
51
58
|
readonly onError: (error: unknown) => void;
|
|
52
59
|
readonly onResult?: (result: McpToolCallResult) => void;
|
|
53
60
|
}
|
|
61
|
+
/** @deprecated Use `createA2uiV1NativeRenderPlan`. */
|
|
54
62
|
export declare function createNativeRenderPlan(surface: A2uiSurface): NativeElement;
|
|
55
|
-
/**
|
|
63
|
+
/** @deprecated Use `A2uiV1NativeSurface`. */
|
|
56
64
|
export declare function useNativeRenderPlan(surface: A2uiSurface): NativeElement;
|
|
57
65
|
/**
|
|
58
66
|
* Creates a stable, synchronous event handler for a runtime's asynchronous
|
|
@@ -60,8 +68,13 @@ export declare function useNativeRenderPlan(surface: A2uiSurface): NativeElement
|
|
|
60
68
|
* routed to the required error hook.
|
|
61
69
|
*/
|
|
62
70
|
export declare function useMcpNativeActionDispatcher(dispatcher: McpNativeDispatcher, options: McpNativeActionDispatcherOptions): NativeActionHandler;
|
|
63
|
-
/**
|
|
71
|
+
/** @deprecated Use `A2uiV1NativeSurface`. */
|
|
64
72
|
export declare function McpNativeSurface({ surface, components, onAction, onBindingChange, }: McpNativeSurfaceProps): ReactElement;
|
|
65
|
-
|
|
66
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Mounts the supported A2UI v1 subset with renderer-local two-way bindings.
|
|
75
|
+
* Agent events are resolved against the latest local model at press time.
|
|
76
|
+
*/
|
|
77
|
+
export declare function A2uiV1NativeSurface({ surface, policy, components, onAction, openUrlPolicy, onOpenUrl, onDataModelChange, actionMetadata, locale, now, }: A2uiV1NativeSurfaceProps): ReactElement;
|
|
78
|
+
export { A2UI_V1_NATIVE_COMPONENT_NAMES, A2UI_V1_NATIVE_MAX_OPEN_URL_LENGTH, A2UI_V1_NATIVE_MAX_RENDER_NODES, createA2uiV1NativeRenderPlan, resolveA2uiV1NativeEvent, resolveA2uiV1NativeOpenUrl, } from "./v1.js";
|
|
79
|
+
export type { A2uiV1NativeEventDescriptor, A2uiV1NativeEventResolutionOptions, A2uiV1NativeOpenUrlDescriptor, A2uiV1NativeOpenUrlResolutionOptions, A2uiV1NativeRenderPlanOptions, } from "./v1.js";
|
|
67
80
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,WAAW,EACX,oBAAoB,EACpB,kBAAkB,EAClB,6BAA6B,EAC9B,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,UAAU,EAAa,eAAe,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAClG,OAAO,EAQL,KAAK,YAAY,EAClB,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAGV,sBAAsB,EAMvB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAOL,KAAK,6BAA6B,EACnC,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,yBAAyB,EACzB,uBAAuB,EACvB,4BAA4B,EAC5B,uBAAuB,GACxB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACzE,YAAY,EACV,wBA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