@mcp-native/react-native 0.0.3 → 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/README.md +55 -23
- package/dist/index.d.ts +51 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +81 -0
- package/dist/index.js.map +1 -1
- package/package.json +17 -3
package/README.md
CHANGED
|
@@ -8,27 +8,33 @@
|
|
|
8
8
|
[](https://www.npmjs.com/package/@mcp-native/react-native)
|
|
9
9
|
[](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
|
|
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
|
|
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 A2UI v1.0 conformance. Its current input is MCP Native's custom `0.1` surface; the planned v1.0 adapter will preserve this host-owned rendering 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
|
|
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
|
-
```
|
|
31
|
+
```tsx
|
|
30
32
|
import { parseA2uiSurface } from "@mcp-native/a2ui";
|
|
31
|
-
import {
|
|
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,69 @@ const surface = parseA2uiSurface({
|
|
|
47
53
|
},
|
|
48
54
|
});
|
|
49
55
|
|
|
50
|
-
|
|
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
|
-
|
|
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.
|
|
60
83
|
|
|
61
84
|
## Public API
|
|
62
85
|
|
|
63
|
-
| Export
|
|
64
|
-
|
|
|
65
|
-
| `
|
|
66
|
-
| `
|
|
67
|
-
| `
|
|
86
|
+
| Export | Purpose |
|
|
87
|
+
| --------------------------------------- | ----------------------------------------------------------------------------------------------- |
|
|
88
|
+
| `McpNativeSurface` | Mounts a validated surface using the host's component catalog. |
|
|
89
|
+
| `useMcpNativeActionDispatcher` | Adapts asynchronous runtime dispatch into a stable event callback with required error handling. |
|
|
90
|
+
| `useNativeRenderPlan` | Memoizes a trusted render plan for a validated surface identity. |
|
|
91
|
+
| `createNativeRenderPlan` | Converts a validated `A2uiSurface` into a `NativeElement` tree. |
|
|
92
|
+
| `NativeComponentCatalog` | Contract for locally bundled `View`, `Text`, `Button`, and `TextInput` implementations. |
|
|
93
|
+
| `NativeActionHandler` | Synchronous handler for a validated declared action. |
|
|
94
|
+
| `NativeBindingChangeHandler` | Handler receiving a validated binding name and the next text value. |
|
|
95
|
+
| `McpNativeActionDispatcherOptions` | Required action error callback and optional result callback. |
|
|
96
|
+
| `NativeElement` / `NativeComponentName` | Serializable trusted-plan node and its fixed component-name union. |
|
|
68
97
|
|
|
69
98
|
## Current mappings
|
|
70
99
|
|
|
71
|
-
| Surface node | Native component |
|
|
72
|
-
| ------------ | ---------------- |
|
|
73
|
-
| `container` | `View` | Nested
|
|
74
|
-
| `text` | `Text` |
|
|
75
|
-
| `button` | `Button` | `title` and validated
|
|
76
|
-
| `text-input` | `TextInput` |
|
|
100
|
+
| Surface node | Native component | Host props and event behavior |
|
|
101
|
+
| ------------ | ---------------- | ------------------------------------------------------------------------------------------ |
|
|
102
|
+
| `container` | `View` | Nested trusted children |
|
|
103
|
+
| `text` | `Text` | Validated text as `children` |
|
|
104
|
+
| `button` | `Button` | `title`, matching `accessibilityLabel`, and an `onPress` callback for its validated action |
|
|
105
|
+
| `text-input` | `TextInput` | Label as placeholder/accessibility label, optional value, and binding-aware `onChangeText` |
|
|
77
106
|
|
|
78
107
|
## Trust boundary
|
|
79
108
|
|
|
80
109
|
- The server cannot select components outside the catalog.
|
|
81
110
|
- The server cannot send executable React Native code.
|
|
82
111
|
- Render plans should only be created from a successfully validated surface.
|
|
83
|
-
-
|
|
112
|
+
- Declared actions and their complete JSON arguments are validated again immediately before emission.
|
|
113
|
+
- Rendered component props are selected explicitly; unchecked server props are never spread into host components.
|
|
114
|
+
- The host must explicitly map components, own state, enforce permissions, and configure the runtime action policy; dispatch is denied when no policy allows it.
|
|
115
|
+
- Asynchronous action failures cannot become unhandled rejections because `useMcpNativeActionDispatcher` requires an error callback.
|
|
84
116
|
- Future styling and component expansion must preserve allowlists rather than spreading unchecked server props.
|
|
85
117
|
|
|
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
|
|
118
|
+
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
119
|
|
|
88
120
|
## License
|
|
89
121
|
|
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,54 @@ 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;
|
|
14
65
|
//# 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":"AAAA,OAAO,KAAK,EAAY,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE9D,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;AAE3E;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,SAAS,EAAE,mBAAmB,CAAC;IACxC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAClD,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,aAAa,EAAE,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vE;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"}
|
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,61 @@ 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
|
+
}
|
|
37
118
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EACL,aAAa,EACb,WAAW,EACX,OAAO,GAIR,MAAM,OAAO,CAAC;AAgEf,MAAM,UAAU,sBAAsB,CAAC,OAAoB;IACzD,OAAO,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,mBAAmB,CAAC,OAAoB;IACtD,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,sBAAsB,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;AACnE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,4BAA4B,CAC1C,UAA+B,EAC/B,OAAyC;IAEzC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAEtC,OAAO,WAAW,CAChB,CAAC,MAAM,EAAE,EAAE;QACT,KAAK,OAAO,CAAC,OAAO,EAAE;aACnB,IAAI,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;aACvC,IAAI,CACH,CAAC,MAAM,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gB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AAC3E,CAAC;AAED,SAAS,gBAAgB,CAAC,OAAsB;IAC9C,MAAM,KAAK,GAAG,OAAO,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-native/react-native",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.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
|
|
41
|
-
"@mcp-native/core": "^0.0
|
|
40
|
+
"@mcp-native/a2ui": "^0.1.0",
|
|
41
|
+
"@mcp-native/core": "^0.1.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
|
}
|