react-native-maplibre-lite 0.2.2 → 0.2.4

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.
@@ -122,6 +122,13 @@ interface MapViewProps {
122
122
  * стороне. Без него озвучка и FAB выбора голоса отключены.
123
123
  */
124
124
  navigatorVoiceUrl?: string;
125
+ /**
126
+ * Dev-only: автоматически вести маркер по построенному маршруту
127
+ * (симуляция поездки для отладки). Требует `navigator: true`. Пока
128
+ * включено, реальный GPS в WebView не пробрасывается, чтобы не
129
+ * конфликтовать с симуляцией.
130
+ */
131
+ navigatorSimulate?: boolean;
125
132
  onNavigatorRouteSet?: (params: NavigatorRouteSetParams) => void;
126
133
  onNavigatorInstruction?: (params: NavigatorInstructionParams) => void;
127
134
  onNavigatorPositionSet?: (params: NavigatorPositionSetParams) => void;
@@ -150,6 +157,8 @@ export type MapViewRef = {
150
157
  setNavigatorPosition: (latitude: number, longitude: number, accuracy?: number) => void;
151
158
  /** Режим «клик по карте = новая позиция» (удобно в dev). */
152
159
  pickNavigatorPosition: () => void;
160
+ /** Dev-only: включить/выключить симуляцию поездки по маршруту. */
161
+ setNavigatorSimulation: (enabled: boolean) => void;
153
162
  };
154
163
 
155
164
  type MapViewRegistry = {
@@ -437,6 +446,10 @@ export const MapView = forwardRef<MapViewRef, MapViewProps>((props, ref) => {
437
446
  sendToWebView({ function: 'recenterNavigatorCamera', params: {} });
438
447
  };
439
448
 
449
+ const setNavigatorSimulation = (enabled: boolean) => {
450
+ sendToWebView({ function: 'setNavigatorSimulation', params: { enabled } });
451
+ };
452
+
440
453
  useImperativeHandle(ref, () => ({
441
454
  fitBounds,
442
455
  flyTo,
@@ -444,6 +457,7 @@ export const MapView = forwardRef<MapViewRef, MapViewProps>((props, ref) => {
444
457
  advanceNavigatorInstruction,
445
458
  setNavigatorPosition,
446
459
  pickNavigatorPosition,
460
+ setNavigatorSimulation,
447
461
  }), [fitBounds]);
448
462
 
449
463
 
@@ -563,7 +577,17 @@ export const MapView = forwardRef<MapViewRef, MapViewProps>((props, ref) => {
563
577
  };
564
578
 
565
579
  useEffect(() => {
566
- if (!props.navigator) {
580
+ if (!inited || !props.navigator) {
581
+ return;
582
+ }
583
+ sendToWebViewRef.current({
584
+ function: 'setNavigatorSimulation',
585
+ params: { enabled: !!props.navigatorSimulate },
586
+ });
587
+ }, [inited, props.navigator, props.navigatorSimulate]);
588
+
589
+ useEffect(() => {
590
+ if (!props.navigator || props.navigatorSimulate) {
567
591
  return;
568
592
  }
569
593
 
@@ -615,7 +639,7 @@ export const MapView = forwardRef<MapViewRef, MapViewProps>((props, ref) => {
615
639
  return () => {
616
640
  Geolocation.clearWatch(watchId);
617
641
  };
618
- }, [props.navigator]);
642
+ }, [props.navigator, props.navigatorSimulate]);
619
643
 
620
644
  return (
621
645
  <View style={props.style}>
@@ -1,4 +1,9 @@
1
- import { forwardRef, useImperativeHandle, useRef, useState } from 'react';
1
+ import {
2
+ forwardRef,
3
+ useImperativeHandle,
4
+ useRef,
5
+ useState,
6
+ } from 'react';
2
7
 
3
8
  import Video from 'react-native-video';
4
9
 
@@ -10,7 +15,7 @@ import Video from 'react-native-video';
10
15
  */
11
16
 
12
17
  /** Пауза между клипами (как в веб-плеере). */
13
- const CLIP_PAUSE_MS = 300;
18
+ const CLIP_PAUSE_MS = 0;
14
19
 
15
20
  export type NavigatorVoicePlayerRef = {
16
21
  /** Проиграть очередь URL подряд (прерывает текущую очередь). */
@@ -238,6 +238,11 @@ export type MapLiteSetNavigatorPositionParams = {
238
238
  accuracy?: number,
239
239
  }
240
240
 
241
+ /** RN → Web: `setNavigatorSimulation`. Отладочная симуляция поездки по маршруту. */
242
+ export type MapLiteSetNavigatorSimulationParams = {
243
+ enabled: boolean,
244
+ }
245
+
241
246
  /** RN → Web: JSON в `WebView.postMessage` (`webProject/src/map/MapLiteController.receive`). */
242
247
  export type NativeToWebCommand =
243
248
  | { function: 'init', params: MapLiteInitParams }
@@ -255,6 +260,7 @@ export type NativeToWebCommand =
255
260
  | { function: 'setNavigatorPosition', params: MapLiteSetNavigatorPositionParams }
256
261
  | { function: 'pickNavigatorPosition', params: Record<string, never> }
257
262
  | { function: 'recenterNavigatorCamera', params: Record<string, never> }
263
+ | { function: 'setNavigatorSimulation', params: MapLiteSetNavigatorSimulationParams }
258
264
 
259
265
  /** Web → RN: `postToNative` (`webProject/src/map/types.ts`). */
260
266
  export type WebToNativeMessage =