@webview-bridge/react-native 1.5.0-rc.1 → 1.5.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.
@@ -16,8 +16,34 @@ export declare const createWebView: <BridgeObject extends Bridge, PostMessageSch
16
16
  WebView: React.ForwardRefExoticComponent<import("react-native-webview/lib/WebViewTypes").IOSWebViewProps & import("react-native-webview/lib/WebViewTypes").AndroidWebViewProps & import("react-native-webview/lib/WebViewTypes").WindowsWebViewProps & React.RefAttributes<BridgeWebView>>;
17
17
  /**
18
18
  * @deprecated Use `postMessage` instead. And complete the type through the `postMessageSchema` option.
19
- * @see https://gronxb.github.io/webview-bridge/postMessage-native-to-web.html
20
- */
19
+ * @see https://gronxb.github.io/webview-bridge/using-a-post-message.html
20
+ * @example
21
+ import { createWebView, postMessageSchema } from "@webview-bridge/react-native";
22
+ import { z } from "zod";
23
+
24
+ const appPostMessageSchema = postMessageSchema({
25
+ eventName1: z.object({
26
+ message: z.string(),
27
+ }),
28
+ eventName2: z.string(),
29
+ });
30
+
31
+
32
+ // Export the event schema to be used in the web application
33
+ export type AppPostMessageSchema = typeof appPostMessageSchema;
34
+
35
+ // When you bridge a webview, a postMessage is extracted.
36
+ export const { postMessage } = createWebView({
37
+ postMessageSchema: appPostMessageSchema, // Pass in the your schema. This is optional, so if the type doesn't matter to you, you don't need to include it.
38
+ // ..
39
+ });
40
+
41
+ // usage
42
+ postMessage("eventName1", {
43
+ message: "test",
44
+ });
45
+ postMessage("eventName2", "test");
46
+ */
21
47
  linkWebMethod<T>(): {
22
48
  current: WebMethod<T>;
23
49
  };
@@ -140,8 +140,34 @@ const createWebView = ({ bridge, debug, responseTimeout = 2000, postMessageSchem
140
140
  }),
141
141
  /**
142
142
  * @deprecated Use `postMessage` instead. And complete the type through the `postMessageSchema` option.
143
- * @see https://gronxb.github.io/webview-bridge/postMessage-native-to-web.html
144
- */
143
+ * @see https://gronxb.github.io/webview-bridge/using-a-post-message.html
144
+ * @example
145
+ import { createWebView, postMessageSchema } from "@webview-bridge/react-native";
146
+ import { z } from "zod";
147
+
148
+ const appPostMessageSchema = postMessageSchema({
149
+ eventName1: z.object({
150
+ message: z.string(),
151
+ }),
152
+ eventName2: z.string(),
153
+ });
154
+
155
+
156
+ // Export the event schema to be used in the web application
157
+ export type AppPostMessageSchema = typeof appPostMessageSchema;
158
+
159
+ // When you bridge a webview, a postMessage is extracted.
160
+ export const { postMessage } = createWebView({
161
+ postMessageSchema: appPostMessageSchema, // Pass in the your schema. This is optional, so if the type doesn't matter to you, you don't need to include it.
162
+ // ..
163
+ });
164
+
165
+ // usage
166
+ postMessage("eventName1", {
167
+ message: "test",
168
+ });
169
+ postMessage("eventName2", "test");
170
+ */
145
171
  linkWebMethod() {
146
172
  return WebMethod;
147
173
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webview-bridge/react-native",
3
- "version": "1.5.0-rc.1",
3
+ "version": "1.5.0",
4
4
  "type": "module",
5
5
  "description": "Fully Type-Safe Integration for React Native WebView and Web",
6
6
  "main": "dist/packages/react-native/src/index.js",