wovvmap-webview-bridge 1.0.25 → 1.0.26

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
@@ -16,6 +16,66 @@ yarn add react-native-webview zustand
16
16
 
17
17
  ## Quick start
18
18
 
19
+ ### Web (React TS) usage
20
+
21
+ Use the web entrypoint so you don't need `react-native` or `react-native-webview` in your web app.
22
+
23
+ ```tsx
24
+ import React from "react";
25
+ import { WebIframeScreen } from "wovvmap-webview-bridge/web";
26
+
27
+ export default function App() {
28
+ return (
29
+ <WebIframeScreen
30
+ url="https://your-map-app-url.com"
31
+ origin="https://your-map-app-url.com"
32
+ onload={() => console.log("iframe loaded")}
33
+ style={{ width: "100%", height: "100vh" }}
34
+ />
35
+ );
36
+ }
37
+ ```
38
+
39
+ You can also attach to your own iframe ref:
40
+
41
+ ```tsx
42
+ import React, { useEffect, useRef } from "react";
43
+ import {
44
+ attachIframeBridge,
45
+ registerBridgeHandler,
46
+ sendStartPointToBridge,
47
+ } from "wovvmap-webview-bridge/web";
48
+
49
+ export default function App() {
50
+ const iframeRef = useRef<HTMLIFrameElement>(null);
51
+
52
+ useEffect(() => {
53
+ if (!iframeRef.current) return;
54
+
55
+ const cleanup = attachIframeBridge({
56
+ iframe: iframeRef.current,
57
+ origin: "https://your-map-app-url.com",
58
+ onLoad: () => sendStartPointToBridge("A1"),
59
+ });
60
+
61
+ registerBridgeHandler("isSceneClick", (payload) => {
62
+ console.log("Scene clicked", payload);
63
+ });
64
+
65
+ return cleanup;
66
+ }, []);
67
+
68
+ return (
69
+ <iframe
70
+ ref={iframeRef}
71
+ src="https://your-map-app-url.com"
72
+ style={{ width: "100%", height: "100%", border: 0 }}
73
+ title="Wovv Map"
74
+ />
75
+ );
76
+ }
77
+ ```
78
+
19
79
  ### 1) Render the WebView
20
80
 
21
81
  ```tsx
@@ -84,31 +144,31 @@ registerBridgeHandler("isShapeClick", (payload) => {
84
144
  ```tsx
85
145
  import { useBridgeStorage } from "wovvmap-webview-bridge";
86
146
 
87
- const state = useBridgeStorage((s) => ({
88
- isBridgeLoaded: s.isBridgeLoaded,
89
- isMapLoaded: s.isMapLoaded,
90
- searchablePoints: s.searchablePoints,
91
- amenities: s.amenities,
92
- allOffers: s.allOffers,
93
- activeFloor: s.activeFloor,
94
- stepByStepList: s.stepByStepList,
95
- pathSummary: s.pathSummary,
96
- categories: s.categories,
97
- subCategories: s.subCategories,
147
+ const state = useBridgeStorage((s) => ({
148
+ isBridgeLoaded: s.isBridgeLoaded,
149
+ isMapLoaded: s.isMapLoaded,
150
+ searchablePoints: s.searchablePoints,
151
+ amenities: s.amenities,
152
+ allOffers: s.allOffers,
153
+ activeFloor: s.activeFloor,
154
+ stepByStepList: s.stepByStepList,
155
+ pathSummary: s.pathSummary,
156
+ categories: s.categories,
157
+ subCategories: s.subCategories,
98
158
  }));
99
159
  ```
100
160
 
101
161
  Store fields:
102
162
  - isBridgeLoaded
103
- - isMapLoaded
104
- - searchablePoints
105
- - amenities
106
- - allOffers
107
- - activeFloor
108
- - elevator, escalator
109
- - floorImages
110
- - stepByStepList
111
- - pathSummary
163
+ - isMapLoaded
164
+ - searchablePoints
165
+ - amenities
166
+ - allOffers
167
+ - activeFloor
168
+ - elevator, escalator
169
+ - floorImages
170
+ - stepByStepList
171
+ - pathSummary
112
172
  - nextPreState
113
173
  - pointsByKey
114
174
  - categories
@@ -119,16 +179,16 @@ Store fields:
119
179
 
120
180
  ### IncomingMessage (Web -> RN)
121
181
  Keys and payloads:
122
- - pong: boolean
123
- - isConnection: boolean
124
- - mapLoaded: boolean
125
- - _searchablePoints: NodePoint[]
126
- - _allAmenities: AmenityWithNodePoint[]
127
- - _allOffers: string[]
128
- - _activeFloor: number
129
- - FloorImg: FloorImage[]
130
- - categories: Record<ExternalId, Category>
131
- - subCategories: Record<ExternalId, SubCategory>
182
+ - pong: boolean
183
+ - isConnection: boolean
184
+ - mapLoaded: boolean
185
+ - _searchablePoints: NodePoint[]
186
+ - _allAmenities: AmenityWithNodePoint[]
187
+ - _allOffers: string[]
188
+ - _activeFloor: number
189
+ - FloorImg: FloorImage[]
190
+ - categories: Record<ExternalId, Category>
191
+ - subCategories: Record<ExternalId, SubCategory>
132
192
  - isSceneClick: no value
133
193
  - isShapeClick: NodePoint
134
194
  - stepByStepList: StepByStepResult
@@ -160,6 +220,7 @@ Keys and payloads:
160
220
 
161
221
  ### Components
162
222
  - WebViewScreen
223
+ - WebIframeScreen (web only)
163
224
 
164
225
  ### Bridge helpers
165
226
  - sendStartPointToBridge
@@ -184,10 +245,10 @@ Keys and payloads:
184
245
  - useBridgeStorage (Zustand)
185
246
 
186
247
  ### Types
187
- - IncomingMessage, OutgoingMessage
188
- - NodePoint
189
- - AmenityWithNodePoint
190
- - Category, SubCategory, ExternalId
248
+ - IncomingMessage, OutgoingMessage
249
+ - NodePoint
250
+ - AmenityWithNodePoint
251
+ - Category, SubCategory, ExternalId
191
252
  - Environment, DayHours, WeeklyHours
192
253
  - NodePointOffer, BrandInfo
193
254
  - MapExportContext, GeometryFloor, GeometryNodePoint, GeometryLayer
@@ -1,4 +1,3 @@
1
- import type { WebViewMessageEvent } from "react-native-webview";
2
1
  import { NodePoint } from "../types/types";
3
2
  export type EventHandlerMap = {
4
3
  isSceneClick?: (sceneClick: {
@@ -15,5 +14,12 @@ export type EventHandlerMap = {
15
14
  };
16
15
  export declare const eventHandlers: Partial<EventHandlerMap>;
17
16
  export declare const registerBridgeHandler: <K extends keyof EventHandlerMap>(type: K, handler: EventHandlerMap[K]) => void;
18
- export declare const handleBridgeMessage: (event: WebViewMessageEvent) => void;
17
+ type BridgeMessageEvent = {
18
+ nativeEvent: {
19
+ data: string;
20
+ };
21
+ };
22
+ export declare const handleBridgeMessageData: (data: string) => void;
23
+ export declare const handleBridgeMessage: (event: BridgeMessageEvent) => void;
24
+ export {};
19
25
  //# sourceMappingURL=WebBridgeHandlers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"WebBridgeHandlers.d.ts","sourceRoot":"","sources":["../../src/handlers/WebBridgeHandlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAmB,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAI5D,MAAM,MAAM,eAAe,GAAG;IAC7B,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,GAAG,EAAE,cAAc,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC1F,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,GAAG,EAAE,cAAc,CAAC;QAAC,KAAK,EAAE,SAAS,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CAC5G,CAAC;AAGF,eAAO,MAAM,aAAa,EAAE,OAAO,CAAC,eAAe,CAAM,CAAC;AAK1D,eAAO,MAAM,qBAAqB,GAAI,CAAC,SAAS,MAAM,eAAe,EACnE,MAAM,CAAC,EACP,SAAS,eAAe,CAAC,CAAC,CAAC,SAG5B,CAAC;AAGF,eAAO,MAAM,mBAAmB,GAC9B,OAAO,mBAAmB,SAkE3B,CAAC"}
1
+ {"version":3,"file":"WebBridgeHandlers.d.ts","sourceRoot":"","sources":["../../src/handlers/WebBridgeHandlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAI5D,MAAM,MAAM,eAAe,GAAG;IAC7B,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,GAAG,EAAE,cAAc,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC1F,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,GAAG,EAAE,cAAc,CAAC;QAAC,KAAK,EAAE,SAAS,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CAC5G,CAAC;AAGF,eAAO,MAAM,aAAa,EAAE,OAAO,CAAC,eAAe,CAAM,CAAC;AAK1D,eAAO,MAAM,qBAAqB,GAAI,CAAC,SAAS,MAAM,eAAe,EACnE,MAAM,CAAC,EACP,SAAS,eAAe,CAAC,CAAC,CAAC,SAG5B,CAAC;AAGF,KAAK,kBAAkB,GAAG;IAAE,WAAW,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAE5D,eAAO,MAAM,uBAAuB,GAAI,MAAM,MAAM,SAiEnD,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,OAAO,kBAAkB,SAE5D,CAAC"}
@@ -5,11 +5,10 @@ export const eventHandlers = {};
5
5
  export const registerBridgeHandler = (type, handler) => {
6
6
  eventHandlers[type] = handler;
7
7
  };
8
- // 5. Main bridge handler
9
- export const handleBridgeMessage = (event) => {
8
+ export const handleBridgeMessageData = (data) => {
10
9
  var _a, _b;
11
10
  try {
12
- const message = JSON.parse(event.nativeEvent.data);
11
+ const message = JSON.parse(data);
13
12
  if (message.key !== "cameraControllerState") {
14
13
  console.log('message: ', message);
15
14
  }
@@ -67,3 +66,7 @@ export const handleBridgeMessage = (event) => {
67
66
  console.error("WebView message error:", e);
68
67
  }
69
68
  };
69
+ export const handleBridgeMessage = (event) => {
70
+ var _a, _b;
71
+ handleBridgeMessageData((_b = (_a = event === null || event === void 0 ? void 0 : event.nativeEvent) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : "");
72
+ };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { WebViewScreen } from "./webviewBridge/WebViewScreen";
2
+ export { attachIframeBridge } from "./webviewBridge/IframeBridge";
2
3
  export { sendStartPointToBridge, sendEndPointToBridge, sendActiveFloorToBridge, sendPathNextBtnClick, sendPathPreBtnClick, sendPathFinishBtnClick, sendSelectCategory, sendZoomIn, sendZoomOut, sendClearStartAndEndPoint, sendGetDirectionToBridge, sendPathFilter, sendNavigateToBridge, sendMapThemeToBridge, } from "./webviewBridge/BridgeService";
3
4
  export { BridgeStorage as useBridgeStorage } from "./webviewBridge/BridgeStorage";
4
5
  export { registerBridgeHandler } from "./handlers/WebBridgeHandlers";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAG9D,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,kBAAkB,EAClB,UAAU,EACV,WAAW,EACX,yBAAyB,EACzB,wBAAwB,EACxB,cAAc,EACd,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,+BAA+B,CAAC;AAGvC,OAAQ,EAAC,aAAa,IAAI,gBAAgB,EAAC,MAAO,+BAA+B,CAAC;AAGlF,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAGrE,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,IAAI,EACJ,UAAU,EACV,OAAO,EACP,eAAe,EACf,eAAe,EACf,SAAS,EACT,QAAQ,EACR,WAAW,EACX,UAAU,EACV,WAAW,EACX,QAAQ,EACR,WAAW,EACX,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,UAAU,EACV,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,QAAQ,EACR,UAAU,EACV,KAAK,EACL,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,aAAa,GACd,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAGlE,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,kBAAkB,EAClB,UAAU,EACV,WAAW,EACX,yBAAyB,EACzB,wBAAwB,EACxB,cAAc,EACd,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,+BAA+B,CAAC;AAGvC,OAAQ,EAAC,aAAa,IAAI,gBAAgB,EAAC,MAAO,+BAA+B,CAAC;AAGlF,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAGrE,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,IAAI,EACJ,UAAU,EACV,OAAO,EACP,eAAe,EACf,eAAe,EACf,SAAS,EACT,QAAQ,EACR,WAAW,EACX,UAAU,EACV,WAAW,EACX,QAAQ,EACR,WAAW,EACX,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,UAAU,EACV,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,QAAQ,EACR,UAAU,EACV,KAAK,EACL,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,aAAa,GACd,MAAM,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // Components
2
2
  export { WebViewScreen } from "./webviewBridge/WebViewScreen";
3
+ export { attachIframeBridge } from "./webviewBridge/IframeBridge";
3
4
  // Bridge helpers (named exports)
4
5
  export { sendStartPointToBridge, sendEndPointToBridge, sendActiveFloorToBridge, sendPathNextBtnClick, sendPathPreBtnClick, sendPathFinishBtnClick, sendSelectCategory, sendZoomIn, sendZoomOut, sendClearStartAndEndPoint, sendGetDirectionToBridge, sendPathFilter, sendNavigateToBridge, sendMapThemeToBridge, } from "./webviewBridge/BridgeService";
5
6
  // State/store
package/dist/web.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ export { attachIframeBridge } from "./webviewBridge/IframeBridge";
2
+ export { WebIframeScreen } from "./webviewBridge/WebIframeScreen";
3
+ export { sendStartPointToBridge, sendEndPointToBridge, sendActiveFloorToBridge, sendPathNextBtnClick, sendPathPreBtnClick, sendPathFinishBtnClick, sendSelectCategory, sendZoomIn, sendZoomOut, sendClearStartAndEndPoint, sendGetDirectionToBridge, sendPathFilter, sendNavigateToBridge, sendMapThemeToBridge, } from "./webviewBridge/BridgeService";
4
+ export { BridgeStorage as useBridgeStorage } from "./webviewBridge/BridgeStorage";
5
+ export { registerBridgeHandler } from "./handlers/WebBridgeHandlers";
6
+ export type { LocationArea, LocationName, Logo, ShapePoint, BrandId, IncomingMessage, OutgoingMessage, NodePoint, Category, SubCategory, ExternalId, Environment, DayHours, WeeklyHours, NodePointOffer, BrandInfo, MapExportContext, GeometryFloor, GeometryNodePoint, GeometryLayer, NodeMetadata, AssetPayloads, FloorImage, StepInstruction, PathSummary, StepByStepResult, NavState, filterPath, Theme, CameraPosition, ControlsPosition, MapApiResponse, MapDataExport, } from "./types/types";
7
+ //# sourceMappingURL=web.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../src/web.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAGlE,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,kBAAkB,EAClB,UAAU,EACV,WAAW,EACX,yBAAyB,EACzB,wBAAwB,EACxB,cAAc,EACd,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EAAE,aAAa,IAAI,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGlF,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAGrE,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,IAAI,EACJ,UAAU,EACV,OAAO,EACP,eAAe,EACf,eAAe,EACf,SAAS,EACT,QAAQ,EACR,WAAW,EACX,UAAU,EACV,WAAW,EACX,QAAQ,EACR,WAAW,EACX,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,UAAU,EACV,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,QAAQ,EACR,UAAU,EACV,KAAK,EACL,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,aAAa,GACd,MAAM,eAAe,CAAC"}
package/dist/web.js ADDED
@@ -0,0 +1,9 @@
1
+ // Web/iframe entrypoint (no react-native-webview dependency)
2
+ export { attachIframeBridge } from "./webviewBridge/IframeBridge";
3
+ export { WebIframeScreen } from "./webviewBridge/WebIframeScreen";
4
+ // Bridge helpers (named exports)
5
+ export { sendStartPointToBridge, sendEndPointToBridge, sendActiveFloorToBridge, sendPathNextBtnClick, sendPathPreBtnClick, sendPathFinishBtnClick, sendSelectCategory, sendZoomIn, sendZoomOut, sendClearStartAndEndPoint, sendGetDirectionToBridge, sendPathFilter, sendNavigateToBridge, sendMapThemeToBridge, } from "./webviewBridge/BridgeService";
6
+ // State/store
7
+ export { BridgeStorage as useBridgeStorage } from "./webviewBridge/BridgeStorage";
8
+ // Handlers
9
+ export { registerBridgeHandler } from "./handlers/WebBridgeHandlers";
@@ -0,0 +1,8 @@
1
+ type IframeBridgeOptions = {
2
+ iframe: HTMLIFrameElement;
3
+ origin?: string;
4
+ onLoad?: () => void;
5
+ };
6
+ export declare const attachIframeBridge: ({ iframe, origin, onLoad, }: IframeBridgeOptions) => () => void;
7
+ export {};
8
+ //# sourceMappingURL=IframeBridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IframeBridge.d.ts","sourceRoot":"","sources":["../../src/webviewBridge/IframeBridge.ts"],"names":[],"mappings":"AAGA,KAAK,mBAAmB,GAAG;IACzB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,6BAIhC,mBAAmB,eAwBrB,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { handleBridgeMessageData } from "../handlers/WebBridgeHandlers";
2
+ import { setIframeRef, setIframeTargetOrigin } from "./WebViewBridgeRef";
3
+ export const attachIframeBridge = ({ iframe, origin = "*", onLoad, }) => {
4
+ setIframeRef(iframe);
5
+ setIframeTargetOrigin(origin);
6
+ const handleMessage = (event) => {
7
+ if (origin !== "*" && event.origin !== origin)
8
+ return;
9
+ if (iframe.contentWindow && event.source !== iframe.contentWindow)
10
+ return;
11
+ const payload = typeof event.data === "string" ? event.data : JSON.stringify(event.data);
12
+ handleBridgeMessageData(payload);
13
+ };
14
+ const handleLoad = () => {
15
+ if (onLoad)
16
+ onLoad();
17
+ };
18
+ window.addEventListener("message", handleMessage);
19
+ iframe.addEventListener("load", handleLoad);
20
+ return () => {
21
+ window.removeEventListener("message", handleMessage);
22
+ iframe.removeEventListener("load", handleLoad);
23
+ };
24
+ };
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ type Props = {
3
+ url: string;
4
+ origin?: string;
5
+ onload?: () => void;
6
+ title?: string;
7
+ style?: React.CSSProperties;
8
+ };
9
+ export declare const WebIframeScreen: ({ url, origin, onload, title, style, }: Props) => import("react/jsx-runtime").JSX.Element;
10
+ export {};
11
+ //# sourceMappingURL=WebIframeScreen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebIframeScreen.d.ts","sourceRoot":"","sources":["../../src/webviewBridge/WebIframeScreen.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAGjD,KAAK,KAAK,GAAG;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,wCAM7B,KAAK,4CAuBP,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useRef } from "react";
3
+ import { attachIframeBridge } from "./IframeBridge";
4
+ export const WebIframeScreen = ({ url, origin = "*", onload, title = "Wovv Map", style, }) => {
5
+ const iframeRef = useRef(null);
6
+ useEffect(() => {
7
+ if (!iframeRef.current)
8
+ return;
9
+ const cleanup = attachIframeBridge({
10
+ iframe: iframeRef.current,
11
+ origin,
12
+ onLoad: onload,
13
+ });
14
+ return cleanup;
15
+ }, [origin, onload]);
16
+ return (_jsx("iframe", { ref: iframeRef, src: url, title: title, style: { width: "100%", height: "100%", border: 0, ...style } }));
17
+ };
@@ -1,5 +1,8 @@
1
1
  import type { WebView } from "react-native-webview";
2
2
  import { OutgoingMessage } from "../types/types";
3
3
  export declare const webviewRef: import("react").RefObject<WebView<{}> | null>;
4
+ export declare const iframeRef: import("react").RefObject<HTMLIFrameElement | null>;
5
+ export declare const setIframeRef: (iframe: HTMLIFrameElement | null) => void;
6
+ export declare const setIframeTargetOrigin: (origin: string) => void;
4
7
  export declare const sendToWeb: (data: OutgoingMessage) => void;
5
8
  //# sourceMappingURL=WebViewBridgeRef.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"WebViewBridgeRef.d.ts","sourceRoot":"","sources":["../../src/webviewBridge/WebViewBridgeRef.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGjD,eAAO,MAAM,UAAU,+CAAuB,CAAC;AAG/C,eAAO,MAAM,SAAS,GAAI,MAAM,eAAe,SAQ9C,CAAC"}
1
+ {"version":3,"file":"WebViewBridgeRef.d.ts","sourceRoot":"","sources":["../../src/webviewBridge/WebViewBridgeRef.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGjD,eAAO,MAAM,UAAU,+CAAuB,CAAC;AAC/C,eAAO,MAAM,SAAS,qDAAiC,CAAC;AAGxD,eAAO,MAAM,YAAY,GAAI,QAAQ,iBAAiB,GAAG,IAAI,SAE5D,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,QAAQ,MAAM,SAEnD,CAAC;AAGF,eAAO,MAAM,SAAS,GAAI,MAAM,eAAe,SAc9C,CAAC"}
@@ -1,14 +1,26 @@
1
1
  import { createRef } from "react";
2
2
  // Shared WebView ref
3
3
  export const webviewRef = createRef();
4
+ export const iframeRef = createRef();
5
+ let iframeTargetOrigin = "*";
6
+ export const setIframeRef = (iframe) => {
7
+ iframeRef.current = iframe;
8
+ };
9
+ export const setIframeTargetOrigin = (origin) => {
10
+ iframeTargetOrigin = origin;
11
+ };
4
12
  // Exported send function
5
13
  export const sendToWeb = (data) => {
14
+ var _a;
6
15
  console.log("webviweRef", webviewRef);
7
16
  if (webviewRef.current) {
8
17
  console.log("enter current");
9
18
  webviewRef.current.postMessage(JSON.stringify(data));
19
+ return;
10
20
  }
11
- else {
12
- console.warn("WebView not ready yet");
21
+ if ((_a = iframeRef.current) === null || _a === void 0 ? void 0 : _a.contentWindow) {
22
+ iframeRef.current.contentWindow.postMessage(JSON.stringify(data), iframeTargetOrigin);
23
+ return;
13
24
  }
25
+ console.warn("WebView/iframe not ready yet");
14
26
  };
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "wovvmap-webview-bridge",
3
- "version": "1.0.25",
3
+ "version": "1.0.26",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "exports": {
7
7
  ".": {
8
8
  "types": "./dist/index.d.ts",
9
9
  "default": "./dist/index.js"
10
+ },
11
+ "./web": {
12
+ "types": "./dist/web.d.ts",
13
+ "default": "./dist/web.js"
10
14
  }
11
15
  },
12
16
  "files": [