react-native-maplibre-gl-js 1.0.0 → 1.0.1

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 (29) hide show
  1. package/README.md +7 -5
  2. package/package.json +19 -14
  3. package/src/communication/messages.types.ts +0 -121
  4. package/src/communication/messages.utils.ts +0 -58
  5. package/src/index.ts +0 -31
  6. package/src/react-native/components/Map/Map.tsx +0 -14
  7. package/src/react-native/components/Map/Map.types.ts +0 -149
  8. package/src/react-native/components/MapProvider/MapProvider.hooks.ts +0 -13
  9. package/src/react-native/components/MapProvider/MapProvider.tsx +0 -139
  10. package/src/react-native/components/MapProvider/MapProvider.types.ts +0 -12
  11. package/src/react-native/components/Marker/Marker.tsx +0 -14
  12. package/src/react-native/components/Marker/Marker.types.ts +0 -56
  13. package/src/react-native/components/Popup/Popup.tsx +0 -14
  14. package/src/react-native/components/Popup/Popup.types.ts +0 -43
  15. package/src/react-native/components-factory/createWebObjectAsComponent.ts +0 -33
  16. package/src/react-native/components-factory/createWebObjectAsComponent.types.ts +0 -176
  17. package/src/react-native/components-factory/hooks/useWebObjectMethodsProxy.ts +0 -61
  18. package/src/react-native/components-factory/hooks/useWebObjectMountOnLaunch.ts +0 -79
  19. package/src/react-native/components-factory/hooks/useWebObjectOptionsUpdater.ts +0 -29
  20. package/src/react-native/hooks/atoms/useMapAtoms.ts +0 -261
  21. package/src/react-native/hooks/atoms/useMapAtoms.utils.ts +0 -15
  22. package/src/react-native/logger/rn-logger.ts +0 -51
  23. package/src/typedoc.ts +0 -35
  24. package/src/web/bridge/ReactNativeBridge.ts +0 -44
  25. package/src/web/generated/index.html +0 -18
  26. package/src/web/generated/index.ts +0 -17
  27. package/src/web/generated/webview_static_html.ts +0 -23528
  28. package/src/web/logger/web-logger.ts +0 -36
  29. package/src/web/maplibre-gl-js/MapController.ts +0 -322
package/README.md CHANGED
@@ -69,21 +69,23 @@ npm install react-native-maplibre-gl-js
69
69
  The minimal setup to render a MapLibre map in React Native.
70
70
 
71
71
  ```js
72
- import RNMapLibreGlJs from 'react-native-maplibre-gl-js';
72
+ import { MapProvider, Map } from 'react-native-maplibre-gl-js';
73
73
 
74
- export const MyMapComponent = () => {
74
+ const App = () => {
75
75
  return (
76
- <RNMapLibreGlJs.MapProvider>
77
- <RNMapLibreGlJs.Map
76
+ <MapProvider>
77
+ <Map
78
78
  options={{
79
79
  style: 'https://tiles.openfreemap.org/styles/liberty',
80
80
  center: [2.32, 48.86],
81
81
  zoom: 12,
82
82
  }}
83
83
  />
84
- </RNMapLibreGlJs.MapProvider>
84
+ </MapProvider>
85
85
  )
86
86
  }
87
+
88
+ export default App
87
89
  ```
88
90
 
89
91
 
package/package.json CHANGED
@@ -1,25 +1,34 @@
1
1
  {
2
2
  "name": "react-native-maplibre-gl-js",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "MapLibre GL JS for React Native",
5
+ "files": [
6
+ "lib",
7
+ "package.json",
8
+ "README.md",
9
+ "LICENSE"
10
+ ],
5
11
  "main": "./lib/module/index.js",
6
12
  "types": "./lib/typescript/src/index.d.ts",
7
13
  "exports": {
8
14
  ".": {
9
- "source": "./src/index.ts",
10
15
  "types": "./lib/typescript/src/index.d.ts",
11
16
  "default": "./lib/module/index.js"
12
17
  },
18
+ "./react-native/*": {
19
+ "types": "./lib/typescript/src/react-native/*",
20
+ "default": "./lib/module/react-native/*"
21
+ },
22
+ "./web/*": {
23
+ "types": "./lib/typescript/src/web/*",
24
+ "default": "./lib/module/web/*"
25
+ },
26
+ "./communication/*": {
27
+ "types": "./lib/typescript/src/communication/*",
28
+ "default": "./lib/module/communication/*"
29
+ },
13
30
  "./package.json": "./package.json"
14
31
  },
15
- "files": [
16
- "src",
17
- "lib",
18
- "!**/.*",
19
- "!**/*tests*",
20
- "!**/*fixtures*",
21
- "!**/*mocks*"
22
- ],
23
32
  "scripts": {
24
33
  "build:webview": "node scripts/build.js",
25
34
  "example": "yarn workspace react-native-maplibre-gl-js-example",
@@ -102,10 +111,6 @@
102
111
  {
103
112
  "path": "CHANGELOG.md",
104
113
  "label": "Changelog"
105
- },
106
- {
107
- "path": "*.tgz",
108
- "label": "NPM package (.tgz)"
109
114
  }
110
115
  ]
111
116
  }
@@ -1,121 +0,0 @@
1
- import type {
2
- Map as MapLibreMap,
3
- Marker as MapLibreMarker,
4
- Popup as MapLibrePopup,
5
- } from 'maplibre-gl'
6
- import type {
7
- WebObjectOptionsInferred,
8
- WebObjectListeners,
9
- } from 'react-native-maplibre-gl-js/react-native/components-factory/createWebObjectAsComponent.types'
10
-
11
- /**
12
- * The web objects that are supported by this library.
13
- * A string version to be used as an identifier on the RN side (cannot use
14
- * MapLibre classes directly).
15
- * Must correspond to `WebObjectClass`.
16
- */
17
- export type WebObjectType = 'map' | 'marker' | 'popup'
18
-
19
- /**
20
- * The web objects that are supported by this library.
21
- * A class version to be used on the web side.
22
- * Must correspond to `WebObjectType`.
23
- */
24
- export type WebObjectClass = MapLibreMap | MapLibreMarker | MapLibrePopup
25
-
26
- /**
27
- * UID of a web object in the web world.
28
- */
29
- export type WebObjectId = string
30
-
31
- /**
32
- * UID of a request for a web object method to be executed.
33
- */
34
- export type WebObjectMethodCallRequestId = string
35
-
36
- export type MessageFromRNToWeb =
37
- /**
38
- * TODO Messages about a MapLibre object.
39
- */
40
- | {
41
- type: 'webObjectMount'
42
- payload: {
43
- objectId: WebObjectId
44
- objectType: WebObjectType
45
- options: WebObjectOptionsInferred<any>
46
- listeners: WebObjectListeners
47
- }
48
- }
49
- | {
50
- type: 'webObjectUnmount'
51
- payload: {
52
- objectId: WebObjectId
53
- }
54
- }
55
- | {
56
- type: 'webObjectMethodCall'
57
- payload: {
58
- requestId: WebObjectMethodCallRequestId
59
- objectId: WebObjectId
60
- method: string
61
- args: any[]
62
- }
63
- }
64
- | {
65
- type: 'webObjectOptionsUpdate'
66
- payload: {
67
- objectId: WebObjectId
68
- options: WebObjectOptionsInferred<any>
69
- }
70
- }
71
-
72
- export type MessageFromWebToRN =
73
- /**
74
- * Anything that should be logged in the React Native world.
75
- */
76
- | {
77
- type: 'console'
78
- payload: {
79
- level: 'debug' | 'info' | 'error'
80
- args: [string, ...any[]]
81
- }
82
- }
83
- /**
84
- * Notify the React Native world that the web one is ready.
85
- */
86
- | {
87
- type: 'ready'
88
- }
89
- /**
90
- * Event issued by a web object, eligible to be listened to from the RN world.
91
- */
92
- | {
93
- type: 'webObjectListenerEvent'
94
- payload: {
95
- objectId: WebObjectId
96
- eventName: keyof WebObjectListeners
97
- event?: any
98
- }
99
- }
100
- /**
101
- * Response to a call to a method of a web object.
102
- */
103
- | {
104
- type: 'webObjectMethodResponse'
105
- payload: {
106
- requestId: WebObjectMethodCallRequestId
107
- result: any
108
- }
109
- }
110
-
111
- /**
112
- * To replace HTMLElement instances that cannot be created in React Native.
113
- */
114
- export type HTMLElementDescriptor = {
115
- tagName?: string
116
- className?: string
117
- attributes?: Record<string, string>
118
- style?: Record<string, string>
119
- dataset?: Record<string, string>
120
- innerHTML?: string
121
- }
@@ -1,58 +0,0 @@
1
- import type {
2
- WebObjectListenerOnHTMLElement,
3
- WebObjectListenerOnMapLayer,
4
- WebObjectListenerOnObject,
5
- WebObjectListenerOnRN,
6
- } from 'react-native-maplibre-gl-js/react-native/components-factory/createWebObjectAsComponent.types'
7
-
8
- export const isWebObjectListenerOnRN = (
9
- listener?:
10
- | WebObjectListenerOnRN<any>
11
- | WebObjectListenerOnObject<any>
12
- | WebObjectListenerOnHTMLElement<any>
13
- | WebObjectListenerOnMapLayer<any>,
14
- ): boolean => {
15
- if (!listener) {
16
- return false
17
- }
18
- return 'rnListener' in listener
19
- }
20
-
21
- export const isWebObjectListenerOnObject = (
22
- listener?:
23
- | WebObjectListenerOnRN<any>
24
- | WebObjectListenerOnObject<any>
25
- | WebObjectListenerOnHTMLElement<any>
26
- | WebObjectListenerOnMapLayer<any>,
27
- ): boolean => {
28
- if (!listener) {
29
- return false
30
- }
31
- return 'objectListener' in listener
32
- }
33
-
34
- export const isWebObjectListenerOnMapLayer = (
35
- listener?:
36
- | WebObjectListenerOnRN<any>
37
- | WebObjectListenerOnObject<any>
38
- | WebObjectListenerOnHTMLElement<any>
39
- | WebObjectListenerOnMapLayer<any>,
40
- ): boolean => {
41
- if (!listener) {
42
- return false
43
- }
44
- return 'layerListener' in listener
45
- }
46
-
47
- export const isWebObjectListenerOnHTMLElement = (
48
- listener?:
49
- | WebObjectListenerOnRN<any>
50
- | WebObjectListenerOnObject<any>
51
- | WebObjectListenerOnHTMLElement<any>
52
- | WebObjectListenerOnMapLayer<any>,
53
- ): boolean => {
54
- if (!listener) {
55
- return false
56
- }
57
- return 'elementListener' in listener
58
- }
package/src/index.ts DELETED
@@ -1,31 +0,0 @@
1
- /**
2
- * Public API of react-native-maplibre-gl-js.
3
- * @module Public API
4
- * @packageDocumentation
5
- */
6
-
7
- import type { MapProviderProps } from 'react-native-maplibre-gl-js/react-native/components/MapProvider/MapProvider.types'
8
- import type {
9
- MapRef,
10
- MapProps,
11
- } from 'react-native-maplibre-gl-js/react-native/components/Map/Map.types'
12
- import type {
13
- MarkerRef,
14
- MarkerProps,
15
- } from 'react-native-maplibre-gl-js/react-native/components/Marker/Marker.types'
16
- import type {
17
- PopupRef,
18
- PopupProps,
19
- } from 'react-native-maplibre-gl-js/react-native/components/Popup/Popup.types'
20
-
21
- export type { MapProviderProps }
22
- export type { MapRef, MapProps }
23
- export type { MarkerRef, MarkerProps }
24
- export type { PopupRef, PopupProps }
25
-
26
- import MapProvider from 'react-native-maplibre-gl-js/react-native/components/MapProvider/MapProvider'
27
- import Map from 'react-native-maplibre-gl-js/react-native/components/Map/Map'
28
- import Marker from 'react-native-maplibre-gl-js/react-native/components/Marker/Marker'
29
- import Popup from 'react-native-maplibre-gl-js/react-native/components/Popup/Popup'
30
-
31
- export { MapProvider, Map, Marker, Popup }
@@ -1,14 +0,0 @@
1
- import createWebObjectAsComponent from 'react-native-maplibre-gl-js/react-native/components-factory/createWebObjectAsComponent'
2
- import type {
3
- MapRef,
4
- MapProps,
5
- } from 'react-native-maplibre-gl-js/react-native/components/Map/Map.types'
6
-
7
- /**
8
- * MapLibre Map view.
9
- * @see {@link https://maplibre.org/maplibre-gl-js/docs/API/classes/Map/ MapLibre GL JS docs}
10
- * @group Components
11
- */
12
- const Map = createWebObjectAsComponent<MapRef, MapProps>('map')
13
-
14
- export default Map
@@ -1,149 +0,0 @@
1
- import {
2
- type Map as MapLibreMap,
3
- type MapContextEvent,
4
- type MapLayerMouseEvent,
5
- type MapLayerTouchEvent,
6
- type MapLibreEvent,
7
- type MapLibreZoomEvent,
8
- type MapOptions as MapLibreMapOptions,
9
- MapTouchEvent,
10
- MapWheelEvent,
11
- ErrorEvent,
12
- type MapDataEvent,
13
- type MapStyleDataEvent,
14
- type MapSourceDataEvent,
15
- type MapStyleImageMissingEvent,
16
- } from 'maplibre-gl'
17
- import type {
18
- WebObjectMethodsInferred,
19
- WebObjectOptionsInferred,
20
- WebObjectListenerOnMapLayer,
21
- WebObjectListenerOnObject,
22
- WebObjectListenerOnRN,
23
- WebObjectProps,
24
- WebObjectRef,
25
- } from 'react-native-maplibre-gl-js/react-native/components-factory/createWebObjectAsComponent.types'
26
-
27
- /**
28
- * A Map component ref.
29
- * @group Types
30
- */
31
- export type MapRef = WebObjectRef<MapMethods>
32
-
33
- /**
34
- * A Map component props.
35
- * @group Types
36
- */
37
- export type MapProps = WebObjectProps<MapOptions, MapListeners>
38
-
39
- type MapMethods = WebObjectMethodsInferred<MapLibreMap>
40
- type MapOptions = WebObjectOptionsInferred<MapLibreMapOptions, {}, 'container'>
41
- type MapListeners = {
42
- // React native events.
43
- mount: WebObjectListenerOnRN<void>
44
- unmount: WebObjectListenerOnRN<void>
45
- // MapLibre GL JS events.
46
- // https://maplibre.org/maplibre-gl-js/docs/API/classes/Map/#on
47
- mousedown:
48
- | WebObjectListenerOnObject<MapLayerMouseEvent>
49
- | WebObjectListenerOnMapLayer<MapLayerMouseEvent>
50
- mouseup:
51
- | WebObjectListenerOnObject<MapLayerMouseEvent>
52
- | WebObjectListenerOnMapLayer<MapLayerMouseEvent>
53
- mouseover:
54
- | WebObjectListenerOnObject<MapLayerMouseEvent>
55
- | WebObjectListenerOnMapLayer<MapLayerMouseEvent>
56
- mouseout:
57
- | WebObjectListenerOnObject<MapLayerMouseEvent>
58
- | WebObjectListenerOnMapLayer<MapLayerMouseEvent>
59
- mousemove:
60
- | WebObjectListenerOnObject<MapLayerMouseEvent>
61
- | WebObjectListenerOnMapLayer<MapLayerMouseEvent>
62
- mouseenter: WebObjectListenerOnMapLayer<MapLayerMouseEvent>
63
- mouseleave: WebObjectListenerOnMapLayer<MapLayerMouseEvent>
64
- click:
65
- | WebObjectListenerOnObject<MapLayerMouseEvent>
66
- | WebObjectListenerOnMapLayer<MapLayerMouseEvent>
67
- dblclick:
68
- | WebObjectListenerOnObject<MapLayerMouseEvent>
69
- | WebObjectListenerOnMapLayer<MapLayerMouseEvent>
70
- contextmenu:
71
- | WebObjectListenerOnObject<MapLayerMouseEvent>
72
- | WebObjectListenerOnMapLayer<MapLayerMouseEvent>
73
- touchstart:
74
- | WebObjectListenerOnObject<MapLayerTouchEvent>
75
- | WebObjectListenerOnMapLayer<MapLayerTouchEvent>
76
- touchend:
77
- | WebObjectListenerOnObject<MapLayerTouchEvent>
78
- | WebObjectListenerOnMapLayer<MapLayerTouchEvent>
79
- touchcancel:
80
- | WebObjectListenerOnObject<MapLayerTouchEvent>
81
- | WebObjectListenerOnMapLayer<MapLayerTouchEvent>
82
- wheel: WebObjectListenerOnObject<MapWheelEvent>
83
- resize: WebObjectListenerOnObject<MapLibreEvent>
84
- remove: WebObjectListenerOnObject<MapLibreEvent>
85
- touchmove: WebObjectListenerOnObject<MapTouchEvent>
86
- movestart: WebObjectListenerOnObject<
87
- MapLibreEvent<MouseEvent | TouchEvent | WheelEvent | undefined>
88
- >
89
- move: WebObjectListenerOnObject<
90
- MapLibreEvent<MouseEvent | TouchEvent | WheelEvent | undefined>
91
- >
92
- moveend: WebObjectListenerOnObject<
93
- MapLibreEvent<MouseEvent | TouchEvent | WheelEvent | undefined>
94
- >
95
- dragstart: WebObjectListenerOnObject<
96
- MapLibreEvent<MouseEvent | TouchEvent | undefined>
97
- >
98
- drag: WebObjectListenerOnObject<
99
- MapLibreEvent<MouseEvent | TouchEvent | undefined>
100
- >
101
- dragend: WebObjectListenerOnObject<
102
- MapLibreEvent<MouseEvent | TouchEvent | undefined>
103
- >
104
- zoomstart: WebObjectListenerOnObject<
105
- MapLibreEvent<MouseEvent | TouchEvent | WheelEvent | undefined>
106
- >
107
- zoom: WebObjectListenerOnObject<
108
- MapLibreEvent<MouseEvent | TouchEvent | WheelEvent | undefined>
109
- >
110
- zoomend: WebObjectListenerOnObject<
111
- MapLibreEvent<MouseEvent | TouchEvent | WheelEvent | undefined>
112
- >
113
- rotatestart: WebObjectListenerOnObject<
114
- MapLibreEvent<MouseEvent | TouchEvent | undefined>
115
- >
116
- rotate: WebObjectListenerOnObject<
117
- MapLibreEvent<MouseEvent | TouchEvent | undefined>
118
- >
119
- rotateend: WebObjectListenerOnObject<
120
- MapLibreEvent<MouseEvent | TouchEvent | undefined>
121
- >
122
- pitchstart: WebObjectListenerOnObject<
123
- MapLibreEvent<MouseEvent | TouchEvent | undefined>
124
- >
125
- pitch: WebObjectListenerOnObject<
126
- MapLibreEvent<MouseEvent | TouchEvent | undefined>
127
- >
128
- pitchend: WebObjectListenerOnObject<
129
- MapLibreEvent<MouseEvent | TouchEvent | undefined>
130
- >
131
- boxzoomstart: WebObjectListenerOnObject<MapLibreZoomEvent>
132
- boxzoomend: WebObjectListenerOnObject<MapLibreZoomEvent>
133
- boxzoomcancel: WebObjectListenerOnObject<MapLibreZoomEvent>
134
- webglcontextlost: WebObjectListenerOnObject<MapContextEvent>
135
- webglcontextrestored: WebObjectListenerOnObject<MapContextEvent>
136
- load: WebObjectListenerOnObject<MapLibreEvent>
137
- render: WebObjectListenerOnObject<MapLibreEvent>
138
- idle: WebObjectListenerOnObject<MapLibreEvent>
139
- error: WebObjectListenerOnObject<ErrorEvent>
140
- data: WebObjectListenerOnObject<MapDataEvent>
141
- styledata: WebObjectListenerOnObject<MapStyleDataEvent>
142
- sourcedata: WebObjectListenerOnObject<MapSourceDataEvent>
143
- dataloading: WebObjectListenerOnObject<MapDataEvent>
144
- styledataloading: WebObjectListenerOnObject<MapStyleDataEvent>
145
- sourcedataloading: WebObjectListenerOnObject<MapSourceDataEvent>
146
- styleimagemissing: WebObjectListenerOnObject<MapStyleImageMissingEvent>
147
- dataabort: WebObjectListenerOnObject<MapDataEvent>
148
- sourcedataabort: WebObjectListenerOnObject<MapSourceDataEvent>
149
- }
@@ -1,13 +0,0 @@
1
- import { StyleSheet } from 'react-native'
2
- import { useMemo } from 'react'
3
-
4
- export const useStyles = () => {
5
- return useMemo(
6
- () =>
7
- StyleSheet.create({
8
- container: { width: '100%', height: '100%', overflow: 'hidden' },
9
- webview: { flex: 1, backgroundColor: 'transparent' },
10
- }),
11
- [],
12
- )
13
- }
@@ -1,139 +0,0 @@
1
- import { View } from 'react-native'
2
- import { WebView, type WebViewMessageEvent } from 'react-native-webview'
3
- import { WEBVIEW_STATIC_HTML } from 'react-native-maplibre-gl-js/web/generated/webview_static_html'
4
- import type { MessageFromWebToRN } from 'react-native-maplibre-gl-js/communication/messages.types'
5
- import RNLogger from 'react-native-maplibre-gl-js/react-native/logger/rn-logger'
6
- import useMapAtoms from 'react-native-maplibre-gl-js/react-native/hooks/atoms/useMapAtoms'
7
- import {
8
- isWebObjectListenerOnHTMLElement,
9
- isWebObjectListenerOnMapLayer,
10
- isWebObjectListenerOnObject,
11
- isWebObjectListenerOnRN,
12
- } from 'react-native-maplibre-gl-js/communication/messages.utils'
13
- import { useStyles } from 'react-native-maplibre-gl-js/react-native/components/MapProvider/MapProvider.hooks'
14
- import { useCallback, useEffect } from 'react'
15
- import type {
16
- WebObjectListenerOnHTMLElement,
17
- WebObjectListenerOnMapLayer,
18
- WebObjectListenerOnObject,
19
- WebObjectListenerOnRN,
20
- } from 'react-native-maplibre-gl-js/react-native/components-factory/createWebObjectAsComponent.types'
21
- import type { MapProviderProps } from 'react-native-maplibre-gl-js/react-native/components/MapProvider/MapProvider.types'
22
-
23
- /**
24
- * Provide the main
25
- * @param props -
26
- * @group Components
27
- */
28
- const MapProvider = ({ children }: MapProviderProps) => {
29
- // States.
30
- // - Global.
31
- const {
32
- setWebView,
33
- setIsWebWorldReady,
34
- isMapMountMessageReady,
35
- flushMessages,
36
- getWebObjectListeners,
37
- resolveWebObjectPendingMethodResponse,
38
- } = useMapAtoms()
39
- // Theme.
40
- const styles = useStyles()
41
-
42
- // On start, the map must be mounted before any other map element. When the
43
- // mount message of the map is ready, we flush all the pending messages to
44
- // the web world.
45
- useEffect(() => {
46
- if (isMapMountMessageReady) {
47
- flushMessages()
48
- }
49
- }, [flushMessages, isMapMountMessageReady])
50
-
51
- // Handler of messages from the web world.
52
- const onMessage = useCallback(
53
- // Not an anonymous function => get the function name for logger.
54
- function handleMessage(event: WebViewMessageEvent) {
55
- try {
56
- RNLogger.debug('RN', handleMessage.name, event?.nativeEvent?.data)
57
- const message = JSON.parse(event.nativeEvent.data) as MessageFromWebToRN
58
-
59
- switch (message.type) {
60
- case 'console': {
61
- RNLogger[message.payload.level](
62
- 'Web',
63
- message.payload.args[0],
64
- ...message.payload.args.slice(1),
65
- )
66
- break
67
- }
68
- case 'ready': {
69
- setIsWebWorldReady(true)
70
- break
71
- }
72
- case 'webObjectListenerEvent': {
73
- // Retrieve the corresponding object listener.
74
- const listener = getWebObjectListeners({
75
- objectId: message.payload.objectId,
76
- })?.[message.payload.eventName]
77
- // Then, call it.
78
- if (isWebObjectListenerOnRN(listener)) {
79
- ;(listener as WebObjectListenerOnRN<any>).rnListener(
80
- message.payload.event,
81
- )
82
- }
83
- if (isWebObjectListenerOnObject(listener)) {
84
- ;(listener as WebObjectListenerOnObject<any>).objectListener(
85
- message.payload.event,
86
- )
87
- }
88
- if (isWebObjectListenerOnMapLayer(listener)) {
89
- ;(listener as WebObjectListenerOnMapLayer<any>).layerListener(
90
- message.payload.event,
91
- )
92
- }
93
- if (isWebObjectListenerOnHTMLElement(listener)) {
94
- ;(
95
- listener as WebObjectListenerOnHTMLElement<any>
96
- ).elementListener(message.payload.event)
97
- }
98
- break
99
- }
100
- case 'webObjectMethodResponse': {
101
- resolveWebObjectPendingMethodResponse({
102
- requestId: message.payload.requestId,
103
- result: message.payload.result,
104
- })
105
- break
106
- }
107
- }
108
- } catch (error: any) {
109
- RNLogger.error('RN', handleMessage.name, error.message)
110
- }
111
- },
112
- [
113
- setIsWebWorldReady,
114
- getWebObjectListeners,
115
- resolveWebObjectPendingMethodResponse,
116
- ],
117
- )
118
-
119
- return (
120
- <View style={styles.container}>
121
- <WebView
122
- ref={setWebView}
123
- style={styles.webview}
124
- originWhitelist={['*']}
125
- javaScriptEnabled={true}
126
- allowFileAccess={true}
127
- domStorageEnabled={true}
128
- scrollEnabled={false}
129
- allowUniversalAccessFromFileURLs={true}
130
- mixedContentMode={'always'}
131
- onMessage={onMessage}
132
- source={{ html: WEBVIEW_STATIC_HTML }}
133
- />
134
- {children}
135
- </View>
136
- )
137
- }
138
-
139
- export default MapProvider
@@ -1,12 +0,0 @@
1
- import type { ReactNode } from 'react'
2
-
3
- /**
4
- * TODO
5
- * @group Types
6
- */
7
- export type MapProviderProps = {
8
- /**
9
- * The map elements (e.g., Map) as direct children.
10
- */
11
- children?: ReactNode
12
- }
@@ -1,14 +0,0 @@
1
- import createWebObjectAsComponent from 'react-native-maplibre-gl-js/react-native/components-factory/createWebObjectAsComponent'
2
- import type {
3
- MarkerProps,
4
- MarkerRef,
5
- } from 'react-native-maplibre-gl-js/react-native/components/Marker/Marker.types'
6
-
7
- /**
8
- * MapLibre Marker view.
9
- * @see {@link https://maplibre.org/maplibre-gl-js/docs/API/classes/Marker/ MapLibre GL JS docs}
10
- * @group Components
11
- */
12
- const Marker = createWebObjectAsComponent<MarkerRef, MarkerProps>('marker')
13
-
14
- export default Marker