From c911a9d8268f6486d50502ab09edbd9f21ad0240 Mon Sep 17 00:00:00 2001 From: Kilian Finger Date: Mon, 18 Nov 2024 09:20:34 +0100 Subject: [PATCH] refactor: align casing on MapLibre and MapLibreRN usages --- .gitignore | 2 -- __tests__/interface.test.js | 2 +- docs/Style.md | 2 +- docs/docs.json | 2 +- scripts/codegen.ts | 4 +-- ...eStyles.ts.ejs => MapLibreRNStyles.ts.ejs} | 0 src/MapLibreRN.ts | 2 +- src/components/Annotation.tsx | 2 +- src/components/BackgroundLayer.tsx | 2 +- src/components/CircleLayer.tsx | 2 +- src/components/FillExtrusionLayer.tsx | 2 +- src/components/FillLayer.tsx | 2 +- src/components/HeatmapLayer.tsx | 2 +- src/components/Light.tsx | 2 +- src/components/LineLayer.tsx | 2 +- src/components/MapView.tsx | 2 +- src/components/RasterLayer.tsx | 2 +- src/components/ShapeSource.tsx | 2 +- src/components/Style.tsx | 32 +++++++++---------- src/components/SymbolLayer.tsx | 2 +- src/components/UserLocation.tsx | 2 +- src/components/VectorSource.tsx | 2 +- src/hooks/useAbstractLayer.ts | 2 +- ...libreStyles.d.ts => MapLibreRNStyles.d.ts} | 0 src/utils/StyleValue.ts | 2 +- src/utils/filterUtils.ts | 2 +- 26 files changed, 39 insertions(+), 41 deletions(-) rename scripts/templates/{MaplibreStyles.ts.ejs => MapLibreRNStyles.ts.ejs} (100%) rename src/utils/{MaplibreStyles.d.ts => MapLibreRNStyles.d.ts} (100%) diff --git a/.gitignore b/.gitignore index 409981788..5afb68c96 100644 --- a/.gitignore +++ b/.gitignore @@ -63,8 +63,6 @@ package.tgz .vs # project specific -ios/Mapbox.framework -ios/Maplibre.framework ios/temp.zip ios/.framework_version ios/Pods/ diff --git a/__tests__/interface.test.js b/__tests__/interface.test.js index 71fe35f2d..5327800d8 100644 --- a/__tests__/interface.test.js +++ b/__tests__/interface.test.js @@ -1,6 +1,6 @@ import MapLibreGL from "../src"; -// Assert that all required Maplibre modules are accessible and exported +// Assert that all required MapLibre modules are accessible and exported describe("Public Interface", () => { it("should contain all expected components and utils", () => { const actualKeys = Object.keys(MapLibreGL); diff --git a/docs/Style.md b/docs/Style.md index 69686edf8..b7968ea6c 100644 --- a/docs/Style.md +++ b/docs/Style.md @@ -6,6 +6,6 @@ Style is a component that automatically adds sources / layers to the map using M ## Props | Prop | Type | Default | Required | Description | | ---- | :--: | :-----: | :------: | :----------: | -| json | `MaplibreJSON \| URL` | `none` | `false` | A JSON object conforming to the schema described in the MapLibre Style Specification, or a URL to such JSON. | +| json | `MapLibreJSON \| URL` | `none` | `false` | A JSON object conforming to the schema described in the MapLibre Style Specification, or a URL to such JSON. | diff --git a/docs/docs.json b/docs/docs.json index 4986e5817..d7f926fb1 100644 --- a/docs/docs.json +++ b/docs/docs.json @@ -3356,7 +3356,7 @@ { "name": "json", "required": false, - "type": "MaplibreJSON \\| URL", + "type": "MapLibreJSON \\| URL", "default": "none", "description": "A JSON object conforming to the schema described in the MapLibre Style Specification, or a URL to such JSON." } diff --git a/scripts/codegen.ts b/scripts/codegen.ts index b8d50bb93..501794d8e 100644 --- a/scripts/codegen.ts +++ b/scripts/codegen.ts @@ -40,8 +40,8 @@ const TEMPLATE_MAPPINGS = [ output: path.join(IOS_OUTPUT_PATH, "RCTMLNStyle.h"), }, { - input: path.join(TMPL_PATH, "MaplibreStyles.ts.ejs"), - output: path.join(JS_OUTPUT_PATH, "MaplibreStyles.d.ts"), + input: path.join(TMPL_PATH, "MapLibreRNStyles.ts.ejs"), + output: path.join(JS_OUTPUT_PATH, "MapLibreRNStyles.d.ts"), }, { input: path.join(TMPL_PATH, "RCTMLNStyle.m.ejs"), diff --git a/scripts/templates/MaplibreStyles.ts.ejs b/scripts/templates/MapLibreRNStyles.ts.ejs similarity index 100% rename from scripts/templates/MaplibreStyles.ts.ejs rename to scripts/templates/MapLibreRNStyles.ts.ejs diff --git a/src/MapLibreRN.ts b/src/MapLibreRN.ts index 49ca7a5c2..d0618d374 100644 --- a/src/MapLibreRN.ts +++ b/src/MapLibreRN.ts @@ -64,7 +64,7 @@ export type { HillshadeLayerStyleProps as HillshadeLayerStyle, BackgroundLayerStyleProps as BackgroundLayerStyle, LightLayerStyleProps as LightLayerStyle, -} from "./utils/MaplibreStyles"; +} from "./utils/MapLibreRNStyles"; /** @deprecated UserTrackingModes is deprecated use UserTrackingMode */ export const UserTrackingModes = UserTrackingMode; diff --git a/src/components/Annotation.tsx b/src/components/Annotation.tsx index ad6f3704e..6c8ec6811 100644 --- a/src/components/Annotation.tsx +++ b/src/components/Annotation.tsx @@ -10,7 +10,7 @@ import { Animated as RNAnimated, Easing } from "react-native"; import SymbolLayer from "./SymbolLayer"; import { type OnPressEvent } from "../types/OnPressEvent"; -import { type SymbolLayerStyleProps } from "../utils/MaplibreStyles"; +import { type SymbolLayerStyleProps } from "../utils/MapLibreRNStyles"; import { AnimatedShapeSource } from "../utils/animated/Animated"; import AnimatedMapPoint from "../utils/animated/AnimatedPoint"; diff --git a/src/components/BackgroundLayer.tsx b/src/components/BackgroundLayer.tsx index 56d4b41ff..1b7a06844 100644 --- a/src/components/BackgroundLayer.tsx +++ b/src/components/BackgroundLayer.tsx @@ -6,7 +6,7 @@ import useAbstractLayer, { type NativeBaseProps, } from "../hooks/useAbstractLayer"; import { type BaseProps } from "../types/BaseProps"; -import { type BackgroundLayerStyleProps } from "../utils/MaplibreStyles"; +import { type BackgroundLayerStyleProps } from "../utils/MapLibreRNStyles"; const MapLibreGL = NativeModules.MLNModule; diff --git a/src/components/CircleLayer.tsx b/src/components/CircleLayer.tsx index ea91d0b38..cb95fa3c3 100644 --- a/src/components/CircleLayer.tsx +++ b/src/components/CircleLayer.tsx @@ -6,7 +6,7 @@ import useAbstractLayer, { type NativeBaseProps, } from "../hooks/useAbstractLayer"; import { type BaseProps } from "../types/BaseProps"; -import { type CircleLayerStyleProps } from "../utils/MaplibreStyles"; +import { type CircleLayerStyleProps } from "../utils/MapLibreRNStyles"; const MapLibreGL = NativeModules.MLNModule; diff --git a/src/components/FillExtrusionLayer.tsx b/src/components/FillExtrusionLayer.tsx index 8191a917c..cd000f0ad 100644 --- a/src/components/FillExtrusionLayer.tsx +++ b/src/components/FillExtrusionLayer.tsx @@ -6,7 +6,7 @@ import useAbstractLayer, { type NativeBaseProps, } from "../hooks/useAbstractLayer"; import { type BaseProps } from "../types/BaseProps"; -import { type FillExtrusionLayerStyleProps } from "../utils/MaplibreStyles"; +import { type FillExtrusionLayerStyleProps } from "../utils/MapLibreRNStyles"; const MapLibreGL = NativeModules.MLNModule; diff --git a/src/components/FillLayer.tsx b/src/components/FillLayer.tsx index d37ca6e9b..cfb58d7ef 100644 --- a/src/components/FillLayer.tsx +++ b/src/components/FillLayer.tsx @@ -6,7 +6,7 @@ import useAbstractLayer, { type NativeBaseProps, } from "../hooks/useAbstractLayer"; import { type BaseProps } from "../types/BaseProps"; -import { type FillLayerStyleProps } from "../utils/MaplibreStyles"; +import { type FillLayerStyleProps } from "../utils/MapLibreRNStyles"; const MapLibreGL = NativeModules.MLNModule; diff --git a/src/components/HeatmapLayer.tsx b/src/components/HeatmapLayer.tsx index a697582f6..c8f30a8a0 100644 --- a/src/components/HeatmapLayer.tsx +++ b/src/components/HeatmapLayer.tsx @@ -6,7 +6,7 @@ import useAbstractLayer, { type NativeBaseProps, } from "../hooks/useAbstractLayer"; import { type BaseProps } from "../types/BaseProps"; -import { type HeatmapLayerStyleProps } from "../utils/MaplibreStyles"; +import { type HeatmapLayerStyleProps } from "../utils/MapLibreRNStyles"; const MapLibreGL = NativeModules.MLNModule; diff --git a/src/components/Light.tsx b/src/components/Light.tsx index 04c4cdaed..449280e60 100644 --- a/src/components/Light.tsx +++ b/src/components/Light.tsx @@ -5,7 +5,7 @@ import useAbstractLayer, { type BaseLayerProps, } from "../hooks/useAbstractLayer"; import { type BaseProps } from "../types/BaseProps"; -import { type LightLayerStyleProps } from "../utils/MaplibreStyles"; +import { type LightLayerStyleProps } from "../utils/MapLibreRNStyles"; import { type StyleValue } from "../utils/StyleValue"; export const NATIVE_MODULE_NAME = "RCTMLNLight"; diff --git a/src/components/LineLayer.tsx b/src/components/LineLayer.tsx index 4756a34dc..d286196d2 100644 --- a/src/components/LineLayer.tsx +++ b/src/components/LineLayer.tsx @@ -6,7 +6,7 @@ import useAbstractLayer, { type NativeBaseProps, } from "../hooks/useAbstractLayer"; import { type BaseProps } from "../types/BaseProps"; -import { type LineLayerStyleProps } from "../utils/MaplibreStyles"; +import { type LineLayerStyleProps } from "../utils/MapLibreRNStyles"; const MapLibreGL = NativeModules.MLNModule; diff --git a/src/components/MapView.tsx b/src/components/MapView.tsx index 0c950aa12..8ea0b7ca4 100644 --- a/src/components/MapView.tsx +++ b/src/components/MapView.tsx @@ -28,7 +28,7 @@ import { type Location } from "../modules/location/locationManager"; import { type BaseProps } from "../types/BaseProps"; import { isFunction, isAndroid } from "../utils"; import Logger from "../utils/Logger"; -import { type FilterExpression } from "../utils/MaplibreStyles"; +import { type FilterExpression } from "../utils/MapLibreRNStyles"; import { getFilter } from "../utils/filterUtils"; const MapLibreGL = NativeModules.MLNModule; diff --git a/src/components/RasterLayer.tsx b/src/components/RasterLayer.tsx index 85a2a7348..926a0cd29 100644 --- a/src/components/RasterLayer.tsx +++ b/src/components/RasterLayer.tsx @@ -6,7 +6,7 @@ import useAbstractLayer, { type NativeBaseProps, } from "../hooks/useAbstractLayer"; import { type BaseProps } from "../types/BaseProps"; -import { type RasterLayerStyleProps } from "../utils/MaplibreStyles"; +import { type RasterLayerStyleProps } from "../utils/MapLibreRNStyles"; const MapLibreGL = NativeModules.MLNModule; diff --git a/src/components/ShapeSource.tsx b/src/components/ShapeSource.tsx index ad04cd213..98d41b9fb 100644 --- a/src/components/ShapeSource.tsx +++ b/src/components/ShapeSource.tsx @@ -25,7 +25,7 @@ import { import { type ExpressionField, type FilterExpression, -} from "../utils/MaplibreStyles"; +} from "../utils/MapLibreRNStyles"; import { copyPropertiesAsDeprecated } from "../utils/deprecation"; import { getFilter } from "../utils/filterUtils"; diff --git a/src/components/Style.tsx b/src/components/Style.tsx index 82eabb3f3..b48f10f31 100644 --- a/src/components/Style.tsx +++ b/src/components/Style.tsx @@ -23,7 +23,7 @@ import VectorSource from "./VectorSource"; import { type ExpressionField, type FilterExpression, -} from "../utils/MaplibreStyles"; +} from "../utils/MapLibreRNStyles"; function toCamelCase(s: string): string { return s.replace(/([-_][a-z])/gi, ($1) => { @@ -62,7 +62,7 @@ type LayerProps = | HeatmapLayerProps; function getLayerComponentType( - layer: MaplibreJSONLayer, + layer: MapLibreJSONLayer, ): ComponentType | null { const { type } = layer; @@ -90,7 +90,7 @@ function getLayerComponentType( return null; } -interface MaplibreJSONLayer { +interface MapLibreJSONLayer { type: string; paint: { [k: string]: unknown }; layout: { [k: string]: unknown }; @@ -103,7 +103,7 @@ interface MaplibreJSONLayer { } function asLayerComponent( - layer: MaplibreJSONLayer, + layer: MapLibreJSONLayer, ): ReactElement | null { const LayerComponent = getLayerComponentType(layer); @@ -140,7 +140,7 @@ function asLayerComponent( return ; } -interface MaplibreJSONSource { +interface MapLibreJSONSource { type: string; url?: string; tiles?: string[]; @@ -178,7 +178,7 @@ type SourceProps = { tms?: boolean; }; -function getTileSourceProps(source: MaplibreJSONSource): SourceProps { +function getTileSourceProps(source: MapLibreJSONSource): SourceProps { const sourceProps: Partial = {}; if (source.url) { sourceProps.url = source.url; @@ -201,12 +201,12 @@ function getTileSourceProps(source: MaplibreJSONSource): SourceProps { return sourceProps; } -function getVectorSource(id: string, source: MaplibreJSONSource): ReactElement { +function getVectorSource(id: string, source: MapLibreJSONSource): ReactElement { const sourceProps = { ...getTileSourceProps(source) }; return ; } -function getRasterSource(id: string, source: MaplibreJSONSource): ReactElement { +function getRasterSource(id: string, source: MapLibreJSONSource): ReactElement { const sourceProps: SourceProps & { tileSize?: number } = { ...getTileSourceProps(source), }; @@ -216,7 +216,7 @@ function getRasterSource(id: string, source: MaplibreJSONSource): ReactElement { return ; } -function getImageSource(id: string, source: MaplibreJSONSource): ReactElement { +function getImageSource(id: string, source: MapLibreJSONSource): ReactElement { const sourceProps = { url: source.url, coordinates: source.coordinates, @@ -226,7 +226,7 @@ function getImageSource(id: string, source: MaplibreJSONSource): ReactElement { type ShapeSourceShape = (typeof ShapeSource.prototype.props)["shape"]; -function getShapeSource(id: string, source: MaplibreJSONSource): ReactElement { +function getShapeSource(id: string, source: MapLibreJSONSource): ReactElement { const sourceProps: SourceProps & { shape?: ShapeSourceShape; cluster?: boolean; @@ -271,7 +271,7 @@ function getShapeSource(id: string, source: MaplibreJSONSource): ReactElement { function asSourceComponent( id: string, - source: MaplibreJSONSource, + source: MapLibreJSONSource, ): ReactElement | null { switch (source.type) { case "vector": @@ -289,16 +289,16 @@ function asSourceComponent( return null; } -interface MaplibreJSON { - layers?: MaplibreJSONLayer[]; - sources?: { [key: string]: MaplibreJSONSource }; +interface MapLibreJSON { + layers?: MapLibreJSONLayer[]; + sources?: { [key: string]: MapLibreJSONSource }; } interface StyleProps { /** * A JSON object conforming to the schema described in the MapLibre Style Specification, or a URL to such JSON. */ - json?: MaplibreJSON | URL; + json?: MapLibreJSON | URL; } /** @@ -310,7 +310,7 @@ interface StyleProps { */ const Style = (props: StyleProps): ReactElement => { const [fetchedJson, setFetchedJson] = useState({}); - const json: MaplibreJSON = + const json: MapLibreJSON = typeof props.json === "object" ? props.json : fetchedJson; // Fetch style when props.json is a URL diff --git a/src/components/SymbolLayer.tsx b/src/components/SymbolLayer.tsx index f1fa0a6db..606d3b0ce 100644 --- a/src/components/SymbolLayer.tsx +++ b/src/components/SymbolLayer.tsx @@ -6,7 +6,7 @@ import useAbstractLayer, { type NativeBaseProps, } from "../hooks/useAbstractLayer"; import { type BaseProps } from "../types/BaseProps"; -import { type SymbolLayerStyleProps } from "../utils/MaplibreStyles"; +import { type SymbolLayerStyleProps } from "../utils/MapLibreRNStyles"; const MapLibreGL = NativeModules.MLNModule; diff --git a/src/components/UserLocation.tsx b/src/components/UserLocation.tsx index e4a40ae06..e5ded6551 100644 --- a/src/components/UserLocation.tsx +++ b/src/components/UserLocation.tsx @@ -15,7 +15,7 @@ import NativeUserLocation from "./NativeUserLocation"; import locationManager, { type Location, } from "../modules/location/locationManager"; -import { type CircleLayerStyleProps } from "../utils/MaplibreStyles"; +import { type CircleLayerStyleProps } from "../utils/MapLibreRNStyles"; const mapboxBlue = "rgba(51, 181, 229, 100)"; diff --git a/src/components/VectorSource.tsx b/src/components/VectorSource.tsx index 9f3368c18..08b07a72e 100644 --- a/src/components/VectorSource.tsx +++ b/src/components/VectorSource.tsx @@ -11,7 +11,7 @@ import useNativeBridge from "../hooks/useNativeBridge"; import { type BaseProps } from "../types/BaseProps"; import { type OnPressEvent } from "../types/OnPressEvent"; import { cloneReactChildrenWithProps, isFunction, isAndroid } from "../utils"; -import { type FilterExpression } from "../utils/MaplibreStyles"; +import { type FilterExpression } from "../utils/MapLibreRNStyles"; import { copyPropertiesAsDeprecated } from "../utils/deprecation"; import { getFilter } from "../utils/filterUtils"; diff --git a/src/hooks/useAbstractLayer.ts b/src/hooks/useAbstractLayer.ts index 7a0099054..5e9aeef5f 100644 --- a/src/hooks/useAbstractLayer.ts +++ b/src/hooks/useAbstractLayer.ts @@ -7,7 +7,7 @@ import { type ExpressionField, type ExpressionName, type FilterExpression, -} from "../utils/MaplibreStyles"; +} from "../utils/MapLibreRNStyles"; import { type StyleValue, transformStyle } from "../utils/StyleValue"; import { getFilter } from "../utils/filterUtils"; diff --git a/src/utils/MaplibreStyles.d.ts b/src/utils/MapLibreRNStyles.d.ts similarity index 100% rename from src/utils/MaplibreStyles.d.ts rename to src/utils/MapLibreRNStyles.d.ts diff --git a/src/utils/StyleValue.ts b/src/utils/StyleValue.ts index cc7ba7ce4..cec2c0cde 100644 --- a/src/utils/StyleValue.ts +++ b/src/utils/StyleValue.ts @@ -4,7 +4,7 @@ import BridgeValue, { type RawValueType, type StyleValueJSON, } from "./BridgeValue"; -import { type AllLayerStyleProps } from "./MaplibreStyles"; +import { type AllLayerStyleProps } from "./MapLibreRNStyles"; import { getStyleType } from "./styleMap"; export type StyleValue = { diff --git a/src/utils/filterUtils.ts b/src/utils/filterUtils.ts index de3caa930..39ffd8a63 100644 --- a/src/utils/filterUtils.ts +++ b/src/utils/filterUtils.ts @@ -1,4 +1,4 @@ -import { type FilterExpression } from "./MaplibreStyles"; +import { type FilterExpression } from "./MapLibreRNStyles"; export function getFilter(filter: FilterExpression | undefined): string[] { if (!Array.isArray(filter) || filter.length === 0) {