@mappable-world/mappable-types 0.0.17 → 0.0.19

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.
@@ -104,6 +104,7 @@ type MapTheme = 'dark';
104
104
  type VectorTileSize = 'X1' | 'X4' | 'X16';
105
105
  type VectorDataSourcePriority = 'low' | 'medium' | 'high';
106
106
  type VectorObjectsCollisionPriority = 'low' | 'medium' | 'high' | 'ultra';
107
+ type VectorMapType = 'map' | 'driving' | 'transit' | 'admin';
107
108
  interface VectorTileDataSourceDescription {
108
109
  /** Default is `'vmap2'` */
109
110
  tileFormat?: 'vmap2' | 'vmap3';
@@ -138,10 +139,14 @@ interface VectorTileDataSourceDescription {
138
139
  allObjectsInteractive?: boolean;
139
140
  /** Forces tiles to wait for the icons, disables hiding icons by zoom diff */
140
141
  iconsOnlyTiles?: boolean;
142
+ /** Milliseconds */
143
+ cameraIdleThrottling?: number;
141
144
  richModelDecoderWorkerUrl?: string;
142
145
  customization?: VectorCustomization;
143
146
  theme?: MapTheme;
147
+ hdModeEnabled?: boolean;
148
+ mapType?: VectorMapType;
144
149
  /** Defines how hotspots of type should be treated: enabled/disabled or use custom hotspots instead. */
145
150
  hotspots?: Record<string, boolean | FetchHotspotsFunction | HotspotsOptions>;
146
151
  }
147
- export { VectorCustomizationTypes, VectorCustomizationElements, VectorCustomizationItem, VectorCustomization, RasterTileDataSourceDescription, FetchHotspotsFunction, VectorTileDataSourceDescription, VectorTileSize, VectorObjectsCollisionPriority, VectorDataSourcePriority, HotspotsOptions, FetchTileFunction, ComposeTileUrlFunction, Hotspot, WorldHotspot, RenderedHotspot, FetchedRasterTile, FetchedTile, FetchedCommonTile, MapTheme };
152
+ export { VectorCustomizationTypes, VectorCustomizationElements, VectorCustomizationItem, VectorCustomization, RasterTileDataSourceDescription, FetchHotspotsFunction, VectorTileDataSourceDescription, VectorTileSize, VectorObjectsCollisionPriority, VectorDataSourcePriority, VectorMapType, HotspotsOptions, FetchTileFunction, ComposeTileUrlFunction, Hotspot, WorldHotspot, RenderedHotspot, FetchedRasterTile, FetchedTile, FetchedCommonTile, MapTheme };
@@ -10,4 +10,8 @@ interface HotspotObject {
10
10
  type: 'hotspot';
11
11
  feature: HotspotFeature<LngLat>;
12
12
  }
13
- export { HotspotFeature, HotspotObject };
13
+ interface RawHotspotObject {
14
+ type: 'raw-hotspot';
15
+ feature: HotspotFeature<LngLat>;
16
+ }
17
+ export { HotspotFeature, HotspotObject, RawHotspotObject };
@@ -4,7 +4,7 @@ import type { Vec2 } from "./vec2";
4
4
  import type { Camera } from "./camera";
5
5
  import type { WorldOptions } from "./world-options";
6
6
  import type { GenericProjection } from "./projection";
7
- import type { PixelCoordinates } from "./coordinates";
7
+ import type { PixelCoordinates, WorldCoordinates } from "./coordinates";
8
8
  interface WorldOffset {
9
9
  readonly left: number;
10
10
  readonly top: number;
@@ -21,6 +21,10 @@ interface RasterLayerImplementationRenderProps extends LayerImplementationRender
21
21
  interface RasterLayerImplementation {
22
22
  destroy(): void;
23
23
  render(props: RasterLayerImplementationRenderProps): void;
24
+ findObjectInPosition?(coords: {
25
+ readonly worldCoordinates: WorldCoordinates;
26
+ readonly screenCoordinates: PixelCoordinates;
27
+ }): unknown | undefined | null;
24
28
  }
25
29
  interface RasterLayerImplementationConstructorProps {
26
30
  requestRender: () => void;
@@ -26,6 +26,7 @@ type WithDefaults<Props, DefaultProps extends Partial<Props>> = Props & {
26
26
  * name: 'entity'
27
27
  * };
28
28
  * class MMapSomeEntity extends GenericEntity<MMapSomeEntityProps, typeof defaultProps> {
29
+ * static defaultProps = defaultProps;
29
30
  * public isAttached: boolean;
30
31
  * constructor(props: MMapSomeEntityProps) {
31
32
  * super(props);
@@ -49,6 +50,12 @@ declare abstract class GenericEntity<Props, DefaultProps extends {} = {}, Root e
49
50
  * @param props - The value of input props.
50
51
  */
51
52
  constructor(props: Props);
53
+ /**
54
+ * The method provides the default values for the properties of an Entity.
55
+ * @param _props - Input props value for the Entity.
56
+ * @returns Props with default values.
57
+ */
58
+ protected _getDefaultProps(_props: Props): DefaultProps | undefined;
52
59
  /**
53
60
  * Method for updating props of Entity.
54
61
  * @param changedProps - New props values.
@@ -122,6 +129,7 @@ interface ComplexOptions<Root extends GenericRootEntity<unknown> = GenericRootEn
122
129
  * name: 'entity'
123
130
  * };
124
131
  * class MMapSomeComplexEntity extends GenericComplexEntity<MMapSomeComplexEntityProps, typeof defaultProps> {
132
+ * static defaultProps = defaultProps;
125
133
  * private _someEntity?: MMapSomeEntity; // MMapSomeEntity extends GenericEntity
126
134
  * protected _onAttach(): void {
127
135
  * this._someEntity = new MMapSomeEntity();
@@ -187,6 +195,7 @@ declare class GenericComplexEntity<Props, DefaultProps extends {} = {}, Root ext
187
195
  * name: 'entity'
188
196
  * };
189
197
  * class MMapSomeGroupEntity extends GenericGroupEntity<MMapSomeGroupEntityProps, typeof defaultProps> {
198
+ * static defaultProps = defaultProps;
190
199
  * // ...
191
200
  * }
192
201
  * const groupEntity = new MMapSomeGroupEntity()
@@ -215,6 +224,7 @@ declare class GenericGroupEntity<Props, DefaultProps extends {} = {}, Root exten
215
224
  * }
216
225
  * // Now we can specify their root element for the Entity
217
226
  * class MMapSomeEntity extends GenericEntity<MMapSomeEntityProps, typeof defaultProps, MMap> {
227
+ * static defaultProps = defaultProps;
218
228
  * // ...
219
229
  * }
220
230
  */
@@ -13,6 +13,7 @@ import { GenericComplexEntity, GenericEntity, GenericGroupEntity, Context } from
13
13
  * name: 'entity'
14
14
  * };
15
15
  * class MMapSomeEntity extends MMapEntity<MMapSomeEntityProps, typeof defaultProps> {
16
+ * static defaultProps = defaultProps;
16
17
  * public isAttached: boolean;
17
18
  * constructor(props: MMapSomeEntityProps) {
18
19
  * super(props);
@@ -45,6 +46,7 @@ declare abstract class MMapEntity<Props, DefaultProps extends {} = {}> extends G
45
46
  * name: 'entity'
46
47
  * };
47
48
  * class MMapSomeComplexEntity extends MMapComplexEntity<MMapSomeComplexEntityProps, typeof defaultProps> {
49
+ * static defaultProps = defaultProps;
48
50
  * private _someEntity?: MMapSomeEntity; // MMapSomeEntity extends GenericEntity
49
51
  * protected _onAttach(): void {
50
52
  * this._someEntity = new MMapSomeEntity();
@@ -73,6 +75,7 @@ declare abstract class MMapComplexEntity<Props, DefaultProps extends {} = {}> ex
73
75
  * name: 'entity'
74
76
  * };
75
77
  * class MMapSomeGroupEntity extends MMapGroupEntity<MMapSomeGroupEntityProps, typeof defaultProps> {
78
+ * static defaultProps = defaultProps;
76
79
  * // ...
77
80
  * }
78
81
  * const groupEntity = new MMapSomeGroupEntity()
@@ -1,5 +1,5 @@
1
1
  import type { DrawingStyle, GenericGeometry, LngLat, HideOutsideRule } from "../../common/types";
2
- import type { DraggableProps, FeatureClickEvents } from "./types";
2
+ import type { BlockingProps, DraggableProps, FeatureClickEvents } from "./types";
3
3
  import { MMapEntity } from "../MMapEnities";
4
4
  import type { Geometry, MMapFeatureEventHandler } from "./types";
5
5
  /**
@@ -15,7 +15,7 @@ type MMapFeatureProps = {
15
15
  disableRoundCoordinates?: boolean;
16
16
  /** Hide the marker if it goes beyond the edge of the viewport */
17
17
  hideOutsideViewport?: HideOutsideRule;
18
- } & DraggableProps<MMapFeatureEventHandler> & FeatureClickEvents;
18
+ } & DraggableProps<MMapFeatureEventHandler> & BlockingProps & FeatureClickEvents;
19
19
  declare const defaultProps: Readonly<{
20
20
  source: "mappable-default-feature";
21
21
  }>;
@@ -59,6 +59,7 @@ declare class MMapFeature extends MMapEntity<MMapFeatureProps, DefaultProps> {
59
59
  protected _onAttach(): void;
60
60
  protected _onDetach(): void;
61
61
  protected _onUpdate({ id, source }: Partial<MMapFeatureProps>): void;
62
+ protected _getDefaultProps(): DefaultProps;
62
63
  private __onDragStart;
63
64
  private __onDragMove;
64
65
  private __onDragEnd;
@@ -9,17 +9,27 @@ export interface DraggableProps<Callback> {
9
9
  /** Fires on drag start */
10
10
  onDragStart?: Callback;
11
11
  /**
12
- * Maybe a function which will be called when the user drags and drops the element to a new position in the map.
13
- * The arguments to the function will be with new coordinates.
14
- * A component using with component should immediately store the new coordinates into its state and then pass
15
- * the new coordinates as the marker's props.
12
+ * May be a function that will be called when the user drags and drops an element to a new location on the map.
13
+ * The arguments to the function will include the new coordinates.
14
+ * A component that uses this component should immediately save the new coordinates in its state and then use
15
+ * the new coordinates as props for the marker.
16
16
  * */
17
17
  onDragEnd?: Callback;
18
18
  /** Fires on drag move */
19
19
  onDragMove?: Callback;
20
- /** Will block maps events on marker */
20
+ }
21
+ export interface BlockingProps {
22
+ /**
23
+ * This parameter block all map events for the element.
24
+ * The map will no longer be able to respond to any {@link DomEvents} on this element, including clicks, double-clicks and others.
25
+ */
21
26
  blockEvents?: boolean;
22
- /** Will block maps behaviors on marker */
27
+ /**
28
+ * This parameter block all map behaviors for the element.
29
+ * The element itself can be zoomed and scrolled by mouse and gestures.
30
+ * The map will no longer be able to respond to any {@link BehaviorType} on this element (except `dblClick`).
31
+ * Double clicks and other map events will be blocked by the {@link BlockingProps.blockEvents} parameter.
32
+ */
23
33
  blockBehaviors?: boolean;
24
34
  }
25
35
  export interface FeatureClickEvents {
@@ -4,6 +4,8 @@ import type { GenericGeometry, LngLat } from "../../common/types";
4
4
  * But you can check it by `instance of` in MMapListener handlers
5
5
  */
6
6
  declare class MMapHotspot {
7
+ private static _uid;
8
+ readonly id: string;
7
9
  readonly geometry?: GenericGeometry<LngLat>;
8
10
  readonly properties: Record<string, unknown>;
9
11
  constructor(geometry: GenericGeometry<LngLat> | undefined, properties: Record<string, unknown>);
@@ -35,6 +35,7 @@ declare class MMapLayer extends MMapEntity<MMapLayerProps, DefaultProps> {
35
35
  static defaultProps: Readonly<{
36
36
  zIndex: 1500;
37
37
  }>;
38
+ protected _getDefaultProps(props: MMapLayerProps): DefaultProps;
38
39
  protected _onAttach(): void;
39
40
  protected _onDetach(): void;
40
41
  protected _onUpdate(): void;
@@ -1,5 +1,5 @@
1
1
  import type { HideOutsideRule, LngLat } from "../../common/types";
2
- import type { DraggableProps, FeatureClickEvents } from "../MMapFeature/types";
2
+ import type { BlockingProps, DraggableProps, FeatureClickEvents } from "../MMapFeature/types";
3
3
  import { MMapGroupEntity } from "../MMapEnities";
4
4
  import { overrideKeyReactify } from "../wrappers";
5
5
  /**
@@ -43,7 +43,7 @@ type MMapMarkerProps = {
43
43
  * A point will be removed from the map if its coordinates are 1000px outside the visible area of the map.
44
44
  */
45
45
  hideOutsideViewport?: HideOutsideRule;
46
- } & DraggableProps<MMapMarkerEventHandler> & FeatureClickEvents;
46
+ } & DraggableProps<MMapMarkerEventHandler> & BlockingProps & FeatureClickEvents;
47
47
  declare const defaultProps: Readonly<{
48
48
  draggable: false;
49
49
  mapFollowsOnDrag: false;
@@ -137,7 +137,7 @@ declare class MMapMarker extends MMapGroupEntity<MMapMarkerProps, DefaultProps>
137
137
  * A point will be removed from the map if its coordinates are 1000px outside the visible area of the map.
138
138
  */
139
139
  hideOutsideViewport?: HideOutsideRule | undefined;
140
- } & DraggableProps<MMapMarkerEventHandler> & FeatureClickEvents & {
140
+ } & DraggableProps<MMapMarkerEventHandler> & BlockingProps & FeatureClickEvents & {
141
141
  markerElement?: HTMLElement | undefined;
142
142
  }, {}, import("../Entities").GenericRootEntity<unknown, {}>>> | undefined;
143
143
  key?: import("react").Key | null | undefined;
@@ -145,15 +145,6 @@ declare class MMapMarker extends MMapGroupEntity<MMapMarkerProps, DefaultProps>
145
145
  readonly element: HTMLElement;
146
146
  private _destroyDomCtx?;
147
147
  constructor(props: MMapMarkerProps, element?: HTMLElement);
148
- protected _getDefaultProps(): Readonly<{
149
- draggable: false;
150
- mapFollowsOnDrag: false;
151
- blockEvents: false;
152
- blockBehaviors: false;
153
- hideOutsideViewport: false;
154
- zIndex: 0;
155
- source: "mappable-default-feature";
156
- }>;
157
148
  private __feature;
158
149
  get properties(): Record<string, unknown> | undefined;
159
150
  get coordinates(): LngLat;
@@ -1,6 +1,7 @@
1
1
  interface Apikeys {
2
2
  suggest?: string;
3
3
  router?: string;
4
+ search?: string;
4
5
  }
5
6
  export declare class Config {
6
7
  readonly description: string;
@@ -1,7 +1,8 @@
1
- import type { BaseRouteResponse, RouteFeature, RouteOptions, RawRoute } from "./interface";
1
+ import type { BaseRouteResponse, RawRoute, RouteFeature, RouteOptions } from "./interface";
2
2
  export declare class DrivingRouteResponse implements BaseRouteResponse {
3
3
  #private;
4
4
  private _options?;
5
5
  constructor(data: RawRoute, options?: RouteOptions);
6
6
  toRoute(): RouteFeature;
7
+ toSteps(): RouteFeature[];
7
8
  }
@@ -1,4 +1,4 @@
1
1
  import { Config } from "../config";
2
- import type { BaseRouteResponse, RouteOptions, RouteFeature } from "./interface";
2
+ import type { BaseRouteResponse, RouteFeature, RouteOptions, TruckParameters } from "./interface";
3
3
  export declare function route(options: RouteOptions, config?: Config | undefined): Promise<BaseRouteResponse[]>;
4
- export { RouteOptions, BaseRouteResponse, RouteFeature };
4
+ export { BaseRouteResponse, RouteFeature, RouteOptions, TruckParameters };
@@ -3,6 +3,7 @@ export interface RawStep {
3
3
  length: number;
4
4
  duration: number;
5
5
  mode: string;
6
+ feature_class?: string;
6
7
  polyline: {
7
8
  points: LngLat[];
8
9
  };
@@ -24,7 +25,11 @@ export interface RawRoute {
24
25
  export interface RouteFeature extends GenericFeature<LngLat> {
25
26
  geometry: LineStringGeometry;
26
27
  properties: {
28
+ length?: number;
29
+ duration?: number;
30
+ mode?: string;
27
31
  bounds?: LngLatBounds;
32
+ featureClass?: string;
28
33
  flags?: {
29
34
  hasTolls?: boolean;
30
35
  hasNonTransactionalTolls?: boolean;
@@ -34,14 +39,38 @@ export interface RouteFeature extends GenericFeature<LngLat> {
34
39
  export interface BaseRouteResponse {
35
40
  /** Return requested route as {@link RouteFeature RouteFeature}. */
36
41
  toRoute(): RouteFeature;
42
+ /** Returns requested route, divided into steps, as {@link RouteFeature RouteFeature}[]. */
43
+ toSteps(): RouteFeature[];
44
+ }
45
+ export interface TruckParameters {
46
+ /** Vehicle weight in tons */
47
+ weight?: number;
48
+ /** Actual vehicle axle load in tons */
49
+ axleWeight?: number;
50
+ /** Maximum allowed vehicle weight in tons */
51
+ maxWeight?: number;
52
+ /** Maximum vehicle load capacity in tons */
53
+ payload?: number;
54
+ /** Vehicle height in meters */
55
+ height?: number;
56
+ /** Vehicle width in meters */
57
+ width?: number;
58
+ /** Vehicle length in meters */
59
+ length?: number;
60
+ /** Vehicle emission standard (number from 1 to 6, for example, 1 corresponds to Euro-1 class) */
61
+ ecoClass?: number;
62
+ /** Has a truck trailer */
63
+ hasTrailer?: boolean;
37
64
  }
38
65
  export interface RouteOptions {
39
66
  /** Route points represented by {@link LngLat LngLat} coordinates. */
40
67
  points: LngLat[];
41
- /** Route type. Only 'driving' type is available at this moment. */
42
- type: 'driving';
68
+ /** Route type. */
69
+ type: 'driving' | 'truck' | 'walking' | 'transit';
43
70
  /** If specified, bounding box of the route will be returned in properties. Default is `false`. */
44
71
  bounds?: boolean;
45
72
  /** Avoid roads with tolls. Default is `false`. */
46
73
  avoidTolls?: boolean;
74
+ /** Parameters for a truck (only for `type=truck`). */
75
+ truck?: TruckParameters;
47
76
  }
@@ -0,0 +1,8 @@
1
+ import type { BaseRouteResponse, RawRoute, RouteFeature, RouteOptions } from "./interface";
2
+ export declare class TransitRouteResponse implements BaseRouteResponse {
3
+ #private;
4
+ private _options?;
5
+ constructor(data: RawRoute, options?: RouteOptions);
6
+ toRoute(): RouteFeature;
7
+ toSteps(): RouteFeature[];
8
+ }
@@ -0,0 +1,8 @@
1
+ import type { BaseRouteResponse, RawRoute, RouteFeature, RouteOptions } from "./interface";
2
+ export declare class TruckRouteResponse implements BaseRouteResponse {
3
+ #private;
4
+ private _options?;
5
+ constructor(data: RawRoute, options?: RouteOptions);
6
+ toRoute(): RouteFeature;
7
+ toSteps(): RouteFeature[];
8
+ }
@@ -1,2 +1,3 @@
1
- import type { LngLatBounds } from "../../../common/types";
1
+ import type { LngLat, LngLatBounds } from "../../../common/types";
2
2
  export declare function isFiniteBounds(bounds: LngLatBounds): boolean;
3
+ export declare function boundsFromCoordinates(coordinates: LngLat[]): LngLatBounds;
@@ -1,2 +1,4 @@
1
1
  export * from "./bounds";
2
2
  export * from "./points";
3
+ export * from "./step-to-feature";
4
+ export * from "./to-route";
@@ -0,0 +1,2 @@
1
+ import type { RawRoute, RawStep, RouteFeature, RouteOptions } from "../interface";
2
+ export declare function stepToBasicRouteFeature(step: RawStep, featureId: string, route: RawRoute["route"], options?: RouteOptions): RouteFeature;
@@ -0,0 +1,2 @@
1
+ import type { RawRoute, RouteFeature, RouteOptions } from "../interface";
2
+ export declare function toRoute(rawRoute: RawRoute, featureId: string, options?: RouteOptions): RouteFeature;
@@ -0,0 +1,8 @@
1
+ import type { BaseRouteResponse, RawRoute, RouteFeature, RouteOptions } from "./interface";
2
+ export declare class WalkingRouteResponse implements BaseRouteResponse {
3
+ #private;
4
+ private _options?;
5
+ constructor(data: RawRoute, options?: RouteOptions);
6
+ toRoute(): RouteFeature;
7
+ toSteps(): RouteFeature[];
8
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mappable-world/mappable-types",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
4
4
  "description": "Types for mappable maps library",
5
5
  "main": "",
6
6
  "types": "index.d.ts",
@@ -25,7 +25,7 @@ type DefaultProps = typeof defaultProps;
25
25
  * map.addChild(controls);
26
26
  * ```
27
27
  */
28
- declare class MMapZoomControl extends mappable.MMapComplexEntity<MMapZoomControlProps> {
28
+ declare class MMapZoomControl extends mappable.MMapComplexEntity<MMapZoomControlProps, DefaultProps> {
29
29
  static [mappable.optionsKeyVuefy]: CustomVuefyOptions<MMapZoomControl>;
30
30
  static defaultProps: Readonly<{
31
31
  duration: 200;
@@ -15,7 +15,6 @@ export type Reactify = {
15
15
  module: ReactifyModule;
16
16
  entity: ReactifyEntity;
17
17
  };
18
- export declare const moduleOverrideExport: string;
19
18
  export type CustomReactify<TEntity extends GenericEntity<unknown>, TResult> = (ctor: EntityConstructor<TEntity>, params: {
20
19
  reactify: {
21
20
  module: ReactifyModule;
@@ -40,7 +39,9 @@ export type GetReactContext<TContext extends Context<unknown>> = (context?: TCon
40
39
  export type ReactifiedModule<TModule extends BaseModule> = {
41
40
  [Property in keyof TModule]: TModule[Property] extends EntityConstructor<GenericEntity<unknown>> ? ReturnType<InternalReactifyEntity<TModule[Property]>> : TModule[Property] extends Context<any> ? ReturnType<GetReactContext<TModule[Property]>> : TModule[Property];
42
41
  };
43
- export type BaseModule = Record<string | symbol, unknown>;
42
+ export type BaseModule = Record<string | symbol, unknown> & {
43
+ __implReactifyOverride?: (reactify: Reactify) => object;
44
+ };
44
45
  export type Prettify<T> = {
45
46
  [K in keyof T]: T[K];
46
47
  } & {};