@mappedin/react-sdk 6.0.0-rc.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.
- package/LICENSE.txt +104 -0
- package/README.md +48 -0
- package/THIRD_PARTY_LICENSES.txt +13448 -0
- package/lib/esm/index.d.ts +391 -0
- package/lib/esm/index.js +1 -0
- package/package.json +36 -0
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
// Generated by dts-bundle v0.7.3
|
|
2
|
+
// Dependencies for this module:
|
|
3
|
+
// ../react/react
|
|
4
|
+
// ../react/@mappedin/mappedin-js
|
|
5
|
+
// ../react/type-fest
|
|
6
|
+
|
|
7
|
+
declare module '@mappedin/react-sdk' {
|
|
8
|
+
export { MapDataProvider } from '@mappedin/react-sdk/react-sdk/src/MapDataProvider';
|
|
9
|
+
export type { MapDataProviderProps } from '@mappedin/react-sdk/react-sdk/src/MapDataProvider';
|
|
10
|
+
export { useMapData } from '@mappedin/react-sdk/react-sdk/src/hooks/useMapData';
|
|
11
|
+
export { useMapDataEvent } from '@mappedin/react-sdk/react-sdk/src/hooks/useMapDataEvent';
|
|
12
|
+
export { MapView } from '@mappedin/react-sdk/react-sdk/src/MapView';
|
|
13
|
+
export type { MapViewProps } from '@mappedin/react-sdk/react-sdk/src/MapView';
|
|
14
|
+
export { useMapViewEvent } from '@mappedin/react-sdk/react-sdk/src/hooks/useMapViewEvent';
|
|
15
|
+
export { Path } from '@mappedin/react-sdk/react-sdk/src/Path';
|
|
16
|
+
export type { PathProps } from '@mappedin/react-sdk/react-sdk/src/Path';
|
|
17
|
+
export { Navigation } from '@mappedin/react-sdk/react-sdk/src/Navigation';
|
|
18
|
+
export type { NavigationProps } from '@mappedin/react-sdk/react-sdk/src/Navigation';
|
|
19
|
+
export { Shape } from '@mappedin/react-sdk/react-sdk/src/Shape';
|
|
20
|
+
export type { ShapeProps } from '@mappedin/react-sdk/react-sdk/src/Shape';
|
|
21
|
+
export { Model } from '@mappedin/react-sdk/react-sdk/src/Model';
|
|
22
|
+
export type { ModelProps } from '@mappedin/react-sdk/react-sdk/src/Model';
|
|
23
|
+
export { useMap } from '@mappedin/react-sdk/react-sdk/src/hooks/useMap';
|
|
24
|
+
export { Marker, AnimatedMarker } from '@mappedin/react-sdk/react-sdk/src/Marker';
|
|
25
|
+
export type { MarkerProps } from '@mappedin/react-sdk/react-sdk/src/Marker';
|
|
26
|
+
export { Label } from '@mappedin/react-sdk/react-sdk/src/Label';
|
|
27
|
+
export type { LabelProps } from '@mappedin/react-sdk/react-sdk/src/Label';
|
|
28
|
+
import type * as React from 'react';
|
|
29
|
+
export type { React };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
declare module '@mappedin/react-sdk/react-sdk/src/MapDataProvider' {
|
|
33
|
+
import type { MapData, TGetMapDataOptions } from '@mappedin/mappedin-js';
|
|
34
|
+
import type { PropsWithChildren } from 'react';
|
|
35
|
+
import React from 'react';
|
|
36
|
+
export type CachedMapDataEntry = {
|
|
37
|
+
mapData: MapData;
|
|
38
|
+
options: TGetMapDataOptions;
|
|
39
|
+
};
|
|
40
|
+
export type MapDataContextType = {
|
|
41
|
+
getCache: () => CachedMapDataEntry | undefined;
|
|
42
|
+
setCache: (entry: CachedMapDataEntry) => void;
|
|
43
|
+
};
|
|
44
|
+
export const MapDataContext: React.Context<MapDataContextType>;
|
|
45
|
+
export type MapDataProviderProps = {
|
|
46
|
+
mapData: MapData;
|
|
47
|
+
};
|
|
48
|
+
export function MapDataProvider({ mapData, children }: PropsWithChildren<MapDataProviderProps>): React.JSX.Element;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
declare module '@mappedin/react-sdk/react-sdk/src/hooks/useMapData' {
|
|
52
|
+
import type { MapData, TGetMapDataOptions } from '@mappedin/mappedin-js';
|
|
53
|
+
/**
|
|
54
|
+
* Hook to get the MapData and handle loading and error states.
|
|
55
|
+
*
|
|
56
|
+
* If used outside of a {@link MapDataProvider} or {@link MapView} component, options are required to fetch the MapData.
|
|
57
|
+
* If used within a {@link MapDataProvider} or {@link MapView} component, options are optional and will use the MapData from the context if available.
|
|
58
|
+
*
|
|
59
|
+
* @category Hooks
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```tsx
|
|
63
|
+
* const { mapData, isLoading, error } = useMapData(options);
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export function useMapData(options?: TGetMapDataOptions): {
|
|
67
|
+
mapData?: MapData;
|
|
68
|
+
isLoading: boolean;
|
|
69
|
+
error?: Error;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
declare module '@mappedin/react-sdk/react-sdk/src/hooks/useMapDataEvent' {
|
|
74
|
+
import type { TMapDataEvents } from '@mappedin/mappedin-js';
|
|
75
|
+
/**
|
|
76
|
+
* Hook to subscribe to an event on the MapData.
|
|
77
|
+
*
|
|
78
|
+
* Must be used within a {@link MapDataProvider} or {@link MapView} component.
|
|
79
|
+
* @throws If used outside of a {@link MapDataProvider} or {@link MapView} component.
|
|
80
|
+
*
|
|
81
|
+
* @param event - The event to listen for.
|
|
82
|
+
* @param callback - The callback to call when the event is triggered.
|
|
83
|
+
*
|
|
84
|
+
* @category Hooks
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```tsx
|
|
88
|
+
* useMapDataEvent('language-change', event => {
|
|
89
|
+
* console.log(`Map language changed to ${event.name} (${event.code})`);
|
|
90
|
+
* });
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export function useMapDataEvent<T extends keyof TMapDataEvents>(event: T, callback: (payload: TMapDataEvents[T] extends {
|
|
94
|
+
data: null;
|
|
95
|
+
} ? TMapDataEvents[T]['data'] : TMapDataEvents[T]) => void): void;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
declare module '@mappedin/react-sdk/react-sdk/src/MapView' {
|
|
99
|
+
import type { ReactNode } from 'react';
|
|
100
|
+
import React from 'react';
|
|
101
|
+
import type { TupleToObjectWithPropNames } from '@mappedin/react-sdk/react-sdk/src/type-utils';
|
|
102
|
+
import { show3dMap } from '@mappedin/mappedin-js';
|
|
103
|
+
import type { MapView as MapViewJS } from '@mappedin/mappedin-js';
|
|
104
|
+
type MapViewContextType = {
|
|
105
|
+
mapView?: MapViewJS;
|
|
106
|
+
};
|
|
107
|
+
export const MapViewContext: React.Context<MapViewContextType>;
|
|
108
|
+
type ParamsArray = Parameters<typeof show3dMap>;
|
|
109
|
+
type StreamAgentParameterNames = ['el', 'mapData', 'options'];
|
|
110
|
+
/**
|
|
111
|
+
* @interface
|
|
112
|
+
*/
|
|
113
|
+
export type MapViewProps = Omit<TupleToObjectWithPropNames<ParamsArray, StreamAgentParameterNames> & {
|
|
114
|
+
children?: ReactNode;
|
|
115
|
+
/**
|
|
116
|
+
* The fallback content to render while the map is loading.
|
|
117
|
+
*/
|
|
118
|
+
fallback?: ReactNode;
|
|
119
|
+
}, 'el'>;
|
|
120
|
+
/**
|
|
121
|
+
* MapView component.
|
|
122
|
+
*
|
|
123
|
+
* The root component which renders the map and provides context to the hooks and child components.
|
|
124
|
+
*
|
|
125
|
+
* @category Components
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```tsx
|
|
129
|
+
* const { mapData } = useMapData({ key: '...', secret: '...', mapId: '...' });
|
|
130
|
+
* return (
|
|
131
|
+
* <MapView mapData={mapData}>
|
|
132
|
+
* <Marker target={...} />
|
|
133
|
+
* </MapView>
|
|
134
|
+
* )
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
export const MapView: React.ForwardRefExoticComponent<Omit<MapViewProps & Omit<React.HTMLProps<HTMLDivElement>, "options" | "mapData" | "children" | "fallback">, "ref"> & React.RefAttributes<MapViewJS | undefined>>;
|
|
138
|
+
export {};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
declare module '@mappedin/react-sdk/react-sdk/src/hooks/useMapViewEvent' {
|
|
142
|
+
import type { TEvents } from '@mappedin/mappedin-js';
|
|
143
|
+
/**
|
|
144
|
+
* Hook to subscribe to an event on the {@link MapView}.
|
|
145
|
+
*
|
|
146
|
+
* Must be used within a {@link MapView} component.
|
|
147
|
+
* @throws If used outside of a {@link MapView} component.
|
|
148
|
+
*
|
|
149
|
+
* @param event - The event to listen for.
|
|
150
|
+
* @param callback - The callback to call when the event is triggered.
|
|
151
|
+
*
|
|
152
|
+
* @category Hooks
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```tsx
|
|
156
|
+
* useMapViewEvent('click', event => {
|
|
157
|
+
* const { coordinate } = event;
|
|
158
|
+
* const { latitude, longitude } = coordinate;
|
|
159
|
+
* console.log(`Map was clicked at ${latitude}, ${longitude}`);
|
|
160
|
+
* });
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
export function useMapViewEvent<T extends keyof TEvents>(event: T, callback: (payload: TEvents[T] extends {
|
|
164
|
+
data: null;
|
|
165
|
+
} ? TEvents[T]['data'] : TEvents[T]) => void): void;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
declare module '@mappedin/react-sdk/react-sdk/src/Path' {
|
|
169
|
+
import type { TupleToObjectWithPropNames } from '@mappedin/react-sdk/react-sdk/src/type-utils';
|
|
170
|
+
import type { MapView, Path as PathJS } from '@mappedin/mappedin-js';
|
|
171
|
+
type ParamsArray = Parameters<MapView['Paths']['add']>;
|
|
172
|
+
type StreamAgentParameterNames = ['coordinate', 'options'];
|
|
173
|
+
/**
|
|
174
|
+
* @interface
|
|
175
|
+
*/
|
|
176
|
+
export type PathProps = TupleToObjectWithPropNames<ParamsArray, StreamAgentParameterNames> & {
|
|
177
|
+
onDrawComplete?: () => void;
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* Path component.
|
|
181
|
+
*
|
|
182
|
+
* A Path indicates a route on the map.
|
|
183
|
+
*
|
|
184
|
+
* @category Components
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```tsx
|
|
188
|
+
* const space1 = mapData.getByType('space')[0];
|
|
189
|
+
* const space2 = mapData.getByType('space')[1];
|
|
190
|
+
* const directions = mapView.getDirections(space1, space2);
|
|
191
|
+
*
|
|
192
|
+
* return directions ? <Path coordinate={directions.coordinates} options={{ color: 'blue' }} /> : null;
|
|
193
|
+
* ```
|
|
194
|
+
*/
|
|
195
|
+
export const Path: import("react").ForwardRefExoticComponent<TupleToObjectWithPropNames<[coordinates: import("@mappedin/mappedin-js").Coordinate[], options?: import("@mappedin/mappedin-js").TAddPathOptions | undefined], StreamAgentParameterNames> & {
|
|
196
|
+
onDrawComplete?: () => void;
|
|
197
|
+
} & import("react").RefAttributes<PathJS | undefined>>;
|
|
198
|
+
export {};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
declare module '@mappedin/react-sdk/react-sdk/src/Navigation' {
|
|
202
|
+
import type { TupleToObjectWithPropNames } from '@mappedin/react-sdk/react-sdk/src/type-utils';
|
|
203
|
+
import type { MapView } from '@mappedin/mappedin-js';
|
|
204
|
+
type ParamsArray = Parameters<MapView['Navigation']['draw']>;
|
|
205
|
+
type StreamAgentParameterNames = ['directions', 'options'];
|
|
206
|
+
/**
|
|
207
|
+
* @interface
|
|
208
|
+
*/
|
|
209
|
+
export type NavigationProps = TupleToObjectWithPropNames<ParamsArray, StreamAgentParameterNames> & {
|
|
210
|
+
onDrawComplete?: () => void;
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* Navigation component.
|
|
214
|
+
*
|
|
215
|
+
* Navigation draws a route on the map with pre-defined Markers for connections and the start and end points.
|
|
216
|
+
*
|
|
217
|
+
* @category Components
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* ```tsx
|
|
221
|
+
* const space1 = mapData.getByType('space')[0];
|
|
222
|
+
* const space2 = mapData.getByType('space')[1];
|
|
223
|
+
* const directions = mapView.getDirections(space1, space2);
|
|
224
|
+
*
|
|
225
|
+
* return directions ? <Navigation directions={directions} /> : null;
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
export function Navigation(props: NavigationProps): null;
|
|
229
|
+
export {};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
declare module '@mappedin/react-sdk/react-sdk/src/Shape' {
|
|
233
|
+
import type { TupleToObjectWithPropNames } from '@mappedin/react-sdk/react-sdk/src/type-utils';
|
|
234
|
+
import type { MapView, Shape as ShapeJS } from '@mappedin/mappedin-js';
|
|
235
|
+
type ParamsArray = Parameters<MapView['Shapes']['add']>;
|
|
236
|
+
type StreamAgentParameterNames = ['geometry', 'style', 'floor'];
|
|
237
|
+
/**
|
|
238
|
+
* @interface
|
|
239
|
+
*/
|
|
240
|
+
export type ShapeProps = TupleToObjectWithPropNames<ParamsArray, StreamAgentParameterNames>;
|
|
241
|
+
/**
|
|
242
|
+
* Shape component.
|
|
243
|
+
*
|
|
244
|
+
* A Shape is a custom geometry on the map created from a GeoJSON feature collection.
|
|
245
|
+
*
|
|
246
|
+
* @category Components
|
|
247
|
+
*
|
|
248
|
+
* @example
|
|
249
|
+
* ```tsx
|
|
250
|
+
* <Shape geometry={geojson} style={{ color: 'blue', height: 2 }} />
|
|
251
|
+
* ```
|
|
252
|
+
*/
|
|
253
|
+
export const Shape: import("react").ForwardRefExoticComponent<ShapeProps & import("react").RefAttributes<ShapeJS | undefined>>;
|
|
254
|
+
export {};
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
declare module '@mappedin/react-sdk/react-sdk/src/Model' {
|
|
258
|
+
import type { TupleToObjectWithPropNames } from '@mappedin/react-sdk/react-sdk/src/type-utils';
|
|
259
|
+
import type { MapView, Model as ModelJS } from '@mappedin/mappedin-js';
|
|
260
|
+
type ParamsArray = Parameters<MapView['Models']['add']>;
|
|
261
|
+
type StreamAgentParameterNames = ['coordinate', 'url', 'options'];
|
|
262
|
+
/**
|
|
263
|
+
* @interface
|
|
264
|
+
*/
|
|
265
|
+
export type ModelProps = TupleToObjectWithPropNames<ParamsArray, StreamAgentParameterNames>;
|
|
266
|
+
/**
|
|
267
|
+
* Model component.
|
|
268
|
+
*
|
|
269
|
+
* A Model is a 3D model in GLTF or GLB format anchored to a Coordinate on the map.
|
|
270
|
+
*
|
|
271
|
+
* @category Components
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* ```tsx
|
|
275
|
+
* <Model
|
|
276
|
+
* coordinate={coordinate}
|
|
277
|
+
* url={'/path/to/model.glb'}
|
|
278
|
+
* options={{
|
|
279
|
+
* scale: [0.01, 0.01, 0.01],
|
|
280
|
+
* rotation: [90, 0, 0],
|
|
281
|
+
* opacity: 0.5,
|
|
282
|
+
* }}
|
|
283
|
+
* />
|
|
284
|
+
* ```
|
|
285
|
+
*/
|
|
286
|
+
export const Model: import("react").ForwardRefExoticComponent<ModelProps & import("react").RefAttributes<ModelJS | undefined>>;
|
|
287
|
+
export {};
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
declare module '@mappedin/react-sdk/react-sdk/src/hooks/useMap' {
|
|
291
|
+
import type { MapData, MapView } from '@mappedin/mappedin-js';
|
|
292
|
+
/**
|
|
293
|
+
* Hook to get the MapData and MapView from the current MapView context.
|
|
294
|
+
*
|
|
295
|
+
* Must be used within a {@link MapView} component.
|
|
296
|
+
* @throws If used outside of a {@link MapView} component.
|
|
297
|
+
*
|
|
298
|
+
* @category Hooks
|
|
299
|
+
*
|
|
300
|
+
* @example
|
|
301
|
+
* ```tsx
|
|
302
|
+
* const { mapData, mapView } = useMap();
|
|
303
|
+
* ```
|
|
304
|
+
*/
|
|
305
|
+
export function useMap(): {
|
|
306
|
+
mapData: MapData;
|
|
307
|
+
mapView: MapView;
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
declare module '@mappedin/react-sdk/react-sdk/src/Marker' {
|
|
312
|
+
import React from 'react';
|
|
313
|
+
import type { TupleToObjectWithPropNames } from '@mappedin/react-sdk/react-sdk/src/type-utils';
|
|
314
|
+
import type { MapView, TAnimationOptions, Marker as MarkerJS } from '@mappedin/mappedin-js';
|
|
315
|
+
type ParamsArray = Parameters<MapView['Markers']['add']>;
|
|
316
|
+
type StreamAgentParameterNames = ['target', 'contentHtml', 'options'];
|
|
317
|
+
/**
|
|
318
|
+
* @interface
|
|
319
|
+
*/
|
|
320
|
+
export type MarkerProps = Omit<TupleToObjectWithPropNames<ParamsArray, StreamAgentParameterNames>, 'contentHtml'>;
|
|
321
|
+
/**
|
|
322
|
+
* Marker component.
|
|
323
|
+
*
|
|
324
|
+
* A Marker is a 2D component anchored to a position on the map.
|
|
325
|
+
* To animate the Marker when its target changes, see {@link AnimatedMarker}.
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* ```tsx
|
|
329
|
+
* <Marker target={mapData.getByType('space')[0]}>
|
|
330
|
+
* <div>Hello, world!</div>
|
|
331
|
+
* </Marker>
|
|
332
|
+
* ```
|
|
333
|
+
*
|
|
334
|
+
* @category Components
|
|
335
|
+
*/
|
|
336
|
+
export const Marker: React.ForwardRefExoticComponent<MarkerProps & {
|
|
337
|
+
children?: React.ReactNode | undefined;
|
|
338
|
+
} & React.RefAttributes<MarkerJS | undefined>>;
|
|
339
|
+
/**
|
|
340
|
+
* AnimatedMarker component.
|
|
341
|
+
* @experimental
|
|
342
|
+
*
|
|
343
|
+
* A {@link Marker} component that animates between positions when its target changes.
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* ```tsx
|
|
347
|
+
* <AnimatedMarker target={mapData.getByType('space')[0]} duration={1000}>
|
|
348
|
+
* <div>Hello, world!</div>
|
|
349
|
+
* </AnimatedMarker>
|
|
350
|
+
* ```
|
|
351
|
+
*
|
|
352
|
+
* @category Components
|
|
353
|
+
*/
|
|
354
|
+
export const AnimatedMarker: React.ForwardRefExoticComponent<MarkerProps & TAnimationOptions & {
|
|
355
|
+
children?: React.ReactNode | undefined;
|
|
356
|
+
} & React.RefAttributes<MarkerJS | undefined>>;
|
|
357
|
+
export {};
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
declare module '@mappedin/react-sdk/react-sdk/src/Label' {
|
|
361
|
+
import type { TupleToObjectWithPropNames } from '@mappedin/react-sdk/react-sdk/src/type-utils';
|
|
362
|
+
import type { MapView, Label as LabelJS } from '@mappedin/mappedin-js';
|
|
363
|
+
type ParamsArray = Parameters<MapView['Labels']['add']>;
|
|
364
|
+
type StreamAgentParameterNames = ['target', 'text', 'options'];
|
|
365
|
+
/**
|
|
366
|
+
* @interface
|
|
367
|
+
*/
|
|
368
|
+
export type LabelProps = TupleToObjectWithPropNames<ParamsArray, StreamAgentParameterNames>;
|
|
369
|
+
/**
|
|
370
|
+
* Label component.
|
|
371
|
+
*
|
|
372
|
+
* A Label is a 2D text label anchored to a position on the map.
|
|
373
|
+
*
|
|
374
|
+
* @category Components
|
|
375
|
+
*
|
|
376
|
+
* @example
|
|
377
|
+
* ```tsx
|
|
378
|
+
* <Label target={mapData.getByType('space')[0]} text={"Hello, world!"} />
|
|
379
|
+
* ```
|
|
380
|
+
*/
|
|
381
|
+
export const Label: import("react").ForwardRefExoticComponent<LabelProps & import("react").RefAttributes<LabelJS | undefined>>;
|
|
382
|
+
export {};
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
declare module '@mappedin/react-sdk/react-sdk/src/type-utils' {
|
|
386
|
+
import type { TupleToObject } from 'type-fest';
|
|
387
|
+
export type TupleToObjectWithPropNames<T extends any[], N extends Record<keyof TupleToObject<T>, PropertyKey>> = {
|
|
388
|
+
[K in keyof TupleToObject<T> as N[K]]: T[K];
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
|
package/lib/esm/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var ue=Object.create;var N=Object.defineProperty,fe=Object.defineProperties,ce=Object.getOwnPropertyDescriptor,le=Object.getOwnPropertyDescriptors,de=Object.getOwnPropertyNames,L=Object.getOwnPropertySymbols,Me=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var H=(e,r,t)=>r in e?N(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,y=(e,r)=>{for(var t in r||(r={}))b.call(r,t)&&H(e,t,r[t]);if(L)for(var t of L(r))z.call(r,t)&&H(e,t,r[t]);return e},v=(e,r)=>fe(e,le(r)),p=(e,r)=>N(e,"name",{value:r,configurable:!0});var $=(e,r)=>{var t={};for(var a in e)b.call(e,a)&&r.indexOf(a)<0&&(t[a]=e[a]);if(e!=null&&L)for(var a of L(e))r.indexOf(a)<0&&z.call(e,a)&&(t[a]=e[a]);return t};var ye=(e,r)=>()=>(e&&(r=e(e=0)),r);var he=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var Pe=(e,r,t,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of de(r))!b.call(e,o)&&o!==t&&N(e,o,{get:()=>r[o],enumerable:!(a=ce(r,o))||a.enumerable});return e};var U=(e,r,t)=>(t=e!=null?ue(Me(e)):{},Pe(r||!e||!e.__esModule?N(t,"default",{value:e,enumerable:!0}):t,e));var m,n=ye(()=>{m={env:{NODE_ENV:"production",npm_package_version:"6.0.0-rc.1"}}});var A=he((Wt,q)=>{"use strict";n();q.exports=p(function e(r,t){if(r===t)return!0;if(r&&t&&typeof r=="object"&&typeof t=="object"){if(r.constructor!==t.constructor)return!1;var a,o,s;if(Array.isArray(r)){if(a=r.length,a!=t.length)return!1;for(o=a;o--!==0;)if(!e(r[o],t[o]))return!1;return!0}if(r.constructor===RegExp)return r.source===t.source&&r.flags===t.flags;if(r.valueOf!==Object.prototype.valueOf)return r.valueOf()===t.valueOf();if(r.toString!==Object.prototype.toString)return r.toString()===t.toString();if(s=Object.keys(r),a=s.length,a!==Object.keys(t).length)return!1;for(o=a;o--!==0;)if(!Object.prototype.hasOwnProperty.call(t,s[o]))return!1;for(o=a;o--!==0;){var i=s[o];if(!e(r[i],t[i]))return!1}return!0}return r!==r&&t!==t},"equal")});n();n();import we,{createContext as De,useMemo as Se,useState as Ee}from"react";var E=De({getCache:p(()=>{},"getCache"),setCache:p(()=>{},"setCache")});function k({mapData:e,children:r}){let[t,a]=Ee(e?{mapData:e,options:{}}:void 0),o=Se(()=>({getCache:p(()=>t,"getCache"),setCache:a}),[t]);return we.createElement(E.Provider,{value:o},r)}p(k,"MapDataProvider");n();var Y=U(A());import{useCallback as Ve,useContext as Ce,useEffect as B,useRef as Oe,useState as j}from"react";import{getMapData as Le}from"@mappedin/mappedin-js";n();var ge="[MappedinJS]";function Te(e="",{prefix:r=ge}={}){let t="".concat(r).concat(e?"-".concat(e):""),a=p((o,s)=>{if(typeof window<"u"&&window.rnDebug){let i=s.map(M=>M instanceof Error&&M.stack?"".concat(M.message,"\n").concat(M.stack):M);window.rnDebug("".concat(e," ").concat(o,": ").concat(i.join(" ")))}},"rnDebug");return{logState:m.env.NODE_ENV==="test"?3:0,log(...o){this.logState<=0&&(console.log(t,...o),a("log",o))},warn(...o){this.logState<=1&&(console.warn(t,...o),a("warn",o))},error(...o){this.logState<=2&&(console.error(t,...o),a("error",o))},assert(...o){console.assert(...o)},time(o){console.time(o)},timeEnd(o){console.timeEnd(o)},setLevel(o){0<=o&&o<=3&&(this.logState=o)}}}p(Te,"createLogger");var ve=Te();var V=ve;n();var K=U(A());import{useRef as F}from"react";function d(e,r){let t=F(),a=F();return(0,K.default)(r,a.current)||(t.current=e(),a.current=r),t.current}p(d,"useMemoDeep");function Ne(e){let{getCache:r,setCache:t}=Ce(E),[a,o]=j(void 0),[s,i]=j(!0),[M,u]=j(void 0),D=Oe(0),l=d(()=>e&&v(y({},e),{analytics:y({context:"reactsdk"},e==null?void 0:e.analytics)}),[e]),g=Ve(h=>{let S=++D.current;i(!0),u(void 0),Le(h).then(P=>{D.current===S&&o(P)}).catch(P=>{D.current===S&&(V.error("Failed to fetch MapData",P),u(P))}).finally(()=>{D.current===S&&i(!1)})},[]);return B(()=>{let h=r==null?void 0:r();if(h!=null&&(l==null||h.mapData.mapId===l.mapId&&(0,Y.default)(h.options,l))){o(h.mapData),i(!1),u(void 0);return}if(!l){u(new Error("useMapData requires options if not use within a MapDataProvider or MapView component."));return}g(l)},[g,r,l,a]),B(()=>{let h=r==null?void 0:r();a!=null&&(h==null||h.mapData.mapId===a.mapId)&&(t==null||t({mapData:a,options:l||{}}))},[a,l,r,t]),{mapData:a,isLoading:s,error:M}}p(Ne,"useMapData");n();import{useCallback as Re,useContext as be,useEffect as ke}from"react";function Ae(e,r){let{getCache:t}=be(E),a=Re(o=>r(o),[r]);ke(()=>{var s;let o=(s=t==null?void 0:t())==null?void 0:s.mapData;if(o==null)throw new Error("useMapDataEvent must be used within a MapDataProvider or MapView component.");return o.on(e,a),()=>{o!=null&&o.off(e,a)}},[t,e,a])}p(Ae,"useMapDataEvent");n();import C,{useCallback as je,useEffect as Ie,useMemo as Q,useRef as X,useState as Z,forwardRef as Je,useImperativeHandle as We,createContext as _e}from"react";import{show3dMap as Ge}from"@mappedin/mappedin-js";var f=_e({mapView:void 0}),He={width:"100%",height:"100%",position:"relative"},ze=Je((e,r)=>{let _=e,{mapData:t,options:a,style:o,fallback:s,children:i}=_,M=$(_,["mapData","options","style","fallback","children"]),u=X({}).current,[D,l]=Z(!0),[g,h]=Z(!1),S=X(null),P=Q(()=>t,[t]),W=d(()=>a,[a]);We(r,()=>u.mapView);let se=Q(()=>({mapData:P,mapView:u.mapView}),[P,u.mapView]),O=je(T=>{var G;let x=T||u.mapView;try{(G=x==null?void 0:x.destroy)==null||G.call(x)}catch(me){V.error("Failed to destroy MapView",me)}T||(u.mapView=void 0,h(!1))},[u]);return Ie(()=>{if(!P||!S.current)return;O();let T=!1;return l(!0),Ge(S.current,P,W).then(x=>{T?O(x):(u.mapView=x,h(!0))}).catch(x=>{V.error("Failed to render MapView",x)}).finally(()=>{T||l(!1)}),()=>{T=!0,u.mapView&&O()}},[P,W,u,O]),C.createElement(k,{mapData:P},C.createElement(f.Provider,{value:se},C.createElement("div",y({"data-testid":"mappedin-map",ref:S,style:y(y({},He),o)},M)),D?C.createElement(C.Fragment,null,s):g?i:null))});n();import{useCallback as $e,useContext as Ue,useEffect as qe}from"react";n();var I=class I extends Error{constructor(r){super("".concat(r," must be used within a MapView component."))}};p(I,"MapViewNullError");var c=I;function Fe(e,r){let{mapView:t}=Ue(f),a=$e(o=>r(o),[r]);qe(()=>{if(t==null)throw new c("useMapViewEvent");return t.on(e,a),()=>{t!=null&&t.off(e,a)}},[t,e,r])}p(Fe,"useMapViewEvent");n();import{useContext as Ye,useEffect as Qe,useRef as Xe,forwardRef as Ze,useImperativeHandle as et,useState as tt}from"react";n();import{useEffect as Ke,useRef as Be}from"react";function w(e,r){let t=Be(!0);Ke(()=>{if(t.current){t.current=!1;return}return e()},r)}p(w,"useUpdateEffect");var rt=Ze((e,r)=>{let{mapView:t}=Ye(f),a=Xe(),o=d(()=>e.options,[e.options]),[s,i]=tt(!1);return et(r,()=>a.current,[s]),Qe(()=>{if(t==null)throw new c("Path");let M=t.Paths.add(e.coordinate,o);return M.animation.then(()=>{var u;(u=e.onDrawComplete)==null||u.call(e)}),a.current=M,i(!0),()=>{a.current&&t.Paths.remove(a.current),i(!1)}},[t,e.coordinate]),w(()=>{a.current&&o&&(t==null||t.updateState(a.current,o))},[o]),null});n();import{useContext as at,useEffect as ot}from"react";function nt(e){let{mapView:r}=at(f),t=d(()=>e.options,[e.options]);return ot(()=>{if(r==null)throw new c("Navigation");return r.Navigation.draw(e.directions,t).then(()=>{var a;(a=e.onDrawComplete)==null||a.call(e)}),()=>{r.Navigation.clear()}},[r,e.directions,t]),null}p(nt,"Navigation");n();import{useContext as it,useEffect as pt,useRef as st,forwardRef as mt,useImperativeHandle as ut,useState as ft}from"react";var ct=mt((e,r)=>{let{mapView:t}=it(f),a=st(),o=d(()=>e.style,[e.style]),[s,i]=ft(!1);return ut(r,()=>a.current,[s]),pt(()=>{if(t==null)throw new Error("MapView not initialized");return a.current=t.Shapes.add(e.geometry,e.style,e.floor),i(!0),()=>{t==null||a.current==null||(t.Shapes.remove(a.current),i(!1))}},[t,e.geometry,e.style,e.floor]),w(()=>{a.current&&o&&(t==null||t.updateState(a.current,o))},[o]),null});n();import{useContext as lt,useEffect as dt,useRef as Mt,forwardRef as yt,useImperativeHandle as ht,useState as Pt}from"react";var xt=yt((e,r)=>{let{mapView:t}=lt(f),a=Mt(),o=d(()=>e.options,[e.options]),[s,i]=Pt(!1);return ht(r,()=>a.current,[s]),dt(()=>{if(t==null)throw new c("Model");return a.current=t.Models.add(e.coordinate,e.url,o),i(!0),()=>{t==null||a.current==null||(t.Models.remove(a.current),i(!1))}},[t,e.url]),w(()=>{a.current&&(t==null||t.updateState(a.current,y({position:e.coordinate},o)))},[e.coordinate,o]),null});n();import{useContext as ee}from"react";function wt(){var t;let{mapView:e}=ee(f),{getCache:r}=ee(E);if(!e)throw new c("useMap");return{mapData:((t=r==null?void 0:r())==null?void 0:t.mapData)||e.getMapData(),mapView:e}}p(wt,"useMap");n();import Dt,{useCallback as St,useContext as re,useEffect as ae,useMemo as Et,useRef as R,forwardRef as oe,useImperativeHandle as ne,useState as ie}from"react";import{createPortal as gt}from"react-dom";n();var J=[0,4,6,8,10],te=p(()=>{let e=new Array(16).fill(0),r=Math.random()*4294967296;for(let a=0;a<e.length;a++)a>0&&(a&3)===0&&(r=Math.random()*4294967296),e[a]=r>>>((a&3)<<3)&255;let t=e.map(a=>a.toString(16).padStart(2,"0"));return t[6]="4"+t[6][1],t[8]=["8","9","a","b"].includes(t[7][0])?t[7]:"a"+t[7][1],J.map((a,o)=>t.slice(a,o===J.length-1?void 0:J[o+1]).join("")).join("-")},"randomId");var pe=oe((e,r)=>{let{mapView:t}=re(f),a=R(),[o,s]=ie(!1),i=d(()=>e.options,[e.options]);return ne(r,()=>a.current,[o]),ae(()=>{if(t==null)throw new c("Marker");return a.current=t.Markers.add(e.target,"",i),s(!0),()=>{t==null||a.current==null||(t.Markers.remove(a.current),s(!1))}},[t,e.target]),w(()=>{a.current&&i&&(t==null||t.updateState(a.current,i))},[i]),t==null||a.current==null?null:gt(e.children,a.current.contentEl,a.current.id)}),Tt=oe((e,r)=>{let{mapView:t}=re(f),a=R(te()),o=R(),[s,i]=ie(!1),M=R(e.target);ne(r,()=>o.current,[s]);let u=St(l=>{o.current=l||void 0,i(!!l)},[]);ae(()=>{if(t==null)throw new c("Marker");if(o.current&&o.current.target!==e.target){let{duration:l=300,easing:g="linear"}=e;t.Markers.animateTo(o.current,e.target,{duration:l,easing:g})}return()=>{i(!1)}},[t,e.target]);let D=Et(()=>v(y({},e),{duration:void 0,easing:void 0}),[e.duration,e.easing]);return Dt.createElement(pe,v(y({},D),{key:a.current,target:M.current,ref:u}))});n();import{forwardRef as vt,useContext as Vt,useEffect as Ct,useImperativeHandle as Ot,useRef as Lt,useState as Nt}from"react";var Rt=vt((e,r)=>{let{mapView:t}=Vt(f),a=Lt(),[o,s]=Nt(!1),i=d(()=>e.options,[e.options]);return Ot(r,()=>a.current,[o]),Ct(()=>{if(t==null)throw new c("Label");return a.current=t.Labels.add(e.target,e.text,i),s(!0),()=>{t==null||a.current==null||(t.Labels.remove(a.current),s(!1))}},[t,e.target]),w(()=>{a.current&&(t==null||t.updateState(a.current,y({text:e.text},i)))},[e.text,i]),null});export{Tt as AnimatedMarker,Rt as Label,k as MapDataProvider,ze as MapView,pe as Marker,xt as Model,nt as Navigation,rt as Path,ct as Shape,wt as useMap,Ne as useMapData,Ae as useMapDataEvent,Fe as useMapViewEvent};
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mappedin/react-sdk",
|
|
3
|
+
"version": "6.0.0-rc.1",
|
|
4
|
+
"homepage": "https://developer.mappedin.com/",
|
|
5
|
+
"private": false,
|
|
6
|
+
"main": "lib/esm/index.js",
|
|
7
|
+
"module": "lib/esm/index.js",
|
|
8
|
+
"browser": "lib/esm/index.js",
|
|
9
|
+
"types": "lib/esm/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"lib",
|
|
12
|
+
"README.md",
|
|
13
|
+
"LICENSE.txt",
|
|
14
|
+
"THIRD_PARTY_LICENSES.txt"
|
|
15
|
+
],
|
|
16
|
+
"license": "SEE LICENSE IN LICENSE.txt",
|
|
17
|
+
"scripts": {
|
|
18
|
+
"start": "pnpm build && concurrently \"node scripts/build.mjs --watchChanges\" \"node scripts/start.mjs\"",
|
|
19
|
+
"build": "pnpm clean && tsc -b && node scripts/build.mjs",
|
|
20
|
+
"build:prod": "cross-env NODE_ENV=production pnpm build",
|
|
21
|
+
"types": "tsc -b",
|
|
22
|
+
"test": "NODE_ENV=test jest",
|
|
23
|
+
"test:cov": "NODE_ENV=test jest --coverage",
|
|
24
|
+
"clean": "rm -rf lib/** && rm -rf examples/dist/**",
|
|
25
|
+
"docs": "pnpm build && typedoc"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"@mappedin/mappedin-js": "workspace:*",
|
|
29
|
+
"react": ">=16.8.0",
|
|
30
|
+
"react-dom": ">=16.8.0"
|
|
31
|
+
},
|
|
32
|
+
"volta": {
|
|
33
|
+
"extends": "../../package.json"
|
|
34
|
+
},
|
|
35
|
+
"gitHead": "6f653df01e872470753a4ddfeb213b6e28c50f93"
|
|
36
|
+
}
|