@mcp-native/react-native 0.0.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,27 +8,33 @@
8
8
  [![downloads](https://img.shields.io/npm/dm/@mcp-native/react-native)](https://www.npmjs.com/package/@mcp-native/react-native)
9
9
  [![license](https://img.shields.io/npm/l/@mcp-native/react-native)](https://github.com/pablospaniard/mcp-native/blob/main/LICENSE)
10
10
 
11
- [GitHub](https://github.com/pablospaniard/mcp-native) · [Architecture](https://github.com/pablospaniard/mcp-native/blob/main/docs/RFC-0001-architecture.md) · [Security](https://github.com/pablospaniard/mcp-native/blob/main/SECURITY.md)
11
+ [GitHub](https://github.com/pablospaniard/mcp-native) · [Architecture](https://github.com/pablospaniard/mcp-native/blob/main/docs/RFC-0001-architecture.md) · [Standards status](https://github.com/pablospaniard/mcp-native/blob/main/docs/standards-compatibility.md) · [Security](https://github.com/pablospaniard/mcp-native/blob/main/SECURITY.md)
12
12
 
13
13
  </div>
14
14
 
15
- > **Experimental:** this package currently produces a serializable render plan. It does not yet ship React components, hooks, or a complete React Native renderer.
15
+ > **Experimental:** this package now mounts the initial surface model, but its API and component catalog may change before `1.0.0`.
16
16
 
17
- `@mcp-native/react-native` converts a surface already validated by `@mcp-native/a2ui` into a tree whose component names come from a fixed host-owned catalog. Servers provide data and declared actions—not JavaScript modules or arbitrary component names.
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
+
19
+ The renderer is an internal platform layer, not proof of complete A2UI v1.0 conformance. The custom `0.1` surface remains supported, and the separate v1.0 adapter now converts a strict static subset into the same host-owned `NativeElement` boundary.
18
20
 
19
21
  ## Install
20
22
 
21
23
  ```bash
22
- npm install @mcp-native/react-native
24
+ npm install @mcp-native/react-native react react-native
23
25
  ```
24
26
 
25
- `@mcp-native/a2ui` and `@mcp-native/core` are installed as dependencies. React and React Native are not dependencies yet because this preview returns data rather than mounting components.
27
+ `@mcp-native/a2ui` and `@mcp-native/core` are installed as dependencies. React is a peer dependency. React Native is an optional peer because the renderer does not import it or choose a platform implementation; a native host supplies its locally bundled components.
26
28
 
27
29
  ## Quick start
28
30
 
29
- ```ts
31
+ ```tsx
30
32
  import { parseA2uiSurface } from "@mcp-native/a2ui";
31
- import { createNativeRenderPlan } from "@mcp-native/react-native";
33
+ import type { McpNativeRuntime } from "@mcp-native/core";
34
+ import { McpNativeSurface, useMcpNativeActionDispatcher } from "@mcp-native/react-native";
35
+ import { Button, Text, TextInput, View } from "react-native";
36
+
37
+ const components = { Button, Text, TextInput, View };
32
38
 
33
39
  const surface = parseA2uiSurface({
34
40
  version: "0.1",
@@ -47,43 +53,99 @@ const surface = parseA2uiSurface({
47
53
  },
48
54
  });
49
55
 
50
- const plan = createNativeRenderPlan(surface);
56
+ function Example({ runtime }: { runtime: McpNativeRuntime }) {
57
+ const onAction = useMcpNativeActionDispatcher(runtime, {
58
+ onError(error) {
59
+ console.error("MCP action failed", error);
60
+ },
61
+ });
62
+
63
+ return (
64
+ <McpNativeSurface
65
+ surface={surface}
66
+ components={components}
67
+ onAction={onAction}
68
+ onBindingChange={(binding, value) => {
69
+ console.log("binding changed", binding, value);
70
+ }}
71
+ />
72
+ );
73
+ }
51
74
  ```
52
75
 
53
- `plan` contains only the currently allowed component names:
76
+ The renderer uses only the currently allowed component names:
54
77
 
55
78
  ```ts
56
79
  type NativeComponentName = "Button" | "Text" | "TextInput" | "View";
57
80
  ```
58
81
 
59
- The application host decides how each name maps to a locally bundled component and how declared button actions reach `McpNativeRuntime`.
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; this milestone deliberately leaves local state ownership and server synchronization to the host.
83
+
84
+ ## A2UI v1 render-plan adapter
85
+
86
+ Use the v1 adapter only with an explicit host policy. It revalidates the snapshot before resolving data-model bindings or creating a trusted plan.
87
+
88
+ ```ts
89
+ import { createA2uiV1BasicCatalogPolicy } from "@mcp-native/a2ui";
90
+ import {
91
+ A2UI_V1_NATIVE_COMPONENT_NAMES,
92
+ createA2uiV1NativeRenderPlan,
93
+ } from "@mcp-native/react-native";
94
+
95
+ const policy = createA2uiV1BasicCatalogPolicy({
96
+ allowedComponentNames: A2UI_V1_NATIVE_COMPONENT_NAMES,
97
+ allowedEventNames: ["save_profile"],
98
+ });
99
+
100
+ const surface = store.get("profile");
101
+ const plan = surface && createA2uiV1NativeRenderPlan(surface, policy);
102
+ ```
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`. It resolves absolute JSON Pointer values, preserves supported container alignment, event context, and explicit accessibility fields. Event descriptors remain inert plan data; mounting them and constructing renderer-to-agent envelopes is the next boundary.
105
+
106
+ Dynamic list templates, relative bindings, renderer functions, renderer-side checks, local function actions, and every other basic-catalog component fail closed. Expanded plans are capped at 1,024 nodes so repeated references cannot amplify a small component graph into unbounded work.
60
107
 
61
108
  ## Public API
62
109
 
63
- | Export | Purpose |
64
- | ------------------------ | ----------------------------------------------------------------------------------------------- |
65
- | `createNativeRenderPlan` | Converts a validated `A2uiSurface` into a `NativeElement` tree. |
66
- | `NativeElement` | Serializable render-plan node with a key, trusted component name, props, and optional children. |
67
- | `NativeComponentName` | Union of component names currently allowed in the plan. |
110
+ | Export | Purpose |
111
+ | --------------------------------------- | ----------------------------------------------------------------------------------------------- |
112
+ | `McpNativeSurface` | Mounts a validated surface using the host's component catalog. |
113
+ | `useMcpNativeActionDispatcher` | Adapts asynchronous runtime dispatch into a stable event callback with required error handling. |
114
+ | `useNativeRenderPlan` | Memoizes a trusted render plan for a validated surface identity. |
115
+ | `createNativeRenderPlan` | Converts a validated `A2uiSurface` into a `NativeElement` tree. |
116
+ | `createA2uiV1NativeRenderPlan` | Revalidates and adapts the supported v1 subset into a trusted `NativeElement` tree. |
117
+ | `A2UI_V1_NATIVE_COMPONENT_NAMES` | Exact basic-catalog component names implemented by the current native adapter. |
118
+ | `A2UI_V1_NATIVE_MAX_RENDER_NODES` | Bound on expanded v1 render-plan nodes. |
119
+ | `A2uiV1NativeEventDescriptor` | Resolved inert event data retained for later renderer-to-agent dispatch. |
120
+ | `NativeComponentCatalog` | Contract for locally bundled `View`, `Text`, `Button`, and `TextInput` implementations. |
121
+ | `NativeActionHandler` | Synchronous handler for a validated declared action. |
122
+ | `NativeBindingChangeHandler` | Handler receiving a validated binding name and the next text value. |
123
+ | `McpNativeActionDispatcherOptions` | Required action error callback and optional result callback. |
124
+ | `NativeElement` / `NativeComponentName` | Serializable trusted-plan node and its fixed component-name union. |
68
125
 
69
126
  ## Current mappings
70
127
 
71
- | Surface node | Native component | Selected props |
72
- | ------------ | ---------------- | --------------------------------------------- |
73
- | `container` | `View` | Nested `children` |
74
- | `text` | `Text` | Text as `children` |
75
- | `button` | `Button` | `title` and validated `action` |
76
- | `text-input` | `TextInput` | `label`, optional `value`, optional `binding` |
128
+ | Surface node | Native component | Host props and event behavior |
129
+ | ------------ | ---------------- | ------------------------------------------------------------------------------------------ |
130
+ | `container` | `View` | Nested trusted children |
131
+ | `text` | `Text` | Validated text as `children` |
132
+ | `button` | `Button` | `title`, matching `accessibilityLabel`, and an `onPress` callback for its validated action |
133
+ | `text-input` | `TextInput` | Label as placeholder/accessibility label, optional value, and binding-aware `onChangeText` |
77
134
 
78
135
  ## Trust boundary
79
136
 
80
137
  - The server cannot select components outside the catalog.
81
138
  - The server cannot send executable React Native code.
82
139
  - Render plans should only be created from a successfully validated surface.
83
- - The host must explicitly map component names, bind events, enforce permissions, and approve sensitive tool calls.
140
+ - The v1 adapter performs policy validation again at its public boundary.
141
+ - Unsupported v1 components, dynamic templates, and executable functions fail closed.
142
+ - Declared actions and their complete JSON arguments are validated again immediately before emission.
143
+ - Rendered component props are selected explicitly; unchecked server props are never spread into host components.
144
+ - The host must explicitly map components, own state, enforce permissions, and configure the runtime action policy; dispatch is denied when no policy allows it.
145
+ - Asynchronous action failures cannot become unhandled rejections because `useMcpNativeActionDispatcher` requires an error callback.
84
146
  - Future styling and component expansion must preserve allowlists rather than spreading unchecked server props.
85
147
 
86
- 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 every public API.
148
+ 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.
87
149
 
88
150
  ## License
89
151
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import type { A2uiSurface } from "@mcp-native/a2ui";
2
+ import type { McpNativeAction, McpToolCallResult } from "@mcp-native/core";
3
+ import { type ComponentType, type ReactElement, type ReactNode } from "react";
2
4
  export type NativeComponentName = "Button" | "Text" | "TextInput" | "View";
3
5
  /**
4
6
  * A serializable render plan. A React Native host maps these trusted component
@@ -10,5 +12,56 @@ export interface NativeElement {
10
12
  readonly props: Readonly<Record<string, unknown>>;
11
13
  readonly children?: readonly NativeElement[];
12
14
  }
15
+ export interface NativeViewComponentProps {
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
+ }
39
+ export type NativeActionHandler = (action: McpNativeAction) => void;
40
+ export type NativeBindingChangeHandler = (binding: string, value: string) => void;
41
+ export interface McpNativeSurfaceProps {
42
+ readonly surface: A2uiSurface;
43
+ readonly components: NativeComponentCatalog;
44
+ readonly onAction: NativeActionHandler;
45
+ readonly onBindingChange?: NativeBindingChangeHandler;
46
+ }
47
+ export interface McpNativeDispatcher {
48
+ dispatch(action: McpNativeAction): Promise<McpToolCallResult>;
49
+ }
50
+ export interface McpNativeActionDispatcherOptions {
51
+ readonly onError: (error: unknown) => void;
52
+ readonly onResult?: (result: McpToolCallResult) => void;
53
+ }
13
54
  export declare function createNativeRenderPlan(surface: A2uiSurface): NativeElement;
55
+ /** Memoizes the trusted render plan for a validated surface identity. */
56
+ export declare function useNativeRenderPlan(surface: A2uiSurface): NativeElement;
57
+ /**
58
+ * Creates a stable, synchronous event handler for a runtime's asynchronous
59
+ * action dispatcher. Synchronous throws and promise rejections are always
60
+ * routed to the required error hook.
61
+ */
62
+ export declare function useMcpNativeActionDispatcher(dispatcher: McpNativeDispatcher, options: McpNativeActionDispatcherOptions): NativeActionHandler;
63
+ /** Renders a validated surface with the host's locally bundled components. */
64
+ export declare function McpNativeSurface({ surface, components, onAction, onBindingChange, }: McpNativeSurfaceProps): ReactElement;
65
+ export { A2UI_V1_NATIVE_COMPONENT_NAMES, A2UI_V1_NATIVE_MAX_RENDER_NODES, createA2uiV1NativeRenderPlan, } from "./v1.js";
66
+ export type { A2uiV1NativeEventDescriptor } from "./v1.js";
14
67
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAY,WAAW,EAAE,MAAM,kBAAkB,CAAC;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iB,CAAC,CAAC;CAC/D;AAED,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3C,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;CACzD;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,WAAW,GAAG,aAAa,CAE1E;AAED,yEAAyE;AACzE,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,WAAW,GAAG,aAAa,CAEvE;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,mBAAmB,EAC/B,OAAO,EAAE,gCAAgC,GACxC,mBAAmB,CAcrB;AAED,8EAA8E;AAC9E,wBAAgB,gBAAgB,CAAC,EAC/B,OAAO,EACP,UAAU,EACV,QAAQ,EACR,eAAe,GAChB,EAAE,qBAAqB,GAAG,YAAY,CAGtC;AA2GD,OAAO,EACL,8BAA8B,EAC9B,+BAA+B,EAC/B,4BAA4B,GAC7B,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,30 @@
1
+ import { parseMcpNativeAction } from "@mcp-native/core";
2
+ import { createElement, useCallback, useMemo, } from "react";
1
3
  export function createNativeRenderPlan(surface) {
2
4
  return renderNode(surface.root);
3
5
  }
6
+ /** Memoizes the trusted render plan for a validated surface identity. */
7
+ export function useNativeRenderPlan(surface) {
8
+ return useMemo(() => createNativeRenderPlan(surface), [surface]);
9
+ }
10
+ /**
11
+ * Creates a stable, synchronous event handler for a runtime's asynchronous
12
+ * action dispatcher. Synchronous throws and promise rejections are always
13
+ * routed to the required error hook.
14
+ */
15
+ export function useMcpNativeActionDispatcher(dispatcher, options) {
16
+ const { onError, onResult } = options;
17
+ return useCallback((action) => {
18
+ void Promise.resolve()
19
+ .then(() => dispatcher.dispatch(action))
20
+ .then((result) => onResult?.(result), (error) => onError(error));
21
+ }, [dispatcher, onError, onResult]);
22
+ }
23
+ /** Renders a validated surface with the host's locally bundled components. */
24
+ export function McpNativeSurface({ surface, components, onAction, onBindingChange, }) {
25
+ const plan = useNativeRenderPlan(surface);
26
+ return renderElement(plan, components, onAction, onBindingChange);
27
+ }
4
28
  function renderNode(node) {
5
29
  switch (node.type) {
6
30
  case "container":
@@ -34,4 +58,62 @@ function renderNode(node) {
34
58
  };
35
59
  }
36
60
  }
61
+ function renderElement(element, components, onAction, onBindingChange) {
62
+ switch (element.component) {
63
+ case "View":
64
+ return createElement(components.View, { key: element.key }, element.children?.map((child) => renderElement(child, components, onAction, onBindingChange)));
65
+ case "Text":
66
+ return createElement(components.Text, {
67
+ key: element.key,
68
+ children: expectStringProp(element, "children"),
69
+ });
70
+ case "Button": {
71
+ const title = expectStringProp(element, "title");
72
+ const action = expectActionProp(element);
73
+ return createElement(components.Button, {
74
+ key: element.key,
75
+ title,
76
+ accessibilityLabel: title,
77
+ onPress: () => onAction(action),
78
+ });
79
+ }
80
+ case "TextInput": {
81
+ const label = expectStringProp(element, "label");
82
+ const value = optionalStringProp(element, "value");
83
+ const binding = optionalStringProp(element, "binding");
84
+ return createElement(components.TextInput, {
85
+ key: element.key,
86
+ accessibilityLabel: label,
87
+ placeholder: label,
88
+ ...(value === undefined ? {} : { value }),
89
+ ...(binding === undefined || onBindingChange === undefined
90
+ ? {}
91
+ : { onChangeText: (nextValue) => onBindingChange(binding, nextValue) }),
92
+ });
93
+ }
94
+ }
95
+ }
96
+ function expectStringProp(element, name) {
97
+ const value = element.props[name];
98
+ if (typeof value !== "string") {
99
+ throw new TypeError(`Expected a string at native element ${element.key}.${name}`);
100
+ }
101
+ return value;
102
+ }
103
+ function optionalStringProp(element, name) {
104
+ const value = element.props[name];
105
+ return value === undefined ? undefined : expectStringProp(element, name);
106
+ }
107
+ function expectActionProp(element) {
108
+ const value = element.props.action;
109
+ const path = `native element ${element.key}.action`;
110
+ try {
111
+ return parseMcpNativeAction(value, path);
112
+ }
113
+ catch (error) {
114
+ const message = error instanceof Error ? error.message : `Expected a tool action at ${path}`;
115
+ throw new TypeError(message, { cause: error });
116
+ }
117
+ }
118
+ export { A2UI_V1_NATIVE_COMPONENT_NAMES, A2UI_V1_NATIVE_MAX_RENDER_NODES, createA2uiV1NativeRenderPlan, } from "./v1.js";
37
119
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,MAAM,UAAU,sBAAsB,CAAC,OAAoB;IACzD,OAAO,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC;AAED,SAAS,UAAU,CAAC,IAAc;IAChC,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,WAAW;YACd,OAAO;gBACL,GAAG,EAAE,IAAI,CAAC,EAAE;gBACZ,SAAS,EAAE,MAAM;gBACjB,KAAK,EAAE,EAAE;gBACT,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC;aACxC,CAAC;QACJ,KAAK,MAAM;YACT,OAAO;gBACL,GAAG,EAAE,IAAI,CAAC,EAAE;gBACZ,SAAS,EAAE,MAAM;gBACjB,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE;aAC/B,CAAC;QACJ,KAAK,QAAQ;YACX,OAAO;gBACL,GAAG,EAAE,IAAI,CAAC,EAAE;gBACZ,SAAS,EAAE,QAAQ;gBACnB,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE;aAClD,CAAC;QACJ,KAAK,YAAY;YACf,OAAO;gBACL,GAAG,EAAE,IAAI,CAAC,EAAE;gBACZ,SAAS,EAAE,WAAW;gBACtB,KAAK,EAAE;oBACL,KAAK,EAAE,IAAI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O,CAAC,KAAK,CAAC,MAAM,CAAC;IACnC,MAAM,IAAI,GAAG,kBAAkB,OAAO,CAAC,GAAG,SAAS,CAAC;IACpD,IAAI,CAAC;QACH,OAAO,oBAAoB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC3C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,6BAA6B,IAAI,EAAE,CAAC;QAC7F,MAAM,IAAI,SAAS,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACjD,CAAC;AACH,CAAC;AAED,OAAO,EACL,8BAA8B,EAC9B,+BAA+B,EAC/B,4BAA4B,GAC7B,MAAM,SAAS,CAAC"}
package/dist/v1.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ import type { A2uiV1SurfaceState, A2uiV1SurfaceValidationPolicy } from "@mcp-native/a2ui";
2
+ import type { JsonObject } from "@mcp-native/core";
3
+ import type { NativeElement } from "./index.js";
4
+ export declare const A2UI_V1_NATIVE_COMPONENT_NAMES: readonly string[];
5
+ /** Maximum expanded native-plan nodes, including repeated component references. */
6
+ export declare const A2UI_V1_NATIVE_MAX_RENDER_NODES = 1024;
7
+ /** Resolved event data retained in a trusted plan until renderer-to-agent dispatch. */
8
+ export interface A2uiV1NativeEventDescriptor {
9
+ readonly name: string;
10
+ readonly surfaceId: string;
11
+ readonly sourceComponentId: string;
12
+ readonly userMessage?: string;
13
+ readonly context: JsonObject;
14
+ }
15
+ /**
16
+ * Converts a policy-validated A2UI v1 surface into the existing host-owned
17
+ * native render plan. Unsupported renderer semantics fail closed.
18
+ */
19
+ export declare function createA2uiV1NativeRenderPlan(surface: A2uiV1SurfaceState, policy: A2uiV1SurfaceValidationPolicy): NativeElement;
20
+ //# sourceMappingURL=v1.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v1.d.ts","sourceRoot":"","sources":["../src/v1.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEV,kBAAkB,EAClB,6BAA6B,EAC9B,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,kBAAkB,CAAC;AAE9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,eAAO,MAAM,8BAA8B,EAQrC,SAAS,MAAM,EAAE,CAAC;AAExB,mFAAmF;AACnF,eAAO,MAAM,+BAA+B,OAAyB,CAAC;AAEtE,uFAAuF;AACvF,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;CAC9B;AASD;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,kBAAkB,EAC3B,MAAM,EAAE,6BAA6B,GACpC,aAAa,CASf"}
package/dist/v1.js ADDED
@@ -0,0 +1,315 @@
1
+ import { A2UI_V1_MAX_COMPONENTS, A2uiParseError, validateA2uiV1SurfaceState, } from "@mcp-native/a2ui";
2
+ import { parseJsonObject, parseJsonValue } from "@mcp-native/core";
3
+ export const A2UI_V1_NATIVE_COMPONENT_NAMES = Object.freeze([
4
+ "Button",
5
+ "Card",
6
+ "Column",
7
+ "List",
8
+ "Row",
9
+ "Text",
10
+ "TextField",
11
+ ]);
12
+ /** Maximum expanded native-plan nodes, including repeated component references. */
13
+ export const A2UI_V1_NATIVE_MAX_RENDER_NODES = A2UI_V1_MAX_COMPONENTS;
14
+ /**
15
+ * Converts a policy-validated A2UI v1 surface into the existing host-owned
16
+ * native render plan. Unsupported renderer semantics fail closed.
17
+ */
18
+ export function createA2uiV1NativeRenderPlan(surface, policy) {
19
+ const validated = validateA2uiV1SurfaceState(surface, policy);
20
+ const context = {
21
+ surface: validated,
22
+ dataModel: parseJsonObject(validated.dataModel, "surface.dataModel"),
23
+ visiting: new Set(),
24
+ renderNodeCount: 0,
25
+ };
26
+ return adaptComponent("root", "root", context);
27
+ }
28
+ function adaptComponent(id, key, context) {
29
+ context.renderNodeCount += 1;
30
+ if (context.renderNodeCount > A2UI_V1_NATIVE_MAX_RENDER_NODES) {
31
+ throw new A2uiParseError(`Expanded A2UI native plan exceeds maximum of ${A2UI_V1_NATIVE_MAX_RENDER_NODES} nodes`);
32
+ }
33
+ if (context.visiting.has(id)) {
34
+ throw new A2uiParseError(`A2UI native adapter encountered a cycle at ${JSON.stringify(id)}`);
35
+ }
36
+ const component = context.surface.components.get(id);
37
+ if (component === undefined) {
38
+ throw new A2uiParseError(`A2UI native adapter cannot find component ${JSON.stringify(id)}`);
39
+ }
40
+ context.visiting.add(id);
41
+ try {
42
+ switch (component.component) {
43
+ case "Row":
44
+ return adaptContainer(component, key, "row", undefined, context);
45
+ case "Column":
46
+ return adaptContainer(component, key, "column", undefined, context);
47
+ case "List":
48
+ return adaptList(component, key, context);
49
+ case "Card":
50
+ return adaptCard(component, key, context);
51
+ case "Text":
52
+ return adaptText(component, key, context);
53
+ case "Button":
54
+ return adaptButton(component, key, context);
55
+ case "TextField":
56
+ return adaptTextField(component, key, context);
57
+ default:
58
+ throw new A2uiParseError(`A2UI component ${JSON.stringify(id)} uses ${JSON.stringify(component.component)}, which the native adapter does not support`);
59
+ }
60
+ }
61
+ finally {
62
+ context.visiting.delete(id);
63
+ }
64
+ }
65
+ function adaptContainer(component, key, layout, variant, context) {
66
+ if (!Array.isArray(component.children)) {
67
+ throw new A2uiParseError(`A2UI native adapter does not yet support dynamic children at components.${component.id}.children`);
68
+ }
69
+ const props = { layout };
70
+ if (variant !== undefined) {
71
+ props.variant = variant;
72
+ }
73
+ if (component.justify !== undefined) {
74
+ props.justify = expectString(component.justify, `components.${component.id}.justify`);
75
+ }
76
+ if (component.align !== undefined) {
77
+ props.align = expectString(component.align, `components.${component.id}.align`);
78
+ }
79
+ addCommonProps(component, props, context);
80
+ return {
81
+ key,
82
+ component: "View",
83
+ props,
84
+ children: component.children.map((childId, index) => adaptComponent(childId, `${key}/${childId}:${index}`, context)),
85
+ };
86
+ }
87
+ function adaptList(component, key, context) {
88
+ return adaptContainer(component, key, component.direction === "horizontal" ? "row" : "column", "list", context);
89
+ }
90
+ function adaptCard(component, key, context) {
91
+ const childId = expectString(component.child, `components.${component.id}.child`);
92
+ const props = { layout: "column", variant: "card" };
93
+ addCommonProps(component, props, context);
94
+ return {
95
+ key,
96
+ component: "View",
97
+ props,
98
+ children: [adaptComponent(childId, `${key}/${childId}:0`, context)],
99
+ };
100
+ }
101
+ function adaptText(component, key, context) {
102
+ const props = {
103
+ children: resolveDynamicString(component.text, `components.${component.id}.text`, context),
104
+ };
105
+ if (component.variant !== undefined) {
106
+ props.variant = component.variant;
107
+ }
108
+ addCommonProps(component, props, context);
109
+ return { key, component: "Text", props };
110
+ }
111
+ function adaptButton(component, key, context) {
112
+ rejectUnsupportedChecks(component);
113
+ const childId = expectString(component.child, `components.${component.id}.child`);
114
+ const child = context.surface.components.get(childId);
115
+ if (child?.component !== "Text") {
116
+ throw new A2uiParseError(`A2UI native Button ${JSON.stringify(component.id)} requires a Text child`);
117
+ }
118
+ const props = {
119
+ title: resolveDynamicString(child.text, `components.${child.id}.text`, context),
120
+ event: resolveButtonEvent(component, context),
121
+ };
122
+ if (component.variant !== undefined) {
123
+ props.variant = component.variant;
124
+ }
125
+ addCommonProps(component, props, context);
126
+ if (props.accessibilityLabel === undefined) {
127
+ props.accessibilityLabel = props.title;
128
+ }
129
+ return { key, component: "Button", props };
130
+ }
131
+ function adaptTextField(component, key, context) {
132
+ rejectUnsupportedChecks(component);
133
+ const componentPath = `components.${component.id}`;
134
+ const label = resolveDynamicString(component.label, `${componentPath}.label`, context);
135
+ const props = {
136
+ label,
137
+ placeholder: component.placeholder === undefined
138
+ ? label
139
+ : resolveDynamicString(component.placeholder, `${componentPath}.placeholder`, context),
140
+ };
141
+ if (component.value !== undefined) {
142
+ props.value = resolveDynamicString(component.value, `${componentPath}.value`, context);
143
+ if (isBinding(component.value)) {
144
+ props.binding = expectAbsoluteBinding(component.value.path, `${componentPath}.value.path`);
145
+ }
146
+ }
147
+ if (component.variant !== undefined) {
148
+ props.variant = component.variant;
149
+ }
150
+ addCommonProps(component, props, context);
151
+ if (props.accessibilityLabel === undefined) {
152
+ props.accessibilityLabel = label;
153
+ }
154
+ return { key, component: "TextInput", props };
155
+ }
156
+ function rejectUnsupportedChecks(component) {
157
+ if (component.checks !== undefined) {
158
+ throw new A2uiParseError(`A2UI native adapter does not yet support renderer-side checks at components.${component.id}.checks`);
159
+ }
160
+ }
161
+ function resolveButtonEvent(component, context) {
162
+ const action = expectObject(component.action, `components.${component.id}.action`);
163
+ if (!Object.hasOwn(action, "event")) {
164
+ throw new A2uiParseError(`A2UI native Button ${JSON.stringify(component.id)} does not support local function actions`);
165
+ }
166
+ const event = expectObject(action.event, `components.${component.id}.action.event`);
167
+ const eventName = expectString(event.name, `components.${component.id}.action.event.name`);
168
+ const eventContext = expectOptionalObject(event.context, `components.${component.id}.action.event.context`);
169
+ const resolvedContext = {};
170
+ for (const [name, value] of Object.entries(eventContext ?? {})) {
171
+ defineJsonProperty(resolvedContext, name, resolveDynamicValue(value, `components.${component.id}.action.event.context.${name}`, context));
172
+ }
173
+ const userMessage = event.userMessage === undefined
174
+ ? undefined
175
+ : resolveDynamicString(event.userMessage, `components.${component.id}.action.event.userMessage`, context);
176
+ return {
177
+ name: eventName,
178
+ surfaceId: context.surface.surfaceId,
179
+ sourceComponentId: component.id,
180
+ ...(userMessage === undefined ? {} : { userMessage }),
181
+ context: parseJsonObject(resolvedContext, `components.${component.id}.action.event.context`),
182
+ };
183
+ }
184
+ function addCommonProps(component, props, context) {
185
+ if (component.weight !== undefined) {
186
+ props.weight = expectFiniteNumber(component.weight, `components.${component.id}.weight`);
187
+ }
188
+ if (component.accessibility === undefined) {
189
+ return;
190
+ }
191
+ const accessibility = expectObject(component.accessibility, `components.${component.id}.accessibility`);
192
+ if (accessibility.label !== undefined) {
193
+ props.accessibilityLabel = resolveDynamicString(accessibility.label, `components.${component.id}.accessibility.label`, context);
194
+ }
195
+ if (accessibility.description !== undefined) {
196
+ props.accessibilityHint = resolveDynamicString(accessibility.description, `components.${component.id}.accessibility.description`, context);
197
+ }
198
+ if (accessibility.live !== undefined) {
199
+ props.accessibilityLive = accessibility.live;
200
+ }
201
+ if (accessibility.hidden !== undefined) {
202
+ props.accessibilityHidden = resolveDynamicBoolean(accessibility.hidden, `components.${component.id}.accessibility.hidden`, context);
203
+ }
204
+ }
205
+ function resolveDynamicString(value, path, context) {
206
+ const resolved = resolveDynamicValue(value, path, context);
207
+ return expectString(resolved, path);
208
+ }
209
+ function resolveDynamicBoolean(value, path, context) {
210
+ const resolved = resolveDynamicValue(value, path, context);
211
+ if (typeof resolved !== "boolean") {
212
+ throw new A2uiParseError(`Expected a boolean at ${path}`);
213
+ }
214
+ return resolved;
215
+ }
216
+ function resolveDynamicValue(value, path, context) {
217
+ if (value === undefined) {
218
+ throw new A2uiParseError(`Missing dynamic value at ${path}`);
219
+ }
220
+ if (isFunctionCall(value)) {
221
+ throw new A2uiParseError(`A2UI native adapter does not execute function ${JSON.stringify(value.call)} at ${path}`);
222
+ }
223
+ if (isBinding(value)) {
224
+ const pointer = expectAbsoluteBinding(value.path, `${path}.path`);
225
+ return parseJsonValue(resolveJsonPointer(context.dataModel, pointer, path), path);
226
+ }
227
+ return parseJsonValue(value, path);
228
+ }
229
+ function resolveJsonPointer(document, pointer, path) {
230
+ if (pointer === "") {
231
+ return document;
232
+ }
233
+ let cursor = document;
234
+ for (const encodedToken of pointer.slice(1).split("/")) {
235
+ const token = decodePointerToken(encodedToken, pointer);
236
+ if (Array.isArray(cursor)) {
237
+ if (!/^(0|[1-9][0-9]*)$/.test(token)) {
238
+ throw new A2uiParseError(`Invalid array binding index in ${JSON.stringify(pointer)} at ${path}`);
239
+ }
240
+ const index = Number(token);
241
+ if (!Number.isSafeInteger(index) || index >= cursor.length) {
242
+ throw new A2uiParseError(`A2UI binding ${JSON.stringify(pointer)} is missing at ${path}`);
243
+ }
244
+ cursor = cursor[index];
245
+ continue;
246
+ }
247
+ if (cursor === null || typeof cursor !== "object" || !Object.hasOwn(cursor, token)) {
248
+ throw new A2uiParseError(`A2UI binding ${JSON.stringify(pointer)} is missing at ${path}`);
249
+ }
250
+ cursor = cursor[token];
251
+ }
252
+ return cursor;
253
+ }
254
+ function expectAbsoluteBinding(value, path) {
255
+ const pointer = expectString(value, path);
256
+ if (pointer !== "" && !pointer.startsWith("/")) {
257
+ throw new A2uiParseError(`A2UI native adapter requires an absolute binding at ${path}; dynamic templates are not supported`);
258
+ }
259
+ return pointer;
260
+ }
261
+ function decodePointerToken(token, pointer) {
262
+ for (let index = 0; index < token.length; index += 1) {
263
+ if (token[index] !== "~") {
264
+ continue;
265
+ }
266
+ const escaped = token[index + 1];
267
+ if (escaped !== "0" && escaped !== "1") {
268
+ throw new A2uiParseError(`Invalid JSON Pointer escape in ${JSON.stringify(pointer)}`);
269
+ }
270
+ index += 1;
271
+ }
272
+ return token.replaceAll("~1", "/").replaceAll("~0", "~");
273
+ }
274
+ function isBinding(value) {
275
+ return (value !== null &&
276
+ !Array.isArray(value) &&
277
+ typeof value === "object" &&
278
+ Object.hasOwn(value, "path"));
279
+ }
280
+ function isFunctionCall(value) {
281
+ return (value !== null &&
282
+ !Array.isArray(value) &&
283
+ typeof value === "object" &&
284
+ Object.hasOwn(value, "call"));
285
+ }
286
+ function expectObject(value, path) {
287
+ if (value === null || value === undefined || typeof value !== "object" || Array.isArray(value)) {
288
+ throw new A2uiParseError(`Expected an object at ${path}`);
289
+ }
290
+ return value;
291
+ }
292
+ function expectOptionalObject(value, path) {
293
+ return value === undefined ? undefined : expectObject(value, path);
294
+ }
295
+ function expectString(value, path) {
296
+ if (typeof value !== "string") {
297
+ throw new A2uiParseError(`Expected a string at ${path}`);
298
+ }
299
+ return value;
300
+ }
301
+ function expectFiniteNumber(value, path) {
302
+ if (typeof value !== "number" || !Number.isFinite(value)) {
303
+ throw new A2uiParseError(`Expected a finite number at ${path}`);
304
+ }
305
+ return value;
306
+ }
307
+ function defineJsonProperty(object, key, value) {
308
+ Object.defineProperty(object, key, {
309
+ configurable: true,
310
+ enumerable: true,
311
+ value,
312
+ writable: true,
313
+ });
314
+ }
315
+ //# sourceMappingURL=v1.js.map
package/dist/v1.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v1.js","sourceRoot":"","sources":["../src/v1.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,0BAA0B,GAC3B,MAAM,kBAAkB,CAAC;AAM1B,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKnE,MAAM,CAAC,MAAM,8BAA8B,GAAG,MAAM,CAAC,MAAM,CAAC;IAC1D,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,MAAM;IACN,KAAK;IACL,MAAM;IACN,WAAW;CACZ,CAAsB,CAAC;AAExB,mFAAmF;AACnF,MAAM,CAAC,MAAM,+BAA+B,GAAG,sBAAsB,CAAC;AAkBtE;;;GAGG;AACH,MAAM,UAAU,4BAA4B,CAC1C,OAA2B,EAC3B,MAAqC;IAErC,MAAM,SAAS,GAAG,0BAA0B,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC9D,MAAM,OAAO,GAAmB;QAC9B,OAAO,EAAE,SAAS;QAClB,SAAS,EAAE,eAAe,CAAC,SAAS,CAAC,SAAS,EAAE,mBAAmB,CAAC;QACpE,QAAQ,EAAE,IAAI,GAAG,EAAU;QAC3B,eAAe,EAAE,CAAC;KACnB,CAAC;IACF,OAAO,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAA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C3D,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAgB,EAAE,IAAY;IACxD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACzD,MAAM,IAAI,cAAc,CAAC,+BAA+B,IAAI,EAAE,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,kBAAkB,CACzB,MAAiC,EACjC,GAAW,EACX,KAAgB;IAEhB,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE;QACjC,YAAY,EAAE,IAAI;QAClB,UAAU,EAAE,IAAI;QAChB,KAAK;QACL,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcp-native/react-native",
3
- "version": "0.0.3",
3
+ "version": "0.2.0",
4
4
  "description": "React Native renderer primitives for MCP Native.",
5
5
  "keywords": [
6
6
  "a2ui",
@@ -37,7 +37,21 @@
37
37
  "access": "public"
38
38
  },
39
39
  "dependencies": {
40
- "@mcp-native/a2ui": "^0.0.3",
41
- "@mcp-native/core": "^0.0.3"
40
+ "@mcp-native/a2ui": "^0.2.0",
41
+ "@mcp-native/core": "^0.2.0"
42
+ },
43
+ "devDependencies": {
44
+ "@types/react": "19.1.17",
45
+ "react": "19.2.8",
46
+ "test-renderer": "1.2.0"
47
+ },
48
+ "peerDependencies": {
49
+ "react": ">=18.3.1 <20",
50
+ "react-native": ">=0.76.0 <1"
51
+ },
52
+ "peerDependenciesMeta": {
53
+ "react-native": {
54
+ "optional": true
55
+ }
42
56
  }
43
57
  }