@mappedin/react-native-sdk 6.0.0-alpha.10 → 6.0.0-alpha.12

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.
@@ -0,0 +1,45 @@
1
+ import type { Coordinate, TAddModelOptions } from '@mappedin/mappedin-js';
2
+ import type { Mappedin } from '../types';
3
+ export interface ModelProps {
4
+ /**
5
+ * The target coordinate where the model should be placed
6
+ */
7
+ target: Coordinate;
8
+ /**
9
+ * URL of the 3D model (GLTF or GLB format)
10
+ */
11
+ url: string;
12
+ /**
13
+ * Optional model options
14
+ */
15
+ options?: TAddModelOptions;
16
+ /**
17
+ * Callback called when model is successfully created
18
+ * @param model - The model object
19
+ */
20
+ onLoad?: (model: Mappedin.Model) => void;
21
+ }
22
+ /**
23
+ * Model component for React Native.
24
+ *
25
+ * Displays a 3D model on the map at the specified coordinate.
26
+ * The model is managed through the WebView bridge and communicates with the core SDK.
27
+ * Models are in GLTF or GLB format and can be scaled, rotated, and positioned.
28
+ *
29
+ * @example
30
+ * ```tsx
31
+ * <Model
32
+ * target={coordinate}
33
+ * url="https://example.com/model.glb"
34
+ * options={{
35
+ * scale: [2, 2, 2],
36
+ * rotation: [0, 90, 0],
37
+ * opacity: 0.8,
38
+ * interactive: true
39
+ * }}
40
+ * onLoad={(model) => console.log('Model loaded:', model)}
41
+ * />
42
+ * ```
43
+ */
44
+ export declare function Model(props: ModelProps): null;
45
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/components/model.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,WAAW,UAAU;IAC1B;;OAEG;IACH,MAAM,EAAE,UAAU,CAAC;IACnB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,KAAK,IAAI,CAAC;CACzC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,QA2DtC"}
@@ -0,0 +1,42 @@
1
+ import type { Coordinate, TAddPathOptions } from '@mappedin/mappedin-js';
2
+ import type { Mappedin } from '../types';
3
+ export interface PathProps {
4
+ /**
5
+ * Array of coordinates to form the path
6
+ */
7
+ coordinate: Coordinate[];
8
+ /**
9
+ * Optional path options
10
+ */
11
+ options?: TAddPathOptions;
12
+ /**
13
+ * Callback called when path is successfully created
14
+ * @param path - The path object
15
+ */
16
+ onLoad?: (path: Mappedin.Path) => void;
17
+ /**
18
+ * Callback called when path animation completes
19
+ */
20
+ onDrawComplete?: () => void;
21
+ }
22
+ /**
23
+ * Path component for React Native.
24
+ *
25
+ * Displays a path on the map using the provided coordinates.
26
+ * The path is managed through the WebView bridge and communicates with the core SDK.
27
+ *
28
+ * @example
29
+ * ```tsx
30
+ * const directions = await mapView.getDirections(startSpace, endSpace);
31
+ * return directions ? (
32
+ * <Path
33
+ * coordinate={directions.coordinates}
34
+ * options={{ color: 'blue', nearRadius: 0.5, farRadius: 0.5 }}
35
+ * onLoad={(path) => console.log('Path loaded:', path)}
36
+ * onDrawComplete={() => console.log('Path drawing complete')}
37
+ * />
38
+ * ) : null;
39
+ * ```
40
+ */
41
+ export declare function Path(props: PathProps): null;
42
+ //# sourceMappingURL=path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/components/path.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,WAAW,SAAS;IACzB;;OAEG;IACH,UAAU,EAAE,UAAU,EAAE,CAAC;IACzB;;OAEG;IACH,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,KAAK,IAAI,CAAC;IACvC;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,QAmEpC"}
@@ -0,0 +1,54 @@
1
+ import type { Mappedin } from '../types';
2
+ type Add = Mappedin.MapView['Shapes']['add'];
3
+ export interface ShapeProps {
4
+ /**
5
+ * GeoJSON FeatureCollection containing the geometry for the shape
6
+ */
7
+ geometry: Parameters<Add>[0];
8
+ /**
9
+ * Style configuration for the shape
10
+ */
11
+ style: Parameters<Add>[1];
12
+ /**
13
+ * Optional floor to add the shape to
14
+ */
15
+ floor?: Parameters<Add>[2];
16
+ /**
17
+ * Callback called when shape is successfully created
18
+ * @param shape - The shape object
19
+ */
20
+ onLoad?: (shape: Mappedin.Shape) => void;
21
+ }
22
+ /**
23
+ * Shape component for React Native.
24
+ *
25
+ * Displays custom GeoJSON geometry on the map using the provided style.
26
+ * The shape is managed through the WebView bridge and communicates with the core SDK.
27
+ *
28
+ * @example
29
+ * ```tsx
30
+ * const geometry = {
31
+ * type: 'FeatureCollection',
32
+ * features: [{
33
+ * type: 'Feature',
34
+ * geometry: {
35
+ * type: 'Polygon',
36
+ * coordinates: [[[-80.521, 43.466], [-80.521, 43.465], [-80.520, 43.465], [-80.520, 43.466], [-80.521, 43.466]]]
37
+ * },
38
+ * properties: { id: 'my-shape' }
39
+ * }]
40
+ * };
41
+ *
42
+ * return (
43
+ * <Shape
44
+ * geometry={geometry}
45
+ * style={{ color: 'blue', height: 2, opacity: 0.7 }}
46
+ * floor={currentFloor}
47
+ * onLoad={(shape) => console.log('Shape loaded:', shape)}
48
+ * />
49
+ * );
50
+ * ```
51
+ */
52
+ export declare function Shape(props: ShapeProps): null;
53
+ export {};
54
+ //# sourceMappingURL=shape.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shape.d.ts","sourceRoot":"","sources":["../../src/components/shape.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,KAAK,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC;AAC7C,MAAM,WAAW,UAAU;IAC1B;;OAEG;IACH,QAAQ,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7B;;OAEG;IACH,KAAK,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1B;;OAEG;IACH,KAAK,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3B;;;OAGG;IACH,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,KAAK,IAAI,CAAC;CACzC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,QAkEtC"}
@@ -0,0 +1,89 @@
1
+ import type { TEvents } from '@mappedin/mappedin-js';
2
+ /**
3
+ * # Event Management System
4
+ *
5
+ * The React Native SDK uses a sophisticated event management system that bridges events
6
+ * between the WebView (where the actual map runs) and the React Native application.
7
+ *
8
+ * ## Architecture Overview
9
+ *
10
+ * The event system follows a hub-and-spoke pattern with these key principles:
11
+ *
12
+ * ### 1. Single WebView Subscription Per Event Type
13
+ * - The WebView only maintains **one subscription** per event type (e.g., 'click', 'hover')
14
+ * - This prevents duplicate event listeners and reduces overhead in the WebView
15
+ * - Event subscription is managed via the bridge communication layer
16
+ *
17
+ * ### 2. Multiple React Native Callbacks Per Event
18
+ * - Multiple React Native components can register callbacks for the same event type
19
+ * - When the WebView event fires, React Native receives it via the bridge
20
+ * - React Native then fires **all registered callbacks** for that event type
21
+ *
22
+ * ## Event Flow
23
+ *
24
+ * ```
25
+ * ┌─────────────────┐ ┌──────────────────┐ ┌─────────────────────┐
26
+ * │ React Native │ │ Bridge │ │ WebView │
27
+ * │ Components │ │ Communication │ │ (Mappedin SDK) │
28
+ * └─────────────────┘ └──────────────────┘ └─────────────────────┘
29
+ * │ │ │
30
+ * │ useEvent('click', cb1)│ │
31
+ * ├──────────────────────>│ │
32
+ * │ │ │
33
+ * │ │ Subscribe to 'click' │
34
+ * │ ├─────────────────────-─>│
35
+ * │ │ │
36
+ * │ │ │ (Only once per
37
+ * │ useEvent('click', cb2)│ │ event type)
38
+ * ├──────────────────────>│ │
39
+ * │ │ │
40
+ * │ │ (No new subscription) │
41
+ * │ │ Click Event Fired │
42
+ * │ │<────────────────────-──┤
43
+ * │ cb1(eventData) │ │
44
+ * │<──────────────────────┤ │
45
+ * │ cb2(eventData) │ │
46
+ * │<──────────────────────┤ │
47
+ * ```
48
+ * @internal This module is used internally by the SDK
49
+ */
50
+ type TEventPayload<EventName extends keyof TEvents> = TEvents[EventName] extends {
51
+ data: null;
52
+ } ? TEvents[EventName]['data'] : TEvents[EventName];
53
+ type EventCallback<T extends keyof TEvents> = (payload: TEventPayload<T>) => void;
54
+ /**
55
+ * Creates an event control system for managing event callbacks.
56
+ * This is used internally to manage event subscriptions and callbacks.
57
+ *
58
+ * @internal
59
+ */
60
+ export declare function createEventControl(): {
61
+ /**
62
+ * Register a callback for a specific event type
63
+ * @internal
64
+ */
65
+ registerEventCallback<T extends keyof TEvents>(event: T, callback: EventCallback<T>): void;
66
+ /**
67
+ * Unregister a callback for a specific event type
68
+ * @internal
69
+ */
70
+ unregisterEventCallback<T extends keyof TEvents>(event: T, callback: EventCallback<T>): void;
71
+ /**
72
+ * Check if there are any callbacks registered for a specific event type
73
+ * @internal
74
+ */
75
+ hasEventCallbacks<T extends keyof TEvents>(event: T): boolean;
76
+ /**
77
+ * Trigger all callbacks for a specific event with the given payload
78
+ * @internal
79
+ */
80
+ handleEvent<T extends keyof TEvents>(event: T, payload: TEventPayload<T>): void;
81
+ /**
82
+ * Destroy all event callbacks
83
+ * @internal
84
+ */
85
+ destroy(): void;
86
+ };
87
+ export type EventControl = ReturnType<typeof createEventControl>;
88
+ export {};
89
+ //# sourceMappingURL=event-control.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-control.d.ts","sourceRoot":"","sources":["../../src/controls/event-control.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,KAAK,aAAa,CAAC,SAAS,SAAS,MAAM,OAAO,IAAI,OAAO,CAAC,SAAS,CAAC,SAAS;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,GAC5F,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,GAC1B,OAAO,CAAC,SAAS,CAAC,CAAC;AAEtB,KAAK,aAAa,CAAC,CAAC,SAAS,MAAM,OAAO,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;AAElF;;;;;GAKG;AACH,wBAAgB,kBAAkB;IAKhC;;;OAGG;0BACmB,CAAC,SAAS,MAAM,OAAO,SAAS,CAAC,YAAY,aAAa,CAAC,CAAC,CAAC;IAYnF;;;OAGG;4BACqB,CAAC,SAAS,MAAM,OAAO,SAAS,CAAC,YAAY,aAAa,CAAC,CAAC,CAAC;IAYrF;;;OAGG;sBACe,CAAC,SAAS,MAAM,OAAO,SAAS,CAAC,GAAG,OAAO;IAO7D;;;OAGG;gBACS,CAAC,SAAS,MAAM,OAAO,SAAS,CAAC,WAAW,aAAa,CAAC,CAAC,CAAC;IAgBxE;;;OAGG;;EAKJ;AAED,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
@@ -0,0 +1,210 @@
1
+ import type { MapView, Space, TUpdateState, TUpdateStates, Text3D, MapObject, Label, Marker, Shape, Door, Facade, Floor, WALLS, DOORS, Model, Path, PathSegment, Directions, TNavigationOptions, TAddMarkerOptions, TStateChangedInternalPayload } from '@mappedin/mappedin-js';
2
+ import type { UseBridgeHook } from '../hooks/use-bridge.js';
3
+ import type { Mappedin } from '../types.js';
4
+ import type { EventControl } from './event-control.js';
5
+ /**
6
+ * Configuration for a navigation marker's template and display options.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * // Basic distance marker
11
+ * {
12
+ * template: 'Distance: {{instruction.distance}}m',
13
+ * options: { interactive: true, rank: 'high' }
14
+ * }
15
+ *
16
+ * // Turn instruction marker
17
+ * {
18
+ * template: 'Turn {{instruction.action.bearing}} in {{instruction.distance}}m',
19
+ * options: { rank: 'medium' }
20
+ * }
21
+ * ```
22
+ */
23
+ export type NavigationMarkerConfig = {
24
+ /**
25
+ * Handlebars templates receive objects with an 'instruction' property containing TDirectionInstruction data. @see {@link TDirectionInstruction} in @mappedin/mappedin-js for full type details
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * {
30
+ * template: '<div>Turn {{instruction.action.bearing}} in {{instruction.distance}}m</div>',
31
+ * }
32
+ */
33
+ template?: string;
34
+ /** Optional configuration for marker behavior */
35
+ options?: TAddMarkerOptions;
36
+ };
37
+ /**
38
+ * Extended navigation options that support configurable markers.
39
+ *
40
+ * Example:
41
+ * ```typescript
42
+ * createMarkers: {
43
+ * departure: {
44
+ * template: 'Departure: {{instruction.action.type}}',
45
+ * options: { interactive: true }
46
+ * },
47
+ * destination: {
48
+ * template: 'Destination: {{instruction.action.type}}',
49
+ * options: { rank: 'medium' }
50
+ * },
51
+ * connection: false // Disable connection markers
52
+ * }
53
+ * ```
54
+ */
55
+ export type ExtendedNavigationOptions = Omit<TNavigationOptions, 'createMarkers'> & {
56
+ createMarkers?: {
57
+ /** Departure marker configuration or boolean to enable/disable */
58
+ departure?: NavigationMarkerConfig | boolean;
59
+ /** Destination marker configuration or boolean to enable/disable */
60
+ destination?: NavigationMarkerConfig | boolean;
61
+ /** Connection marker configuration or boolean to enable/disable */
62
+ connection?: NavigationMarkerConfig | boolean;
63
+ };
64
+ };
65
+ type Promisify<T> = {
66
+ [K in keyof T]: T[K] extends (...args: infer Args) => infer Return ? Return extends Promise<any> ? T[K] : (...args: Args) => Promise<Return> : T[K] extends object ? Promisify<T[K]> : T[K];
67
+ };
68
+ type PromisifiedUpdateState = {
69
+ <T extends Space | Text3D | MapObject | Label | Marker | Shape | Door | Facade | Floor | WALLS | DOORS | Model | Path | PathSegment>(target: T, state: TUpdateState<T>): Promise<void>;
70
+ <T extends string & NonNullable<unknown>>(target: T, state: TUpdateStates): Promise<void>;
71
+ };
72
+ /**
73
+ * Extended navigation with custom marker templates
74
+ *
75
+ * @see {@link ExtendedNavigationOptions} for more information on the options
76
+ *
77
+ * @interface
78
+ */
79
+ export type Navigation = {
80
+ draw(directions: Directions | Directions[], options?: ExtendedNavigationOptions): Promise<void>;
81
+ } & Omit<MapView['Navigation'], 'draw'>;
82
+ type MapViewMethods = Omit<MapView, 'on' | 'off' | 'emit' | '__core' | 'then' | 'catch' | 'finally' | 'valueOf' | 'toString' | 'toJSON' | typeof Symbol.toPrimitive | typeof Symbol.toStringTag> & {
83
+ /**
84
+ * Internal method used by useEvent hook to call the bridge.
85
+ *
86
+ * @remarks
87
+ * This method is used by useEvent hook to call the bridge.
88
+ * It is not part of the public API and should not be used directly.
89
+ *
90
+ * @internal
91
+ */
92
+ _bridgeCall: UseBridgeHook['instruct'];
93
+ };
94
+ /**
95
+ * A proxy that intercepts {@link MapView} method calls and forwards them through the bridge to the WebView.
96
+ * All method calls are converted to asynchronous bridge instructions.
97
+ *
98
+ * This interface provides access to all MapView methods and properties in an async manner,
99
+ * with specialized handling for Navigation and updateState methods.
100
+ *
101
+ * **Key Properties:**
102
+ * - `updateState` - Async wrapper for updating entity states with type safety
103
+ * - `Navigation` - Extended navigation with custom marker templates
104
+ * - `on` - Subscribe to map events
105
+ * - `off` - Unsubscribe from map events
106
+ * - `destroy` - Clean up resources and event subscriptions
107
+ * - All other MapView methods are available as async calls
108
+ *
109
+ * @example Basic Usage
110
+ * ```typescript
111
+ * // All MapView methods are available as async calls
112
+ * await mapView.setFloor('floor-id');
113
+ * await mapView.Camera.focusOn(target, options);
114
+ * await mapView.Labels.add(coordinate, content);
115
+ *
116
+ * // Navigation with custom markers
117
+ * await mapView.Navigation.draw(directions, {
118
+ * createMarkers: {
119
+ * connection: { template: '<div>{{instruction.action.type}}</div>', options: { rank: 'always-visible' } }
120
+ * }
121
+ * });
122
+ *
123
+ * // Event handling
124
+ * mapView.on('click', handler);
125
+ * mapView.off('click', handler);
126
+ *
127
+ * // Cleanup when unmounting
128
+ * mapView.destroy();
129
+ * ```
130
+ *
131
+ * @interface
132
+ */
133
+ export type MapViewControl = Omit<Promisify<MapViewMethods>, 'updateState' | 'Navigation'> & {
134
+ /** Async wrapper for updating entity states with type safety */
135
+ updateState: PromisifiedUpdateState;
136
+ /** Extended navigation with custom marker templates */
137
+ Navigation: Navigation;
138
+ /** Subscribe to map events */
139
+ on: MapView['on'];
140
+ /** Unsubscribe from map events */
141
+ off: MapView['off'];
142
+ /** Destroy resources, caches, and event subscriptions */
143
+ destroy: () => Promise<void>;
144
+ /**
145
+ * Internal method to get cache state for testing
146
+ * @internal
147
+ */
148
+ __getCacheState?: () => {
149
+ cacheSize: number;
150
+ propertyCacheKeys: string[];
151
+ };
152
+ };
153
+ /**
154
+ * Creates a typed wrapper that allows calling any method on the MapView class through the bridge.
155
+ *
156
+ * Features:
157
+ * - Full TypeScript support with auto-completion
158
+ * - Type-safe method calls with proper parameter and return type checking
159
+ * - Supports any method call on MapView (e.g., mapView.setFloor(...))
160
+ * - Supports namespaced methods (e.g., mapView.Camera.focusOn(...))
161
+ * - Supports property access for direct values (e.g., mapView.currentFloor, mapView.Camera.maxZoomLevel)
162
+ * - All methods automatically return Promises since they go through the bridge
163
+ * - Properties return cached values directly (synchronously)
164
+ * - Automatically stays in sync with MapView API changes
165
+ * - Subscribes to camera-state-change events to keep camera properties in sync
166
+ * - Extended Navigation.draw method supports custom createMarker property
167
+ *
168
+ * Usage examples:
169
+ * ```typescript
170
+ * const mapView = createMapViewControl(instruct);
171
+ *
172
+ * // Direct method calls with full type safety
173
+ * await mapView.setFloor('floor-id'); // TypeScript knows the parameter type
174
+ *
175
+ * // Namespaced method calls with auto-completion
176
+ * await mapView.Camera.focusOn(target, options);
177
+ * await mapView.Labels.add(coordinate, content);
178
+ * await mapView.Markers.add(coordinate, '<div>Marker</div>');
179
+ *
180
+ * // Extended Navigation.draw with custom createMarker property
181
+ * await mapView.Navigation.draw(directions, {
182
+ * createMarkers: {
183
+ * departure: '<div>departure</div>',
184
+ * destination: false,
185
+ * connection: '<div>connection {{instruction.action.type}}</div>',
186
+ * },
187
+ * pathOptions: { color: '#ff0000' },
188
+ * // ... all other TNavigationOptions remain available
189
+ * });
190
+ *
191
+ * // Property access returns cached values directly (no await needed)
192
+ * const currentFloor = mapView.currentFloor; // Returns 'floor-1'
193
+ * const maxZoom = mapView.Camera.maxZoomLevel; // Returns 1
194
+ * const minZoom = mapView.Camera.minZoomLevel; // Returns 0.5
195
+ *
196
+ * // All method return types are properly typed as Promises
197
+ * const directions = await mapView.getDirections(from, to);
198
+ * const mapData = await mapView.getMapData();
199
+ * ```
200
+ *
201
+ * @param instruct - The bridge instruction function from useBridge hook
202
+ * @param mapData - The map data for the map view
203
+ * @param eventControl - Optional event control instance for handling events
204
+ * @returns A typed proxy that intercepts any method call and forwards it to the bridge
205
+ */
206
+ export declare function createMapViewControl(instruct: UseBridgeHook['instruct'], mapData: Mappedin.MapData, eventControl: EventControl, { startInitialState }?: {
207
+ startInitialState?: TStateChangedInternalPayload;
208
+ }): Promise<MapViewControl>;
209
+ export {};
210
+ //# sourceMappingURL=map-view-control.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map-view-control.d.ts","sourceRoot":"","sources":["../../src/controls/map-view-control.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,4 @@
1
+ export declare class MapViewNullError extends Error {
2
+ constructor(name: string);
3
+ }
4
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,gBAAiB,SAAQ,KAAK;gBAC9B,IAAI,EAAE,MAAM;CAGxB"}
@@ -0,0 +1,73 @@
1
+ import type { WebView, WebViewMessageEvent } from 'react-native-webview';
2
+ /**
3
+ * React hook for communicating with a WebView using a bridge pattern.
4
+ *
5
+ * @example
6
+ * ```tsx
7
+ * import { useRef, useState } from 'react';
8
+ * import { WebView } from 'react-native-webview';
9
+ * import { useBridge } from './hooks/use-bridge';
10
+ *
11
+ * function MyComponent() {
12
+ * const [webView, setWebView] = useState<WebView | null>(null);
13
+ * const { instruct, handleMessage, cleanup } = useBridge(webView);
14
+ *
15
+ * const handlePress = async () => {
16
+ * try {
17
+ * const result = await instruct({
18
+ * type: 'function',
19
+ * payload: {
20
+ * name: 'getMapData',
21
+ * options: [{ venueId: '123' }]
22
+ * }
23
+ * });
24
+ * console.log('Map data:', result);
25
+ * } catch (error) {
26
+ * console.error('Failed to get map data:', error);
27
+ * }
28
+ * };
29
+ *
30
+ * // Clean up on unmount
31
+ * useEffect(() => {
32
+ * return () => {
33
+ * cleanup();
34
+ * };
35
+ * }, [cleanup]);
36
+ *
37
+ * return (
38
+ * <WebView
39
+ * ref={setWebView}
40
+ * source={{ uri: 'https://example.com' }}
41
+ * onMessage={handleMessage}
42
+ * />
43
+ * );
44
+ * }
45
+ * ```
46
+ *
47
+ * @param webView - The WebView instance (can be null)
48
+ * @returns Object containing the instruct function, handleMessage callback, and cleanup function
49
+ */
50
+ type FunctionInstruction = {
51
+ type: 'function';
52
+ payload: {
53
+ name: string;
54
+ options?: any[];
55
+ };
56
+ };
57
+ type MethodInstruction = {
58
+ type: 'method';
59
+ payload: {
60
+ target: string;
61
+ method: string;
62
+ args?: any[];
63
+ };
64
+ };
65
+ export type Instruction = FunctionInstruction | MethodInstruction;
66
+ export declare function useBridge(webView: WebView | null): {
67
+ instruct: <T = any>(instruction: Instruction) => Promise<T>;
68
+ handleMessage: (event: WebViewMessageEvent) => void;
69
+ destroy: () => void;
70
+ };
71
+ export type UseBridgeHook = ReturnType<typeof useBridge>;
72
+ export {};
73
+ //# sourceMappingURL=use-bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-bridge.d.ts","sourceRoot":"","sources":["../../src/hooks/use-bridge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAGzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAGH,KAAK,mBAAmB,GAAG;IAC1B,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;KAChB,CAAC;CACF,CAAC;AACF,KAAK,iBAAiB,GAAG;IACxB,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE;QACR,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;KACb,CAAC;CACF,CAAC;AACF,MAAM,MAAM,WAAW,GAAG,mBAAmB,GAAG,iBAAiB,CAAC;AAqBlE,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;eA+B9C,CAAC,qBAAqB,WAAW,KAAG,OAAO,CAAC,CAAC,CAAC;2BA3BN,mBAAmB;;EAsF7D;AAED,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { TEvents } from '@mappedin/mappedin-js';
2
+ type TEventPayload<EventName extends keyof TEvents> = TEvents[EventName] extends {
3
+ data: null;
4
+ } ? TEvents[EventName]['data'] : TEvents[EventName];
5
+ /**
6
+ * Hook to subscribe to an event on the MapView in React Native.
7
+ *
8
+ * This hook uses the MapView's .on() and .off() methods to subscribe to events
9
+ * on the MapView instance running in the WebView.
10
+ *
11
+ * @param event - The event to listen for.
12
+ * @param callback - The callback to call when the event is triggered.
13
+ *
14
+ * @category Hooks
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * useEvent('click', event => {
19
+ * const { coordinate } = event;
20
+ * const { latitude, longitude } = coordinate;
21
+ * console.log(`Map was clicked at ${latitude}, ${longitude}`);
22
+ * });
23
+ * ```
24
+ */
25
+ export declare function useEvent<T extends keyof TEvents>(event: T, callback: (payload: TEventPayload<T>) => void): void;
26
+ export {};
27
+ //# sourceMappingURL=use-event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-event.d.ts","sourceRoot":"","sources":["../../src/hooks/use-event.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAErD,KAAK,aAAa,CAAC,SAAS,SAAS,MAAM,OAAO,IAAI,OAAO,CAAC,SAAS,CAAC,SAAS;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,GAC5F,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,GAC1B,OAAO,CAAC,SAAS,CAAC,CAAC;AAEtB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,IAAI,QAwCxG"}
@@ -0,0 +1,42 @@
1
+ import type { Mappedin } from '../types';
2
+ import type { MapViewControl } from '../controls/map-view-control';
3
+ import type { EventControl } from '../controls/event-control';
4
+ export declare const MappedinContext: import("react").Context<{
5
+ mapData?: Mappedin.MapData;
6
+ mapView?: MapViewControl;
7
+ /**
8
+ * Event control system for managing event callbacks.
9
+ * @internal
10
+ */
11
+ _events?: EventControl;
12
+ }>;
13
+ /**
14
+ * Hook to get the MapData and MapView instances from the MapView context.
15
+ *
16
+ * This hook provides access to the mapData and mapView instances that are
17
+ * created and managed by the MapView component. It ensures that the hook
18
+ * is used within a MapView component context.
19
+ *
20
+ * @throws {MapViewNullError} When used outside of a MapView component or when mapData/mapView are not yet initialized
21
+ *
22
+ * @returns Object containing mapData and mapView instances
23
+ *
24
+ * @example
25
+ * ```tsx
26
+ * function MyMapComponent() {
27
+ * const { mapData, mapView } = useMap();
28
+ *
29
+ * useEffect(() => {
30
+ * // Use mapView to interact with the map
31
+ * mapView.Camera.animateTo({ center: mapData.getByType('space')[0] });
32
+ * }, [mapData, mapView]);
33
+ *
34
+ * return <Text>Map is ready!</Text>;
35
+ * }
36
+ * ```
37
+ */
38
+ export declare function useMap(): {
39
+ mapData: Mappedin.MapData;
40
+ mapView: MapViewControl;
41
+ };
42
+ //# sourceMappingURL=use-map.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-map.d.ts","sourceRoot":"","sources":["../../src/hooks/use-map.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAG9D,eAAO,MAAM,eAAe;cACjB,QAAQ,CAAC,OAAO;cAChB,cAAc;IACxB;;;OAGG;cACO,YAAY;EAKrB,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,MAAM,IAAI;IACzB,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC;IAC1B,OAAO,EAAE,cAAc,CAAC;CACxB,CAQA"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ export { MapView } from './map-view';
2
+ export type { MapViewProps } from './map-view';
3
+ export { useMap, MappedinContext } from './hooks/use-map';
4
+ export { type MapViewControl } from './controls/map-view-control';
5
+ export { useEvent } from './hooks/use-event';
6
+ export { Marker } from './components/marker';
7
+ export type { MarkerProps } from './components/marker';
8
+ export { Label } from './components/label';
9
+ export type { LabelProps } from './components/label';
10
+ export { Path } from './components/path';
11
+ export type { PathProps } from './components/path';
12
+ export { Shape } from './components/shape';
13
+ export type { ShapeProps } from './components/shape';
14
+ export type { Navigation } from './controls/map-view-control';
15
+ export { Model } from './components/model';
16
+ export type { ModelProps } from './components/model';
17
+ export { setLoggerLevel } from './utils';
18
+ export * from './types';
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,YAAY,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,cAAc,SAAS,CAAC"}