diff --git a/scripts/codegen.ts b/scripts/codegen.ts index 581602a37..6c160d01b 100644 --- a/scripts/codegen.ts +++ b/scripts/codegen.ts @@ -32,7 +32,7 @@ const ANDROID_OUTPUT_PATH = path.join( "styles", ); -const JS_OUTPUT_PATH = path.join(__dirname, "..", "src", "utils"); +const JS_OUTPUT_PATH = path.join(__dirname, "..", "src"); const TEMPLATE_MAPPINGS = [ { @@ -40,8 +40,8 @@ const TEMPLATE_MAPPINGS = [ output: path.join(IOS_OUTPUT_PATH, "MLRNStyle.h"), }, { - input: path.join(TEMPLATES_PATH, "MapLibreRNStyles.ts.ejs"), - output: path.join(JS_OUTPUT_PATH, "MapLibreRNStyles.d.ts"), + input: path.join(TEMPLATES_PATH, "MapLibreRNStyles.d.ts.ejs"), + output: path.join(JS_OUTPUT_PATH, "types", "MapLibreRNStyles.d.ts"), }, { input: path.join(TEMPLATES_PATH, "MLRNStyle.m.ejs"), @@ -53,7 +53,7 @@ const TEMPLATE_MAPPINGS = [ }, { input: path.join(TEMPLATES_PATH, "getStylePropertyType.ts.ejs"), - output: path.join(JS_OUTPUT_PATH, "getStylePropertyType.ts"), + output: path.join(JS_OUTPUT_PATH, "utils", "getStylePropertyType.ts"), }, ]; diff --git a/scripts/templates/MapLibreRNStyles.ts.ejs b/scripts/templates/MapLibreRNStyles.d.ts.ejs similarity index 98% rename from scripts/templates/MapLibreRNStyles.ts.ejs rename to scripts/templates/MapLibreRNStyles.d.ts.ejs index a5a5021c9..7892eeadb 100644 --- a/scripts/templates/MapLibreRNStyles.ts.ejs +++ b/scripts/templates/MapLibreRNStyles.d.ts.ejs @@ -16,7 +16,7 @@ export interface Transition { export type FormattedString = string; /* TODO */ -type ExpressionName = +export type ExpressionName = // Types | 'array' | 'boolean' | 'collator' | 'format' | 'image' | 'literal' | 'number' | 'number-format' | 'object' | 'string' | 'to-boolean' | 'to-color' | 'to-number' | 'to-string' | 'typeof' @@ -40,7 +40,7 @@ type ExpressionName = // Zoom, Heatmap | 'zoom' | 'heatmap-density'; -type ExpressionField = +export type ExpressionField = | string | number | boolean diff --git a/src/MapLibreRN.ts b/src/MapLibreRN.ts index 3135c7212..424222148 100644 --- a/src/MapLibreRN.ts +++ b/src/MapLibreRN.ts @@ -66,4 +66,4 @@ export type { HillshadeLayerStyle, BackgroundLayerStyle, LightLayerStyle, -} from "./utils/MapLibreRNStyles"; +} from "./types/MapLibreRNStyles"; diff --git a/src/components/Annotation.tsx b/src/components/Annotation.tsx index 9ed478466..6b93fab76 100644 --- a/src/components/Annotation.tsx +++ b/src/components/Annotation.tsx @@ -9,8 +9,8 @@ import { import { Animated as RNAnimated, Easing } from "react-native"; import SymbolLayer from "./SymbolLayer"; +import { type SymbolLayerStyle } from "../types/MapLibreRNStyles"; import { type OnPressEvent } from "../types/OnPressEvent"; -import { type SymbolLayerStyle } 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 af586c3ad..fc54d7570 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 BackgroundLayerStyle } from "../utils/MapLibreRNStyles"; +import { type BackgroundLayerStyle } from "../types/MapLibreRNStyles"; const MapLibreRN = NativeModules.MLRNModule; diff --git a/src/components/CircleLayer.tsx b/src/components/CircleLayer.tsx index 3497fa698..50b4253a2 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 CircleLayerStyle } from "../utils/MapLibreRNStyles"; +import { type CircleLayerStyle } from "../types/MapLibreRNStyles"; const MapLibreRN = NativeModules.MLRNModule; diff --git a/src/components/FillExtrusionLayer.tsx b/src/components/FillExtrusionLayer.tsx index 003962cb6..6ed0bc6a7 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 FillExtrusionLayerStyle } from "../utils/MapLibreRNStyles"; +import { type FillExtrusionLayerStyle } from "../types/MapLibreRNStyles"; const MapLibreRN = NativeModules.MLRNModule; diff --git a/src/components/FillLayer.tsx b/src/components/FillLayer.tsx index 5944b80c8..aa5dd181f 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 FillLayerStyle } from "../utils/MapLibreRNStyles"; +import { type FillLayerStyle } from "../types/MapLibreRNStyles"; const MapLibreRN = NativeModules.MLRNModule; diff --git a/src/components/HeatmapLayer.tsx b/src/components/HeatmapLayer.tsx index eb728469b..f4bd84bf3 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 HeatmapLayerStyle } from "../utils/MapLibreRNStyles"; +import { type HeatmapLayerStyle } from "../types/MapLibreRNStyles"; const MapLibreRN = NativeModules.MLRNModule; diff --git a/src/components/Light.tsx b/src/components/Light.tsx index 0cf125d37..a24f2cb8e 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 LightLayerStyle } from "../utils/MapLibreRNStyles"; +import { type LightLayerStyle } from "../types/MapLibreRNStyles"; import { type StyleValue } from "../utils/StyleValue"; export const NATIVE_MODULE_NAME = "MLRNLight"; diff --git a/src/components/LineLayer.tsx b/src/components/LineLayer.tsx index a8b3d31f6..1b8daa71b 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 LineLayerStyle } from "../utils/MapLibreRNStyles"; +import { type LineLayerStyle } from "../types/MapLibreRNStyles"; const MapLibreRN = NativeModules.MLRNModule; diff --git a/src/components/MapView.tsx b/src/components/MapView.tsx index 97c2d6b87..ece9160a6 100644 --- a/src/components/MapView.tsx +++ b/src/components/MapView.tsx @@ -26,9 +26,9 @@ import useNativeBridge from "../hooks/useNativeBridge"; import useOnce from "../hooks/useOnce"; import { type Location } from "../modules/location/locationManager"; import { type BaseProps } from "../types/BaseProps"; +import { type FilterExpression } from "../types/MapLibreRNStyles"; import { isFunction, isAndroid } from "../utils"; import Logger from "../utils/Logger"; -import { type FilterExpression } from "../utils/MapLibreRNStyles"; import { getFilter } from "../utils/filterUtils"; const MapLibreRN = NativeModules.MLRNModule; diff --git a/src/components/RasterLayer.tsx b/src/components/RasterLayer.tsx index ccad105de..2a0516f6b 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 RasterLayerStyle } from "../utils/MapLibreRNStyles"; +import { type RasterLayerStyle } from "../types/MapLibreRNStyles"; const MapLibreRN = NativeModules.MLRNModule; diff --git a/src/components/ShapeSource.tsx b/src/components/ShapeSource.tsx index 147256cfc..656b1804f 100644 --- a/src/components/ShapeSource.tsx +++ b/src/components/ShapeSource.tsx @@ -15,6 +15,10 @@ import { import useNativeBridge from "../hooks/useNativeBridge"; import { type BaseProps } from "../types/BaseProps"; +import { + type ExpressionField, + type FilterExpression, +} from "../types/MapLibreRNStyles"; import { type OnPressEvent } from "../types/OnPressEvent"; import { cloneReactChildrenWithProps, @@ -22,10 +26,6 @@ import { isFunction, toJSONString, } from "../utils"; -import { - type ExpressionField, - type FilterExpression, -} from "../utils/MapLibreRNStyles"; import { getFilter } from "../utils/filterUtils"; const MapLibreRN = NativeModules.MLRNModule; diff --git a/src/components/SymbolLayer.tsx b/src/components/SymbolLayer.tsx index cd2f55062..18ee78526 100644 --- a/src/components/SymbolLayer.tsx +++ b/src/components/SymbolLayer.tsx @@ -5,7 +5,7 @@ import useAbstractLayer, { type NativeBaseProps, } from "../hooks/useAbstractLayer"; import { type BaseProps } from "../types/BaseProps"; -import { type SymbolLayerStyle } from "../utils/MapLibreRNStyles"; +import { type SymbolLayerStyle } from "../types/MapLibreRNStyles"; const MapLibreRN = NativeModules.MLRNModule; diff --git a/src/components/UserLocation.tsx b/src/components/UserLocation.tsx index 4ffdf603a..5df37befb 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 CircleLayerStyle } from "../utils/MapLibreRNStyles"; +import { type CircleLayerStyle } from "../types/MapLibreRNStyles"; const mapboxBlue = "rgba(51, 181, 229, 100)"; diff --git a/src/components/VectorSource.tsx b/src/components/VectorSource.tsx index 604b30d9b..9c196d890 100644 --- a/src/components/VectorSource.tsx +++ b/src/components/VectorSource.tsx @@ -9,9 +9,9 @@ import { import useAbstractSource from "../hooks/useAbstractSource"; import useNativeBridge from "../hooks/useNativeBridge"; import { type BaseProps } from "../types/BaseProps"; +import { type FilterExpression } from "../types/MapLibreRNStyles"; import { type OnPressEvent } from "../types/OnPressEvent"; import { cloneReactChildrenWithProps, isFunction, isAndroid } from "../utils"; -import { type FilterExpression } from "../utils/MapLibreRNStyles"; import { getFilter } from "../utils/filterUtils"; const MapLibreRN = NativeModules.MLRNModule; diff --git a/src/hooks/useAbstractLayer.ts b/src/hooks/useAbstractLayer.ts index e59391c8a..a1079c837 100644 --- a/src/hooks/useAbstractLayer.ts +++ b/src/hooks/useAbstractLayer.ts @@ -7,7 +7,7 @@ import { type ExpressionField, type ExpressionName, type FilterExpression, -} from "../utils/MapLibreRNStyles"; +} from "../types/MapLibreRNStyles"; import { type StyleValue, transformStyle } from "../utils/StyleValue"; import { getFilter } from "../utils/filterUtils"; diff --git a/src/utils/MapLibreRNStyles.d.ts b/src/types/MapLibreRNStyles.d.ts similarity index 99% rename from src/utils/MapLibreRNStyles.d.ts rename to src/types/MapLibreRNStyles.d.ts index ca3c6d3b8..2fd501792 100644 --- a/src/utils/MapLibreRNStyles.d.ts +++ b/src/types/MapLibreRNStyles.d.ts @@ -1,5 +1,5 @@ // DO NOT MODIFY -// This file is auto-generated from scripts/templates/MapLibreRNStyles.ts.ejs +// This file is auto-generated from scripts/templates/MapLibreRNStyles.d.ts.ejs import { type ImageSourcePropType } from "react-native"; @@ -12,7 +12,7 @@ export interface Transition { export type FormattedString = string; /* TODO */ -type ExpressionName = +export type ExpressionName = // Types | "array" | "boolean" @@ -107,7 +107,7 @@ type ExpressionName = | "zoom" | "heatmap-density"; -type ExpressionField = +export type ExpressionField = | string | number | boolean diff --git a/src/utils/StyleValue.ts b/src/utils/StyleValue.ts index 73cf4cf82..efa6a0353 100644 --- a/src/utils/StyleValue.ts +++ b/src/utils/StyleValue.ts @@ -4,8 +4,8 @@ import BridgeValue, { type RawValueType, type StyleValueJSON, } from "./BridgeValue"; -import { type AllLayerStyle } from "./MapLibreRNStyles"; import { getStylePropertyType } from "./getStylePropertyType"; +import { type AllLayerStyle } from "../types/MapLibreRNStyles"; export type StyleValue = { styletype: string; diff --git a/src/utils/filterUtils.ts b/src/utils/filterUtils.ts index 39ffd8a63..7dddac161 100644 --- a/src/utils/filterUtils.ts +++ b/src/utils/filterUtils.ts @@ -1,4 +1,4 @@ -import { type FilterExpression } from "./MapLibreRNStyles"; +import { type FilterExpression } from "../types/MapLibreRNStyles"; export function getFilter(filter: FilterExpression | undefined): string[] { if (!Array.isArray(filter) || filter.length === 0) {