@vetc-miniapp/ui-react 0.0.9 → 0.0.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vetc-miniapp/ui-react",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "description": "MiniApp Platform UI React",
5
5
  "main": "src/ui-react/index.js",
6
6
  "types": "src/ui-react/index.ts",
@@ -7,10 +7,20 @@ const getBridge = () => {
7
7
  return window.flutter_inappwebview;
8
8
  };
9
9
 
10
- export const callHost = (action, payload = {}) => {
10
+ export const callHost = async (action, payload = {}) => {
11
11
  const bridge = getBridge();
12
12
  if (!bridge) {
13
13
  return Promise.reject(new Error("MiniApp bridge not available"));
14
14
  }
15
- return bridge.callHandler("MiniAppBridge", { action, payload });
15
+ try {
16
+ const response = await bridge.callHandler("MiniAppBridge", {
17
+ action,
18
+ payload,
19
+ });
20
+
21
+ return response;
22
+ } catch (error) {
23
+ console.error("Bridge error:", error);
24
+ throw error;
25
+ }
16
26
  };
@@ -34,7 +34,7 @@ export function App({ config, children }) {
34
34
  initRouter(config);
35
35
 
36
36
  // 2. Lấy pathname từ URL WebView
37
- const rawPath = window.location.path || "/";
37
+ const rawPath = window.location.pathname || "/";
38
38
  const path = rawPath.replace("/miniapp", "") || "/";
39
39
  console.log(rawPath);
40
40
 
@@ -62,7 +62,7 @@ export function App({ config, children }) {
62
62
  <>
63
63
  <div></div>
64
64
  </>
65
- );
65
+ );
66
66
  }
67
67
 
68
68
  const Component = page.Component || <div />;