wovvmap-webview-bridge 1.0.26 → 1.0.27

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.
Files changed (2) hide show
  1. package/README.md +282 -282
  2. package/package.json +41 -33
package/README.md CHANGED
@@ -1,282 +1,282 @@
1
- # wovvmap-webview-bridge
2
-
3
- A typed bridge between React Native and a WebView for Wovvmap maps. It provides:
4
- - WebViewScreen wrapper for React Native WebView
5
- - BridgeService helpers to send events to the WebView
6
- - Zustand store (useBridgeStorage) that keeps incoming state in sync
7
- - Strongly typed message contracts
8
-
9
- ## Installation
10
-
11
- ```bash
12
- npm install react-native-webview zustand
13
- # or
14
- yarn add react-native-webview zustand
15
- ```
16
-
17
- ## Quick start
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
-
79
- ### 1) Render the WebView
80
-
81
- ```tsx
82
- import React from "react";
83
- import { WebViewScreen } from "wovvmap-webview-bridge";
84
-
85
- export default function App() {
86
- return <WebViewScreen url="https://your-map-app-url.com" />;
87
- }
88
- ```
89
-
90
- ### 2) Send events to the WebView (RN -> Web)
91
-
92
- ```tsx
93
- import {
94
- sendStartPointToBridge,
95
- sendEndPointToBridge,
96
- sendActiveFloorToBridge,
97
- sendPathNextBtnClick,
98
- sendPathPreBtnClick,
99
- sendPathFinishBtnClick,
100
- sendSelectCategory,
101
- sendZoomIn,
102
- sendZoomOut,
103
- sendClearStartAndEndPoint,
104
- sendPathFilter,
105
- sendGetDirectionToBridge,
106
- sendNavigateToBridge,
107
- sendMapThemeToBridge,
108
- } from "wovvmap-webview-bridge";
109
-
110
- sendStartPointToBridge("A1");
111
- sendEndPointToBridge("B5");
112
- sendActiveFloorToBridge(2);
113
- sendPathNextBtnClick();
114
- sendPathPreBtnClick();
115
- sendPathFinishBtnClick();
116
- sendSelectCategory(["Food", "Fashion"]);
117
- sendZoomIn();
118
- sendZoomOut();
119
- sendClearStartAndEndPoint();
120
- sendPathFilter();
121
- sendGetDirectionToBridge();
122
- sendNavigateToBridge("map-id-123");
123
- sendMapThemeToBridge({ "theme-path-color": "#00AAFF" });
124
- ```
125
-
126
- ### 3) Handle events from the WebView (Web -> RN)
127
-
128
- You can register handlers for click events. All other events are stored in the Zustand store.
129
-
130
- ```tsx
131
- import { registerBridgeHandler } from "wovvmap-webview-bridge";
132
-
133
- registerBridgeHandler("isSceneClick", (payload) => {
134
- console.log("Scene clicked", payload);
135
- });
136
-
137
- registerBridgeHandler("isShapeClick", (payload) => {
138
- console.log("Shape clicked", payload.value);
139
- });
140
- ```
141
-
142
- ### 4) Read synced state from the store
143
-
144
- ```tsx
145
- import { useBridgeStorage } from "wovvmap-webview-bridge";
146
-
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,
158
- }));
159
- ```
160
-
161
- Store fields:
162
- - isBridgeLoaded
163
- - isMapLoaded
164
- - searchablePoints
165
- - amenities
166
- - allOffers
167
- - activeFloor
168
- - elevator, escalator
169
- - floorImages
170
- - stepByStepList
171
- - pathSummary
172
- - nextPreState
173
- - pointsByKey
174
- - categories
175
- - subCategories
176
- - cameraControllerState
177
-
178
- ## Bridge message contracts
179
-
180
- ### IncomingMessage (Web -> RN)
181
- Keys and payloads:
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>
192
- - isSceneClick: no value
193
- - isShapeClick: NodePoint
194
- - stepByStepList: StepByStepResult
195
- - pathNextPreState: NavState
196
- - cameraControllerState: { cameraPosition: CameraPosition; controlsPosition: ControlsPosition }
197
-
198
- ### OutgoingMessage (RN -> Web)
199
- Keys and payloads:
200
- - applyCSS: { selector: string; style: Partial<CSSStyleDeclaration> }
201
- - ping: boolean
202
- - setEndPoint: string
203
- - setStartPoint: string
204
- - setActiveFloor: number
205
- - pathNextBtnClick: no value
206
- - pathPreBtnClick: no value
207
- - pathFinishBtnClick: no value
208
- - setSelectCategory: string | string[] | null
209
- - zoomIn: no value
210
- - zoomOut: no value
211
- - clearStartAndEndPoint: no value
212
- - setPathFilter: filterPath
213
- - getDirection: no value
214
- - setMapTheme: Theme | null
215
- - navigateTo: string
216
- - editableView: MapApiResponse
217
- - pathHighlightByStepIndex: number
218
-
219
- ## Exported API
220
-
221
- ### Components
222
- - WebViewScreen
223
- - WebIframeScreen (web only)
224
-
225
- ### Bridge helpers
226
- - sendStartPointToBridge
227
- - sendEndPointToBridge
228
- - sendActiveFloorToBridge
229
- - sendPathNextBtnClick
230
- - sendPathPreBtnClick
231
- - sendPathFinishBtnClick
232
- - sendSelectCategory
233
- - sendZoomIn
234
- - sendZoomOut
235
- - sendClearStartAndEndPoint
236
- - sendGetDirectionToBridge
237
- - sendPathFilter
238
- - sendNavigateToBridge
239
- - sendMapThemeToBridge
240
-
241
- ### Handlers
242
- - registerBridgeHandler
243
-
244
- ### Store
245
- - useBridgeStorage (Zustand)
246
-
247
- ### Types
248
- - IncomingMessage, OutgoingMessage
249
- - NodePoint
250
- - AmenityWithNodePoint
251
- - Category, SubCategory, ExternalId
252
- - Environment, DayHours, WeeklyHours
253
- - NodePointOffer, BrandInfo
254
- - MapExportContext, GeometryFloor, GeometryNodePoint, GeometryLayer
255
- - NodeMetadata, AssetPayloads
256
- - FloorImage
257
- - StepInstruction, PathSummary, StepByStepResult
258
- - NavState
259
- - filterPath
260
- - Theme
261
- - CameraPosition, ControlsPosition
262
- - MapApiResponse, MapDataExport
263
-
264
- ## File structure
265
-
266
- ```
267
- src/
268
- index.ts
269
- webviewBridge/
270
- WebViewScreen.tsx
271
- BridgeService.ts
272
- BridgeStorage.ts
273
- WebViewBridgeRef.ts
274
- handlers/
275
- WebBridgeHandlers.ts
276
- types/
277
- types.ts
278
- ```
279
-
280
- ## License
281
-
282
- MIT
1
+ # wovvmap-webview-bridge
2
+
3
+ A typed bridge between React Native and a WebView for Wovvmap maps. It provides:
4
+ - WebViewScreen wrapper for React Native WebView
5
+ - BridgeService helpers to send events to the WebView
6
+ - Zustand store (useBridgeStorage) that keeps incoming state in sync
7
+ - Strongly typed message contracts
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install react-native-webview zustand
13
+ # or
14
+ yarn add react-native-webview zustand
15
+ ```
16
+
17
+ ## Quick start
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
+
79
+ ### 1) Render the WebView
80
+
81
+ ```tsx
82
+ import React from "react";
83
+ import { WebViewScreen } from "wovvmap-webview-bridge";
84
+
85
+ export default function App() {
86
+ return <WebViewScreen url="https://your-map-app-url.com" />;
87
+ }
88
+ ```
89
+
90
+ ### 2) Send events to the WebView (RN -> Web)
91
+
92
+ ```tsx
93
+ import {
94
+ sendStartPointToBridge,
95
+ sendEndPointToBridge,
96
+ sendActiveFloorToBridge,
97
+ sendPathNextBtnClick,
98
+ sendPathPreBtnClick,
99
+ sendPathFinishBtnClick,
100
+ sendSelectCategory,
101
+ sendZoomIn,
102
+ sendZoomOut,
103
+ sendClearStartAndEndPoint,
104
+ sendPathFilter,
105
+ sendGetDirectionToBridge,
106
+ sendNavigateToBridge,
107
+ sendMapThemeToBridge,
108
+ } from "wovvmap-webview-bridge";
109
+
110
+ sendStartPointToBridge("A1");
111
+ sendEndPointToBridge("B5");
112
+ sendActiveFloorToBridge(2);
113
+ sendPathNextBtnClick();
114
+ sendPathPreBtnClick();
115
+ sendPathFinishBtnClick();
116
+ sendSelectCategory(["Food", "Fashion"]);
117
+ sendZoomIn();
118
+ sendZoomOut();
119
+ sendClearStartAndEndPoint();
120
+ sendPathFilter();
121
+ sendGetDirectionToBridge();
122
+ sendNavigateToBridge("map-id-123");
123
+ sendMapThemeToBridge({ "theme-path-color": "#00AAFF" });
124
+ ```
125
+
126
+ ### 3) Handle events from the WebView (Web -> RN)
127
+
128
+ You can register handlers for click events. All other events are stored in the Zustand store.
129
+
130
+ ```tsx
131
+ import { registerBridgeHandler } from "wovvmap-webview-bridge";
132
+
133
+ registerBridgeHandler("isSceneClick", (payload) => {
134
+ console.log("Scene clicked", payload);
135
+ });
136
+
137
+ registerBridgeHandler("isShapeClick", (payload) => {
138
+ console.log("Shape clicked", payload.value);
139
+ });
140
+ ```
141
+
142
+ ### 4) Read synced state from the store
143
+
144
+ ```tsx
145
+ import { useBridgeStorage } from "wovvmap-webview-bridge";
146
+
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,
158
+ }));
159
+ ```
160
+
161
+ Store fields:
162
+ - isBridgeLoaded
163
+ - isMapLoaded
164
+ - searchablePoints
165
+ - amenities
166
+ - allOffers
167
+ - activeFloor
168
+ - elevator, escalator
169
+ - floorImages
170
+ - stepByStepList
171
+ - pathSummary
172
+ - nextPreState
173
+ - pointsByKey
174
+ - categories
175
+ - subCategories
176
+ - cameraControllerState
177
+
178
+ ## Bridge message contracts
179
+
180
+ ### IncomingMessage (Web -> RN)
181
+ Keys and payloads:
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>
192
+ - isSceneClick: no value
193
+ - isShapeClick: NodePoint
194
+ - stepByStepList: StepByStepResult
195
+ - pathNextPreState: NavState
196
+ - cameraControllerState: { cameraPosition: CameraPosition; controlsPosition: ControlsPosition }
197
+
198
+ ### OutgoingMessage (RN -> Web)
199
+ Keys and payloads:
200
+ - applyCSS: { selector: string; style: Partial<CSSStyleDeclaration> }
201
+ - ping: boolean
202
+ - setEndPoint: string
203
+ - setStartPoint: string
204
+ - setActiveFloor: number
205
+ - pathNextBtnClick: no value
206
+ - pathPreBtnClick: no value
207
+ - pathFinishBtnClick: no value
208
+ - setSelectCategory: string | string[] | null
209
+ - zoomIn: no value
210
+ - zoomOut: no value
211
+ - clearStartAndEndPoint: no value
212
+ - setPathFilter: filterPath
213
+ - getDirection: no value
214
+ - setMapTheme: Theme | null
215
+ - navigateTo: string
216
+ - editableView: MapApiResponse
217
+ - pathHighlightByStepIndex: number
218
+
219
+ ## Exported API
220
+
221
+ ### Components
222
+ - WebViewScreen
223
+ - WebIframeScreen (web only)
224
+
225
+ ### Bridge helpers
226
+ - sendStartPointToBridge
227
+ - sendEndPointToBridge
228
+ - sendActiveFloorToBridge
229
+ - sendPathNextBtnClick
230
+ - sendPathPreBtnClick
231
+ - sendPathFinishBtnClick
232
+ - sendSelectCategory
233
+ - sendZoomIn
234
+ - sendZoomOut
235
+ - sendClearStartAndEndPoint
236
+ - sendGetDirectionToBridge
237
+ - sendPathFilter
238
+ - sendNavigateToBridge
239
+ - sendMapThemeToBridge
240
+
241
+ ### Handlers
242
+ - registerBridgeHandler
243
+
244
+ ### Store
245
+ - useBridgeStorage (Zustand)
246
+
247
+ ### Types
248
+ - IncomingMessage, OutgoingMessage
249
+ - NodePoint
250
+ - AmenityWithNodePoint
251
+ - Category, SubCategory, ExternalId
252
+ - Environment, DayHours, WeeklyHours
253
+ - NodePointOffer, BrandInfo
254
+ - MapExportContext, GeometryFloor, GeometryNodePoint, GeometryLayer
255
+ - NodeMetadata, AssetPayloads
256
+ - FloorImage
257
+ - StepInstruction, PathSummary, StepByStepResult
258
+ - NavState
259
+ - filterPath
260
+ - Theme
261
+ - CameraPosition, ControlsPosition
262
+ - MapApiResponse, MapDataExport
263
+
264
+ ## File structure
265
+
266
+ ```
267
+ src/
268
+ index.ts
269
+ webviewBridge/
270
+ WebViewScreen.tsx
271
+ BridgeService.ts
272
+ BridgeStorage.ts
273
+ WebViewBridgeRef.ts
274
+ handlers/
275
+ WebBridgeHandlers.ts
276
+ types/
277
+ types.ts
278
+ ```
279
+
280
+ ## License
281
+
282
+ MIT
package/package.json CHANGED
@@ -1,33 +1,41 @@
1
- {
2
- "name": "wovvmap-webview-bridge",
3
- "version": "1.0.26",
4
- "main": "dist/index.js",
5
- "types": "dist/index.d.ts",
6
- "exports": {
7
- ".": {
8
- "types": "./dist/index.d.ts",
9
- "default": "./dist/index.js"
10
- },
11
- "./web": {
12
- "types": "./dist/web.d.ts",
13
- "default": "./dist/web.js"
14
- }
15
- },
16
- "files": [
17
- "dist"
18
- ],
19
- "sideEffects": false,
20
- "scripts": {
21
- "build": "tsc -p tsconfig.json"
22
- },
23
- "peerDependencies": {
24
- "react": "^19.1.0",
25
- "react-native": "^0.80.1",
26
- "react-native-webview": "^13.16.0",
27
- "zustand": "^5.0.8"
28
- },
29
- "devDependencies": {
30
- "@types/react": "^19.1.8",
31
- "typescript": "^5.5.0"
32
- }
33
- }
1
+ {
2
+ "name": "wovvmap-webview-bridge",
3
+ "version": "1.0.27",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "default": "./dist/index.js"
10
+ },
11
+ "./web": {
12
+ "types": "./dist/web.d.ts",
13
+ "default": "./dist/web.js"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "sideEffects": false,
20
+ "scripts": {
21
+ "build": "tsc -p tsconfig.json"
22
+ },
23
+ "peerDependencies": {
24
+ "react": "^19.1.0",
25
+ "react-native": "^0.80.1",
26
+ "react-native-webview": "^13.16.0",
27
+ "zustand": "^5.0.8"
28
+ },
29
+ "peerDependenciesMeta": {
30
+ "react-native": {
31
+ "optional": true
32
+ },
33
+ "react-native-webview": {
34
+ "optional": true
35
+ }
36
+ },
37
+ "devDependencies": {
38
+ "@types/react": "^19.1.8",
39
+ "typescript": "^5.5.0"
40
+ }
41
+ }