Skip to content

Commit

Permalink
refactor: move MapLibreRNStyles
Browse files Browse the repository at this point in the history
  • Loading branch information
KiwiKilian committed Dec 15, 2024
1 parent c5e946b commit be6d765
Show file tree
Hide file tree
Showing 21 changed files with 30 additions and 30 deletions.
8 changes: 4 additions & 4 deletions scripts/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ 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 = [
{
input: path.join(TEMPLATES_PATH, "MLRNStyle.h.ejs"),
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"),
Expand All @@ -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"),
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -40,7 +40,7 @@ type ExpressionName =
// Zoom, Heatmap
| 'zoom' | 'heatmap-density';

type ExpressionField =
export type ExpressionField =
| string
| number
| boolean
Expand Down
2 changes: 1 addition & 1 deletion src/MapLibreRN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ export type {
HillshadeLayerStyle,
BackgroundLayerStyle,
LightLayerStyle,
} from "./utils/MapLibreRNStyles";
} from "./types/MapLibreRNStyles";
2 changes: 1 addition & 1 deletion src/components/Annotation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
2 changes: 1 addition & 1 deletion src/components/BackgroundLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/components/CircleLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/components/FillExtrusionLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/components/FillLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/components/HeatmapLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/components/Light.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/components/LineLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/components/MapView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/components/RasterLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 4 additions & 4 deletions src/components/ShapeSource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ 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,
isAndroid,
isFunction,
toJSONString,
} from "../utils";
import {
type ExpressionField,
type FilterExpression,
} from "../utils/MapLibreRNStyles";
import { getFilter } from "../utils/filterUtils";

const MapLibreRN = NativeModules.MLRNModule;
Expand Down
2 changes: 1 addition & 1 deletion src/components/SymbolLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/components/UserLocation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)";

Expand Down
2 changes: 1 addition & 1 deletion src/components/VectorSource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useAbstractLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -12,7 +12,7 @@ export interface Transition {

export type FormattedString = string; /* TODO */

type ExpressionName =
export type ExpressionName =
// Types
| "array"
| "boolean"
Expand Down Expand Up @@ -107,7 +107,7 @@ type ExpressionName =
| "zoom"
| "heatmap-density";

type ExpressionField =
export type ExpressionField =
| string
| number
| boolean
Expand Down
2 changes: 1 addition & 1 deletion src/utils/StyleValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/filterUtils.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down

0 comments on commit be6d765

Please sign in to comment.