From 56e554486a9e2d5035954bc2f568c92b8ec190cb Mon Sep 17 00:00:00 2001 From: Ty Rauber Date: Mon, 15 Jul 2024 13:22:49 +0200 Subject: [PATCH] fix: prettier config --- .eslintrc.js | 7 - .prettierrc.js | 7 - example/src/assets/index.d.ts | 6 +- .../examples/Annotations/CustomCallout.tsx | 48 +- example/src/examples/Map/ShowMap.tsx | 23 +- .../src/examples/Map/ShowMapLocalStyle.tsx | 16 +- example/src/examples/common/Page.tsx | 14 +- javascript/@types/assets.d.ts | 2 +- javascript/MLNModule.ts | 4 +- javascript/Maplibre.ts | 72 +- javascript/components/BackgroundLayer.tsx | 16 +- javascript/components/Callout.tsx | 38 +- javascript/components/Camera.tsx | 54 +- javascript/components/CircleLayer.tsx | 16 +- javascript/components/FillExtrusionLayer.tsx | 16 +- javascript/components/FillLayer.tsx | 16 +- javascript/components/HeadingIndicator.tsx | 14 +- javascript/components/HeatmapLayer.tsx | 16 +- javascript/components/ImageSource.tsx | 14 +- javascript/components/Images.tsx | 36 +- javascript/components/Light.tsx | 29 +- javascript/components/LineLayer.tsx | 16 +- javascript/components/MapView.tsx | 142 ++-- javascript/components/MarkerView.tsx | 18 +- javascript/components/NativeUserLocation.tsx | 8 +- javascript/components/PointAnnotation.tsx | 32 +- javascript/components/RasterLayer.tsx | 16 +- javascript/components/RasterSource.tsx | 20 +- javascript/components/ShapeSource.tsx | 100 +-- javascript/components/Style.tsx | 110 +-- javascript/components/SymbolLayer.tsx | 18 +- javascript/components/UserLocation.tsx | 45 +- javascript/components/VectorSource.tsx | 36 +- .../components/annotations/Annotation.tsx | 25 +- javascript/hooks/useAbstractLayer.ts | 25 +- javascript/hooks/useAbstractSource.ts | 4 +- javascript/hooks/useNativeBridge.ts | 14 +- javascript/hooks/useNativeRef.ts | 4 +- javascript/hooks/useOnce.ts | 2 +- javascript/index.ts | 4 +- .../modules/location/locationManager.ts | 8 +- .../offline/OfflineCreatePackOptions.ts | 10 +- javascript/modules/offline/OfflinePack.ts | 6 +- javascript/modules/offline/offlineManager.ts | 16 +- .../modules/snapshot/SnapshotOptions.ts | 8 +- .../modules/snapshot/snapshotManager.ts | 4 +- .../requestAndroidLocationPermissions.ts | 6 +- javascript/types/index.ts | 6 +- javascript/utils/BridgeValue.ts | 40 +- javascript/utils/Logger.ts | 28 +- javascript/utils/MaplibreStyles.d.ts | 718 +++++++++--------- javascript/utils/StyleValue.ts | 20 +- .../animated/AbstractAnimatedCoordinates.ts | 12 +- javascript/utils/animated/Animated.ts | 28 +- .../animated/AnimatedCoordinatesArray.ts | 14 +- .../AnimatedExtractCoordinateFromArray.ts | 6 +- javascript/utils/animated/AnimatedPoint.ts | 14 +- .../animated/AnimatedRouteCoordinatesArray.ts | 30 +- javascript/utils/animated/AnimatedShape.ts | 30 +- javascript/utils/deprecation.ts | 2 +- javascript/utils/filterUtils.ts | 2 +- javascript/utils/geoUtils.ts | 16 +- javascript/utils/index.ts | 28 +- package.json | 24 +- plugin/src/__tests__/withMapLibre-test.ts | 24 +- plugin/src/withMapLibre.ts | 64 +- yarn.lock | 12 +- 67 files changed, 1152 insertions(+), 1127 deletions(-) delete mode 100644 .eslintrc.js delete mode 100644 .prettierrc.js diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 4904bb712..000000000 --- a/.eslintrc.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - "root": true, - "extends": [ - 'universe/native' - ], - "ignorePatterns": ["node_modules/*", "*.js", "**/dist/*.js", "/plugin/build"] -} \ No newline at end of file diff --git a/.prettierrc.js b/.prettierrc.js deleted file mode 100644 index 84196d95f..000000000 --- a/.prettierrc.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - bracketSpacing: false, - jsxBracketSameLine: true, - singleQuote: true, - trailingComma: 'all', - arrowParens: 'avoid', -}; diff --git a/example/src/assets/index.d.ts b/example/src/assets/index.d.ts index f0d408a79..c1bbaa182 100644 --- a/example/src/assets/index.d.ts +++ b/example/src/assets/index.d.ts @@ -1,14 +1,14 @@ -declare module '*.jpg' { +declare module "*.jpg" { const content: number; export default content; } -declare module '*.png' { +declare module "*.png" { const content: number; export default content; } -declare module '*.json' { +declare module "*.json" { const content: string; export default content; } diff --git a/example/src/examples/Annotations/CustomCallout.tsx b/example/src/examples/Annotations/CustomCallout.tsx index 06453fe67..2451e429e 100644 --- a/example/src/examples/Annotations/CustomCallout.tsx +++ b/example/src/examples/Annotations/CustomCallout.tsx @@ -1,11 +1,11 @@ -import MapLibreGL, {SymbolLayerStyle} from '@maplibre/maplibre-react-native'; -import {Feature} from '@turf/helpers/dist/js'; -import React, {FC, useState, ReactElement} from 'react'; -import {View, Text, ViewStyle, StyleProp, TextStyle} from 'react-native'; +import MapLibreGL, { SymbolLayerStyle } from "@maplibre/maplibre-react-native"; +import { Feature } from "@turf/helpers/dist/js"; +import React, { FC, useState, ReactElement } from "react"; +import { View, Text, ViewStyle, StyleProp, TextStyle } from "react-native"; -import exampleIcon from '../../assets/pin.png'; -import sheet from '../../styles/sheet'; -import Page from '../common/Page'; +import exampleIcon from "../../assets/pin.png"; +import sheet from "../../styles/sheet"; +import Page from "../common/Page"; const defaultCamera = { centerCoordinate: [12.338, 45.4385], @@ -13,17 +13,17 @@ const defaultCamera = { }; const featureCollection: GeoJSON.FeatureCollection = { - type: 'FeatureCollection', + type: "FeatureCollection", features: [ { - type: 'Feature', - id: '9d10456e-bdda-4aa9-9269-04c1667d4552', + type: "Feature", + id: "9d10456e-bdda-4aa9-9269-04c1667d4552", properties: { - icon: 'example', - message: 'Hello!', + icon: "example", + message: "Hello!", }, geometry: { - type: 'Point', + type: "Point", coordinates: [12.338, 45.4385], }, }, @@ -34,7 +34,7 @@ type CustomCalloutViewProps = { message: string; }; -const CustomCalloutView: FC = ({message}) => { +const CustomCalloutView: FC = ({ message }) => { return ( {message} @@ -48,7 +48,7 @@ type CustomCalloutProps = { const CustomCallout = (props: CustomCalloutProps): ReactElement => { const [selectedFeature, setSelectedFeature] = - useState>(); + useState>(); const onPinPress = (e: any): void => { if (selectedFeature) { @@ -67,7 +67,8 @@ const CustomCallout = (props: CustomCalloutProps): ReactElement => { + onPress={onPinPress} + > { {selectedFeature && ( + coordinate={selectedFeature.geometry.coordinates} + > )} @@ -94,21 +96,21 @@ interface CustomCalloutStyles { const styles: CustomCalloutStyles = { mapPinLayer: { iconAllowOverlap: true, - iconAnchor: 'bottom', + iconAnchor: "bottom", iconSize: 1.0, iconImage: exampleIcon, }, customCalloutText: { - color: 'black', + color: "black", fontSize: 16, }, calloutContainerStyle: { - backgroundColor: 'white', + backgroundColor: "white", width: 60, height: 40, - display: 'flex', - justifyContent: 'center', - alignItems: 'center', + display: "flex", + justifyContent: "center", + alignItems: "center", }, }; diff --git a/example/src/examples/Map/ShowMap.tsx b/example/src/examples/Map/ShowMap.tsx index f733c459f..ca0f14658 100755 --- a/example/src/examples/Map/ShowMap.tsx +++ b/example/src/examples/Map/ShowMap.tsx @@ -1,14 +1,14 @@ -import MapLibreGL from '@maplibre/maplibre-react-native'; -import React, {useState, useEffect, ReactElement} from 'react'; -import {Alert} from 'react-native'; +import MapLibreGL from "@maplibre/maplibre-react-native"; +import React, { useState, useEffect, ReactElement } from "react"; +import { Alert } from "react-native"; -import sheet from '../../styles/sheet'; -import {onSortOptions} from '../../utils'; -import TabBarPage from '../common/TabBarPage'; +import sheet from "../../styles/sheet"; +import { onSortOptions } from "../../utils"; +import TabBarPage from "../common/TabBarPage"; const ShowMap = (): ReactElement => { const _mapOptions = Object.keys(MapLibreGL.StyleURL) - .map(key => { + .map((key) => { return { label: key, data: (MapLibreGL.StyleURL as any)[key], // bad any, because enums @@ -16,7 +16,7 @@ const ShowMap = (): ReactElement => { }) .sort(onSortOptions); - const [styleURL, setStyleURL] = useState({styleURL: _mapOptions[0].data}); + const [styleURL, setStyleURL] = useState({ styleURL: _mapOptions[0].data }); useEffect(() => { MapLibreGL.locationManager.start(); @@ -30,18 +30,19 @@ const ShowMap = (): ReactElement => { index: number, newStyleURL: MapLibreGL.StyleURL, ): void => { - setStyleURL({styleURL: newStyleURL}); + setStyleURL({ styleURL: newStyleURL }); }; const onUserMarkerPress = (): void => { - Alert.alert('You pressed on the user location annotation'); + Alert.alert("You pressed on the user location annotation"); }; return ( + style={sheet.matchParent} + > diff --git a/example/src/examples/Map/ShowMapLocalStyle.tsx b/example/src/examples/Map/ShowMapLocalStyle.tsx index 344c7b35a..dc346f0cd 100644 --- a/example/src/examples/Map/ShowMapLocalStyle.tsx +++ b/example/src/examples/Map/ShowMapLocalStyle.tsx @@ -1,14 +1,14 @@ -import MapLibreGL from '@maplibre/maplibre-react-native'; -import React, {FC, useEffect} from 'react'; -import {Alert} from 'react-native'; +import MapLibreGL from "@maplibre/maplibre-react-native"; +import React, { FC, useEffect } from "react"; +import { Alert } from "react-native"; -import sheet from '../../styles/sheet'; -import Page from '../common/Page'; +import sheet from "../../styles/sheet"; +import Page from "../common/Page"; // eslint-disable-next-line @typescript-eslint/no-var-requires -const style = JSON.stringify(require('../../assets/map-styleURL-style.json')); +const style = JSON.stringify(require("../../assets/map-styleURL-style.json")); -const ShowMap: FC = props => { +const ShowMap: FC = (props) => { useEffect(() => { MapLibreGL.locationManager.start(); @@ -18,7 +18,7 @@ const ShowMap: FC = props => { }, []); const onUserMarkerPress = (): void => { - Alert.alert('You pressed on the user location annotation'); + Alert.alert("You pressed on the user location annotation"); }; return ( diff --git a/example/src/examples/common/Page.tsx b/example/src/examples/common/Page.tsx index 8f61339c1..6922eb934 100755 --- a/example/src/examples/common/Page.tsx +++ b/example/src/examples/common/Page.tsx @@ -1,16 +1,16 @@ -import {useNavigation, useRoute} from '@react-navigation/native'; -import React, {ReactElement} from 'react'; -import {View} from 'react-native'; +import { useNavigation, useRoute } from "@react-navigation/native"; +import React, { ReactElement } from "react"; +import { View } from "react-native"; -import MapHeader from './MapHeader'; -import colors from '../../styles/colors'; -import sheet from '../../styles/sheet'; +import MapHeader from "./MapHeader"; +import colors from "../../styles/colors"; +import sheet from "../../styles/sheet"; interface PageProps { children: ReactElement | ReactElement[]; } -const Page = ({children}: PageProps): ReactElement => { +const Page = ({ children }: PageProps): ReactElement => { const navigation = useNavigation(); const route = useRoute(); const label = route.name; diff --git a/javascript/@types/assets.d.ts b/javascript/@types/assets.d.ts index 00cf07cc4..d779e258a 100644 --- a/javascript/@types/assets.d.ts +++ b/javascript/@types/assets.d.ts @@ -1,4 +1,4 @@ -declare module '*.png' { +declare module "*.png" { const content: number; export default content; } diff --git a/javascript/MLNModule.ts b/javascript/MLNModule.ts index d90d705c4..78a28d9a1 100644 --- a/javascript/MLNModule.ts +++ b/javascript/MLNModule.ts @@ -1,4 +1,4 @@ -import {NativeModules} from 'react-native'; +import { NativeModules } from "react-native"; interface IMLNModule { StyleURL: { @@ -24,7 +24,7 @@ interface IMLNModule { setConnected(connected: boolean): void; } -const MLNModule: IMLNModule = {...NativeModules.MLNModule}; +const MLNModule: IMLNModule = { ...NativeModules.MLNModule }; export const { StyleURL, diff --git a/javascript/Maplibre.ts b/javascript/Maplibre.ts index d1d0e5b94..ee4ee08ed 100644 --- a/javascript/Maplibre.ts +++ b/javascript/Maplibre.ts @@ -1,6 +1,6 @@ -import {UserTrackingMode} from './components/Camera'; +import { UserTrackingMode } from "./components/Camera"; -export * from './MLNModule'; +export * from "./MLNModule"; export { default as Camera, UserTrackingMode, @@ -8,45 +8,45 @@ export { type CameraAnimationMode, type CameraBounds, type CameraRef, -} from './components/Camera'; -export {default as MapView, type MapViewRef} from './components/MapView'; -export {default as Light} from './components/Light'; -export {default as PointAnnotation} from './components/PointAnnotation'; -export type {PointAnnotationRef} from './components/PointAnnotation'; -export {default as Annotation} from './components/annotations/Annotation'; -export {default as Callout} from './components/Callout'; -export {requestAndroidLocationPermissions} from './requestAndroidLocationPermissions'; +} from "./components/Camera"; +export { default as MapView, type MapViewRef } from "./components/MapView"; +export { default as Light } from "./components/Light"; +export { default as PointAnnotation } from "./components/PointAnnotation"; +export type { PointAnnotationRef } from "./components/PointAnnotation"; +export { default as Annotation } from "./components/annotations/Annotation"; +export { default as Callout } from "./components/Callout"; +export { requestAndroidLocationPermissions } from "./requestAndroidLocationPermissions"; export { default as UserLocation, UserLocationRenderMode, -} from './components/UserLocation'; -export type {UserLocationRef} from './components/UserLocation'; -export {default as VectorSource} from './components/VectorSource'; -export {default as ShapeSource} from './components/ShapeSource'; -export type {ShapeSourceRef} from './components/ShapeSource'; -export {default as RasterSource} from './components/RasterSource'; -export {default as ImageSource} from './components/ImageSource'; -export {default as Images} from './components/Images'; -export {default as FillLayer} from './components/FillLayer'; -export {default as FillExtrusionLayer} from './components/FillExtrusionLayer'; -export {default as HeatmapLayer} from './components/HeatmapLayer'; -export {default as LineLayer} from './components/LineLayer'; -export {default as CircleLayer} from './components/CircleLayer'; -export {default as SymbolLayer} from './components/SymbolLayer'; -export {default as RasterLayer} from './components/RasterLayer'; -export {default as BackgroundLayer} from './components/BackgroundLayer'; +} from "./components/UserLocation"; +export type { UserLocationRef } from "./components/UserLocation"; +export { default as VectorSource } from "./components/VectorSource"; +export { default as ShapeSource } from "./components/ShapeSource"; +export type { ShapeSourceRef } from "./components/ShapeSource"; +export { default as RasterSource } from "./components/RasterSource"; +export { default as ImageSource } from "./components/ImageSource"; +export { default as Images } from "./components/Images"; +export { default as FillLayer } from "./components/FillLayer"; +export { default as FillExtrusionLayer } from "./components/FillExtrusionLayer"; +export { default as HeatmapLayer } from "./components/HeatmapLayer"; +export { default as LineLayer } from "./components/LineLayer"; +export { default as CircleLayer } from "./components/CircleLayer"; +export { default as SymbolLayer } from "./components/SymbolLayer"; +export { default as RasterLayer } from "./components/RasterLayer"; +export { default as BackgroundLayer } from "./components/BackgroundLayer"; export { default as locationManager, type Location, -} from './modules/location/locationManager'; -export {default as offlineManager} from './modules/offline/offlineManager'; -export {default as OfflineCreatePackOptions} from './modules/offline/OfflineCreatePackOptions'; -export {default as snapshotManager} from './modules/snapshot/snapshotManager'; -export type {SnapshotInputOptions} from './modules/snapshot/SnapshotOptions'; -export {default as MarkerView} from './components/MarkerView'; -export {default as Animated} from './utils/animated/Animated'; -export {default as Style} from './components/Style'; -export {default as Logger, type LogLevel} from './utils/Logger'; +} from "./modules/location/locationManager"; +export { default as offlineManager } from "./modules/offline/offlineManager"; +export { default as OfflineCreatePackOptions } from "./modules/offline/OfflineCreatePackOptions"; +export { default as snapshotManager } from "./modules/snapshot/snapshotManager"; +export type { SnapshotInputOptions } from "./modules/snapshot/SnapshotOptions"; +export { default as MarkerView } from "./components/MarkerView"; +export { default as Animated } from "./utils/animated/Animated"; +export { default as Style } from "./components/Style"; +export { default as Logger, type LogLevel } from "./utils/Logger"; export type { FillLayerStyleProps as FillLayerStyle, LineLayerStyleProps as LineLayerStyle, @@ -58,7 +58,7 @@ export type { HillshadeLayerStyleProps as HillshadeLayerStyle, BackgroundLayerStyleProps as BackgroundLayerStyle, LightLayerStyleProps as LightLayerStyle, -} from './utils/MaplibreStyles'; +} from "./utils/MaplibreStyles"; /** @deprecated UserTrackingModes is deprecated use UserTrackingMode */ export const UserTrackingModes = UserTrackingMode; diff --git a/javascript/components/BackgroundLayer.tsx b/javascript/components/BackgroundLayer.tsx index 288d83195..6b3c854bc 100644 --- a/javascript/components/BackgroundLayer.tsx +++ b/javascript/components/BackgroundLayer.tsx @@ -1,16 +1,16 @@ -import React from 'react'; -import {NativeModules, requireNativeComponent} from 'react-native'; +import React from "react"; +import { NativeModules, requireNativeComponent } from "react-native"; import useAbstractLayer, { BaseLayerProps, NativeBaseProps, -} from '../hooks/useAbstractLayer'; -import BaseProps from '../types/BaseProps'; -import {BackgroundLayerStyleProps} from '../utils/MaplibreStyles'; +} from "../hooks/useAbstractLayer"; +import BaseProps from "../types/BaseProps"; +import { BackgroundLayerStyleProps } from "../utils/MaplibreStyles"; const MapLibreGL = NativeModules.MLNModule; -export const NATIVE_MODULE_NAME = 'RCTMLNBackgroundLayer'; +export const NATIVE_MODULE_NAME = "RCTMLNBackgroundLayer"; export interface BackgroundLayerProps extends BaseProps, BaseLayerProps { /** @@ -20,7 +20,7 @@ export interface BackgroundLayerProps extends BaseProps, BaseLayerProps { } interface NativeProps - extends Omit, + extends Omit, NativeBaseProps {} const RCTMLNBackgroundLayer = @@ -30,7 +30,7 @@ const BackgroundLayer: React.FC = ({ sourceID = MapLibreGL.StyleSource.DefaultSourceID, ...props }: BackgroundLayerProps) => { - const {baseProps, setNativeLayer} = useAbstractLayer< + const { baseProps, setNativeLayer } = useAbstractLayer< BackgroundLayerProps, NativeProps >({ diff --git a/javascript/components/Callout.tsx b/javascript/components/Callout.tsx index b8a10a20e..c94723f66 100644 --- a/javascript/components/Callout.tsx +++ b/javascript/components/Callout.tsx @@ -1,4 +1,4 @@ -import React, {ReactElement} from 'react'; +import React, { ReactElement } from "react"; import { View, Text, @@ -8,47 +8,47 @@ import { ViewStyle, ViewProps, StyleProp, -} from 'react-native'; +} from "react-native"; -export const NATIVE_MODULE_NAME = 'RCTMLNCallout'; +export const NATIVE_MODULE_NAME = "RCTMLNCallout"; const styles = StyleSheet.create({ container: { - alignItems: 'center', - justifyContent: 'center', + alignItems: "center", + justifyContent: "center", width: 180, zIndex: 9999999, }, content: { - backgroundColor: 'white', - borderColor: 'rgba(0, 0, 0, 0.2)', + backgroundColor: "white", + borderColor: "rgba(0, 0, 0, 0.2)", borderRadius: 3, borderWidth: 1, flex: 1, padding: 8, - position: 'relative', + position: "relative", }, tip: { - backgroundColor: 'transparent', - borderBottomColor: 'transparent', + backgroundColor: "transparent", + borderBottomColor: "transparent", borderBottomWidth: 0, - borderLeftColor: 'transparent', + borderLeftColor: "transparent", borderLeftWidth: 8, - borderRightColor: 'transparent', + borderRightColor: "transparent", borderRightWidth: 8, - borderTopColor: 'white', + borderTopColor: "white", borderTopWidth: 16, elevation: 0, marginTop: -2, zIndex: 1000, }, title: { - color: 'black', - textAlign: 'center', + color: "black", + textAlign: "center", }, }); -interface CalloutProps extends Omit { +interface CalloutProps extends Omit { /** * String that get's displayed in the default callout. */ @@ -75,7 +75,7 @@ interface CalloutProps extends Omit { textStyle?: ViewStyle; } -interface NativeProps extends Omit { +interface NativeProps extends Omit { style: StyleProp; } @@ -95,9 +95,9 @@ const Callout = (props: CalloutProps): ReactElement => { const _containerStyle: ViewStyle[] = [ { - position: 'absolute', + position: "absolute", zIndex: 999, - backgroundColor: 'transparent', + backgroundColor: "transparent", ...containerStyle, } as ViewStyle, ]; diff --git a/javascript/components/Camera.tsx b/javascript/components/Camera.tsx index f3eaa0fff..93407b9ff 100644 --- a/javascript/components/Camera.tsx +++ b/javascript/components/Camera.tsx @@ -6,27 +6,27 @@ import React, { useMemo, useRef, useCallback, -} from 'react'; -import {NativeModules, requireNativeComponent, ViewProps} from 'react-native'; +} from "react"; +import { NativeModules, requireNativeComponent, ViewProps } from "react-native"; -import {useNativeRef} from '../hooks/useNativeRef'; -import {MaplibreGLEvent} from '../types'; -import {toJSONString} from '../utils'; -import * as geoUtils from '../utils/geoUtils'; +import { useNativeRef } from "../hooks/useNativeRef"; +import { MaplibreGLEvent } from "../types"; +import { toJSONString } from "../utils"; +import * as geoUtils from "../utils/geoUtils"; const MapLibreGL = NativeModules.MLNModule; -export const NATIVE_MODULE_NAME = 'RCTMLNCamera'; +export const NATIVE_MODULE_NAME = "RCTMLNCamera"; export enum UserTrackingMode { - Follow = 'normal', - FollowWithHeading = 'compass', - FollowWithCourse = 'course', + Follow = "normal", + FollowWithHeading = "compass", + FollowWithCourse = "course", } export type UserTrackingModeChangeCallback = ( event: MaplibreGLEvent< - 'usertrackingmodechange', + "usertrackingmodechange", { followUserLocation: boolean; followUserMode: UserTrackingMode | null; @@ -96,8 +96,8 @@ interface CameraBoundsWithPadding extends CameraBounds, Partial {} -type NativeAnimationMode = 'flight' | 'ease' | 'linear' | 'none' | 'move'; -export type CameraAnimationMode = 'flyTo' | 'easeTo' | 'linearTo' | 'moveTo'; +type NativeAnimationMode = "flight" | "ease" | "linear" | "none" | "move"; +export type CameraAnimationMode = "flyTo" | "easeTo" | "linearTo" | "moveTo"; export interface NativeCameraStop extends Required { mode: NativeAnimationMode; @@ -133,7 +133,7 @@ export type CameraStops = { stops: CameraStop[]; }; -interface CameraProps extends Omit, CameraStop { +interface CameraProps extends Omit, CameraStop { /** * If false, the camera will not send any props to the native module. Intended to be used to prevent unnecessary tile fetching and improve performance when the map is not visible. Defaults to true. */ @@ -193,7 +193,7 @@ interface CameraProps extends Omit, CameraStop { onUserTrackingModeChange?: UserTrackingModeChangeCallback; } -interface NativeProps extends Omit { +interface NativeProps extends Omit { maxBounds: string | null; stop: NativeCameraStop | null; defaultStop: NativeCameraStop | null; @@ -204,7 +204,7 @@ const Camera = memo( ( { allowUpdates = true, - animationMode = 'easeTo', + animationMode = "easeTo", animationDuration = 2000, ...rest }: CameraProps, @@ -340,7 +340,7 @@ const Camera = memo( } if (config.bounds && config.bounds.ne && config.bounds.sw) { - const {ne, sw} = config.bounds; + const { ne, sw } = config.bounds; stopConfig.bounds = toJSONString(geoUtils.makeLatLngBounds(ne, sw)); } @@ -351,7 +351,7 @@ const Camera = memo( const _setCamera = useCallback( (config: CameraStop | CameraStops = {}): void => { - if ('stops' in config) { + if ("stops" in config) { let nativeStops: NativeCameraStop[] = []; for (const stop of config.stops) { @@ -360,12 +360,12 @@ const Camera = memo( nativeStops = [...nativeStops, nativeStop]; } } - cameraRef.current?.setNativeProps({stop: {stops: nativeStops}}); + cameraRef.current?.setNativeProps({ stop: { stops: nativeStops } }); } else { const nativeStop = _createStopConfig(config); if (nativeStop) { - cameraRef.current?.setNativeProps({stop: nativeStop}); + cameraRef.current?.setNativeProps({ stop: nativeStop }); } } }, @@ -521,7 +521,7 @@ const Camera = memo( }, padding: pad, animationDuration, - animationMode: 'easeTo', + animationMode: "easeTo", }); }; @@ -532,7 +532,7 @@ const Camera = memo( setCamera({ centerCoordinate: coordinates, animationDuration, - animationMode: 'flyTo', + animationMode: "flyTo", }); }; @@ -550,7 +550,7 @@ const Camera = memo( setCamera({ zoomLevel, animationDuration, - animationMode: 'flyTo', + animationMode: "flyTo", }); }; @@ -569,7 +569,7 @@ const Camera = memo( _defaultCamera.current = _createStopConfig( { ...props.defaultSettings, - animationMode: 'moveTo', + animationMode: "moveTo", }, true, ); @@ -580,11 +580,11 @@ const Camera = memo( config: CameraStop, ): NativeAnimationMode => { switch (config.animationMode) { - case 'flyTo': + case "flyTo": return MapLibreGL.CameraModes.Flight; - case 'moveTo': + case "moveTo": return MapLibreGL.CameraModes.None; - case 'linearTo': + case "linearTo": return MapLibreGL.CameraModes.Linear; default: return MapLibreGL.CameraModes.Ease; diff --git a/javascript/components/CircleLayer.tsx b/javascript/components/CircleLayer.tsx index aa273f9c4..46d5418d6 100644 --- a/javascript/components/CircleLayer.tsx +++ b/javascript/components/CircleLayer.tsx @@ -1,16 +1,16 @@ -import React from 'react'; -import {NativeModules, requireNativeComponent} from 'react-native'; +import React from "react"; +import { NativeModules, requireNativeComponent } from "react-native"; import useAbstractLayer, { BaseLayerProps, NativeBaseProps, -} from '../hooks/useAbstractLayer'; -import BaseProps from '../types/BaseProps'; -import {CircleLayerStyleProps} from '../utils/MaplibreStyles'; +} from "../hooks/useAbstractLayer"; +import BaseProps from "../types/BaseProps"; +import { CircleLayerStyleProps } from "../utils/MaplibreStyles"; const MapLibreGL = NativeModules.MLNModule; -export const NATIVE_MODULE_NAME = 'RCTMLNCircleLayer'; +export const NATIVE_MODULE_NAME = "RCTMLNCircleLayer"; export interface CircleLayerProps extends BaseProps, BaseLayerProps { /** @@ -20,7 +20,7 @@ export interface CircleLayerProps extends BaseProps, BaseLayerProps { } interface NativeProps - extends Omit, + extends Omit, NativeBaseProps {} const RCTMLNCircleLayer = @@ -33,7 +33,7 @@ const CircleLayer: React.FC = ({ sourceID = MapLibreGL.StyleSource.DefaultSourceID, ...props }: CircleLayerProps) => { - const {baseProps, setNativeLayer} = useAbstractLayer< + const { baseProps, setNativeLayer } = useAbstractLayer< CircleLayerProps, NativeProps >({ diff --git a/javascript/components/FillExtrusionLayer.tsx b/javascript/components/FillExtrusionLayer.tsx index 6adce2e58..a39ee5dd4 100644 --- a/javascript/components/FillExtrusionLayer.tsx +++ b/javascript/components/FillExtrusionLayer.tsx @@ -1,16 +1,16 @@ -import React from 'react'; -import {NativeModules, requireNativeComponent} from 'react-native'; +import React from "react"; +import { NativeModules, requireNativeComponent } from "react-native"; import useAbstractLayer, { BaseLayerProps, NativeBaseProps, -} from '../hooks/useAbstractLayer'; -import BaseProps from '../types/BaseProps'; -import {FillExtrusionLayerStyleProps} from '../utils/MaplibreStyles'; +} from "../hooks/useAbstractLayer"; +import BaseProps from "../types/BaseProps"; +import { FillExtrusionLayerStyleProps } from "../utils/MaplibreStyles"; const MapLibreGL = NativeModules.MLNModule; -export const NATIVE_MODULE_NAME = 'RCTMLNFillExtrusionLayer'; +export const NATIVE_MODULE_NAME = "RCTMLNFillExtrusionLayer"; export interface FillExtrusionLayerProps extends BaseProps, BaseLayerProps { /** @@ -20,7 +20,7 @@ export interface FillExtrusionLayerProps extends BaseProps, BaseLayerProps { } interface NativeProps - extends Omit, + extends Omit, NativeBaseProps {} const RCTMLNFillExtrusionLayer = @@ -33,7 +33,7 @@ const FillExtrusionLayer: React.FC = ({ sourceID = MapLibreGL.StyleSource.DefaultSourceID, ...props }: FillExtrusionLayerProps) => { - const {baseProps, setNativeLayer} = useAbstractLayer< + const { baseProps, setNativeLayer } = useAbstractLayer< FillExtrusionLayerProps, NativeProps >({ diff --git a/javascript/components/FillLayer.tsx b/javascript/components/FillLayer.tsx index fc1d5af48..a09203c87 100644 --- a/javascript/components/FillLayer.tsx +++ b/javascript/components/FillLayer.tsx @@ -1,16 +1,16 @@ -import React from 'react'; -import {NativeModules, requireNativeComponent} from 'react-native'; +import React from "react"; +import { NativeModules, requireNativeComponent } from "react-native"; import useAbstractLayer, { BaseLayerProps, NativeBaseProps, -} from '../hooks/useAbstractLayer'; -import BaseProps from '../types/BaseProps'; -import {FillLayerStyleProps} from '../utils/MaplibreStyles'; +} from "../hooks/useAbstractLayer"; +import BaseProps from "../types/BaseProps"; +import { FillLayerStyleProps } from "../utils/MaplibreStyles"; const MapLibreGL = NativeModules.MLNModule; -export const NATIVE_MODULE_NAME = 'RCTMLNFillLayer'; +export const NATIVE_MODULE_NAME = "RCTMLNFillLayer"; export interface FillLayerProps extends BaseProps, BaseLayerProps { /** @@ -19,7 +19,7 @@ export interface FillLayerProps extends BaseProps, BaseLayerProps { style?: FillLayerStyleProps; } -interface NativeProps extends Omit, NativeBaseProps {} +interface NativeProps extends Omit, NativeBaseProps {} const RCTMLNFillLayer = requireNativeComponent(NATIVE_MODULE_NAME); @@ -30,7 +30,7 @@ const FillLayer: React.FC = ({ sourceID = MapLibreGL.StyleSource.DefaultSourceID, ...props }: FillLayerProps) => { - const {baseProps, setNativeLayer} = useAbstractLayer< + const { baseProps, setNativeLayer } = useAbstractLayer< FillLayerProps, NativeProps >({ diff --git a/javascript/components/HeadingIndicator.tsx b/javascript/components/HeadingIndicator.tsx index 2591a2a4a..4e4d84792 100644 --- a/javascript/components/HeadingIndicator.tsx +++ b/javascript/components/HeadingIndicator.tsx @@ -1,21 +1,21 @@ -import React, {ReactElement} from 'react'; +import React, { ReactElement } from "react"; -import SymbolLayer from './SymbolLayer'; -import headingIcon from '../../assets/heading.png'; -import BaseProps from '../types/BaseProps'; +import SymbolLayer from "./SymbolLayer"; +import headingIcon from "../../assets/heading.png"; +import BaseProps from "../types/BaseProps"; const style = { iconImage: headingIcon, iconAllowOverlap: true, - iconPitchAlignment: 'map', - iconRotationAlignment: 'map', + iconPitchAlignment: "map", + iconRotationAlignment: "map", } as const; interface HeadingIndicatorProps extends BaseProps { heading?: number; } -const HeadingIndicator = ({heading}: HeadingIndicatorProps): ReactElement => ( +const HeadingIndicator = ({ heading }: HeadingIndicatorProps): ReactElement => ( , + extends Omit, NativeBaseProps {} const RCTMLNHeatmapLayer = @@ -32,7 +32,7 @@ const HeatmapLayer: React.FC = ({ sourceID = MapLibreGL.StyleSource.DefaultSourceID, ...props }: HeatmapLayerProps) => { - const {baseProps, setNativeLayer} = useAbstractLayer< + const { baseProps, setNativeLayer } = useAbstractLayer< HeatmapLayerProps, NativeProps >({ diff --git a/javascript/components/ImageSource.tsx b/javascript/components/ImageSource.tsx index 53b2584b5..2c2261397 100644 --- a/javascript/components/ImageSource.tsx +++ b/javascript/components/ImageSource.tsx @@ -1,15 +1,15 @@ -import React, {ReactElement} from 'react'; -import {requireNativeComponent} from 'react-native'; +import React, { ReactElement } from "react"; +import { requireNativeComponent } from "react-native"; -import useAbstractSource from '../hooks/useAbstractSource'; -import BaseProps from '../types/BaseProps'; +import useAbstractSource from "../hooks/useAbstractSource"; +import BaseProps from "../types/BaseProps"; import { cloneReactChildrenWithProps, isNumber, resolveImagePath, -} from '../utils'; +} from "../utils"; -export const NATIVE_MODULE_NAME = 'RCTMLNImageSource'; +export const NATIVE_MODULE_NAME = "RCTMLNImageSource"; export interface ImageSourceProps extends BaseProps { /** @@ -44,7 +44,7 @@ const RCTMLNImageSource = * The georeferenced image scales and rotates as the user zooms and rotates the map */ const ImageSource: React.FC = (props: ImageSourceProps) => { - const {setNativeRef} = useAbstractSource(); + const { setNativeRef } = useAbstractSource(); const _getURL = (): string | undefined => { return isNumber(props.url) ? resolveImagePath(props.url) : props.url; diff --git a/javascript/components/Images.tsx b/javascript/components/Images.tsx index f3efe6bed..e3595545d 100644 --- a/javascript/components/Images.tsx +++ b/javascript/components/Images.tsx @@ -1,39 +1,39 @@ -import React, {ReactElement} from 'react'; +import React, { ReactElement } from "react"; import { requireNativeComponent, Image, NativeSyntheticEvent, ImageSourcePropType, ImageURISource, -} from 'react-native'; +} from "react-native"; -import {SHAPE_SOURCE_NATIVE_ASSETS_KEY} from './ShapeSource'; -import BaseProps from '../types/BaseProps'; +import { SHAPE_SOURCE_NATIVE_ASSETS_KEY } from "./ShapeSource"; +import BaseProps from "../types/BaseProps"; -export const NATIVE_MODULE_NAME = 'RCTMLNImages'; +export const NATIVE_MODULE_NAME = "RCTMLNImages"; export type ImageEntry = string | ImageSourcePropType; function _isUrlOrPath(value: ImageEntry): boolean { return ( - (typeof value === 'string' || value instanceof String) && - (value.startsWith('file://') || - value.startsWith('http://') || - value.startsWith('https://') || - value.startsWith('data:') || - value.startsWith('asset://') || - value.startsWith('/')) + (typeof value === "string" || value instanceof String) && + (value.startsWith("file://") || + value.startsWith("http://") || + value.startsWith("https://") || + value.startsWith("data:") || + value.startsWith("asset://") || + value.startsWith("/")) ); } function _isImageSourcePropType( value: ImageEntry, ): value is ImageSourcePropType { - if (typeof value === 'number' || value instanceof Number) { + if (typeof value === "number" || value instanceof Number) { return true; } const valueAsSource = value as ImageURISource; - return !!valueAsSource.uri && typeof valueAsSource.uri === 'string'; + return !!valueAsSource.uri && typeof valueAsSource.uri === "string"; } interface ImagesProps extends BaseProps { @@ -42,7 +42,7 @@ interface ImagesProps extends BaseProps { * Keys are names - see iconImage expressions, values can be either urls-s objects * with format {uri: 'http://...'}` or `require('image.png')` or `import 'image.png'` */ - images?: {[key: string]: ImageEntry}; + images?: { [key: string]: ImageEntry }; /** * If you have an asset under Image.xcassets on iOS and the drawables directory on android * you can specify an array of string names with assets as the key `['pin']`. @@ -68,14 +68,14 @@ const Images = ({ children, }: ImagesProps): ReactElement => { const _getImages = (): { - images?: {[key: string]: ImageEntry}; + images?: { [key: string]: ImageEntry }; nativeImages?: ImageEntry[]; } => { if (!images && !nativeAssetImages) { return {}; } - const imagesResult: {[key: string]: ImageEntry} = {}; + const imagesResult: { [key: string]: ImageEntry } = {}; let nativeImages: ImageEntry[] = []; if (images) { @@ -112,7 +112,7 @@ const Images = ({ }; const _onImageMissing = ( - event: NativeSyntheticEvent<{payload: {imageKey: string}}>, + event: NativeSyntheticEvent<{ payload: { imageKey: string } }>, ): void => { if (onImageMissing) { onImageMissing(event.nativeEvent.payload.imageKey); diff --git a/javascript/components/Light.tsx b/javascript/components/Light.tsx index bf0eef50b..fb8e1beb3 100644 --- a/javascript/components/Light.tsx +++ b/javascript/components/Light.tsx @@ -1,12 +1,12 @@ -import React from 'react'; -import {requireNativeComponent} from 'react-native'; +import React from "react"; +import { requireNativeComponent } from "react-native"; -import useAbstractLayer, {BaseLayerProps} from '../hooks/useAbstractLayer'; -import BaseProps from '../types/BaseProps'; -import {LightLayerStyleProps} from '../utils/MaplibreStyles'; -import {StyleValue} from '../utils/StyleValue'; +import useAbstractLayer, { BaseLayerProps } from "../hooks/useAbstractLayer"; +import BaseProps from "../types/BaseProps"; +import { LightLayerStyleProps } from "../utils/MaplibreStyles"; +import { StyleValue } from "../utils/StyleValue"; -export const NATIVE_MODULE_NAME = 'RCTMLNLight'; +export const NATIVE_MODULE_NAME = "RCTMLNLight"; interface LightProps extends BaseProps, BaseLayerProps { /** @@ -15,8 +15,8 @@ interface LightProps extends BaseProps, BaseLayerProps { style?: LightLayerStyleProps; } -interface NativeProps extends Omit { - reactStyle?: {[key: string]: StyleValue}; +interface NativeProps extends Omit { + reactStyle?: { [key: string]: StyleValue }; } const RCTMLNLight = requireNativeComponent(NATIVE_MODULE_NAME); @@ -25,11 +25,12 @@ const RCTMLNLight = requireNativeComponent(NATIVE_MODULE_NAME); * Light represents the light source for extruded geometries */ const Light: React.FC = (props: LightProps) => { - const {baseProps, setNativeLayer} = useAbstractLayer( - { - ...props, - }, - ); + const { baseProps, setNativeLayer } = useAbstractLayer< + LightProps, + NativeProps + >({ + ...props, + }); return ( diff --git a/javascript/components/LineLayer.tsx b/javascript/components/LineLayer.tsx index 196d5b8f2..48148a0f3 100644 --- a/javascript/components/LineLayer.tsx +++ b/javascript/components/LineLayer.tsx @@ -1,16 +1,16 @@ -import React from 'react'; -import {NativeModules, requireNativeComponent} from 'react-native'; +import React from "react"; +import { NativeModules, requireNativeComponent } from "react-native"; import useAbstractLayer, { BaseLayerProps, NativeBaseProps, -} from '../hooks/useAbstractLayer'; -import BaseProps from '../types/BaseProps'; -import {LineLayerStyleProps} from '../utils/MaplibreStyles'; +} from "../hooks/useAbstractLayer"; +import BaseProps from "../types/BaseProps"; +import { LineLayerStyleProps } from "../utils/MaplibreStyles"; const MapLibreGL = NativeModules.MLNModule; -export const NATIVE_MODULE_NAME = 'RCTMLNLineLayer'; +export const NATIVE_MODULE_NAME = "RCTMLNLineLayer"; export interface LineLayerProps extends BaseProps, BaseLayerProps { /** @@ -19,7 +19,7 @@ export interface LineLayerProps extends BaseProps, BaseLayerProps { style?: LineLayerStyleProps; } -interface NativeProps extends Omit, NativeBaseProps {} +interface NativeProps extends Omit, NativeBaseProps {} const RCTMLNLineLayer = requireNativeComponent(NATIVE_MODULE_NAME); @@ -31,7 +31,7 @@ const LineLayer: React.FC = ({ sourceID = MapLibreGL.StyleSource.DefaultSourceID, ...props }: LineLayerProps) => { - const {baseProps, setNativeLayer} = useAbstractLayer< + const { baseProps, setNativeLayer } = useAbstractLayer< LineLayerProps, NativeProps >({ diff --git a/javascript/components/MapView.tsx b/javascript/components/MapView.tsx index 42387735b..857abc16f 100644 --- a/javascript/components/MapView.tsx +++ b/javascript/components/MapView.tsx @@ -1,4 +1,4 @@ -import debounce from 'debounce'; +import debounce from "debounce"; import React, { Component, memo, @@ -10,7 +10,7 @@ import React, { useMemo, useRef, useState, -} from 'react'; +} from "react"; import { View, StyleSheet, @@ -19,30 +19,30 @@ import { ViewProps, NativeMethods, NativeSyntheticEvent, -} from 'react-native'; +} from "react-native"; -import useNativeBridge from '../hooks/useNativeBridge'; -import useOnce from '../hooks/useOnce'; -import {Location} from '../modules/location/locationManager'; -import BaseProps from '../types/BaseProps'; -import {isFunction, isAndroid} from '../utils'; -import Logger from '../utils/Logger'; -import {FilterExpression} from '../utils/MaplibreStyles'; -import {getFilter} from '../utils/filterUtils'; +import useNativeBridge from "../hooks/useNativeBridge"; +import useOnce from "../hooks/useOnce"; +import { Location } from "../modules/location/locationManager"; +import BaseProps from "../types/BaseProps"; +import { isFunction, isAndroid } from "../utils"; +import Logger from "../utils/Logger"; +import { FilterExpression } from "../utils/MaplibreStyles"; +import { getFilter } from "../utils/filterUtils"; const MapLibreGL = NativeModules.MLNModule; if (MapLibreGL == null) { console.error( - 'Native part of Mapbox React Native libraries were not registered properly, double check our native installation guides.', + "Native part of Mapbox React Native libraries were not registered properly, double check our native installation guides.", ); } -export const NATIVE_MODULE_NAME = 'RCTMLNMapView'; +export const NATIVE_MODULE_NAME = "RCTMLNMapView"; -export const ANDROID_TEXTURE_NATIVE_MODULE_NAME = 'RCTMLNAndroidTextureMapView'; +export const ANDROID_TEXTURE_NATIVE_MODULE_NAME = "RCTMLNAndroidTextureMapView"; const styles = StyleSheet.create({ - matchParent: {flex: 1}, + matchParent: { flex: 1 }, }); const defaultStyleURL = MapLibreGL.StyleURL.Street; @@ -66,7 +66,7 @@ interface MapViewProps extends BaseProps { /** * Style for wrapping React Native View */ - style?: ViewProps['style']; + style?: ViewProps["style"]; /** * Style URL for map - notice, if non is set it _will_ default to `MapLibreGL.StyleURL.Default` */ @@ -117,10 +117,10 @@ interface MapViewProps extends BaseProps { * Adds attribution offset, e.g. `{top: 8, left: 8}` will put attribution button in top-left corner of the map */ attributionPosition?: - | {top?: number; left?: number} - | {top?: number; right?: number} - | {bottom?: number; left?: number} - | {bottom?: number; right?: number}; + | { top?: number; left?: number } + | { top?: number; right?: number } + | { bottom?: number; left?: number } + | { bottom?: number; right?: number }; /** * MapView's tintColor */ @@ -133,10 +133,10 @@ interface MapViewProps extends BaseProps { * Adds logo offset, e.g. `{top: 8, left: 8}` will put the logo in top-left corner of the map */ logoPosition?: - | {top?: number; left?: number} - | {top?: number; right?: number} - | {bottom?: number; left?: number} - | {bottom?: number; right?: number}; + | { top?: number; left?: number } + | { top?: number; right?: number } + | { bottom?: number; left?: number } + | { bottom?: number; right?: number }; /** * Enable/Disable the compass from appearing on the map */ @@ -248,9 +248,9 @@ type CallableProps = { : never; }[keyof MapViewProps]; -interface NativeProps extends Omit { - onPress(event: NativeSyntheticEvent<{payload: GeoJSON.Feature}>): void; - onLongPress(event: NativeSyntheticEvent<{payload: GeoJSON.Feature}>): void; +interface NativeProps extends Omit { + onPress(event: NativeSyntheticEvent<{ payload: GeoJSON.Feature }>): void; + onLongPress(event: NativeSyntheticEvent<{ payload: GeoJSON.Feature }>): void; } export interface MapViewRef { @@ -407,8 +407,11 @@ const MapView = memo( }), ); - const {_runNativeCommand, _runPendingNativeCommands, _onAndroidCallback} = - useNativeBridge(NATIVE_MODULE_NAME); + const { + _runNativeCommand, + _runPendingNativeCommands, + _onAndroidCallback, + } = useNativeBridge(NATIVE_MODULE_NAME); const logger = useRef(Logger.sharedInstance()); // * start the logger before anyuseEffect useOnce(() => { @@ -483,7 +486,7 @@ const MapView = memo( } _runNativeCommand( - 'setHandledMapChangedEvents', + "setHandledMapChangedEvents", _nativeRef.current, events, ); @@ -493,8 +496,8 @@ const MapView = memo( const getPointInView = async ( coordinate: GeoJSON.Position, ): Promise => { - const res: {pointInView: GeoJSON.Point} = await _runNativeCommand( - 'getPointInView', + const res: { pointInView: GeoJSON.Point } = await _runNativeCommand( + "getPointInView", _nativeRef.current, [coordinate], ); @@ -504,16 +507,16 @@ const MapView = memo( const getCoordinateFromView = async ( point: number[], ): Promise => { - const res: {coordinateFromView: GeoJSON.Position} = - await _runNativeCommand('getCoordinateFromView', _nativeRef.current, [ + const res: { coordinateFromView: GeoJSON.Position } = + await _runNativeCommand("getCoordinateFromView", _nativeRef.current, [ point, ]); return res.coordinateFromView; }; const getVisibleBounds = async (): Promise => { - const res: {visibleBounds: VisibleBounds} = await _runNativeCommand( - 'getVisibleBounds', + const res: { visibleBounds: VisibleBounds } = await _runNativeCommand( + "getVisibleBounds", _nativeRef.current, ); return res.visibleBounds; @@ -530,9 +533,9 @@ const MapView = memo( ); } - const res: {data: string | GeoJSON.FeatureCollection} = + const res: { data: string | GeoJSON.FeatureCollection } = await _runNativeCommand( - 'queryRenderedFeaturesAtPoint', + "queryRenderedFeaturesAtPoint", _nativeRef.current, [point, getFilter(filter), layerIDs], ); @@ -551,12 +554,12 @@ const MapView = memo( ): Promise => { if (!bbox || bbox.length !== 4) { throw new Error( - 'Must pass in a valid bounding box[top, right, bottom, left]', + "Must pass in a valid bounding box[top, right, bottom, left]", ); } - const res: {data: string | GeoJSON.FeatureCollection} = + const res: { data: string | GeoJSON.FeatureCollection } = await _runNativeCommand( - 'queryRenderedFeaturesInRect', + "queryRenderedFeaturesInRect", _nativeRef.current, [bbox, getFilter(filter), layerIDs], ); @@ -570,13 +573,13 @@ const MapView = memo( const setCamera = (): void => { console.warn( - 'MapView.setCamera is deprecated - please use Camera#setCamera', + "MapView.setCamera is deprecated - please use Camera#setCamera", ); }; const takeSnap = async (writeToDisk = false): Promise => { - const res: {uri: string} = await _runNativeCommand( - 'takeSnap', + const res: { uri: string } = await _runNativeCommand( + "takeSnap", _nativeRef.current, [writeToDisk], ); @@ -584,16 +587,16 @@ const MapView = memo( }; const getZoom = async (): Promise => { - const res: {zoom: number} = await _runNativeCommand( - 'getZoom', + const res: { zoom: number } = await _runNativeCommand( + "getZoom", _nativeRef.current, ); return res.zoom; }; const getCenter = async (): Promise => { - const res: {center: GeoJSON.Position} = await _runNativeCommand( - 'getCenter', + const res: { center: GeoJSON.Position } = await _runNativeCommand( + "getCenter", _nativeRef.current, ); return res.center; @@ -604,7 +607,7 @@ const MapView = memo( sourceId: string, sourceLayerId: string | null = null, ): void => { - _runNativeCommand('setSourceVisibility', _nativeRef.current, [ + _runNativeCommand("setSourceVisibility", _nativeRef.current, [ visible, sourceId, sourceLayerId, @@ -612,11 +615,11 @@ const MapView = memo( }; const showAttribution = async (): Promise => { - _runNativeCommand('showAttribution', _nativeRef.current); + _runNativeCommand("showAttribution", _nativeRef.current); }; const _onPress = ( - e: NativeSyntheticEvent<{payload: GeoJSON.Feature}>, + e: NativeSyntheticEvent<{ payload: GeoJSON.Feature }>, ): void => { if (isFunction(props.onPress)) { props.onPress(e.nativeEvent.payload); @@ -624,7 +627,7 @@ const MapView = memo( }; const _onLongPress = ( - e: NativeSyntheticEvent<{payload: GeoJSON.Feature}>, + e: NativeSyntheticEvent<{ payload: GeoJSON.Feature }>, ): void => { if (isFunction(props.onLongPress)) { props.onLongPress(e.nativeEvent.payload); @@ -665,7 +668,7 @@ const MapView = memo( payload?: GeoJSON.Feature | Location; }>, ): void => { - const {type, payload} = e.nativeEvent; + const { type, payload } = e.nativeEvent; let propName: CallableProps | undefined; switch (type) { @@ -680,11 +683,11 @@ const MapView = memo( ); } } else { - propName = 'onRegionWillChange'; + propName = "onRegionWillChange"; } break; case MapLibreGL.EventTypes.RegionIsChanging: - propName = 'onRegionIsChanging'; + propName = "onRegionIsChanging"; break; case MapLibreGL.EventTypes.RegionDidChange: if ( @@ -697,44 +700,44 @@ const MapView = memo( ); } } else { - propName = 'onRegionDidChange'; + propName = "onRegionDidChange"; } break; case MapLibreGL.EventTypes.UserLocationUpdated: - propName = 'onUserLocationUpdate'; + propName = "onUserLocationUpdate"; break; case MapLibreGL.EventTypes.WillStartLoadingMap: - propName = 'onWillStartLoadingMap'; + propName = "onWillStartLoadingMap"; break; case MapLibreGL.EventTypes.DidFinishLoadingMap: - propName = 'onDidFinishLoadingMap'; + propName = "onDidFinishLoadingMap"; break; case MapLibreGL.EventTypes.DidFailLoadingMap: - propName = 'onDidFailLoadingMap'; + propName = "onDidFailLoadingMap"; break; case MapLibreGL.EventTypes.WillStartRenderingFrame: - propName = 'onWillStartRenderingFrame'; + propName = "onWillStartRenderingFrame"; break; case MapLibreGL.EventTypes.DidFinishRenderingFrame: - propName = 'onDidFinishRenderingFrame'; + propName = "onDidFinishRenderingFrame"; break; case MapLibreGL.EventTypes.DidFinishRenderingFrameFully: - propName = 'onDidFinishRenderingFrameFully'; + propName = "onDidFinishRenderingFrameFully"; break; case MapLibreGL.EventTypes.WillStartRenderingMap: - propName = 'onWillStartRenderingMap'; + propName = "onWillStartRenderingMap"; break; case MapLibreGL.EventTypes.DidFinishRenderingMap: - propName = 'onDidFinishRenderingMap'; + propName = "onDidFinishRenderingMap"; break; case MapLibreGL.EventTypes.DidFinishRenderingMapFully: - propName = 'onDidFinishRenderingMapFully'; + propName = "onDidFinishRenderingMapFully"; break; case MapLibreGL.EventTypes.DidFinishLoadingStyle: - propName = 'onDidFinishLoadingStyle'; + propName = "onDidFinishLoadingStyle"; break; default: - console.warn('Unhandled event callback type', type); + console.warn("Unhandled event callback type", type); } if (propName) { @@ -856,7 +859,8 @@ const MapView = memo( + testID={mapView ? undefined : props.testID} + > {mapView} ); diff --git a/javascript/components/MarkerView.tsx b/javascript/components/MarkerView.tsx index d2cc5a7ce..f9a3a63a9 100644 --- a/javascript/components/MarkerView.tsx +++ b/javascript/components/MarkerView.tsx @@ -1,11 +1,11 @@ -import React, {ReactElement, useMemo} from 'react'; -import {Platform, requireNativeComponent, ViewProps} from 'react-native'; +import React, { ReactElement, useMemo } from "react"; +import { Platform, requireNativeComponent, ViewProps } from "react-native"; -import PointAnnotation from './PointAnnotation'; -import {toJSONString} from '../utils'; -import {makePoint} from '../utils/geoUtils'; +import PointAnnotation from "./PointAnnotation"; +import { toJSONString } from "../utils"; +import { makePoint } from "../utils/geoUtils"; -export const NATIVE_MODULE_NAME = 'RCTMLNMarkerView'; +export const NATIVE_MODULE_NAME = "RCTMLNMarkerView"; interface MarkerViewProps extends ViewProps { /** @@ -40,7 +40,7 @@ interface MarkerViewProps extends ViewProps { interface NativeProps extends ViewProps { coordinate: string | undefined; - anchor: {x: number; y: number}; + anchor: { x: number; y: number }; allowOverlap: boolean; isSelected: boolean; } @@ -63,7 +63,7 @@ const MarkerView = (props: MarkerViewProps): ReactElement => { return `MV-${MarkerView.lastId}`; }, []); - if (Platform.OS === 'ios') { + if (Platform.OS === "ios") { return ; } @@ -77,7 +77,7 @@ const MarkerView = (props: MarkerViewProps): ReactElement => { MarkerView.lastId = 0; MarkerView.defaultProps = { - anchor: {x: 0.5, y: 0.5}, + anchor: { x: 0.5, y: 0.5 }, allowOverlap: false, isSelected: false, }; diff --git a/javascript/components/NativeUserLocation.tsx b/javascript/components/NativeUserLocation.tsx index c5339a28d..60b78f072 100644 --- a/javascript/components/NativeUserLocation.tsx +++ b/javascript/components/NativeUserLocation.tsx @@ -1,7 +1,7 @@ -import React, {ReactElement} from 'react'; -import {requireNativeComponent} from 'react-native'; +import React, { ReactElement } from "react"; +import { requireNativeComponent } from "react-native"; -const NATIVE_MODULE_NAME = 'RCTMLNNativeUserLocation'; +const NATIVE_MODULE_NAME = "RCTMLNNativeUserLocation"; interface NativeUserLocationProps { /** @@ -13,7 +13,7 @@ interface NativeUserLocationProps { * * @platform android */ - androidRenderMode?: 'normal' | 'compass' | 'gps'; + androidRenderMode?: "normal" | "compass" | "gps"; /** * iOS only. A Boolean value indicating whether the user location annotation may display a permanent heading indicator. * diff --git a/javascript/components/PointAnnotation.tsx b/javascript/components/PointAnnotation.tsx index 07695c85c..cc1d4821f 100644 --- a/javascript/components/PointAnnotation.tsx +++ b/javascript/components/PointAnnotation.tsx @@ -5,25 +5,25 @@ import React, { useImperativeHandle, useRef, ReactElement, -} from 'react'; +} from "react"; import { Platform, StyleSheet, ViewProps, requireNativeComponent, -} from 'react-native'; +} from "react-native"; -import useNativeBridge, {RNMLEvent} from '../hooks/useNativeBridge'; -import {isFunction, toJSONString} from '../utils'; -import {makePoint} from '../utils/geoUtils'; +import useNativeBridge, { RNMLEvent } from "../hooks/useNativeBridge"; +import { isFunction, toJSONString } from "../utils"; +import { makePoint } from "../utils/geoUtils"; -export const NATIVE_MODULE_NAME = 'RCTMLNPointAnnotation'; +export const NATIVE_MODULE_NAME = "RCTMLNPointAnnotation"; const styles = StyleSheet.create({ container: { - alignItems: 'center', - justifyContent: 'center', - position: 'absolute', + alignItems: "center", + justifyContent: "center", + position: "absolute", }, }); @@ -104,10 +104,10 @@ export interface PointAnnotationProps { */ children: React.ReactElement | [React.ReactElement, React.ReactElement]; - style?: ViewProps['style']; + style?: ViewProps["style"]; } -interface NativeProps extends Omit { +interface NativeProps extends Omit { coordinate?: string; } @@ -128,7 +128,7 @@ export interface PointAnnotationRef { const PointAnnotation = forwardRef( ( { - anchor = {x: 0.5, y: 0.5}, + anchor = { x: 0.5, y: 0.5 }, draggable = false, ...props }: PointAnnotationProps, @@ -146,13 +146,13 @@ const PointAnnotation = forwardRef( }), ); - const {_runNativeCommand, _runPendingNativeCommands} = + const { _runNativeCommand, _runPendingNativeCommands } = useNativeBridge(NATIVE_MODULE_NAME); const _nativeRef = useRef | null>(); function refresh(): void { - if (Platform.OS === 'android') { - _runNativeCommand('refresh', _nativeRef.current, []); + if (Platform.OS === "android") { + _runNativeCommand("refresh", _nativeRef.current, []); } } @@ -237,7 +237,7 @@ const PointAnnotation = forwardRef( // eslint complains about it // not sure why only in this component -PointAnnotation.displayName = 'PointAnnotation'; +PointAnnotation.displayName = "PointAnnotation"; const RCTMLNPointAnnotation = requireNativeComponent(NATIVE_MODULE_NAME); diff --git a/javascript/components/RasterLayer.tsx b/javascript/components/RasterLayer.tsx index 9f61445b9..85560ff52 100644 --- a/javascript/components/RasterLayer.tsx +++ b/javascript/components/RasterLayer.tsx @@ -1,16 +1,16 @@ -import React from 'react'; -import {NativeModules, requireNativeComponent} from 'react-native'; +import React from "react"; +import { NativeModules, requireNativeComponent } from "react-native"; import useAbstractLayer, { BaseLayerProps, NativeBaseProps, -} from '../hooks/useAbstractLayer'; -import BaseProps from '../types/BaseProps'; -import {RasterLayerStyleProps} from '../utils/MaplibreStyles'; +} from "../hooks/useAbstractLayer"; +import BaseProps from "../types/BaseProps"; +import { RasterLayerStyleProps } from "../utils/MaplibreStyles"; const MapLibreGL = NativeModules.MLNModule; -export const NATIVE_MODULE_NAME = 'RCTMLNRasterLayer'; +export const NATIVE_MODULE_NAME = "RCTMLNRasterLayer"; export interface RasterLayerProps extends BaseProps, BaseLayerProps { /** @@ -20,7 +20,7 @@ export interface RasterLayerProps extends BaseProps, BaseLayerProps { } interface NativeProps - extends Omit, + extends Omit, NativeBaseProps {} const RCTMLNRasterLayer = @@ -30,7 +30,7 @@ const RasterLayer: React.FC = ({ sourceID = MapLibreGL.StyleSource.DefaultSourceID, ...props }: RasterLayerProps) => { - const {baseProps, setNativeLayer} = useAbstractLayer< + const { baseProps, setNativeLayer } = useAbstractLayer< RasterLayerProps, NativeProps >({ diff --git a/javascript/components/RasterSource.tsx b/javascript/components/RasterSource.tsx index 10a27bea8..f2cdaf4b3 100644 --- a/javascript/components/RasterSource.tsx +++ b/javascript/components/RasterSource.tsx @@ -1,18 +1,18 @@ -import React from 'react'; -import {NativeModules, requireNativeComponent} from 'react-native'; +import React from "react"; +import { NativeModules, requireNativeComponent } from "react-native"; -import useAbstractSource from '../hooks/useAbstractSource'; -import useOnce from '../hooks/useOnce'; -import BaseProps from '../types/BaseProps'; -import {cloneReactChildrenWithProps} from '../utils'; +import useAbstractSource from "../hooks/useAbstractSource"; +import useOnce from "../hooks/useOnce"; +import BaseProps from "../types/BaseProps"; +import { cloneReactChildrenWithProps } from "../utils"; const MapLibreGL = NativeModules.MLNModule; -export const NATIVE_MODULE_NAME = 'RCTMLNRasterSource'; +export const NATIVE_MODULE_NAME = "RCTMLNRasterSource"; const isTileTemplateUrl = (url?: string): url is string => !!url && - (url.includes('{z}') || url.includes('{bbox-') || url.includes('{quadkey}')); + (url.includes("{z}") || url.includes("{bbox-") || url.includes("{quadkey}")); interface RasterSourceProps extends BaseProps { /** @@ -80,9 +80,9 @@ const RasterSource: React.FC = ({ } }); - const {setNativeRef} = useAbstractSource(); + const { setNativeRef } = useAbstractSource(); - let {url, tileUrlTemplates} = props; + let { url, tileUrlTemplates } = props; // Swapping url for tileUrlTemplates to provide backward compatiblity // when RasterSource supported only tile url as url prop diff --git a/javascript/components/ShapeSource.tsx b/javascript/components/ShapeSource.tsx index c145680c2..328dba14f 100644 --- a/javascript/components/ShapeSource.tsx +++ b/javascript/components/ShapeSource.tsx @@ -1,34 +1,34 @@ -import {Feature, FeatureCollection} from '@turf/helpers'; +import { Feature, FeatureCollection } from "@turf/helpers"; import React, { Component, ReactElement, memo, useImperativeHandle, useRef, -} from 'react'; +} from "react"; import { NativeMethods, NativeModules, NativeSyntheticEvent, requireNativeComponent, -} from 'react-native'; +} from "react-native"; -import useNativeBridge from '../hooks/useNativeBridge'; -import BaseProps from '../types/BaseProps'; -import OnPressEvent from '../types/OnPressEvent'; +import useNativeBridge from "../hooks/useNativeBridge"; +import BaseProps from "../types/BaseProps"; +import OnPressEvent from "../types/OnPressEvent"; import { cloneReactChildrenWithProps, isAndroid, isFunction, toJSONString, -} from '../utils'; -import {ExpressionField, FilterExpression} from '../utils/MaplibreStyles'; -import {copyPropertiesAsDeprecated} from '../utils/deprecation'; -import {getFilter} from '../utils/filterUtils'; +} from "../utils"; +import { ExpressionField, FilterExpression } from "../utils/MaplibreStyles"; +import { copyPropertiesAsDeprecated } from "../utils/deprecation"; +import { getFilter } from "../utils/filterUtils"; const MapLibreGL = NativeModules.MLNModule; -export const NATIVE_MODULE_NAME = 'RCTMLNShapeSource'; -export const SHAPE_SOURCE_NATIVE_ASSETS_KEY = 'assets'; +export const NATIVE_MODULE_NAME = "RCTMLNShapeSource"; +export const SHAPE_SOURCE_NATIVE_ASSETS_KEY = "assets"; interface NativeProps { shape?: string; @@ -82,7 +82,7 @@ export interface ShapeSourceProps extends BaseProps { * Example: `{ "resultingSum": [["+", ["accumulated"], ["get", "resultingSum"]], ["get", "scalerank"]] }` * */ - clusterProperties?: {[propertyName: string]: ExpressionField}; + clusterProperties?: { [propertyName: string]: ExpressionField }; /** * Specifies the maximum zoom level at which to create vector tiles. * A greater value produces greater detail at high zoom levels. @@ -146,7 +146,7 @@ export interface ShapeSourceRef { ): Promise; getClusterChildren(feature: Feature): Promise; setNativeProps: (props: NativeProps) => void; - onPress: (event: NativeSyntheticEvent<{payload: OnPressEvent}>) => void; + onPress: (event: NativeSyntheticEvent<{ payload: OnPressEvent }>) => void; // this was required by existing test __tests__/utils/animated/AnimatedCoordinatesArray.test.js _nativeRef: RCTMLNShapeSourceRefType | undefined; @@ -219,8 +219,11 @@ const ShapeSource = memo( const _nativeRef = useRef(); - const {_runNativeCommand, _runPendingNativeCommands, _onAndroidCallback} = - useNativeBridge(NATIVE_MODULE_NAME); + const { + _runNativeCommand, + _runPendingNativeCommands, + _onAndroidCallback, + } = useNativeBridge(NATIVE_MODULE_NAME); const _setNativeRef = (nativeRef: RCTMLNShapeSourceRefType): void => { _nativeRef.current = nativeRef; @@ -230,11 +233,10 @@ const ShapeSource = memo( async function features( filter?: FilterExpression, ): Promise { - const res: {data: string | FeatureCollection} = await _runNativeCommand( - 'features', - _nativeRef.current, - [getFilter(filter)], - ); + const res: { data: string | FeatureCollection } = + await _runNativeCommand("features", _nativeRef.current, [ + getFilter(filter), + ]); if (isAndroid()) { return JSON.parse(res.data as string); @@ -246,20 +248,20 @@ const ShapeSource = memo( async function getClusterExpansionZoom( feature: Feature, ): Promise { - if (typeof feature === 'number') { + if (typeof feature === "number") { console.warn( - 'Using cluster_id is deprecated and will be removed from the future releases. Please use cluster as an argument instead.', + "Using cluster_id is deprecated and will be removed from the future releases. Please use cluster as an argument instead.", ); - const res: {data: number} = await _runNativeCommand( - 'getClusterExpansionZoomById', + const res: { data: number } = await _runNativeCommand( + "getClusterExpansionZoomById", _nativeRef.current, [feature], ); return res.data; } - const res: {data: number} = await _runNativeCommand( - 'getClusterExpansionZoom', + const res: { data: number } = await _runNativeCommand( + "getClusterExpansionZoom", _nativeRef.current, [JSON.stringify(feature)], ); @@ -271,13 +273,13 @@ const ShapeSource = memo( limit: number, offset: number, ): Promise { - if (typeof feature === 'number') { + if (typeof feature === "number") { console.warn( - 'Using cluster_id is deprecated and will be removed from the future releases. Please use cluster as an argument instead.', + "Using cluster_id is deprecated and will be removed from the future releases. Please use cluster as an argument instead.", ); - const res: {data: string | FeatureCollection} = + const res: { data: string | FeatureCollection } = await _runNativeCommand( - 'getClusterLeavesById', + "getClusterLeavesById", _nativeRef.current, [feature, limit, offset], ); @@ -289,11 +291,12 @@ const ShapeSource = memo( return res.data as FeatureCollection; } - const res: {data: string | FeatureCollection} = await _runNativeCommand( - 'getClusterLeaves', - _nativeRef.current, - [JSON.stringify(feature), limit, offset], - ); + const res: { data: string | FeatureCollection } = + await _runNativeCommand("getClusterLeaves", _nativeRef.current, [ + JSON.stringify(feature), + limit, + offset, + ]); if (isAndroid()) { return JSON.parse(res.data as string); @@ -305,13 +308,13 @@ const ShapeSource = memo( async function getClusterChildren( feature: Feature, ): Promise { - if (typeof feature === 'number') { + if (typeof feature === "number") { console.warn( - 'Using cluster_id is deprecated and will be removed from the future releases. Please use cluster as an argument instead.', + "Using cluster_id is deprecated and will be removed from the future releases. Please use cluster as an argument instead.", ); - const res: {data: string | FeatureCollection} = + const res: { data: string | FeatureCollection } = await _runNativeCommand( - 'getClusterChildrenById', + "getClusterChildrenById", _nativeRef.current, [feature], ); @@ -323,11 +326,10 @@ const ShapeSource = memo( return res.data as FeatureCollection; } - const res: {data: string | FeatureCollection} = await _runNativeCommand( - 'getClusterChildren', - _nativeRef.current, - [JSON.stringify(feature)], - ); + const res: { data: string | FeatureCollection } = + await _runNativeCommand("getClusterChildren", _nativeRef.current, [ + JSON.stringify(feature), + ]); if (isAndroid()) { return JSON.parse(res.data as string); @@ -344,7 +346,7 @@ const ShapeSource = memo( const shallowProps = Object.assign({}, nativeProps); // Adds support for Animated - if (shallowProps.shape && typeof shallowProps !== 'string') { + if (shallowProps.shape && typeof shallowProps !== "string") { shallowProps.shape = JSON.stringify(shallowProps.shape); } @@ -359,11 +361,11 @@ const ShapeSource = memo( } function onPress( - event: NativeSyntheticEvent<{payload: OnPressEvent}>, + event: NativeSyntheticEvent<{ payload: OnPressEvent }>, ): void { const { nativeEvent: { - payload: {features, coordinates, point}, + payload: { features, coordinates, point }, }, } = event; let newEvent = { @@ -381,7 +383,7 @@ const ShapeSource = memo( }, { nativeEvent: ( - origNativeEvent: NativeSyntheticEvent<{payload: OnPressEvent}>, + origNativeEvent: NativeSyntheticEvent<{ payload: OnPressEvent }>, ) => ({ ...origNativeEvent, payload: features[0], diff --git a/javascript/components/Style.tsx b/javascript/components/Style.tsx index e76bdfc9c..cac874933 100644 --- a/javascript/components/Style.tsx +++ b/javascript/components/Style.tsx @@ -4,26 +4,26 @@ import React, { useEffect, ReactElement, ComponentType, -} from 'react'; - -import BackgroundLayer from './BackgroundLayer'; -import CircleLayer from './CircleLayer'; -import FillExtrusionLayer from './FillExtrusionLayer'; -import FillLayer from './FillLayer'; -import HeatmapLayer from './HeatmapLayer'; -import ImageSource from './ImageSource'; -import LineLayer from './LineLayer'; -import RasterLayer from './RasterLayer'; -import RasterSource from './RasterSource'; -import ShapeSource from './ShapeSource'; -import SymbolLayer from './SymbolLayer'; -import VectorSource from './VectorSource'; -import {BaseLayerProps} from '../hooks/useAbstractLayer'; -import {ExpressionField, FilterExpression} from '../utils/MaplibreStyles'; +} from "react"; + +import BackgroundLayer from "./BackgroundLayer"; +import CircleLayer from "./CircleLayer"; +import FillExtrusionLayer from "./FillExtrusionLayer"; +import FillLayer from "./FillLayer"; +import HeatmapLayer from "./HeatmapLayer"; +import ImageSource from "./ImageSource"; +import LineLayer from "./LineLayer"; +import RasterLayer from "./RasterLayer"; +import RasterSource from "./RasterSource"; +import ShapeSource from "./ShapeSource"; +import SymbolLayer from "./SymbolLayer"; +import VectorSource from "./VectorSource"; +import { BaseLayerProps } from "../hooks/useAbstractLayer"; +import { ExpressionField, FilterExpression } from "../utils/MaplibreStyles"; function toCamelCase(s: string): string { - return s.replace(/([-_][a-z])/gi, $1 => { - return $1.toUpperCase().replace('-', '').replace('_', ''); + return s.replace(/([-_][a-z])/gi, ($1) => { + return $1.toUpperCase().replace("-", "").replace("_", ""); }); } @@ -36,9 +36,9 @@ function toCamelCaseKeys( return {}; } const newObj: Record = {}; - Object.keys(oldObj).forEach(key => { + Object.keys(oldObj).forEach((key) => { const value = oldObj[key]; - if (key.includes('-')) { + if (key.includes("-")) { newObj[toCamelCase(key)] = value; } else { newObj[key] = value; @@ -50,24 +50,24 @@ function toCamelCaseKeys( function getLayerComponentType( layer: MaplibreJSONLayer, ): ComponentType | null { - const {type} = layer; + const { type } = layer; switch (type) { - case 'circle': + case "circle": return CircleLayer; - case 'symbol': + case "symbol": return SymbolLayer; - case 'raster': + case "raster": return RasterLayer; - case 'line': + case "line": return LineLayer; - case 'fill': + case "fill": return FillLayer; - case 'fill-extrusion': + case "fill-extrusion": return FillExtrusionLayer; - case 'background': + case "background": return BackgroundLayer; - case 'heatmap': + case "heatmap": return HeatmapLayer; } @@ -78,10 +78,10 @@ function getLayerComponentType( interface MaplibreJSONLayer { type: string; - paint: {[k: string]: unknown}; - layout: {[k: string]: unknown}; + paint: { [k: string]: unknown }; + layout: { [k: string]: unknown }; source?: string; - 'source-layer'?: string; + "source-layer"?: string; minzoom?: number; maxzoom?: number; filter?: FilterExpression; @@ -107,8 +107,8 @@ function asLayerComponent( if (layer.source) { layerProps.sourceID = layer.source; } - if (layer['source-layer']) { - layerProps.sourceLayerID = layer['source-layer']; + if (layer["source-layer"]) { + layerProps.sourceLayerID = layer["source-layer"]; } if (layer.minzoom) { layerProps.minZoomLevel = layer.minzoom; @@ -133,7 +133,7 @@ interface MaplibreJSONSource { minzoom?: number; maxzoom?: number; attribution?: string; - scheme?: 'xyz' | 'tms'; + scheme?: "xyz" | "tms"; bounds?: number[]; buffer?: number; tileSize?: number; @@ -147,7 +147,7 @@ interface MaplibreJSONSource { clusterMaxZoom?: number; clusterMinPoints?: number; clusterRadius?: number; - clusterProperties?: {[propertyName: string]: ExpressionField}; + clusterProperties?: { [propertyName: string]: ExpressionField }; data?: string | object; filter?: FilterExpression; generateId?: boolean; @@ -181,19 +181,19 @@ function getTileSourceProps(source: MaplibreJSONSource): SourceProps { if (source.attribution) { sourceProps.attribution = source.attribution; } - if (source.scheme && source.scheme === 'tms') { + if (source.scheme && source.scheme === "tms") { sourceProps.tms = true; } return sourceProps; } function getVectorSource(id: string, source: MaplibreJSONSource): ReactElement { - const sourceProps = {...getTileSourceProps(source)}; + const sourceProps = { ...getTileSourceProps(source) }; return ; } function getRasterSource(id: string, source: MaplibreJSONSource): ReactElement { - const sourceProps: SourceProps & {tileSize?: number} = { + const sourceProps: SourceProps & { tileSize?: number } = { ...getTileSourceProps(source), }; if (source.tileSize) { @@ -210,7 +210,7 @@ function getImageSource(id: string, source: MaplibreJSONSource): ReactElement { return ; } -type ShapeSourceShape = (typeof ShapeSource.prototype.props)['shape']; +type ShapeSourceShape = (typeof ShapeSource.prototype.props)["shape"]; function getShapeSource(id: string, source: MaplibreJSONSource): ReactElement { const sourceProps: SourceProps & { @@ -218,14 +218,14 @@ function getShapeSource(id: string, source: MaplibreJSONSource): ReactElement { cluster?: boolean; clusterRadius?: number; clusterMaxZoomLevel?: number; - clusterProperties?: {[propertyName: string]: ExpressionField}; + clusterProperties?: { [propertyName: string]: ExpressionField }; buffer?: number; tolerance?: number; lineMetrics?: boolean; } = {}; - if (source.data && typeof source.data === 'string') { + if (source.data && typeof source.data === "string") { sourceProps.url = source.data; - } else if (source.data && typeof source.data === 'object') { + } else if (source.data && typeof source.data === "object") { sourceProps.shape = source.data as ShapeSourceShape; } if (source.cluster !== undefined) { @@ -260,13 +260,13 @@ function asSourceComponent( source: MaplibreJSONSource, ): ReactElement | null { switch (source.type) { - case 'vector': + case "vector": return getVectorSource(id, source); - case 'raster': + case "raster": return getRasterSource(id, source); - case 'image': + case "image": return getImageSource(id, source); - case 'geojson': + case "geojson": return getShapeSource(id, source); } @@ -277,7 +277,7 @@ function asSourceComponent( interface MaplibreJSON { layers?: MaplibreJSONLayer[]; - sources?: {[key: string]: MaplibreJSONSource}; + sources?: { [key: string]: MaplibreJSONSource }; } interface StyleProps { @@ -297,7 +297,7 @@ interface StyleProps { const Style = (props: StyleProps): ReactElement => { const [fetchedJson, setFetchedJson] = useState({}); const json: MaplibreJSON = - typeof props.json === 'object' ? props.json : fetchedJson; + typeof props.json === "object" ? props.json : fetchedJson; // Fetch style when props.json is a URL useEffect(() => { @@ -310,14 +310,14 @@ const Style = (props: StyleProps): ReactElement => { const responseJson = await response.json(); setFetchedJson(responseJson); } catch (error: unknown) { - const e = error as {name?: string}; - if (e.name === 'AbortError') { + const e = error as { name?: string }; + if (e.name === "AbortError") { return; } throw e; } }; - if (typeof props.json === 'string') { + if (typeof props.json === "string") { fetchStyleJson(props.json); } return function cleanup(): void { @@ -337,13 +337,13 @@ const Style = (props: StyleProps): ReactElement => { // Extract source components from json const sourceComponents = useMemo(() => { - const {sources} = json; + const { sources } = json; if (!sources || !Object.keys(sources)) { return []; } return Object.keys(sources) - .map(id => asSourceComponent(id, sources[id])) - .filter(x => !!x); + .map((id) => asSourceComponent(id, sources[id])) + .filter((x) => !!x); }, [json]); return ( diff --git a/javascript/components/SymbolLayer.tsx b/javascript/components/SymbolLayer.tsx index 5d707a04e..f24dfbf18 100644 --- a/javascript/components/SymbolLayer.tsx +++ b/javascript/components/SymbolLayer.tsx @@ -1,16 +1,16 @@ -import React, {ReactElement} from 'react'; -import {View, NativeModules, requireNativeComponent} from 'react-native'; +import React, { ReactElement } from "react"; +import { View, NativeModules, requireNativeComponent } from "react-native"; import useAbstractLayer, { BaseLayerProps, NativeBaseProps, -} from '../hooks/useAbstractLayer'; -import BaseProps from '../types/BaseProps'; -import {type SymbolLayerStyleProps} from '../utils/MaplibreStyles'; +} from "../hooks/useAbstractLayer"; +import BaseProps from "../types/BaseProps"; +import { type SymbolLayerStyleProps } from "../utils/MaplibreStyles"; const MapLibreGL = NativeModules.MLNModule; -export const NATIVE_MODULE_NAME = 'RCTMLNSymbolLayer'; +export const NATIVE_MODULE_NAME = "RCTMLNSymbolLayer"; export interface SymbolLayerProps extends BaseProps, BaseLayerProps { /** @@ -25,7 +25,7 @@ export interface SymbolLayerProps extends BaseProps, BaseLayerProps { children?: ReactElement | ReactElement[]; } -interface NativeProps extends Omit, NativeBaseProps { +interface NativeProps extends Omit, NativeBaseProps { snapshot: boolean; } @@ -39,7 +39,7 @@ const SymbolLayer: React.FC = ({ sourceID = MapLibreGL.StyleSource.DefaultSourceID, ...props }: SymbolLayerProps) => { - const {baseProps, setNativeLayer} = useAbstractLayer< + const { baseProps, setNativeLayer } = useAbstractLayer< SymbolLayerProps, NativeBaseProps >({ @@ -54,7 +54,7 @@ const SymbolLayer: React.FC = ({ return isSnapshot; } - React.Children.forEach(props.children, child => { + React.Children.forEach(props.children, (child) => { if (child?.type === View) { isSnapshot = true; } diff --git a/javascript/components/UserLocation.tsx b/javascript/components/UserLocation.tsx index 04e8c9c1d..8d381211c 100644 --- a/javascript/components/UserLocation.tsx +++ b/javascript/components/UserLocation.tsx @@ -1,30 +1,30 @@ -import React, {ReactElement, useEffect, useImperativeHandle} from 'react'; +import React, { ReactElement, useEffect, useImperativeHandle } from "react"; -import CircleLayer from './CircleLayer'; -import HeadingIndicator from './HeadingIndicator'; -import NativeUserLocation from './NativeUserLocation'; -import Annotation from './annotations/Annotation'; -import locationManager, {Location} from '../modules/location/locationManager'; -import {CircleLayerStyleProps} from '../utils/MaplibreStyles'; +import CircleLayer from "./CircleLayer"; +import HeadingIndicator from "./HeadingIndicator"; +import NativeUserLocation from "./NativeUserLocation"; +import Annotation from "./annotations/Annotation"; +import locationManager, { Location } from "../modules/location/locationManager"; +import { CircleLayerStyleProps } from "../utils/MaplibreStyles"; -const mapboxBlue = 'rgba(51, 181, 229, 100)'; +const mapboxBlue = "rgba(51, 181, 229, 100)"; const layerStyles: Record = { pluse: { circleRadius: 15, circleColor: mapboxBlue, circleOpacity: 0.2, - circlePitchAlignment: 'map', + circlePitchAlignment: "map", }, background: { circleRadius: 9, - circleColor: '#fff', - circlePitchAlignment: 'map', + circleColor: "#fff", + circlePitchAlignment: "map", }, foreground: { circleRadius: 6, circleColor: mapboxBlue, - circlePitchAlignment: 'map', + circlePitchAlignment: "map", }, }; @@ -49,7 +49,7 @@ export const normalIcon = ( style={layerStyles.foreground} />, ...(showsUserHeadingIndicator && heading - ? [HeadingIndicator({heading})] + ? [HeadingIndicator({ heading })] : []), ]; @@ -62,7 +62,7 @@ interface UserLocationProps { * Which render mode to use. * Can either be `normal` or `native` */ - renderMode?: 'normal' | 'native'; + renderMode?: "normal" | "native"; /** * native/android only render mode * @@ -72,7 +72,7 @@ interface UserLocationProps { * * @platform android */ - androidRenderMode?: 'normal' | 'compass' | 'gps'; + androidRenderMode?: "normal" | "compass" | "gps"; /** * Whether location icon is visible */ @@ -108,12 +108,12 @@ interface UserLocationState { } export enum UserLocationRenderMode { - Native = 'native', - Normal = 'normal', + Native = "native", + Normal = "normal", } export interface UserLocationRef { - setLocationManager: (props: {running: boolean}) => Promise; + setLocationManager: (props: { running: boolean }) => Promise; needsLocationManagerRunning: () => boolean; _onLocationUpdate: (location: Location | null) => void; } @@ -126,7 +126,7 @@ const UserLocation = React.memo( visible = true, showsUserHeadingIndicator = false, minDisplacement = 0, - renderMode = 'normal', + renderMode = "normal", androidRenderMode, children, onUpdate, @@ -182,7 +182,7 @@ const UserLocation = React.memo( return (): void => { _isMounted.current = false; - setLocationManager({running: false}); + setLocationManager({ running: false }); }; // eslint-disable-next-line react-hooks/exhaustive-deps }, []); @@ -235,7 +235,7 @@ const UserLocation = React.memo( let heading; if (location && location.coords) { - const {longitude, latitude} = location.coords; + const { longitude, latitude } = location.coords; heading = location.coords.heading; coordinates = [longitude, latitude]; } @@ -276,7 +276,8 @@ const UserLocation = React.memo( coordinates={userLocationState.coordinates} style={{ iconRotate: userLocationState.heading, - }}> + }} + > {children || normalIcon(showsUserHeadingIndicator, userLocationState.heading)} diff --git a/javascript/components/VectorSource.tsx b/javascript/components/VectorSource.tsx index 25e634b47..b94880c64 100644 --- a/javascript/components/VectorSource.tsx +++ b/javascript/components/VectorSource.tsx @@ -1,23 +1,23 @@ -import {featureCollection} from '@turf/helpers'; -import React, {memo, useImperativeHandle} from 'react'; +import { featureCollection } from "@turf/helpers"; +import React, { memo, useImperativeHandle } from "react"; import { NativeModules, NativeSyntheticEvent, requireNativeComponent, -} from 'react-native'; +} from "react-native"; -import useAbstractSource from '../hooks/useAbstractSource'; -import useNativeBridge from '../hooks/useNativeBridge'; -import BaseProps from '../types/BaseProps'; -import OnPressEvent from '../types/OnPressEvent'; -import {cloneReactChildrenWithProps, isFunction, isAndroid} from '../utils'; -import {FilterExpression} from '../utils/MaplibreStyles'; -import {copyPropertiesAsDeprecated} from '../utils/deprecation'; -import {getFilter} from '../utils/filterUtils'; +import useAbstractSource from "../hooks/useAbstractSource"; +import useNativeBridge from "../hooks/useNativeBridge"; +import BaseProps from "../types/BaseProps"; +import OnPressEvent from "../types/OnPressEvent"; +import { cloneReactChildrenWithProps, isFunction, isAndroid } from "../utils"; +import { FilterExpression } from "../utils/MaplibreStyles"; +import { copyPropertiesAsDeprecated } from "../utils/deprecation"; +import { getFilter } from "../utils/filterUtils"; const MapLibreGL = NativeModules.MLNModule; -export const NATIVE_MODULE_NAME = 'RCTMLNVectorSource'; +export const NATIVE_MODULE_NAME = "RCTMLNVectorSource"; interface VectorSourceProps extends BaseProps { /** @@ -122,7 +122,7 @@ const VectorSource = memo( // _runPendingNativeCommands, _onAndroidCallback, } = useNativeBridge(NATIVE_MODULE_NAME); - const {setNativeRef, _nativeRef} = useAbstractSource(); + const { setNativeRef, _nativeRef } = useAbstractSource(); // const _setNativeRef = ( // nativeRef: (Component & Readonly) | null, @@ -140,8 +140,8 @@ const VectorSource = memo( if (!_nativeRef) { return featureCollection([]); } - const res: {data: string | GeoJSON.FeatureCollection} = - await _runNativeCommand('features', _nativeRef, [ + const res: { data: string | GeoJSON.FeatureCollection } = + await _runNativeCommand("features", _nativeRef, [ [[layerIDs, getFilter(filter)]], ]); @@ -153,16 +153,16 @@ const VectorSource = memo( }; const onPress = ( - event: NativeSyntheticEvent<{payload: OnPressEvent}>, + event: NativeSyntheticEvent<{ payload: OnPressEvent }>, ): void => { - const {onPress} = props; + const { onPress } = props; if (!onPress) { return; } const { nativeEvent: { - payload: {features, coordinates, point}, + payload: { features, coordinates, point }, }, } = event; let newEvent = { diff --git a/javascript/components/annotations/Annotation.tsx b/javascript/components/annotations/Annotation.tsx index eb1e99ffa..9b97009c2 100644 --- a/javascript/components/annotations/Annotation.tsx +++ b/javascript/components/annotations/Annotation.tsx @@ -3,14 +3,14 @@ import React, { useCallback, useEffect, useImperativeHandle, -} from 'react'; -import {Animated as RNAnimated, Easing} from 'react-native'; +} from "react"; +import { Animated as RNAnimated, Easing } from "react-native"; -import OnPressEvent from '../../types/OnPressEvent'; -import {SymbolLayerStyleProps} from '../../utils/MaplibreStyles'; -import Animated from '../../utils/animated/Animated'; -import AnimatedMapPoint from '../../utils/animated/AnimatedPoint'; -import SymbolLayer from '../SymbolLayer'; +import OnPressEvent from "../../types/OnPressEvent"; +import { SymbolLayerStyleProps } from "../../utils/MaplibreStyles"; +import Animated from "../../utils/animated/Animated"; +import AnimatedMapPoint from "../../utils/animated/AnimatedPoint"; +import SymbolLayer from "../SymbolLayer"; interface AnnotationProps { id: string; @@ -29,7 +29,7 @@ type Shape = AnimatedMapPoint | GeoJSON.Point; function getShapeFromProps(props: Partial = {}): Shape { const lng = props.coordinates?.[0] || 0; const lat = props.coordinates?.[1] || 0; - const point: GeoJSON.Point = {type: 'Point', coordinates: [lng, lat]}; + const point: GeoJSON.Point = { type: "Point", coordinates: [lng, lat] }; if (props.animated) { return new AnimatedMapPoint(point); @@ -77,7 +77,7 @@ const Annotation = React.forwardRef( ); // this will run useEffect only when actual coordinates values change - const coordinateDeps = props.coordinates?.join(','); + const coordinateDeps = props.coordinates?.join(","); useEffect(() => { if (!Array.isArray(props.coordinates)) { @@ -127,7 +127,7 @@ const Annotation = React.forwardRef( const children = []; const symbolStyle: SymbolLayerStyleProps | undefined = props.icon - ? {...props.style, iconImage: props.icon} + ? { ...props.style, iconImage: props.icon } : undefined; if (symbolStyle) { @@ -148,13 +148,14 @@ const Annotation = React.forwardRef( }> + shape={shape as RNAnimated.WithAnimatedObject} + > {children} ); }, ); -Annotation.displayName = 'Annotation'; +Annotation.displayName = "Annotation"; export default Annotation; diff --git a/javascript/hooks/useAbstractLayer.ts b/javascript/hooks/useAbstractLayer.ts index 7f1092e12..32e239f3a 100644 --- a/javascript/hooks/useAbstractLayer.ts +++ b/javascript/hooks/useAbstractLayer.ts @@ -1,15 +1,15 @@ -import React, {useMemo, useRef} from 'react'; -import {processColor, NativeMethods} from 'react-native'; +import React, { useMemo, useRef } from "react"; +import { processColor, NativeMethods } from "react-native"; -import BaseProps from '../types/BaseProps'; +import BaseProps from "../types/BaseProps"; import { AllLayerStyleProps, ExpressionField, ExpressionName, FilterExpression, -} from '../utils/MaplibreStyles'; -import {StyleValue, transformStyle} from '../utils/StyleValue'; -import {getFilter} from '../utils/filterUtils'; +} from "../utils/MaplibreStyles"; +import { StyleValue, transformStyle } from "../utils/StyleValue"; +import { getFilter } from "../utils/filterUtils"; export interface BaseLayerProps { /** @@ -57,7 +57,7 @@ export interface BaseLayerProps { } export interface NativeBaseProps { - reactStyle?: {[key: string]: StyleValue}; + reactStyle?: { [key: string]: StyleValue }; } export default function useAbstractLayer< @@ -71,7 +71,7 @@ export default function useAbstractLayer< instance: (React.Component & Readonly) | null, ) => void; getStyleTypeFormatter: (styleType: string) => typeof processColor | undefined; - setNativeProps: (nativeProps: {[key: string]: unknown}) => void; + setNativeProps: (nativeProps: { [key: string]: unknown }) => void; } { const nativeLayer = useRef< (React.Component & Readonly) | null @@ -102,14 +102,17 @@ export default function useAbstractLayer< const getStyleTypeFormatter = ( styleType: string, ): typeof processColor | undefined => { - return styleType === 'color' ? processColor : undefined; + return styleType === "color" ? processColor : undefined; }; - const setNativeProps = (nativeProps: {[key: string]: unknown}): void => { + const setNativeProps = (nativeProps: { [key: string]: unknown }): void => { if (nativeLayer.current) { let propsToPass = nativeProps; if (nativeProps.style) { - propsToPass = {...nativeProps, reactStyle: transformStyle(props.style)}; + propsToPass = { + ...nativeProps, + reactStyle: transformStyle(props.style), + }; } nativeLayer.current.setNativeProps(propsToPass); } diff --git a/javascript/hooks/useAbstractSource.ts b/javascript/hooks/useAbstractSource.ts index 0ab1d1af4..24b0cdd15 100644 --- a/javascript/hooks/useAbstractSource.ts +++ b/javascript/hooks/useAbstractSource.ts @@ -1,5 +1,5 @@ -import React, {useRef} from 'react'; -import {NativeMethods} from 'react-native'; +import React, { useRef } from "react"; +import { NativeMethods } from "react-native"; export default function useAbstractSource(): { _nativeRef: diff --git a/javascript/hooks/useNativeBridge.ts b/javascript/hooks/useNativeBridge.ts index ebd3dcf5c..369969889 100644 --- a/javascript/hooks/useNativeBridge.ts +++ b/javascript/hooks/useNativeBridge.ts @@ -1,8 +1,8 @@ -import React, {Component, SyntheticEvent, useRef} from 'react'; +import React, { Component, SyntheticEvent, useRef } from "react"; -import {runNativeCommand, isAndroid, NativeArg} from '../utils'; +import { runNativeCommand, isAndroid, NativeArg } from "../utils"; -export type RNMLEvent = { +export type RNMLEvent = { payload: PayloadType; type: string; }; @@ -41,7 +41,7 @@ const useNativeBridge: (moduleName: string) => UseNativeBridge = ( resolve: (value: ReturnType) => void, reject: (error: Error) => void, ): void => { - _callbackMap.current.set(id, {resolve, reject}); + _callbackMap.current.set(id, { resolve, reject }); }; const _removeAndroidCallback = (id: string): void => { @@ -57,7 +57,7 @@ const useNativeBridge: (moduleName: string) => UseNativeBridge = ( } _callbackMap.current.delete(callbackID); - const {payload} = e.nativeEvent; + const { payload } = e.nativeEvent; if (payload.error) { callback.reject.call(null, new Error(payload.error)); } else { @@ -90,9 +90,9 @@ const useNativeBridge: (moduleName: string) => UseNativeBridge = ( args: NativeArg[] = [], ): Promise => { if (!nativeRef) { - return new Promise(resolve => { + return new Promise((resolve) => { _preRefMapMethodQueue.current.push({ - method: {name: methodName, args}, + method: { name: methodName, args }, resolver: resolve, }); }); diff --git a/javascript/hooks/useNativeRef.ts b/javascript/hooks/useNativeRef.ts index ba00c8f1d..a3c430d41 100644 --- a/javascript/hooks/useNativeRef.ts +++ b/javascript/hooks/useNativeRef.ts @@ -1,5 +1,5 @@ -import React, {Component, useRef} from 'react'; -import {NativeMethods} from 'react-native'; +import React, { Component, useRef } from "react"; +import { NativeMethods } from "react-native"; type NativeRef = Component & Readonly; diff --git a/javascript/hooks/useOnce.ts b/javascript/hooks/useOnce.ts index afc438413..a15cb9550 100644 --- a/javascript/hooks/useOnce.ts +++ b/javascript/hooks/useOnce.ts @@ -1,4 +1,4 @@ -import {useRef} from 'react'; +import { useRef } from "react"; const useOnce: (callback: () => void) => void = (callback: () => void) => { const once = useRef(false); diff --git a/javascript/index.ts b/javascript/index.ts index 299cd9bfc..120af94d2 100644 --- a/javascript/index.ts +++ b/javascript/index.ts @@ -1,4 +1,4 @@ -import * as Maplibre from './Maplibre'; -export * from './Maplibre'; +import * as Maplibre from "./Maplibre"; +export * from "./Maplibre"; export default Maplibre; diff --git a/javascript/modules/location/locationManager.ts b/javascript/modules/location/locationManager.ts index 8d01b436f..68c21fef8 100644 --- a/javascript/modules/location/locationManager.ts +++ b/javascript/modules/location/locationManager.ts @@ -2,7 +2,7 @@ import { NativeModules, NativeEventEmitter, EmitterSubscription, -} from 'react-native'; +} from "react-native"; const MapLibreGL = NativeModules.MLNModule; const MapLibreGLLocationManager = NativeModules.MLNLocationModule; @@ -89,7 +89,7 @@ class LocationManager { lastKnownLocation = await MapLibreGLLocationManager.getLastKnownLocation(); } catch (error) { - console.log('locationManager Error: ', error); + console.log("locationManager Error: ", error); } if (!this._lastKnownLocation && lastKnownLocation) { @@ -114,7 +114,7 @@ class LocationManager { } removeListener(listener: (location: Location) => void): void { - this._listeners = this._listeners.filter(l => l !== listener); + this._listeners = this._listeners.filter((l) => l !== listener); if (this._listeners.length === 0) { this.stop(); } @@ -155,7 +155,7 @@ class LocationManager { onUpdate(location: Location): void { this._lastKnownLocation = location; - this._listeners.forEach(l => l(location)); + this._listeners.forEach((l) => l(location)); } } diff --git a/javascript/modules/offline/OfflineCreatePackOptions.ts b/javascript/modules/offline/OfflineCreatePackOptions.ts index 688bc9628..180da604c 100644 --- a/javascript/modules/offline/OfflineCreatePackOptions.ts +++ b/javascript/modules/offline/OfflineCreatePackOptions.ts @@ -1,5 +1,5 @@ -import {toJSONString} from '../../utils'; -import {makeLatLngBounds} from '../../utils/geoUtils'; +import { toJSONString } from "../../utils"; +import { makeLatLngBounds } from "../../utils/geoUtils"; export interface OfflineCreatePackInputOptions { name: string; @@ -32,16 +32,16 @@ class OfflineCreatePackOptions { _assert(options: OfflineCreatePackInputOptions): void { if (!options.styleURL) { throw new Error( - 'Style URL must be provided for creating an offline pack', + "Style URL must be provided for creating an offline pack", ); } if (!options.name) { - throw new Error('Name must be provided for creating an offline pack'); + throw new Error("Name must be provided for creating an offline pack"); } if (!options.bounds) { - throw new Error('Bounds must be provided for creating an offline pack'); + throw new Error("Bounds must be provided for creating an offline pack"); } } diff --git a/javascript/modules/offline/OfflinePack.ts b/javascript/modules/offline/OfflinePack.ts index 28160c3b5..f5348dadf 100644 --- a/javascript/modules/offline/OfflinePack.ts +++ b/javascript/modules/offline/OfflinePack.ts @@ -1,6 +1,6 @@ -import {NativeModules} from 'react-native'; +import { NativeModules } from "react-native"; -import OfflineCreatePackOptions from './OfflineCreatePackOptions'; +import OfflineCreatePackOptions from "./OfflineCreatePackOptions"; const MapLibreGLOfflineManager = NativeModules.MLNOfflineModule; @@ -25,7 +25,7 @@ class OfflinePack { } get name(): string | null { - const {metadata} = this; + const { metadata } = this; return metadata && metadata.name; } diff --git a/javascript/modules/offline/offlineManager.ts b/javascript/modules/offline/offlineManager.ts index 9de8c569b..81be62ee3 100644 --- a/javascript/modules/offline/offlineManager.ts +++ b/javascript/modules/offline/offlineManager.ts @@ -2,13 +2,13 @@ import { NativeModules, NativeEventEmitter, EventSubscription, -} from 'react-native'; +} from "react-native"; import OfflineCreatePackOptions, { OfflineCreatePackInputOptions, -} from './OfflineCreatePackOptions'; -import OfflinePack from './OfflinePack'; -import {isUndefined, isFunction, isAndroid} from '../../utils'; +} from "./OfflineCreatePackOptions"; +import OfflinePack from "./OfflinePack"; +import { isUndefined, isFunction, isAndroid } from "../../utils"; const MapLibreGL = NativeModules.MLNModule; const MapLibreGLOfflineManager = NativeModules.MLNOfflineModule; @@ -231,7 +231,7 @@ class OfflineManager { async getPacks(): Promise { await this._initialize(); return Object.keys(this._offlinePacks).map( - name => this._offlinePacks[name], + (name) => this._offlinePacks[name], ); } @@ -339,7 +339,7 @@ class OfflineManager { // manually set a listener, since listeners are only set on create flow await MapLibreGLOfflineManager.setPackObserver(packName); } catch (e) { - console.log('Unable to set pack observer', e); + console.log("Unable to set pack observer", e); } } } @@ -392,7 +392,7 @@ class OfflineManager { } _onProgress(e: ProgressEvent): void { - const {name, state} = e.payload; + const { name, state } = e.payload; if (!this._hasListeners(name, this._progressListeners)) { return; @@ -408,7 +408,7 @@ class OfflineManager { } _onError(e: ErrorEvent): void { - const {name} = e.payload; + const { name } = e.payload; if (!this._hasListeners(name, this._errorListeners)) { return; diff --git a/javascript/modules/snapshot/SnapshotOptions.ts b/javascript/modules/snapshot/SnapshotOptions.ts index 95cf6ba4d..2f537fe3c 100644 --- a/javascript/modules/snapshot/SnapshotOptions.ts +++ b/javascript/modules/snapshot/SnapshotOptions.ts @@ -1,7 +1,7 @@ -import {NativeModules} from 'react-native'; +import { NativeModules } from "react-native"; -import {toJSONString} from '../../utils'; -import {makePoint, makeFeatureCollection} from '../../utils/geoUtils'; +import { toJSONString } from "../../utils"; +import { makePoint, makeFeatureCollection } from "../../utils/geoUtils"; const MapLibreGL = NativeModules.MLNModule; @@ -46,7 +46,7 @@ export class SnapshotOptions { constructor(options: SnapshotInputOptions) { if (!options.centerCoordinate && !options.bounds) { throw new Error( - 'Center coordinate or bounds must be supplied in order to take a snapshot', + "Center coordinate or bounds must be supplied in order to take a snapshot", ); } diff --git a/javascript/modules/snapshot/snapshotManager.ts b/javascript/modules/snapshot/snapshotManager.ts index 910865b02..77f65c4a4 100644 --- a/javascript/modules/snapshot/snapshotManager.ts +++ b/javascript/modules/snapshot/snapshotManager.ts @@ -1,6 +1,6 @@ -import {NativeModules} from 'react-native'; +import { NativeModules } from "react-native"; -import SnapshotOptions, {SnapshotInputOptions} from './SnapshotOptions'; +import SnapshotOptions, { SnapshotInputOptions } from "./SnapshotOptions"; const MapLibreGLSnapshotManger = NativeModules.MLNSnapshotModule; diff --git a/javascript/requestAndroidLocationPermissions.ts b/javascript/requestAndroidLocationPermissions.ts index ca20278cb..964ac0d31 100644 --- a/javascript/requestAndroidLocationPermissions.ts +++ b/javascript/requestAndroidLocationPermissions.ts @@ -1,6 +1,6 @@ -import {Permission, PermissionsAndroid} from 'react-native'; +import { Permission, PermissionsAndroid } from "react-native"; -import {isAndroid} from './utils'; +import { isAndroid } from "./utils"; export async function requestAndroidLocationPermissions(): Promise { if (isAndroid()) { @@ -25,5 +25,5 @@ export async function requestAndroidLocationPermissions(): Promise { return false; } - throw new Error('You should only call this method on Android!'); + throw new Error("You should only call this method on Android!"); } diff --git a/javascript/types/index.ts b/javascript/types/index.ts index 0a34f7fc4..8a59a428b 100644 --- a/javascript/types/index.ts +++ b/javascript/types/index.ts @@ -1,11 +1,11 @@ -import {SyntheticEvent} from 'react'; +import { SyntheticEvent } from "react"; export type MaplibreGLEvent< T extends string, P = GeoJSON.Feature, V = Element, -> = SyntheticEvent; +> = SyntheticEvent; export enum StyleURL { - Default = 'https://demotiles.maplibre.org/style.json', + Default = "https://demotiles.maplibre.org/style.json", } diff --git a/javascript/utils/BridgeValue.ts b/javascript/utils/BridgeValue.ts index 559c352ae..c2e3d3435 100644 --- a/javascript/utils/BridgeValue.ts +++ b/javascript/utils/BridgeValue.ts @@ -1,20 +1,20 @@ -import {isBoolean, isNumber, isString} from './index'; +import { isBoolean, isNumber, isString } from "./index"; export type RawValueType = | string | number | boolean | RawValueType[] - | {[key: string]: RawValueType}; + | { [key: string]: RawValueType }; export type StyleValueJSON = - | {type: 'boolean'; value: boolean} - | {type: 'number'; value: number} - | {type: 'string'; value: string} - | {type: 'hashmap'; value: object} - | {type: 'array'; value: unknown[]}; + | { type: "boolean"; value: boolean } + | { type: "number"; value: number } + | { type: "string"; value: string } + | { type: "hashmap"; value: object } + | { type: "array"; value: unknown[] }; -type StyleValueTypes = 'boolean' | 'number' | 'string' | 'hashmap' | 'array'; +type StyleValueTypes = "boolean" | "number" | "string" | "hashmap" | "array"; export default class BridgeValue { rawValue: RawValueType; @@ -25,19 +25,19 @@ export default class BridgeValue { get type(): StyleValueTypes { if (Array.isArray(this.rawValue)) { - return 'array'; + return "array"; } if (isBoolean(this.rawValue)) { - return 'boolean'; + return "boolean"; } if (isNumber(this.rawValue)) { - return 'number'; + return "number"; } if (isString(this.rawValue)) { - return 'string'; + return "string"; } - if (this.rawValue && typeof this.rawValue === 'object') { - return 'hashmap'; + if (this.rawValue && typeof this.rawValue === "object") { + return "hashmap"; } throw new Error( `[type - ${this.rawValue}] BridgeValue must be a primitive/array/object`, @@ -48,20 +48,20 @@ export default class BridgeValue { | [StyleValueJSON, StyleValueJSON][] | StyleValueJSON[] | RawValueType { - const {type} = this; + const { type } = this; let value; - if (type === 'array') { + if (type === "array") { value = []; for (const innerRawValue of this.rawValue as RawValueType[]) { const bridgeValue = new BridgeValue(innerRawValue); value.push(bridgeValue.toJSON()); } - } else if (type === 'hashmap') { + } else if (type === "hashmap") { value = []; - const rawValue = this.rawValue as {[key: string]: RawValueType}; + const rawValue = this.rawValue as { [key: string]: RawValueType }; const stringKeys = Object.keys(this.rawValue); for (const stringKey of stringKeys) { value.push([ @@ -69,7 +69,7 @@ export default class BridgeValue { new BridgeValue(rawValue[stringKey]).toJSON(), ] as [StyleValueJSON, StyleValueJSON]); } - } else if (type === 'boolean' || type === 'number' || type === 'string') { + } else if (type === "boolean" || type === "number" || type === "string") { value = this.rawValue; } else { throw new Error( @@ -84,7 +84,7 @@ export default class BridgeValue { return { type: this.type, value: - typeof formatter === 'function' ? formatter(this.value) : this.value, + typeof formatter === "function" ? formatter(this.value) : this.value, } as StyleValueJSON; } } diff --git a/javascript/utils/Logger.ts b/javascript/utils/Logger.ts index 501ea66c0..71cfc5843 100644 --- a/javascript/utils/Logger.ts +++ b/javascript/utils/Logger.ts @@ -2,10 +2,10 @@ import { EmitterSubscription, NativeEventEmitter, NativeModules, -} from 'react-native'; -const {MLNLogging} = NativeModules; +} from "react-native"; +const { MLNLogging } = NativeModules; -export type LogLevel = 'error' | 'warning' | 'info' | 'debug' | 'verbose'; +export type LogLevel = "error" | "warning" | "info" | "debug" | "verbose"; interface Log { message: string; level: LogLevel; @@ -90,7 +90,7 @@ class Logger { } subscribe(): void { - this.subscription = this.loggerEmitter.addListener('LogEvent', log => { + this.subscription = this.loggerEmitter.addListener("LogEvent", (log) => { this.onLog(log); }); } @@ -102,14 +102,14 @@ class Logger { } } - effectiveLevel({level, message, tag}: Log): LogLevel { - if (level === 'warning') { + effectiveLevel({ level, message, tag }: Log): LogLevel { + if (level === "warning") { if ( - tag === 'Mbgl-HttpRequest' && - message.startsWith('Request failed due to a permanent error: Canceled') + tag === "Mbgl-HttpRequest" && + message.startsWith("Request failed due to a permanent error: Canceled") ) { // this seems to happening too much to show a warning every time - return 'info'; + return "info"; } } return level; @@ -117,12 +117,12 @@ class Logger { onLog(log: Log): void { if (!this.logCallback || !this.logCallback(log)) { - const {message} = log; + const { message } = log; const level = this.effectiveLevel(log); - if (level === 'error') { - console.error('MapLibre error', message, log); - } else if (level === 'warning') { - console.warn('MapLibre warning', message, log); + if (level === "error") { + console.error("MapLibre error", message, log); + } else if (level === "warning") { + console.warn("MapLibre warning", message, log); } else { console.log(`MapLibre [${level}]`, message, log); } diff --git a/javascript/utils/MaplibreStyles.d.ts b/javascript/utils/MaplibreStyles.d.ts index f9a32b600..1bf803e06 100644 --- a/javascript/utils/MaplibreStyles.d.ts +++ b/javascript/utils/MaplibreStyles.d.ts @@ -1,7 +1,7 @@ /* This file was generated from MapboxStyle.ts.ejs do not modify */ -import {type ImageSourcePropType} from 'react-native'; +import { type ImageSourcePropType } from "react-native"; -export type Translation = {x: number; y: number} | [number, number]; +export type Translation = { x: number; y: number } | [number, number]; export interface Transition { duration: number; @@ -12,98 +12,98 @@ export type FormattedString = string; /* TODO */ type ExpressionName = // Types - | 'array' - | 'boolean' - | 'collator' - | 'format' - | 'image' - | 'literal' - | 'number' - | 'number-format' - | 'object' - | 'string' - | 'to-boolean' - | 'to-color' - | 'to-number' - | 'to-string' - | 'typeof' + | "array" + | "boolean" + | "collator" + | "format" + | "image" + | "literal" + | "number" + | "number-format" + | "object" + | "string" + | "to-boolean" + | "to-color" + | "to-number" + | "to-string" + | "typeof" // Feature data - | 'accumulated' - | 'feature-state' - | 'geometry-type' - | 'id' - | 'line-progress' - | 'properties' + | "accumulated" + | "feature-state" + | "geometry-type" + | "id" + | "line-progress" + | "properties" // Lookup - | 'at' - | 'get' - | 'has' - | 'in' - | 'index-of' - | 'length' - | 'slice' + | "at" + | "get" + | "has" + | "in" + | "index-of" + | "length" + | "slice" // Decision - | '!' - | '!=' - | '<' - | '<=' - | '==' - | '>' - | '>=' - | 'all' - | 'any' - | 'case' - | 'match' - | 'coalesce' - | 'within' + | "!" + | "!=" + | "<" + | "<=" + | "==" + | ">" + | ">=" + | "all" + | "any" + | "case" + | "match" + | "coalesce" + | "within" // Ramps, scales, curves - | 'interpolate' - | 'interpolate-hcl' - | 'interpolate-lab' - | 'step' + | "interpolate" + | "interpolate-hcl" + | "interpolate-lab" + | "step" // Variable binding - | 'let' - | 'var' + | "let" + | "var" // String - | 'concat' - | 'downcase' - | 'is-supported-script' - | 'resolved-locale' - | 'upcase' + | "concat" + | "downcase" + | "is-supported-script" + | "resolved-locale" + | "upcase" // Color - | 'rgb' - | 'rgba' - | 'to-rgba' + | "rgb" + | "rgba" + | "to-rgba" // Math - | '-' - | '*' - | '/' - | '%' - | '^' - | '+' - | 'abs' - | 'acos' - | 'asin' - | 'atan' - | 'ceil' - | 'cos' - | 'distance' - | 'e' - | 'floor' - | 'ln' - | 'ln2' - | 'log10' - | 'log2' - | 'max' - | 'min' - | 'pi' - | 'round' - | 'sin' - | 'sqrt' - | 'tan' + | "-" + | "*" + | "/" + | "%" + | "^" + | "+" + | "abs" + | "acos" + | "asin" + | "atan" + | "ceil" + | "cos" + | "distance" + | "e" + | "floor" + | "ln" + | "ln2" + | "log10" + | "log2" + | "max" + | "min" + | "pi" + | "round" + | "sin" + | "sqrt" + | "tan" // Zoom, Heatmap - | 'zoom' - | 'heatmap-density'; + | "zoom" + | "heatmap-density"; type ExpressionField = | string @@ -111,19 +111,19 @@ type ExpressionField = | boolean | Expression | ExpressionField[] - | {[key: string]: ExpressionField}; + | { [key: string]: ExpressionField }; export type Expression = readonly [ExpressionName, ...ExpressionField[]]; export type FilterExpression = Expression; type ExpressionParameters = - | 'zoom' - | 'feature' - | 'feature-state' - | 'sky-radial-progress' - | 'line-progress' - | 'heatmap-density'; + | "zoom" + | "feature" + | "feature-state" + | "sky-radial-progress" + | "line-progress" + | "heatmap-density"; type ResolvedImageType = ImageSourcePropType | string; @@ -134,294 +134,294 @@ export type Value = enum VisibilityEnum { /** The layer is shown. */ - Visible = 'visible', + Visible = "visible", /** The layer is not shown. */ - None = 'none', + None = "none", } -type VisibilityEnumValues = 'visible' | 'none'; +type VisibilityEnumValues = "visible" | "none"; enum FillTranslateAnchorEnum { /** The fill is translated relative to the map. */ - Map = 'map', + Map = "map", /** The fill is translated relative to the viewport. */ - Viewport = 'viewport', + Viewport = "viewport", } -type FillTranslateAnchorEnumValues = 'map' | 'viewport'; +type FillTranslateAnchorEnumValues = "map" | "viewport"; enum LineCapEnum { /** A cap with a squared-off end which is drawn to the exact endpoint of the line. */ - Butt = 'butt', + Butt = "butt", /** A cap with a rounded end which is drawn beyond the endpoint of the line at a radius of one-half of the line's width and centered on the endpoint of the line. */ - Round = 'round', + Round = "round", /** A cap with a squared-off end which is drawn beyond the endpoint of the line at a distance of one-half of the line's width. */ - Square = 'square', + Square = "square", } -type LineCapEnumValues = 'butt' | 'round' | 'square'; +type LineCapEnumValues = "butt" | "round" | "square"; enum LineJoinEnum { /** A join with a squared-off end which is drawn beyond the endpoint of the line at a distance of one-half of the line's width. */ - Bevel = 'bevel', + Bevel = "bevel", /** A join with a rounded end which is drawn beyond the endpoint of the line at a radius of one-half of the line's width and centered on the endpoint of the line. */ - Round = 'round', + Round = "round", /** A join with a sharp, angled corner which is drawn with the outer sides beyond the endpoint of the path until they meet. */ - Miter = 'miter', + Miter = "miter", } -type LineJoinEnumValues = 'bevel' | 'round' | 'miter'; +type LineJoinEnumValues = "bevel" | "round" | "miter"; enum LineTranslateAnchorEnum { /** The line is translated relative to the map. */ - Map = 'map', + Map = "map", /** The line is translated relative to the viewport. */ - Viewport = 'viewport', + Viewport = "viewport", } -type LineTranslateAnchorEnumValues = 'map' | 'viewport'; +type LineTranslateAnchorEnumValues = "map" | "viewport"; enum SymbolPlacementEnum { /** The label is placed at the point where the geometry is located. */ - Point = 'point', + Point = "point", /** The label is placed along the line of the geometry. Can only be used on `LineString` and `Polygon` geometries. */ - Line = 'line', + Line = "line", /** The label is placed at the center of the line of the geometry. Can only be used on `LineString` and `Polygon` geometries. Note that a single feature in a vector tile may contain multiple line geometries. */ - LineCenter = 'line-center', + LineCenter = "line-center", } -type SymbolPlacementEnumValues = 'point' | 'line' | 'line-center'; +type SymbolPlacementEnumValues = "point" | "line" | "line-center"; enum SymbolZOrderEnum { /** Sorts symbols by `symbol-sort-key` if set. Otherwise, sorts symbols by their y-position relative to the viewport if `icon-allow-overlap` or `text-allow-overlap` is set to `true` or `icon-ignore-placement` or `text-ignore-placement` is `false`. */ - Auto = 'auto', + Auto = "auto", /** Sorts symbols by their y-position relative to the viewport if `icon-allow-overlap` or `text-allow-overlap` is set to `true` or `icon-ignore-placement` or `text-ignore-placement` is `false`. */ - ViewportY = 'viewport-y', + ViewportY = "viewport-y", /** Sorts symbols by `symbol-sort-key` if set. Otherwise, no sorting is applied; symbols are rendered in the same order as the source data. */ - Source = 'source', + Source = "source", } -type SymbolZOrderEnumValues = 'auto' | 'viewport-y' | 'source'; +type SymbolZOrderEnumValues = "auto" | "viewport-y" | "source"; enum IconRotationAlignmentEnum { /** When `symbol-placement` is set to `point`, aligns icons east-west. When `symbol-placement` is set to `line` or `line-center`, aligns icon x-axes with the line. */ - Map = 'map', + Map = "map", /** Produces icons whose x-axes are aligned with the x-axis of the viewport, regardless of the value of `symbol-placement`. */ - Viewport = 'viewport', + Viewport = "viewport", /** When `symbol-placement` is set to `point`, this is equivalent to `viewport`. When `symbol-placement` is set to `line` or `line-center`, this is equivalent to `map`. */ - Auto = 'auto', + Auto = "auto", } -type IconRotationAlignmentEnumValues = 'map' | 'viewport' | 'auto'; +type IconRotationAlignmentEnumValues = "map" | "viewport" | "auto"; enum IconTextFitEnum { /** The icon is displayed at its intrinsic aspect ratio. */ - None = 'none', + None = "none", /** The icon is scaled in the x-dimension to fit the width of the text. */ - Width = 'width', + Width = "width", /** The icon is scaled in the y-dimension to fit the height of the text. */ - Height = 'height', + Height = "height", /** The icon is scaled in both x- and y-dimensions. */ - Both = 'both', + Both = "both", } -type IconTextFitEnumValues = 'none' | 'width' | 'height' | 'both'; +type IconTextFitEnumValues = "none" | "width" | "height" | "both"; enum IconAnchorEnum { /** The center of the icon is placed closest to the anchor. */ - Center = 'center', + Center = "center", /** The left side of the icon is placed closest to the anchor. */ - Left = 'left', + Left = "left", /** The right side of the icon is placed closest to the anchor. */ - Right = 'right', + Right = "right", /** The top of the icon is placed closest to the anchor. */ - Top = 'top', + Top = "top", /** The bottom of the icon is placed closest to the anchor. */ - Bottom = 'bottom', + Bottom = "bottom", /** The top left corner of the icon is placed closest to the anchor. */ - TopLeft = 'top-left', + TopLeft = "top-left", /** The top right corner of the icon is placed closest to the anchor. */ - TopRight = 'top-right', + TopRight = "top-right", /** The bottom left corner of the icon is placed closest to the anchor. */ - BottomLeft = 'bottom-left', + BottomLeft = "bottom-left", /** The bottom right corner of the icon is placed closest to the anchor. */ - BottomRight = 'bottom-right', + BottomRight = "bottom-right", } type IconAnchorEnumValues = - | 'center' - | 'left' - | 'right' - | 'top' - | 'bottom' - | 'top-left' - | 'top-right' - | 'bottom-left' - | 'bottom-right'; + | "center" + | "left" + | "right" + | "top" + | "bottom" + | "top-left" + | "top-right" + | "bottom-left" + | "bottom-right"; enum IconPitchAlignmentEnum { /** The icon is aligned to the plane of the map. */ - Map = 'map', + Map = "map", /** The icon is aligned to the plane of the viewport. */ - Viewport = 'viewport', + Viewport = "viewport", /** Automatically matches the value of `icon-rotation-alignment`. */ - Auto = 'auto', + Auto = "auto", } -type IconPitchAlignmentEnumValues = 'map' | 'viewport' | 'auto'; +type IconPitchAlignmentEnumValues = "map" | "viewport" | "auto"; enum TextPitchAlignmentEnum { /** The text is aligned to the plane of the map. */ - Map = 'map', + Map = "map", /** The text is aligned to the plane of the viewport. */ - Viewport = 'viewport', + Viewport = "viewport", /** Automatically matches the value of `text-rotation-alignment`. */ - Auto = 'auto', + Auto = "auto", } -type TextPitchAlignmentEnumValues = 'map' | 'viewport' | 'auto'; +type TextPitchAlignmentEnumValues = "map" | "viewport" | "auto"; enum TextRotationAlignmentEnum { /** When `symbol-placement` is set to `point`, aligns text east-west. When `symbol-placement` is set to `line` or `line-center`, aligns text x-axes with the line. */ - Map = 'map', + Map = "map", /** Produces glyphs whose x-axes are aligned with the x-axis of the viewport, regardless of the value of `symbol-placement`. */ - Viewport = 'viewport', + Viewport = "viewport", /** When `symbol-placement` is set to `point`, aligns text to the x-axis of the viewport. When `symbol-placement` is set to `line` or `line-center`, aligns glyphs to the x-axis of the viewport and places them along the line. */ - ViewportGlyph = 'viewport-glyph', + ViewportGlyph = "viewport-glyph", /** When `symbol-placement` is set to `point`, this is equivalent to `viewport`. When `symbol-placement` is set to `line` or `line-center`, this is equivalent to `map`. */ - Auto = 'auto', + Auto = "auto", } type TextRotationAlignmentEnumValues = - | 'map' - | 'viewport' - | 'viewport-glyph' - | 'auto'; + | "map" + | "viewport" + | "viewport-glyph" + | "auto"; enum TextJustifyEnum { /** The text is aligned towards the anchor position. */ - Auto = 'auto', + Auto = "auto", /** The text is aligned to the left. */ - Left = 'left', + Left = "left", /** The text is centered. */ - Center = 'center', + Center = "center", /** The text is aligned to the right. */ - Right = 'right', + Right = "right", } -type TextJustifyEnumValues = 'auto' | 'left' | 'center' | 'right'; +type TextJustifyEnumValues = "auto" | "left" | "center" | "right"; enum TextVariableAnchorEnum { /** The center of the text is placed closest to the anchor. */ - Center = 'center', + Center = "center", /** The left side of the text is placed closest to the anchor. */ - Left = 'left', + Left = "left", /** The right side of the text is placed closest to the anchor. */ - Right = 'right', + Right = "right", /** The top of the text is placed closest to the anchor. */ - Top = 'top', + Top = "top", /** The bottom of the text is placed closest to the anchor. */ - Bottom = 'bottom', + Bottom = "bottom", /** The top left corner of the text is placed closest to the anchor. */ - TopLeft = 'top-left', + TopLeft = "top-left", /** The top right corner of the text is placed closest to the anchor. */ - TopRight = 'top-right', + TopRight = "top-right", /** The bottom left corner of the text is placed closest to the anchor. */ - BottomLeft = 'bottom-left', + BottomLeft = "bottom-left", /** The bottom right corner of the text is placed closest to the anchor. */ - BottomRight = 'bottom-right', + BottomRight = "bottom-right", } type TextVariableAnchorEnumValues = - | 'center' - | 'left' - | 'right' - | 'top' - | 'bottom' - | 'top-left' - | 'top-right' - | 'bottom-left' - | 'bottom-right'; + | "center" + | "left" + | "right" + | "top" + | "bottom" + | "top-left" + | "top-right" + | "bottom-left" + | "bottom-right"; enum TextAnchorEnum { /** The center of the text is placed closest to the anchor. */ - Center = 'center', + Center = "center", /** The left side of the text is placed closest to the anchor. */ - Left = 'left', + Left = "left", /** The right side of the text is placed closest to the anchor. */ - Right = 'right', + Right = "right", /** The top of the text is placed closest to the anchor. */ - Top = 'top', + Top = "top", /** The bottom of the text is placed closest to the anchor. */ - Bottom = 'bottom', + Bottom = "bottom", /** The top left corner of the text is placed closest to the anchor. */ - TopLeft = 'top-left', + TopLeft = "top-left", /** The top right corner of the text is placed closest to the anchor. */ - TopRight = 'top-right', + TopRight = "top-right", /** The bottom left corner of the text is placed closest to the anchor. */ - BottomLeft = 'bottom-left', + BottomLeft = "bottom-left", /** The bottom right corner of the text is placed closest to the anchor. */ - BottomRight = 'bottom-right', + BottomRight = "bottom-right", } type TextAnchorEnumValues = - | 'center' - | 'left' - | 'right' - | 'top' - | 'bottom' - | 'top-left' - | 'top-right' - | 'bottom-left' - | 'bottom-right'; + | "center" + | "left" + | "right" + | "top" + | "bottom" + | "top-left" + | "top-right" + | "bottom-left" + | "bottom-right"; enum TextWritingModeEnum { /** If a text's language supports horizontal writing mode, symbols with point placement would be laid out horizontally. */ - Horizontal = 'horizontal', + Horizontal = "horizontal", /** If a text's language supports vertical writing mode, symbols with point placement would be laid out vertically. */ - Vertical = 'vertical', + Vertical = "vertical", } -type TextWritingModeEnumValues = 'horizontal' | 'vertical'; +type TextWritingModeEnumValues = "horizontal" | "vertical"; enum TextTransformEnum { /** The text is not altered. */ - None = 'none', + None = "none", /** Forces all letters to be displayed in uppercase. */ - Uppercase = 'uppercase', + Uppercase = "uppercase", /** Forces all letters to be displayed in lowercase. */ - Lowercase = 'lowercase', + Lowercase = "lowercase", } -type TextTransformEnumValues = 'none' | 'uppercase' | 'lowercase'; +type TextTransformEnumValues = "none" | "uppercase" | "lowercase"; enum IconTranslateAnchorEnum { /** Icons are translated relative to the map. */ - Map = 'map', + Map = "map", /** Icons are translated relative to the viewport. */ - Viewport = 'viewport', + Viewport = "viewport", } -type IconTranslateAnchorEnumValues = 'map' | 'viewport'; +type IconTranslateAnchorEnumValues = "map" | "viewport"; enum TextTranslateAnchorEnum { /** The text is translated relative to the map. */ - Map = 'map', + Map = "map", /** The text is translated relative to the viewport. */ - Viewport = 'viewport', + Viewport = "viewport", } -type TextTranslateAnchorEnumValues = 'map' | 'viewport'; +type TextTranslateAnchorEnumValues = "map" | "viewport"; enum CircleTranslateAnchorEnum { /** The circle is translated relative to the map. */ - Map = 'map', + Map = "map", /** The circle is translated relative to the viewport. */ - Viewport = 'viewport', + Viewport = "viewport", } -type CircleTranslateAnchorEnumValues = 'map' | 'viewport'; +type CircleTranslateAnchorEnumValues = "map" | "viewport"; enum CirclePitchScaleEnum { /** Circles are scaled according to their apparent distance to the camera. */ - Map = 'map', + Map = "map", /** Circles are not scaled. */ - Viewport = 'viewport', + Viewport = "viewport", } -type CirclePitchScaleEnumValues = 'map' | 'viewport'; +type CirclePitchScaleEnumValues = "map" | "viewport"; enum CirclePitchAlignmentEnum { /** The circle is aligned to the plane of the map. */ - Map = 'map', + Map = "map", /** The circle is aligned to the plane of the viewport. */ - Viewport = 'viewport', + Viewport = "viewport", } -type CirclePitchAlignmentEnumValues = 'map' | 'viewport'; +type CirclePitchAlignmentEnumValues = "map" | "viewport"; enum FillExtrusionTranslateAnchorEnum { /** The fill extrusion is translated relative to the map. */ - Map = 'map', + Map = "map", /** The fill extrusion is translated relative to the viewport. */ - Viewport = 'viewport', + Viewport = "viewport", } -type FillExtrusionTranslateAnchorEnumValues = 'map' | 'viewport'; +type FillExtrusionTranslateAnchorEnumValues = "map" | "viewport"; enum RasterResamplingEnum { /** (Bi)linear filtering interpolates pixel values using the weighted average of the four closest original source pixels creating a smooth but blurry look when overscaled */ - Linear = 'linear', + Linear = "linear", /** Nearest neighbor filtering interpolates pixel values using the nearest original source pixel creating a sharp but pixelated look when overscaled */ - Nearest = 'nearest', + Nearest = "nearest", } -type RasterResamplingEnumValues = 'linear' | 'nearest'; +type RasterResamplingEnumValues = "linear" | "nearest"; enum HillshadeIlluminationAnchorEnum { /** The hillshade illumination is relative to the north direction. */ - Map = 'map', + Map = "map", /** The hillshade illumination is relative to the top of the viewport. */ - Viewport = 'viewport', + Viewport = "viewport", } -type HillshadeIlluminationAnchorEnumValues = 'map' | 'viewport'; +type HillshadeIlluminationAnchorEnumValues = "map" | "viewport"; enum AnchorEnum { /** The position of the light source is aligned to the rotation of the map. */ - Map = 'map', + Map = "map", /** The position of the light source is aligned to the rotation of the viewport. */ - Viewport = 'viewport', + Viewport = "viewport", } -type AnchorEnumValues = 'map' | 'viewport'; +type AnchorEnumValues = "map" | "viewport"; type Enum = EnumType | EnumValues; @@ -429,7 +429,7 @@ export interface FillLayerStyleProps { /** * Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key. */ - fillSortKey?: Value; + fillSortKey?: Value; /** * Whether this layer is displayed. */ @@ -437,11 +437,11 @@ export interface FillLayerStyleProps { /** * Whether or not the fill should be antialiased. */ - fillAntialias?: Value; + fillAntialias?: Value; /** * The opacity of the entire fill layer. In contrast to the `fillColor`, this value will also affect the 1px stroke around the fill, if the stroke is used. */ - fillOpacity?: Value; + fillOpacity?: Value; /** * The transition affecting any changes to this layer’s fillOpacity property. @@ -452,7 +452,7 @@ export interface FillLayerStyleProps { * * @disabledBy fillPattern */ - fillColor?: Value; + fillColor?: Value; /** * The transition affecting any changes to this layer’s fillColor property. @@ -463,7 +463,7 @@ export interface FillLayerStyleProps { * * @disabledBy fillPattern */ - fillOutlineColor?: Value; + fillOutlineColor?: Value; /** * The transition affecting any changes to this layer’s fillOutlineColor property. @@ -472,7 +472,7 @@ export interface FillLayerStyleProps { /** * The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively. */ - fillTranslate?: Value; + fillTranslate?: Value; /** * The transition affecting any changes to this layer’s fillTranslate property. @@ -485,12 +485,12 @@ export interface FillLayerStyleProps { */ fillTranslateAnchor?: Value< Enum, - ['zoom'] + ["zoom"] >; /** * Name of image in sprite to use for drawing image fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512). Note that zoomDependent expressions will be evaluated only at integer zoom levels. */ - fillPattern?: Value; + fillPattern?: Value; /** * The transition affecting any changes to this layer’s fillPattern property. @@ -501,23 +501,23 @@ export interface LineLayerStyleProps { /** * The display of line endings. */ - lineCap?: Value, ['zoom']>; + lineCap?: Value, ["zoom"]>; /** * The display of lines when joining. */ - lineJoin?: Value, ['zoom', 'feature']>; + lineJoin?: Value, ["zoom", "feature"]>; /** * Used to automatically convert miter joins to bevel joins for sharp angles. */ - lineMiterLimit?: Value; + lineMiterLimit?: Value; /** * Used to automatically convert round joins to miter joins for shallow angles. */ - lineRoundLimit?: Value; + lineRoundLimit?: Value; /** * Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key. */ - lineSortKey?: Value; + lineSortKey?: Value; /** * Whether this layer is displayed. */ @@ -525,7 +525,7 @@ export interface LineLayerStyleProps { /** * The opacity at which the line will be drawn. */ - lineOpacity?: Value; + lineOpacity?: Value; /** * The transition affecting any changes to this layer’s lineOpacity property. @@ -536,7 +536,7 @@ export interface LineLayerStyleProps { * * @disabledBy linePattern */ - lineColor?: Value; + lineColor?: Value; /** * The transition affecting any changes to this layer’s lineColor property. @@ -545,7 +545,7 @@ export interface LineLayerStyleProps { /** * The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively. */ - lineTranslate?: Value; + lineTranslate?: Value; /** * The transition affecting any changes to this layer’s lineTranslate property. @@ -558,12 +558,12 @@ export interface LineLayerStyleProps { */ lineTranslateAnchor?: Value< Enum, - ['zoom'] + ["zoom"] >; /** * Stroke thickness. */ - lineWidth?: Value; + lineWidth?: Value; /** * The transition affecting any changes to this layer’s lineWidth property. @@ -572,7 +572,7 @@ export interface LineLayerStyleProps { /** * Draws a line casing outside of a line's actual path. Value indicates the width of the inner gap. */ - lineGapWidth?: Value; + lineGapWidth?: Value; /** * The transition affecting any changes to this layer’s lineGapWidth property. @@ -581,7 +581,7 @@ export interface LineLayerStyleProps { /** * The line's offset. For linear features, a positive value offsets the line to the right, relative to the direction of the line, and a negative value to the left. For polygon features, a positive value results in an inset, and a negative value results in an outset. */ - lineOffset?: Value; + lineOffset?: Value; /** * The transition affecting any changes to this layer’s lineOffset property. @@ -590,7 +590,7 @@ export interface LineLayerStyleProps { /** * Blur applied to the line, in pixels. */ - lineBlur?: Value; + lineBlur?: Value; /** * The transition affecting any changes to this layer’s lineBlur property. @@ -601,7 +601,7 @@ export interface LineLayerStyleProps { * * @disabledBy linePattern */ - lineDasharray?: Value; + lineDasharray?: Value; /** * The transition affecting any changes to this layer’s lineDasharray property. @@ -610,7 +610,7 @@ export interface LineLayerStyleProps { /** * Name of image in sprite to use for drawing image lines. For seamless patterns, image width must be a factor of two (2, 4, 8, ..., 512). Note that zoomDependent expressions will be evaluated only at integer zoom levels. */ - linePattern?: Value; + linePattern?: Value; /** * The transition affecting any changes to this layer’s linePattern property. @@ -621,7 +621,7 @@ export interface LineLayerStyleProps { * * @disabledBy lineDasharray, linePattern */ - lineGradient?: Value; + lineGradient?: Value; } export interface SymbolLayerStyleProps { /** @@ -629,26 +629,26 @@ export interface SymbolLayerStyleProps { */ symbolPlacement?: Value< Enum, - ['zoom'] + ["zoom"] >; /** * Distance between two symbol anchors. */ - symbolSpacing?: Value; + symbolSpacing?: Value; /** * If true, the symbols will not cross tile edges to avoid mutual collisions. Recommended in layers that don't have enough padding in the vector tile to prevent collisions, or if it is a point symbol layer placed after a line symbol layer. When using a client that supports global collision detection, like MapLibre GL JS version 0.42.0 or greater, enabling this property is not needed to prevent clipped labels at tile boundaries. */ - symbolAvoidEdges?: Value; + symbolAvoidEdges?: Value; /** * Sorts features in ascending order based on this value. Features with lower sort keys are drawn and placed first. When `iconAllowOverlap` or `textAllowOverlap` is `false`, features with a lower sort key will have priority during placement. When `iconAllowOverlap` or `textAllowOverlap` is set to `true`, features with a higher sort key will overlap over features with a lower sort key. */ - symbolSortKey?: Value; + symbolSortKey?: Value; /** * Determines whether overlapping symbols in the same layer are rendered in the order that they appear in the data source or by their yPosition relative to the viewport. To control the order and prioritization of symbols otherwise, use `symbolSortKey`. */ symbolZOrder?: Value< Enum, - ['zoom'] + ["zoom"] >; /** * If true, the icon will be visible even if it collides with other previously drawn symbols. @@ -657,19 +657,19 @@ export interface SymbolLayerStyleProps { * * @disabledBy iconOverlap */ - iconAllowOverlap?: Value; + iconAllowOverlap?: Value; /** * If true, other symbols can be visible even if they collide with the icon. * * @requires iconImage */ - iconIgnorePlacement?: Value; + iconIgnorePlacement?: Value; /** * If true, text will display without their corresponding icons when the icon collides with other symbols and the text does not. * * @requires iconImage, textField */ - iconOptional?: Value; + iconOptional?: Value; /** * In combination with `symbolPlacement`, determines the rotation behavior of icons. * @@ -677,54 +677,54 @@ export interface SymbolLayerStyleProps { */ iconRotationAlignment?: Value< Enum, - ['zoom'] + ["zoom"] >; /** * Scales the original size of the icon by the provided factor. The new pixel size of the image will be the original pixel size multiplied by `iconSize`. 1 is the original size; 3 triples the size of the image. * * @requires iconImage */ - iconSize?: Value; + iconSize?: Value; /** * Scales the icon to fit around the associated text. * * @requires iconImage, textField */ - iconTextFit?: Value, ['zoom']>; + iconTextFit?: Value, ["zoom"]>; /** * Size of the additional area added to dimensions determined by `iconTextFit`, in clockwise order: top, right, bottom, left. * * @requires iconImage, textField */ - iconTextFitPadding?: Value; + iconTextFitPadding?: Value; /** * Name of image in sprite to use for drawing an image background. */ - iconImage?: Value; + iconImage?: Value; /** * Rotates the icon clockwise. * * @requires iconImage */ - iconRotate?: Value; + iconRotate?: Value; /** * Size of additional area round the icon bounding box used for detecting symbol collisions. Values are declared using CSS margin shorthand syntax: a single value applies to all four sides; two values apply to [top/bottom, left/right]; three values apply to [top, left/right, bottom]; four values apply to [top, right, bottom, left]. For backwards compatibility, a single bare number is accepted, and treated the same as a oneElement array padding applied to all sides. * * @requires iconImage */ - iconPadding?: Value; + iconPadding?: Value; /** * If true, the icon may be flipped to prevent it from being rendered upsideDown. * * @requires iconImage */ - iconKeepUpright?: Value; + iconKeepUpright?: Value; /** * Offset distance of icon from its anchor. Positive values indicate right and down, while negative values indicate left and up. Each component is multiplied by the value of `iconSize` to obtain the final offset in pixels. When combined with `iconRotate` the offset will be as if the rotated direction was up. * * @requires iconImage */ - iconOffset?: Value; + iconOffset?: Value; /** * Part of the icon placed closest to the anchor. * @@ -732,7 +732,7 @@ export interface SymbolLayerStyleProps { */ iconAnchor?: Value< Enum, - ['zoom', 'feature'] + ["zoom", "feature"] >; /** * Orientation of icon when map is pitched. @@ -741,7 +741,7 @@ export interface SymbolLayerStyleProps { */ iconPitchAlignment?: Value< Enum, - ['zoom'] + ["zoom"] >; /** * Orientation of text when map is pitched. @@ -750,7 +750,7 @@ export interface SymbolLayerStyleProps { */ textPitchAlignment?: Value< Enum, - ['zoom'] + ["zoom"] >; /** * In combination with `symbolPlacement`, determines the rotation behavior of the individual glyphs forming the text. @@ -759,42 +759,42 @@ export interface SymbolLayerStyleProps { */ textRotationAlignment?: Value< Enum, - ['zoom'] + ["zoom"] >; /** * Value to use for a text label. If a plain `string` is provided, it will be treated as a `formatted` with default/inherited formatting options. */ - textField?: Value; + textField?: Value; /** * Font stack to use for displaying text. * * @requires textField */ - textFont?: Value; + textFont?: Value; /** * Font size. * * @requires textField */ - textSize?: Value; + textSize?: Value; /** * The maximum line width for text wrapping. * * @requires textField */ - textMaxWidth?: Value; + textMaxWidth?: Value; /** * Text leading value for multiLine text. * * @requires textField */ - textLineHeight?: Value; + textLineHeight?: Value; /** * Text tracking amount. * * @requires textField */ - textLetterSpacing?: Value; + textLetterSpacing?: Value; /** * Text justification options. * @@ -802,14 +802,14 @@ export interface SymbolLayerStyleProps { */ textJustify?: Value< Enum, - ['zoom', 'feature'] + ["zoom", "feature"] >; /** * Radial offset of text, in the direction of the symbol's anchor. Useful in combination with `textVariableAnchor`, which defaults to using the twoDimensional `textOffset` if present. * * @requires textField */ - textRadialOffset?: Value; + textRadialOffset?: Value; /** * To increase the chance of placing highPriority labels on the map, you can provide an array of `textAnchor` locations: the renderer will attempt to place the label at each location, in order, before moving onto the next label. Use `textJustify: auto` to choose justification based on anchor position. To apply an offset, use the `textRadialOffset` or the twoDimensional `textOffset`. * @@ -817,7 +817,7 @@ export interface SymbolLayerStyleProps { */ textVariableAnchor?: Value< Enum[], - ['zoom'] + ["zoom"] >; /** * Part of the text placed closest to the anchor. @@ -828,14 +828,14 @@ export interface SymbolLayerStyleProps { */ textAnchor?: Value< Enum, - ['zoom', 'feature'] + ["zoom", "feature"] >; /** * Maximum angle change between adjacent characters. * * @requires textField */ - textMaxAngle?: Value; + textMaxAngle?: Value; /** * The property allows control over a symbol's orientation. Note that the property values act as a hint, so that a symbol whose language doesn’t support the provided orientation will be laid out in its natural orientation. Example: English point symbol will be rendered horizontally even if array value contains single 'vertical' enum value. The order of elements in an array define priority order for the placement of an orientation variant. * @@ -843,26 +843,26 @@ export interface SymbolLayerStyleProps { */ textWritingMode?: Value< Enum[], - ['zoom'] + ["zoom"] >; /** * Rotates the text clockwise. * * @requires textField */ - textRotate?: Value; + textRotate?: Value; /** * Size of the additional area around the text bounding box used for detecting symbol collisions. * * @requires textField */ - textPadding?: Value; + textPadding?: Value; /** * If true, the text may be flipped vertically to prevent it from being rendered upsideDown. * * @requires textField */ - textKeepUpright?: Value; + textKeepUpright?: Value; /** * Specifies how to capitalize text, similar to the CSS `textTransform` property. * @@ -870,7 +870,7 @@ export interface SymbolLayerStyleProps { */ textTransform?: Value< Enum, - ['zoom', 'feature'] + ["zoom", "feature"] >; /** * Offset distance of text from its anchor. Positive values indicate right and down, while negative values indicate left and up. If used with textVariableAnchor, input values will be taken as absolute values. Offsets along the x and yAxis will be applied automatically based on the anchor position. @@ -879,7 +879,7 @@ export interface SymbolLayerStyleProps { * * @disabledBy textRadialOffset */ - textOffset?: Value; + textOffset?: Value; /** * If true, the text will be visible even if it collides with other previously drawn symbols. * @@ -887,19 +887,19 @@ export interface SymbolLayerStyleProps { * * @disabledBy textOverlap */ - textAllowOverlap?: Value; + textAllowOverlap?: Value; /** * If true, other symbols can be visible even if they collide with the text. * * @requires textField */ - textIgnorePlacement?: Value; + textIgnorePlacement?: Value; /** * If true, icons will display without their corresponding text when the text collides with other symbols and the icon does not. * * @requires textField, iconImage */ - textOptional?: Value; + textOptional?: Value; /** * Whether this layer is displayed. */ @@ -909,7 +909,7 @@ export interface SymbolLayerStyleProps { * * @requires iconImage */ - iconOpacity?: Value; + iconOpacity?: Value; /** * The transition affecting any changes to this layer’s iconOpacity property. @@ -920,7 +920,7 @@ export interface SymbolLayerStyleProps { * * @requires iconImage */ - iconColor?: Value; + iconColor?: Value; /** * The transition affecting any changes to this layer’s iconColor property. @@ -931,7 +931,7 @@ export interface SymbolLayerStyleProps { * * @requires iconImage */ - iconHaloColor?: Value; + iconHaloColor?: Value; /** * The transition affecting any changes to this layer’s iconHaloColor property. @@ -942,7 +942,7 @@ export interface SymbolLayerStyleProps { * * @requires iconImage */ - iconHaloWidth?: Value; + iconHaloWidth?: Value; /** * The transition affecting any changes to this layer’s iconHaloWidth property. @@ -953,7 +953,7 @@ export interface SymbolLayerStyleProps { * * @requires iconImage */ - iconHaloBlur?: Value; + iconHaloBlur?: Value; /** * The transition affecting any changes to this layer’s iconHaloBlur property. @@ -964,7 +964,7 @@ export interface SymbolLayerStyleProps { * * @requires iconImage */ - iconTranslate?: Value; + iconTranslate?: Value; /** * The transition affecting any changes to this layer’s iconTranslate property. @@ -977,14 +977,14 @@ export interface SymbolLayerStyleProps { */ iconTranslateAnchor?: Value< Enum, - ['zoom'] + ["zoom"] >; /** * The opacity at which the text will be drawn. * * @requires textField */ - textOpacity?: Value; + textOpacity?: Value; /** * The transition affecting any changes to this layer’s textOpacity property. @@ -995,7 +995,7 @@ export interface SymbolLayerStyleProps { * * @requires textField */ - textColor?: Value; + textColor?: Value; /** * The transition affecting any changes to this layer’s textColor property. @@ -1006,7 +1006,7 @@ export interface SymbolLayerStyleProps { * * @requires textField */ - textHaloColor?: Value; + textHaloColor?: Value; /** * The transition affecting any changes to this layer’s textHaloColor property. @@ -1017,7 +1017,7 @@ export interface SymbolLayerStyleProps { * * @requires textField */ - textHaloWidth?: Value; + textHaloWidth?: Value; /** * The transition affecting any changes to this layer’s textHaloWidth property. @@ -1028,7 +1028,7 @@ export interface SymbolLayerStyleProps { * * @requires textField */ - textHaloBlur?: Value; + textHaloBlur?: Value; /** * The transition affecting any changes to this layer’s textHaloBlur property. @@ -1039,7 +1039,7 @@ export interface SymbolLayerStyleProps { * * @requires textField */ - textTranslate?: Value; + textTranslate?: Value; /** * The transition affecting any changes to this layer’s textTranslate property. @@ -1052,14 +1052,14 @@ export interface SymbolLayerStyleProps { */ textTranslateAnchor?: Value< Enum, - ['zoom'] + ["zoom"] >; } export interface CircleLayerStyleProps { /** * Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key. */ - circleSortKey?: Value; + circleSortKey?: Value; /** * Whether this layer is displayed. */ @@ -1067,7 +1067,7 @@ export interface CircleLayerStyleProps { /** * Circle radius. */ - circleRadius?: Value; + circleRadius?: Value; /** * The transition affecting any changes to this layer’s circleRadius property. @@ -1076,7 +1076,7 @@ export interface CircleLayerStyleProps { /** * The fill color of the circle. */ - circleColor?: Value; + circleColor?: Value; /** * The transition affecting any changes to this layer’s circleColor property. @@ -1085,7 +1085,7 @@ export interface CircleLayerStyleProps { /** * Amount to blur the circle. 1 blurs the circle such that only the centerpoint is full opacity. */ - circleBlur?: Value; + circleBlur?: Value; /** * The transition affecting any changes to this layer’s circleBlur property. @@ -1094,7 +1094,7 @@ export interface CircleLayerStyleProps { /** * The opacity at which the circle will be drawn. */ - circleOpacity?: Value; + circleOpacity?: Value; /** * The transition affecting any changes to this layer’s circleOpacity property. @@ -1103,7 +1103,7 @@ export interface CircleLayerStyleProps { /** * The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively. */ - circleTranslate?: Value; + circleTranslate?: Value; /** * The transition affecting any changes to this layer’s circleTranslate property. @@ -1116,26 +1116,26 @@ export interface CircleLayerStyleProps { */ circleTranslateAnchor?: Value< Enum, - ['zoom'] + ["zoom"] >; /** * Controls the scaling behavior of the circle when the map is pitched. */ circlePitchScale?: Value< Enum, - ['zoom'] + ["zoom"] >; /** * Orientation of circle when map is pitched. */ circlePitchAlignment?: Value< Enum, - ['zoom'] + ["zoom"] >; /** * The width of the circle's stroke. Strokes are placed outside of the `circleRadius`. */ - circleStrokeWidth?: Value; + circleStrokeWidth?: Value; /** * The transition affecting any changes to this layer’s circleStrokeWidth property. @@ -1144,7 +1144,7 @@ export interface CircleLayerStyleProps { /** * The stroke color of the circle. */ - circleStrokeColor?: Value; + circleStrokeColor?: Value; /** * The transition affecting any changes to this layer’s circleStrokeColor property. @@ -1153,7 +1153,7 @@ export interface CircleLayerStyleProps { /** * The opacity of the circle's stroke. */ - circleStrokeOpacity?: Value; + circleStrokeOpacity?: Value; /** * The transition affecting any changes to this layer’s circleStrokeOpacity property. @@ -1168,7 +1168,7 @@ export interface HeatmapLayerStyleProps { /** * Radius of influence of one heatmap point in pixels. Increasing the value makes the heatmap smoother, but less detailed. */ - heatmapRadius?: Value; + heatmapRadius?: Value; /** * The transition affecting any changes to this layer’s heatmapRadius property. @@ -1177,11 +1177,11 @@ export interface HeatmapLayerStyleProps { /** * A measure of how much an individual point contributes to the heatmap. A value of 10 would be equivalent to having 10 points of weight 1 in the same spot. Especially useful when combined with clustering. */ - heatmapWeight?: Value; + heatmapWeight?: Value; /** * Similar to `heatmapWeight` but controls the intensity of the heatmap globally. Primarily used for adjusting the heatmap based on zoom level. */ - heatmapIntensity?: Value; + heatmapIntensity?: Value; /** * The transition affecting any changes to this layer’s heatmapIntensity property. @@ -1190,11 +1190,11 @@ export interface HeatmapLayerStyleProps { /** * Defines the color of each pixel based on its density value in a heatmap. Should be an expression that uses `["heatmapDensity"]` as input. */ - heatmapColor?: Value; + heatmapColor?: Value; /** * The global opacity at which the heatmap layer will be drawn. */ - heatmapOpacity?: Value; + heatmapOpacity?: Value; /** * The transition affecting any changes to this layer’s heatmapOpacity property. @@ -1209,7 +1209,7 @@ export interface FillExtrusionLayerStyleProps { /** * The opacity of the entire fill extrusion layer. This is rendered on a perLayer, not perFeature, basis, and dataDriven styling is not available. */ - fillExtrusionOpacity?: Value; + fillExtrusionOpacity?: Value; /** * The transition affecting any changes to this layer’s fillExtrusionOpacity property. @@ -1220,7 +1220,7 @@ export interface FillExtrusionLayerStyleProps { * * @disabledBy fillExtrusionPattern */ - fillExtrusionColor?: Value; + fillExtrusionColor?: Value; /** * The transition affecting any changes to this layer’s fillExtrusionColor property. @@ -1229,7 +1229,7 @@ export interface FillExtrusionLayerStyleProps { /** * The geometry's offset. Values are [x, y] where negatives indicate left and up (on the flat plane), respectively. */ - fillExtrusionTranslate?: Value; + fillExtrusionTranslate?: Value; /** * The transition affecting any changes to this layer’s fillExtrusionTranslate property. @@ -1245,12 +1245,12 @@ export interface FillExtrusionLayerStyleProps { FillExtrusionTranslateAnchorEnum, FillExtrusionTranslateAnchorEnumValues >, - ['zoom'] + ["zoom"] >; /** * Name of image in sprite to use for drawing images on extruded fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512). Note that zoomDependent expressions will be evaluated only at integer zoom levels. */ - fillExtrusionPattern?: Value; + fillExtrusionPattern?: Value; /** * The transition affecting any changes to this layer’s fillExtrusionPattern property. @@ -1259,7 +1259,7 @@ export interface FillExtrusionLayerStyleProps { /** * The height with which to extrude this layer. */ - fillExtrusionHeight?: Value; + fillExtrusionHeight?: Value; /** * The transition affecting any changes to this layer’s fillExtrusionHeight property. @@ -1270,7 +1270,7 @@ export interface FillExtrusionLayerStyleProps { * * @requires fillExtrusionHeight */ - fillExtrusionBase?: Value; + fillExtrusionBase?: Value; /** * The transition affecting any changes to this layer’s fillExtrusionBase property. @@ -1285,7 +1285,7 @@ export interface RasterLayerStyleProps { /** * The opacity at which the image will be drawn. */ - rasterOpacity?: Value; + rasterOpacity?: Value; /** * The transition affecting any changes to this layer’s rasterOpacity property. @@ -1294,7 +1294,7 @@ export interface RasterLayerStyleProps { /** * Rotates hues around the color wheel. */ - rasterHueRotate?: Value; + rasterHueRotate?: Value; /** * The transition affecting any changes to this layer’s rasterHueRotate property. @@ -1303,7 +1303,7 @@ export interface RasterLayerStyleProps { /** * Increase or reduce the brightness of the image. The value is the minimum brightness. */ - rasterBrightnessMin?: Value; + rasterBrightnessMin?: Value; /** * The transition affecting any changes to this layer’s rasterBrightnessMin property. @@ -1312,7 +1312,7 @@ export interface RasterLayerStyleProps { /** * Increase or reduce the brightness of the image. The value is the maximum brightness. */ - rasterBrightnessMax?: Value; + rasterBrightnessMax?: Value; /** * The transition affecting any changes to this layer’s rasterBrightnessMax property. @@ -1321,7 +1321,7 @@ export interface RasterLayerStyleProps { /** * Increase or reduce the saturation of the image. */ - rasterSaturation?: Value; + rasterSaturation?: Value; /** * The transition affecting any changes to this layer’s rasterSaturation property. @@ -1330,7 +1330,7 @@ export interface RasterLayerStyleProps { /** * Increase or reduce the contrast of the image. */ - rasterContrast?: Value; + rasterContrast?: Value; /** * The transition affecting any changes to this layer’s rasterContrast property. @@ -1341,12 +1341,12 @@ export interface RasterLayerStyleProps { */ rasterResampling?: Value< Enum, - ['zoom'] + ["zoom"] >; /** * Fade duration when a new tile is added. */ - rasterFadeDuration?: Value; + rasterFadeDuration?: Value; } export interface HillshadeLayerStyleProps { /** @@ -1356,7 +1356,7 @@ export interface HillshadeLayerStyleProps { /** * The direction of the light source used to generate the hillshading with 0 as the top of the viewport if `hillshadeIlluminationAnchor` is set to `viewport` and due north if `hillshadeIlluminationAnchor` is set to `map`. */ - hillshadeIlluminationDirection?: Value; + hillshadeIlluminationDirection?: Value; /** * Direction of light source when map is rotated. */ @@ -1365,12 +1365,12 @@ export interface HillshadeLayerStyleProps { HillshadeIlluminationAnchorEnum, HillshadeIlluminationAnchorEnumValues >, - ['zoom'] + ["zoom"] >; /** * Intensity of the hillshade */ - hillshadeExaggeration?: Value; + hillshadeExaggeration?: Value; /** * The transition affecting any changes to this layer’s hillshadeExaggeration property. @@ -1379,7 +1379,7 @@ export interface HillshadeLayerStyleProps { /** * The shading color of areas that face away from the light source. */ - hillshadeShadowColor?: Value; + hillshadeShadowColor?: Value; /** * The transition affecting any changes to this layer’s hillshadeShadowColor property. @@ -1388,7 +1388,7 @@ export interface HillshadeLayerStyleProps { /** * The shading color of areas that faces towards the light source. */ - hillshadeHighlightColor?: Value; + hillshadeHighlightColor?: Value; /** * The transition affecting any changes to this layer’s hillshadeHighlightColor property. @@ -1397,7 +1397,7 @@ export interface HillshadeLayerStyleProps { /** * The shading color used to accentuate rugged terrain like sharp cliffs and gorges. */ - hillshadeAccentColor?: Value; + hillshadeAccentColor?: Value; /** * The transition affecting any changes to this layer’s hillshadeAccentColor property. @@ -1414,7 +1414,7 @@ export interface BackgroundLayerStyleProps { * * @disabledBy backgroundPattern */ - backgroundColor?: Value; + backgroundColor?: Value; /** * The transition affecting any changes to this layer’s backgroundColor property. @@ -1423,7 +1423,7 @@ export interface BackgroundLayerStyleProps { /** * Name of image in sprite to use for drawing an image background. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512). Note that zoomDependent expressions will be evaluated only at integer zoom levels. */ - backgroundPattern?: Value; + backgroundPattern?: Value; /** * The transition affecting any changes to this layer’s backgroundPattern property. @@ -1432,7 +1432,7 @@ export interface BackgroundLayerStyleProps { /** * The opacity at which the background will be drawn. */ - backgroundOpacity?: Value; + backgroundOpacity?: Value; /** * The transition affecting any changes to this layer’s backgroundOpacity property. @@ -1443,11 +1443,11 @@ export interface LightLayerStyleProps { /** * Whether extruded geometries are lit relative to the map or viewport. */ - anchor?: Value, ['zoom']>; + anchor?: Value, ["zoom"]>; /** * Position of the light source relative to lit (extruded) geometries, in [r radial coordinate, a azimuthal angle, p polar angle] where r indicates the distance from the center of the base of an object to its light, a indicates the position of the light relative to 0° (0° when `light.anchor` is set to `viewport` corresponds to the top of the viewport, or 0° when `light.anchor` is set to `map` corresponds to due north, and degrees proceed clockwise), and p indicates the height of the light (from 0°, directly above, to 180°, directly below). */ - position?: Value; + position?: Value; /** * The transition affecting any changes to this layer’s position property. @@ -1456,7 +1456,7 @@ export interface LightLayerStyleProps { /** * Color tint for lighting extruded geometries. */ - color?: Value; + color?: Value; /** * The transition affecting any changes to this layer’s color property. @@ -1465,7 +1465,7 @@ export interface LightLayerStyleProps { /** * Intensity of lighting (on a scale from 0 to 1). Higher numbers will present as more extreme contrast. */ - intensity?: Value; + intensity?: Value; /** * The transition affecting any changes to this layer’s intensity property. diff --git a/javascript/utils/StyleValue.ts b/javascript/utils/StyleValue.ts index b07651311..2d5d9b608 100644 --- a/javascript/utils/StyleValue.ts +++ b/javascript/utils/StyleValue.ts @@ -1,11 +1,11 @@ -import {Image, processColor} from 'react-native'; +import { Image, processColor } from "react-native"; import BridgeValue, { type RawValueType, type StyleValueJSON, -} from './BridgeValue'; -import {AllLayerStyleProps} from './MaplibreStyles'; -import {getStyleType} from './styleMap'; +} from "./BridgeValue"; +import { AllLayerStyleProps } from "./MaplibreStyles"; +import { getStyleType } from "./styleMap"; export type StyleValue = { styletype: string; @@ -14,26 +14,26 @@ export type StyleValue = { export function transformStyle( style: AllLayerStyleProps | undefined, -): undefined | {[key: string]: StyleValue} { +): undefined | { [key: string]: StyleValue } { if (!style) { return; } - const nativeStyle: {[key: string]: StyleValue} = {}; + const nativeStyle: { [key: string]: StyleValue } = {}; const styleProps = Object.keys(style) as (keyof typeof style)[]; for (const styleProp of styleProps) { const styleType = getStyleType(styleProp); let rawStyle: RawValueType | undefined = style[styleProp]; - if (styleType === 'color' && typeof rawStyle === 'string') { + if (styleType === "color" && typeof rawStyle === "string") { const color = processColor(rawStyle); - if (color === null || color === undefined || typeof color === 'symbol') { + if (color === null || color === undefined || typeof color === "symbol") { console.error(`RNMaplibre: Invalid color value: ${rawStyle} using red`); - rawStyle = 'ff0000'; + rawStyle = "ff0000"; } else { rawStyle = color; } - } else if (styleType === 'image' && typeof rawStyle === 'number') { + } else if (styleType === "image" && typeof rawStyle === "number") { rawStyle = (Image.resolveAssetSource(rawStyle) as unknown as RawValueType) || {}; } diff --git a/javascript/utils/animated/AbstractAnimatedCoordinates.ts b/javascript/utils/animated/AbstractAnimatedCoordinates.ts index 296c25ceb..f4758e696 100644 --- a/javascript/utils/animated/AbstractAnimatedCoordinates.ts +++ b/javascript/utils/animated/AbstractAnimatedCoordinates.ts @@ -1,12 +1,12 @@ -import {Animated} from 'react-native'; +import { Animated } from "react-native"; // see // https://github.com/facebook/react-native/blob/master/Libraries/Animated/src/nodes/AnimatedWithChildren.js const AnimatedWithChildren = Object.getPrototypeOf(Animated.ValueXY); if (__DEV__) { - if (AnimatedWithChildren.name !== 'AnimatedWithChildren') { + if (AnimatedWithChildren.name !== "AnimatedWithChildren") { console.error( - 'AnimatedCoordinatesArray could not obtain AnimatedWithChildren base class', + "AnimatedCoordinatesArray could not obtain AnimatedWithChildren base class", ); } } @@ -47,7 +47,7 @@ abstract class AbstractAnimatedCoordinates extends AnimatedWithChildren { | Animated.TimingAnimationConfig | Animated.SpringAnimationConfig | Animated.DecayAnimationConfig - ) & {toValue: AnimatedCoordinates[]}, + ) & { toValue: AnimatedCoordinates[] }, ): Animated.CompositeAnimation { const onAnimationStart = (animation: Animated.CompositeAnimation): void => { if (this.animation) { @@ -93,7 +93,7 @@ abstract class AbstractAnimatedCoordinates extends AnimatedWithChildren { } spring( - config: Animated.SpringAnimationConfig & {toValue: AnimatedCoordinates[]}, + config: Animated.SpringAnimationConfig & { toValue: AnimatedCoordinates[] }, ): Animated.CompositeAnimation { const progressValue = new Animated.Value(0.0); return this.animate( @@ -108,7 +108,7 @@ abstract class AbstractAnimatedCoordinates extends AnimatedWithChildren { } decay( - config: Animated.DecayAnimationConfig & {toValue: AnimatedCoordinates[]}, + config: Animated.DecayAnimationConfig & { toValue: AnimatedCoordinates[] }, ): Animated.CompositeAnimation { const progressValue = new Animated.Value(0.0); return this.animate( diff --git a/javascript/utils/animated/Animated.ts b/javascript/utils/animated/Animated.ts index feecd2d56..ecc9704a6 100644 --- a/javascript/utils/animated/Animated.ts +++ b/javascript/utils/animated/Animated.ts @@ -1,18 +1,18 @@ -import {Animated as RNAnimated} from 'react-native'; +import { Animated as RNAnimated } from "react-native"; -import AnimatedCoordinatesArray from './AnimatedCoordinatesArray'; -import AnimatedExtractCoordinateFromArray from './AnimatedExtractCoordinateFromArray'; -import AnimatedRouteCoordinatesArray from './AnimatedRouteCoordinatesArray'; -import AnimatedShape from './AnimatedShape'; -import BackgroundLayer from '../../components/BackgroundLayer'; -import CircleLayer from '../../components/CircleLayer'; -import FillExtrusionLayer from '../../components/FillExtrusionLayer'; -import FillLayer from '../../components/FillLayer'; -import ImageSource from '../../components/ImageSource'; -import LineLayer from '../../components/LineLayer'; -import RasterLayer from '../../components/RasterLayer'; -import ShapeSource from '../../components/ShapeSource'; -import SymbolLayer from '../../components/SymbolLayer'; +import AnimatedCoordinatesArray from "./AnimatedCoordinatesArray"; +import AnimatedExtractCoordinateFromArray from "./AnimatedExtractCoordinateFromArray"; +import AnimatedRouteCoordinatesArray from "./AnimatedRouteCoordinatesArray"; +import AnimatedShape from "./AnimatedShape"; +import BackgroundLayer from "../../components/BackgroundLayer"; +import CircleLayer from "../../components/CircleLayer"; +import FillExtrusionLayer from "../../components/FillExtrusionLayer"; +import FillLayer from "../../components/FillLayer"; +import ImageSource from "../../components/ImageSource"; +import LineLayer from "../../components/LineLayer"; +import RasterLayer from "../../components/RasterLayer"; +import ShapeSource from "../../components/ShapeSource"; +import SymbolLayer from "../../components/SymbolLayer"; const Animated = { // sources diff --git a/javascript/utils/animated/AnimatedCoordinatesArray.ts b/javascript/utils/animated/AnimatedCoordinatesArray.ts index 56f947530..5dee3a7ea 100644 --- a/javascript/utils/animated/AnimatedCoordinatesArray.ts +++ b/javascript/utils/animated/AnimatedCoordinatesArray.ts @@ -1,6 +1,6 @@ import AbstractAnimatedCoordinates, { AnimatedCoordinates, -} from './AbstractAnimatedCoordinates'; +} from "./AbstractAnimatedCoordinates"; interface CoordinatesState { coords: AnimatedCoordinates[]; @@ -16,7 +16,7 @@ class AnimatedCoordinatesArray extends AbstractAnimatedCoordinates [coord[0], coord[1]]), + coords: coordinatesArray.map((coord) => [coord[0], coord[1]]), targetCoords: [], }; } @@ -28,7 +28,7 @@ class AnimatedCoordinatesArray extends AbstractAnimatedCoordinates targetCoords.length) { @@ -78,10 +78,10 @@ class AnimatedCoordinatesArray extends AbstractAnimatedCoordinates { - if (typeof cb === 'function') { + if (typeof cb === "function") { cb(this.__getValue()); } }; @@ -78,7 +78,7 @@ export class AnimatedPoint extends AnimatedWithChildren { spring( config: Partial & { coordinates: GeoJSON.Position; - } = {coordinates: DEFAULT_COORD}, + } = { coordinates: DEFAULT_COORD }, ): Animated.CompositeAnimation { return Animated.parallel([ Animated.spring(this.longitude, { @@ -97,7 +97,7 @@ export class AnimatedPoint extends AnimatedWithChildren { timing( config: Partial & { coordinates: GeoJSON.Position; - } = {coordinates: DEFAULT_COORD}, + } = { coordinates: DEFAULT_COORD }, ): Animated.CompositeAnimation { return Animated.parallel([ Animated.timing(this.longitude, { @@ -115,7 +115,7 @@ export class AnimatedPoint extends AnimatedWithChildren { __getValue(): GeoJSON.Point { return { - type: 'Point', + type: "Point", coordinates: [this.longitude.__getValue(), this.latitude.__getValue()], }; } diff --git a/javascript/utils/animated/AnimatedRouteCoordinatesArray.ts b/javascript/utils/animated/AnimatedRouteCoordinatesArray.ts index e621b2c63..7b3ec8b33 100644 --- a/javascript/utils/animated/AnimatedRouteCoordinatesArray.ts +++ b/javascript/utils/animated/AnimatedRouteCoordinatesArray.ts @@ -1,11 +1,11 @@ -import distance from '@turf/distance'; -import {lineString, point, convertLength, Coord, Units} from '@turf/helpers'; -import length from '@turf/length'; -import nearestPointOnLine from '@turf/nearest-point-on-line'; +import distance from "@turf/distance"; +import { lineString, point, convertLength, Coord, Units } from "@turf/helpers"; +import length from "@turf/length"; +import nearestPointOnLine from "@turf/nearest-point-on-line"; import AbstractAnimatedCoordinates, { AnimatedCoordinates, -} from './AbstractAnimatedCoordinates'; +} from "./AbstractAnimatedCoordinates"; interface AnimatedRouteState { actRoute?: AnimatedCoordinates[]; @@ -31,7 +31,7 @@ export default class AnimatedRouteCoordinatesArray extends AbstractAnimatedCoord fullRoute: coordinatesArray.map( (coord): AnimatedCoordinates => [coord[0], coord[1]], ), - end: {from: 0, to: 0}, + end: { from: 0, to: 0 }, }; } @@ -55,7 +55,7 @@ export default class AnimatedRouteCoordinatesArray extends AbstractAnimatedCoord * @returns {object} next state */ onCalculate(state: AnimatedRouteState, progress: number): AnimatedRouteState { - const {fullRoute, end} = state; + const { fullRoute, end } = state; const currentEnd = end.from * (1.0 - progress) + progress * end.to; let prevsum = 0; @@ -72,7 +72,7 @@ export default class AnimatedRouteCoordinatesArray extends AbstractAnimatedCoord } if (actsum <= currentEnd) { const actRoute = [...fullRoute.slice(0, i + 1)]; - return {fullRoute, end: {...end, current: currentEnd}, actRoute}; + return { fullRoute, end: { ...end, current: currentEnd }, actRoute }; } const r = (currentEnd - prevsum) / (actsum - prevsum); const or = 1.0 - r; @@ -84,7 +84,7 @@ export default class AnimatedRouteCoordinatesArray extends AbstractAnimatedCoord fullRoute[i][1] * r + fullRoute[i + 1][1] * or, ] as AnimatedCoordinates, ]; - return {fullRoute, end: {...end, current: currentEnd}, actRoute}; + return { fullRoute, end: { ...end, current: currentEnd }, actRoute }; } /** @@ -96,17 +96,17 @@ export default class AnimatedRouteCoordinatesArray extends AbstractAnimatedCoord */ onStart( state: AnimatedRouteState, - toValue: {end: {point?: Coord; along?: number}; units?: Units}, + toValue: { end: { point?: Coord; along?: number }; units?: Units }, ): AnimatedRouteState { - const {fullRoute, end} = state; + const { fullRoute, end } = state; let toDist = 0; if (!toValue.end) { console.error( - 'RouteCoordinatesArray: toValue should have end with either along or point', + "RouteCoordinatesArray: toValue should have end with either along or point", ); } if (toValue.end.along) { - const {units} = toValue; + const { units } = toValue; const ls = lineString(fullRoute); toDist = convertLength(toValue.end.along, units); toDist = length(ls) - toDist; @@ -114,7 +114,7 @@ export default class AnimatedRouteCoordinatesArray extends AbstractAnimatedCoord if (toDist != null) { if (toValue.end.point) { console.warn( - 'RouteCoordinatesArray: toValue.end: has both along and point, point is ignored', + "RouteCoordinatesArray: toValue.end: has both along and point, point is ignored", ); } } else if (toValue.end.point) { @@ -124,7 +124,7 @@ export default class AnimatedRouteCoordinatesArray extends AbstractAnimatedCoord toDist = length(ls) - nearest.properties.location!; } else { console.warn( - 'RouteCoordinatesArray: toValue.end: should have either along or point', + "RouteCoordinatesArray: toValue.end: should have either along or point", ); } diff --git a/javascript/utils/animated/AnimatedShape.ts b/javascript/utils/animated/AnimatedShape.ts index 57820a17b..133d36a64 100644 --- a/javascript/utils/animated/AnimatedShape.ts +++ b/javascript/utils/animated/AnimatedShape.ts @@ -1,31 +1,31 @@ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ -import {Animated} from 'react-native'; +import { Animated } from "react-native"; -import AnimatedCoordinatesArray from './AnimatedCoordinatesArray'; -import AnimatedExtractCoordinateFromArray from './AnimatedExtractCoordinateFromArray'; -import AnimatedRouteCoordinatesArray from './AnimatedRouteCoordinatesArray'; +import AnimatedCoordinatesArray from "./AnimatedCoordinatesArray"; +import AnimatedExtractCoordinateFromArray from "./AnimatedExtractCoordinateFromArray"; +import AnimatedRouteCoordinatesArray from "./AnimatedRouteCoordinatesArray"; // see // https://github.com/facebook/react-native/blob/master/Libraries/Animated/src/nodes/AnimatedWithChildren.js const AnimatedWithChildren = Object.getPrototypeOf(Animated.ValueXY); if (__DEV__) { - if (AnimatedWithChildren.name !== 'AnimatedWithChildren') { + if (AnimatedWithChildren.name !== "AnimatedWithChildren") { console.error( - 'AnimatedShape could not obtain AnimatedWithChildren base class', + "AnimatedShape could not obtain AnimatedWithChildren base class", ); } } type Shape = | { - type: 'Point'; + type: "Point"; coordinates: | AnimatedExtractCoordinateFromArray | AnimatedRouteCoordinatesArray; } | { - type: 'LineString'; + type: "LineString"; coordinates: AnimatedCoordinatesArray; }; @@ -45,14 +45,14 @@ class AnimatedShape extends AnimatedWithChildren { _walkShapeAndGetValues(value: any): any { if (Array.isArray(value)) { - return value.map(i => this._walkShapeAndGetValues(i)); + return value.map((i) => this._walkShapeAndGetValues(i)); } // @ts-expect-error Animated.Node is not exported if (value instanceof Animated.Node) { return (value as any).__getValue(); } - if (typeof value === 'object') { - const result: {[key: string]: any} = {}; + if (typeof value === "object") { + const result: { [key: string]: any } = {}; for (const key in value) { result[key] = this._walkShapeAndGetValues(value[key]); } @@ -69,11 +69,11 @@ class AnimatedShape extends AnimatedWithChildren { // @ts-expect-error Animated.Node is not exported _walkAndProcess(value: any, cb: (value: Animated.Node) => void): void { if (Array.isArray(value)) { - value.forEach(i => this._walkAndProcess(i, cb)); + value.forEach((i) => this._walkAndProcess(i, cb)); // @ts-expect-error Animated.Node is not exported } else if (value instanceof Animated.Node) { cb(value); - } else if (typeof value === 'object') { + } else if (typeof value === "object") { for (const key in value) { this._walkAndProcess(value[key], cb); } @@ -81,11 +81,11 @@ class AnimatedShape extends AnimatedWithChildren { } __attach(): void { - this._walkAndProcess(this.shape, v => (v as any).__addChild(this)); + this._walkAndProcess(this.shape, (v) => (v as any).__addChild(this)); } __detach(): void { - this._walkAndProcess(this.shape, v => (v as any).__removeChild(this)); + this._walkAndProcess(this.shape, (v) => (v as any).__removeChild(this)); super.__detach(); } } diff --git a/javascript/utils/deprecation.ts b/javascript/utils/deprecation.ts index e4e6b05ad..79b37208f 100644 --- a/javascript/utils/deprecation.ts +++ b/javascript/utils/deprecation.ts @@ -12,7 +12,7 @@ export function copyPropertiesAsDeprecated< onDeprecatedCalled: (key: string) => void, accessors: Record unknown> = {}, ): WithDeprecatedType { - const result = {...newObject}; + const result = { ...newObject }; for (const [key, value] of Object.entries(origObject)) { if (!(key in newObject)) { diff --git a/javascript/utils/filterUtils.ts b/javascript/utils/filterUtils.ts index 50748e40b..14d878f30 100644 --- a/javascript/utils/filterUtils.ts +++ b/javascript/utils/filterUtils.ts @@ -1,4 +1,4 @@ -import {FilterExpression} from './MaplibreStyles'; +import { FilterExpression } from "./MaplibreStyles"; export function getFilter(filter: FilterExpression | undefined): string[] { if (!Array.isArray(filter) || filter.length === 0) { diff --git a/javascript/utils/geoUtils.ts b/javascript/utils/geoUtils.ts index 47b997a0b..4b89833d6 100644 --- a/javascript/utils/geoUtils.ts +++ b/javascript/utils/geoUtils.ts @@ -1,6 +1,6 @@ -import geoViewport from '@mapbox/geo-viewport'; -import along from '@turf/along'; -import distance from '@turf/distance'; +import geoViewport from "@mapbox/geo-viewport"; +import along from "@turf/along"; +import distance from "@turf/distance"; import { featureCollection, point, @@ -8,7 +8,7 @@ import { lineString, Id, Properties, -} from '@turf/helpers'; +} from "@turf/helpers"; const VECTOR_TILE_SIZE = 512; @@ -30,7 +30,7 @@ export const makeFeature = feature; export function makeFeatureCollection( features: GeoJSON.Feature[] = [], - options?: {bbox?: GeoJSON.BBox; id?: Id}, + options?: { bbox?: GeoJSON.BBox; id?: Id }, ): GeoJSON.FeatureCollection { return featureCollection(features, options); } @@ -50,12 +50,12 @@ export const calculateDistance = distance; export const pointAlongLine = along; export function getOrCalculateVisibleRegion( - coord: [number, number] | {lon: number; lat: number}, + coord: [number, number] | { lon: number; lat: number }, zoomLevel: number, width: number, height: number, - nativeRegion: {properties: {visibleBounds: [number, number][]}}, -): {ne: [number, number]; sw: [number, number]} { + nativeRegion: { properties: { visibleBounds: [number, number][] } }, +): { ne: [number, number]; sw: [number, number] } { const region = { ne: [0, 0] as [number, number], sw: [0, 0] as [number, number], diff --git a/javascript/utils/index.ts b/javascript/utils/index.ts index dd55ecd33..1f529d38e 100644 --- a/javascript/utils/index.ts +++ b/javascript/utils/index.ts @@ -1,11 +1,11 @@ -import React, {Component, ReactElement} from 'react'; +import React, { Component, ReactElement } from "react"; import { Image, NativeModules, findNodeHandle, Platform, ImageSourcePropType, -} from 'react-native'; +} from "react-native"; function getAndroidManagerInstance(module: string): any { const haveViewManagerConfig = @@ -20,7 +20,7 @@ function getIosManagerInstance(module: string): any { } export function isAndroid(): boolean { - return Platform.OS === 'android'; + return Platform.OS === "android"; } export function existenceChange(cur: boolean, next: boolean): boolean { @@ -31,23 +31,23 @@ export function existenceChange(cur: boolean, next: boolean): boolean { } export function isFunction(fn: unknown): fn is boolean { - return typeof fn === 'function'; + return typeof fn === "function"; } export function isNumber(num: unknown): num is number { - return typeof num === 'number' && !Number.isNaN(num); + return typeof num === "number" && !Number.isNaN(num); } export function isUndefined(obj: unknown): obj is undefined { - return typeof obj === 'undefined'; + return typeof obj === "undefined"; } export function isString(str: unknown): str is string { - return typeof str === 'string'; + return typeof str === "string"; } export function isBoolean(bool: unknown): bool is boolean { - return typeof bool === 'boolean'; + return typeof bool === "boolean"; } export function isPrimitive( @@ -61,7 +61,7 @@ export type NativeArg = | number | boolean | null - | {[k: string]: NativeArg} + | { [k: string]: NativeArg } | NativeArg[]; export function runNativeCommand( @@ -96,7 +96,7 @@ export function runNativeCommand( export function cloneReactChildrenWithProps( children: Parameters[0], - propsToAdd: {[key: string]: string} = {}, + propsToAdd: { [key: string]: string } = {}, ): ReactElement[] | undefined { if (!children) { return undefined; @@ -110,8 +110,8 @@ export function cloneReactChildrenWithProps( foundChildren = children; } - const filteredChildren = foundChildren.filter(child => !!child); // filter out falsy children, since some can be null - return React.Children.map(filteredChildren, child => + const filteredChildren = foundChildren.filter((child) => !!child); // filter out falsy children, since some can be null + return React.Children.map(filteredChildren, (child) => React.cloneElement(child, propsToAdd), ); } @@ -122,12 +122,12 @@ export function resolveImagePath(imageRef: ImageSourcePropType): string { } export function getIOSModuleName(moduleName: string): string { - if (moduleName.startsWith('RCT')) { + if (moduleName.startsWith("RCT")) { return moduleName.substring(3); } return moduleName; } -export function toJSONString(json: object | string = ''): string { +export function toJSONString(json: object | string = ""): string { return JSON.stringify(json); } diff --git a/package.json b/package.json index 80a428c27..ab03d004e 100644 --- a/package.json +++ b/package.json @@ -80,8 +80,10 @@ "ejs": "^3.1.3", "ejs-lint": "^2.0.0", "eslint": "^8.57.0", + "eslint-config-prettier": "^9.1.0", "eslint-config-universe": "13.0.0", "eslint-plugin-import": "^2.29.1", + "eslint-plugin-prettier": "^5.1.3", "expo-module-scripts": "^3.1.0", "husky": "^9.0.10", "jest": "^29.7.0", @@ -90,7 +92,7 @@ "metro-react-native-babel-preset": "^0.76.7", "node-dir": "0.1.17", "pinst": "^3.0.0", - "prettier": "^3.2.5", + "prettier": "^3.3.3", "react": "^18.2.0", "react-docgen": "rnmapbox/react-docgen#rnmapbox-dist", "react-native": "0.72.1", @@ -115,5 +117,25 @@ "lint-staged": { "*.{js,jsx,ts,tsx}": "yarn lint" }, + + "eslintConfig": { + "root": true, + "extends": [ + "prettier", + "universe/native" + ], + "ignorePatterns": [ + "node_modules/*", + "*.js", + "**/dist/*.js", + "/plugin/build" + ], + "plugins": [ + "prettier" + ], + "rules": { + "prettier/prettier": "error" + } + }, "packageManager": "yarn@4.1.0" } diff --git a/plugin/src/__tests__/withMapLibre-test.ts b/plugin/src/__tests__/withMapLibre-test.ts index 3b068908c..5f45eb35e 100644 --- a/plugin/src/__tests__/withMapLibre-test.ts +++ b/plugin/src/__tests__/withMapLibre-test.ts @@ -1,36 +1,36 @@ -import * as fixtures from './fixtures/cocoapodFiles'; -import {applyCocoaPodsModifications} from '../withMapLibre'; +import * as fixtures from "./fixtures/cocoapodFiles"; +import { applyCocoaPodsModifications } from "../withMapLibre"; -describe('applyCocoaPodsModifications', () => { - it('adds blocks to a react native template podfile', () => { +describe("applyCocoaPodsModifications", () => { + it("adds blocks to a react native template podfile", () => { expect( applyCocoaPodsModifications(fixtures.reactNativeTemplatePodfile), ).toMatchSnapshot(); }); - it('adds blocks to a expo prebuild template podfile', () => { + it("adds blocks to a expo prebuild template podfile", () => { expect( applyCocoaPodsModifications(fixtures.expoTemplatePodfile), ).toMatchSnapshot(); }); - it('adds blocks to a expo prebuild template podfile with custom modifications', () => { + it("adds blocks to a expo prebuild template podfile with custom modifications", () => { expect( applyCocoaPodsModifications(fixtures.customExpoTemplatePodfile), ).toMatchSnapshot(); }); - it('fails to add blocks to a bare podfile', () => { + it("fails to add blocks to a bare podfile", () => { expect(() => applyCocoaPodsModifications(fixtures.blankTemplatePodfile), - ).toThrow('Failed to match'); - expect(() => applyCocoaPodsModifications('')).toThrow('Failed to match'); + ).toThrow("Failed to match"); + expect(() => applyCocoaPodsModifications("")).toThrow("Failed to match"); }); - it('does not re add blocks to an applied template podfile', () => { + it("does not re add blocks to an applied template podfile", () => { const runOnce = applyCocoaPodsModifications( fixtures.reactNativeTemplatePodfile, ); expect(applyCocoaPodsModifications(runOnce)).toMatch(runOnce); }); - it('works after revisions to blocks', () => { + it("works after revisions to blocks", () => { const runOnce = applyCocoaPodsModifications( fixtures.expoTemplateWithRevisions, ); @@ -39,7 +39,7 @@ describe('applyCocoaPodsModifications', () => { }); // A known issue is that the regex won't work if the template // has a pre_install/post_install block commented out, before the `use_react_native` function. - it('does not work with revisions to blocks after comments', () => { + it("does not work with revisions to blocks after comments", () => { const runOnce = applyCocoaPodsModifications( fixtures.expoTemplateWithRevisionsAfterComments, ); diff --git a/plugin/src/withMapLibre.ts b/plugin/src/withMapLibre.ts index 7533f9879..25d28b187 100644 --- a/plugin/src/withMapLibre.ts +++ b/plugin/src/withMapLibre.ts @@ -4,24 +4,24 @@ import { withDangerousMod, withXcodeProject, XcodeProject, -} from '@expo/config-plugins'; +} from "@expo/config-plugins"; import { mergeContents, removeGeneratedContents, -} from '@expo/config-plugins/build/utils/generateCode'; -import {promises} from 'fs'; -import path from 'path'; +} from "@expo/config-plugins/build/utils/generateCode"; +import { promises } from "fs"; +import path from "path"; -let pkg: {name: string; version?: string} = { - name: '@maplibre/maplibre-react-native', +let pkg: { name: string; version?: string } = { + name: "@maplibre/maplibre-react-native", }; try { - pkg = require('@maplibre/maplibre-react-native/package.json'); + pkg = require("@maplibre/maplibre-react-native/package.json"); } catch { // empty catch block } -type InstallerBlockName = 'pre' | 'post'; +type InstallerBlockName = "pre" | "post"; /** * Dangerously adds the custom installer hooks to the Podfile. @@ -31,19 +31,19 @@ type InstallerBlockName = 'pre' | 'post'; * @param config * @returns */ -const withCocoaPodsInstallerBlocks: ConfigPlugin = c => { +const withCocoaPodsInstallerBlocks: ConfigPlugin = (c) => { return withDangerousMod(c, [ - 'ios', + "ios", // eslint-disable-next-line @typescript-eslint/explicit-function-return-type - async config => { - const file = path.join(config.modRequest.platformProjectRoot, 'Podfile'); + async (config) => { + const file = path.join(config.modRequest.platformProjectRoot, "Podfile"); - const contents = await promises.readFile(file, 'utf8'); + const contents = await promises.readFile(file, "utf8"); await promises.writeFile( file, applyCocoaPodsModifications(contents), - 'utf-8', + "utf-8", ); return config; }, @@ -55,9 +55,9 @@ const withCocoaPodsInstallerBlocks: ConfigPlugin = c => { export function applyCocoaPodsModifications(contents: string): string { // Ensure installer blocks exist // let src = addInstallerBlock(contents, 'pre'); - let src = addInstallerBlock(contents, 'post'); + let src = addInstallerBlock(contents, "post"); // src = addMapLibreInstallerBlock(src, 'pre'); - src = addMapLibreInstallerBlock(src, 'post'); + src = addMapLibreInstallerBlock(src, "post"); return src; } @@ -67,10 +67,10 @@ export function addInstallerBlock( ): string { const matchBlock = new RegExp(`${blockName}_install do \\|installer\\|`); const tag = `${blockName}_installer`; - for (const line of src.split('\n')) { + for (const line of src.split("\n")) { const contents = line.trim(); // Ignore comments - if (!contents.startsWith('#')) { + if (!contents.startsWith("#")) { // Prevent adding the block if it exists outside of comments. if (contents.match(matchBlock)) { // This helps to still allow revisions, since we enabled the block previously. @@ -86,11 +86,11 @@ export function addInstallerBlock( return mergeContents({ tag, src, - newSrc: [` ${blockName}_install do |installer|`, ' end'].join('\n'), + newSrc: [` ${blockName}_install do |installer|`, " end"].join("\n"), anchor: /use_react_native/, // We can't go after the use_react_native block because it might have parameters, causing it to be multi-line (see react-native template). offset: 0, - comment: '#', + comment: "#", }).contents; } @@ -104,7 +104,7 @@ export function addMapLibreInstallerBlock( newSrc: ` $RCTMLN.${blockName}_install(installer)`, anchor: new RegExp(`${blockName}_install do \\|installer\\|`), offset: 1, - comment: '#', + comment: "#", }).contents; } @@ -116,12 +116,12 @@ export function setExcludedArchitectures(project: XcodeProject): XcodeProject { const configurations = project.pbxXCBuildConfigurationSection(); // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - for (const {name, buildSettings} of Object.values(configurations || {})) { + for (const { name, buildSettings } of Object.values(configurations || {})) { // Guessing that this is the best way to emulate Xcode. // Using `project.addToBuildSettings` modifies too many targets. if ( - name === 'Release' && - typeof buildSettings?.PRODUCT_NAME !== 'undefined' + name === "Release" && + typeof buildSettings?.PRODUCT_NAME !== "undefined" ) { buildSettings['"EXCLUDED_ARCHS[sdk=iphonesimulator*]"'] = '"arm64"'; } @@ -129,21 +129,21 @@ export function setExcludedArchitectures(project: XcodeProject): XcodeProject { return project; } -const withoutSignatures: ConfigPlugin = config => { +const withoutSignatures: ConfigPlugin = (config) => { const shellScript = `if [ "$XCODE_VERSION_MAJOR" = "1500" ]; then echo "Remove signature files (Xcode 15 workaround)"; rm -rf "$CONFIGURATION_BUILD_DIR/MapLibre.xcframework-ios.signature"; fi`; - return withXcodeProject(config, async config => { + return withXcodeProject(config, async (config) => { const xcodeProject = config.modResults; xcodeProject.addBuildPhase( [], - 'PBXShellScriptBuildPhase', - 'Remove signature files (Xcode 15 workaround)', + "PBXShellScriptBuildPhase", + "Remove signature files (Xcode 15 workaround)", null, { - shellPath: '/bin/sh', + shellPath: "/bin/sh", shellScript, }, ); @@ -152,14 +152,14 @@ const withoutSignatures: ConfigPlugin = config => { }); }; -const withExcludedSimulatorArchitectures: ConfigPlugin = c => { - return withXcodeProject(c, config => { +const withExcludedSimulatorArchitectures: ConfigPlugin = (c) => { + return withXcodeProject(c, (config) => { config.modResults = setExcludedArchitectures(config.modResults); return config; }); }; -const withMapLibre: ConfigPlugin = config => { +const withMapLibre: ConfigPlugin = (config) => { config = withoutSignatures(withExcludedSimulatorArchitectures(config)); return withCocoaPodsInstallerBlocks(config); }; diff --git a/yarn.lock b/yarn.lock index 310006bf1..01e378113 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2336,8 +2336,10 @@ __metadata: ejs: "npm:^3.1.3" ejs-lint: "npm:^2.0.0" eslint: "npm:^8.57.0" + eslint-config-prettier: "npm:^9.1.0" eslint-config-universe: "npm:13.0.0" eslint-plugin-import: "npm:^2.29.1" + eslint-plugin-prettier: "npm:^5.1.3" expo-module-scripts: "npm:^3.1.0" husky: "npm:^9.0.10" jest: "npm:^29.7.0" @@ -2346,7 +2348,7 @@ __metadata: metro-react-native-babel-preset: "npm:^0.76.7" node-dir: "npm:0.1.17" pinst: "npm:^3.0.0" - prettier: "npm:^3.2.5" + prettier: "npm:^3.3.3" react: "npm:^18.2.0" react-docgen: "rnmapbox/react-docgen#rnmapbox-dist" react-native: "npm:0.72.1" @@ -11814,12 +11816,12 @@ __metadata: languageName: node linkType: hard -"prettier@npm:^3.2.5": - version: 3.2.5 - resolution: "prettier@npm:3.2.5" +"prettier@npm:^3.3.3": + version: 3.3.3 + resolution: "prettier@npm:3.3.3" bin: prettier: bin/prettier.cjs - checksum: 10/d509f9da0b70e8cacc561a1911c0d99ec75117faed27b95cc8534cb2349667dee6351b0ca83fa9d5703f14127faa52b798de40f5705f02d843da133fc3aa416a + checksum: 10/5beac1f30b5b40162532b8e2f7c3a4eb650910a2695e9c8512a62ffdc09dae93190c29db9107fa7f26d1b6c71aad3628ecb9b5de1ecb0911191099be109434d7 languageName: node linkType: hard