Skip to content

Commit

Permalink
feat: setup build step (#504)
Browse files Browse the repository at this point in the history
* refactor: rename javascript to src
* refactor: rename MapLibreRN.ts
* feat: setup react-native-builder-bob
* fix: apply strict tsconfig
* docs: codegen
* refactor: cleanup types director
* refactor: align casing on MapLibre and MapLibreRN usages
* fix: move assets to src
* fix: add plugin to files
* fix: add plugin exports
* fix: improve ts output
* fix: setup rn example for bob
* chore: setup expo example for bob
* chore: enable strict for expo
* refactor: reuse monorepo metro config
* chore: move plugin tests
* chore: fix urls in package.json
* chore: align babel with scaffold
* chore: bump expo example
* chore: use plugin source in expo example
* fix: cleanup published files
* chore: align tsc lint scripts
  • Loading branch information
KiwiKilian authored Nov 26, 2024
1 parent ffb9b8e commit a017d64
Show file tree
Hide file tree
Showing 180 changed files with 2,499 additions and 941 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lib
49 changes: 7 additions & 42 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@ DerivedData
*.xcuserstate
project.xcworkspace

# Gradle
/build/
/RNTester/android/app/build/
/RNTester/android/app/gradle/
/RNTester/android/app/gradlew
/RNTester/android/app/gradlew.bat
/ReactAndroid/build/

# Watchman
.watchmanconfig

Expand All @@ -40,7 +32,6 @@ local.properties
node_modules
*.log
.nvm
/bots/node_modules/

# Yarn
.yarn/*
Expand All @@ -58,35 +49,11 @@ package.tgz
.DS_Store

# Test generated files
/ReactAndroid/src/androidTest/assets/AndroidTestBundle.js
*.js.meta

/coverage
/third-party

# Root dir shouldn't have Xcode project
/*.xcodeproj

# ReactCommon subdir shouldn't have Xcode project
/ReactCommon/**/*.xcodeproj
RNTester/build

# Libs that shouldn't have Xcode project
/Libraries/FBLazyVector/**/*.xcodeproj
/Libraries/FBReactNativeSpec/**/*.xcodeproj
/Libraries/RCTRequired/**/*.xcodeproj
/React/CoreModules/**/*.xcodeproj
/packages/react-native-codegen/**/*.xcodeproj

# CocoaPods
/template/ios/Pods/
/template/ios/Podfile.lock
/RNTester/Gemfile.lock

# Ignore RNTester specific Pods, but keep the __offline_mirrors__ here.
RNTester/Pods/*
!RNTester/Pods/__offline_mirrors

# react-native-codegen
/ReactCommon/fabric/components/rncore/
/schema-rncore.json
Expand All @@ -96,8 +63,6 @@ RNTester/Pods/*
.vs

# project specific
ios/Mapbox.framework
ios/Maplibre.framework
ios/temp.zip
ios/.framework_version
ios/Pods/
Expand All @@ -110,19 +75,19 @@ android/gradle/
android/gradlew
android/gradlew.bat
android/local.properties

.idea
coverage
.project
*.core.prefs
*.iml

# Config plugin
/plugin/build

.env
.yarn

# Expo
packages/expo-app/ios
packages/expo-app/android
packages/expo-app/android

# Build by config plugin
/plugin/build

# Build by bob
lib/
4 changes: 0 additions & 4 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,3 @@ android/local.properties
example
__tests__
coverage

plugin/src
plugin/jest.config.js
plugin/tsconfig.json
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Make sure to correctly configure your Editor following [this docs](https://yarnp
The metro bundlers under [`/packages/react-native-app`](/packages/react-native-app) and [
`/packages/expo-app`](/packages/expo-app) is set up to use the libraries files under root.
Which means, when you change something within [
`/javascript/components/UserLocation.tsx`](/javascript/components/UserLocation.tsx)
`/src/components/UserLocation.tsx`](/src/components/UserLocation.tsx)
it will be reflected in any scene in example that uses that component.

TODO: A better overview of how we use jest, detox, etc. (issue #22)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ diverged, it has become necessary to separate the projects into specific wrapper

<br>

<img src="./assets/indoor_building_map_android.png"
<img src="/docs/assets/indoor-building-map-android.png"
alt="Indoor Building Map Android"
height="300"
/>
<img src="./assets/indoor_building_map_ios.png"
<img src="/docs/assets/indoor-building-map-ios.png"
alt="Indoor Building Map iOS"
height="300"
/>
Expand Down
2 changes: 1 addition & 1 deletion __tests__/components/BackgroundLayer.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { render } from "@testing-library/react-native";
import React from "react";

import BackgroundLayer from "../../javascript/components/BackgroundLayer";
import BackgroundLayer from "../../src/components/BackgroundLayer";

describe("BackgroundLayer", () => {
test("renders correctly with default props", () => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/components/Callout.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { render } from "@testing-library/react-native";
import React from "react";
import { View } from "react-native";

import Callout from "../../javascript/components/Callout";
import Callout from "../../src/components/Callout";

describe("Callout", () => {
test("renders with custom title", () => {
Expand Down
18 changes: 9 additions & 9 deletions __tests__/components/Camera.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ import { render } from "@testing-library/react-native";
import React from "react";

import Camera, {
CameraBounds,
CameraProps,
CameraRef,
CameraStop,
CameraStops,
type CameraBounds,
type CameraProps,
type CameraRef,
type CameraStop,
type CameraStops,
getNativeCameraMode,
NativeCameraProps,
type NativeCameraProps,
UserTrackingMode,
} from "../../javascript/components/Camera";
import { NativeRef } from "../../javascript/hooks/useNativeRef";
} from "../../src/components/Camera";
import { type NativeRef } from "../../src/hooks/useNativeRef";

const mockCameraNativeRef = React.createRef<NativeRef<NativeCameraProps>>();
jest.mock("../../javascript/hooks/useNativeRef", () => ({
jest.mock("../../src/hooks/useNativeRef", () => ({
useNativeRef: () => {
return mockCameraNativeRef;
},
Expand Down
2 changes: 1 addition & 1 deletion __tests__/components/CircleLayer.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { render } from "@testing-library/react-native";
import React from "react";

import CircleLayer from "../../javascript/components/CircleLayer";
import CircleLayer from "../../src/components/CircleLayer";

describe("CircleLayer", () => {
test("renders correctly with default props", () => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/components/HeatmapLayer.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { render } from "@testing-library/react-native";
import React from "react";

import HeatmapLayer from "../../javascript/components/HeatmapLayer";
import HeatmapLayer from "../../src/components/HeatmapLayer";

describe("HeatmapLayer", () => {
test("renders correctly with default props", () => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/components/Light.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { render } from "@testing-library/react-native";
import React from "react";

import Light from "../../javascript/components/Light";
import Light from "../../src/components/Light";

describe("Light", () => {
test("renders correctly", () => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/components/MapView.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { render } from "@testing-library/react-native";
import * as React from "react";

import MapView from "../../javascript/components/MapView";
import MapView from "../../src/components/MapView";

describe("MapView", () => {
test("renders with testID", () => {
Expand Down
26 changes: 13 additions & 13 deletions __tests__/components/Style.test.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { render } from "@testing-library/react-native";
import React from "react";

import BackgroundLayer from "../../javascript/components/BackgroundLayer";
import CircleLayer from "../../javascript/components/CircleLayer";
import FillExtrusionLayer from "../../javascript/components/FillExtrusionLayer";
import FillLayer from "../../javascript/components/FillLayer";
import HeatmapLayer from "../../javascript/components/HeatmapLayer";
import ImageSource from "../../javascript/components/ImageSource";
import LineLayer from "../../javascript/components/LineLayer";
import RasterLayer from "../../javascript/components/RasterLayer";
import RasterSource from "../../javascript/components/RasterSource";
import ShapeSource from "../../javascript/components/ShapeSource";
import Style from "../../javascript/components/Style";
import SymbolLayer from "../../javascript/components/SymbolLayer";
import VectorSource from "../../javascript/components/VectorSource";
import BackgroundLayer from "../../src/components/BackgroundLayer";
import CircleLayer from "../../src/components/CircleLayer";
import FillExtrusionLayer from "../../src/components/FillExtrusionLayer";
import FillLayer from "../../src/components/FillLayer";
import HeatmapLayer from "../../src/components/HeatmapLayer";
import ImageSource from "../../src/components/ImageSource";
import LineLayer from "../../src/components/LineLayer";
import RasterLayer from "../../src/components/RasterLayer";
import RasterSource from "../../src/components/RasterSource";
import ShapeSource from "../../src/components/ShapeSource";
import Style from "../../src/components/Style";
import SymbolLayer from "../../src/components/SymbolLayer";
import VectorSource from "../../src/components/VectorSource";

describe("Style", () => {
test("renders vectory source correctly", () => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/components/SymbolLayer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from "react";

import SymbolLayer, {
NATIVE_MODULE_NAME,
} from "../../javascript/components/SymbolLayer";
} from "../../src/components/SymbolLayer";

describe("SymbolLayer", () => {
test("renders correctly with default props", () => {
Expand Down
8 changes: 4 additions & 4 deletions __tests__/components/UserLocation.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { render, fireEvent, waitFor } from "@testing-library/react-native";
import React from "react";

import CircleLayer from "../../javascript/components/CircleLayer";
import ShapeSource from "../../javascript/components/ShapeSource";
import UserLocation from "../../javascript/components/UserLocation";
import locationManager from "../../javascript/modules/location/locationManager";
import CircleLayer from "../../src/components/CircleLayer";
import ShapeSource from "../../src/components/ShapeSource";
import UserLocation from "../../src/components/UserLocation";
import locationManager from "../../src/modules/location/locationManager";

const position = {
coords: {
Expand Down
4 changes: 2 additions & 2 deletions __tests__/interface.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import MapLibreGL from "../javascript";
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);
Expand Down
2 changes: 1 addition & 1 deletion __tests__/modules/location/locationManager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { NativeModules } from "react-native";

import LocationManager, {
LocationModuleEventEmitter,
} from "../../../javascript/modules/location/locationManager";
} from "../../../src/modules/location/locationManager";

const MapLibreGL = NativeModules.MLNModule;
const MapLibreGLLocationManager = NativeModules.MLNLocationModule;
Expand Down
2 changes: 1 addition & 1 deletion __tests__/modules/offline/OfflineCreatePackOptions.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { featureCollection, point } from "@turf/helpers";

import OfflineCreatePackOptions from "../../../javascript/modules/offline/OfflineCreatePackOptions";
import OfflineCreatePackOptions from "../../../src/modules/offline/OfflineCreatePackOptions";

describe("OfflineCreatePackOptions", () => {
const options = {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/modules/offline/OfflinePack.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NativeModules } from "react-native";

import OfflinePack from "../../../javascript/modules/offline/OfflinePack";
import OfflinePack from "../../../src/modules/offline/OfflinePack";

describe("OfflinePack", () => {
const fakeNativePack = {
Expand Down
4 changes: 2 additions & 2 deletions __tests__/modules/offline/offlineManager.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NativeModules, Platform } from "react-native";

import MapLibreGL from "../../../javascript";
import { OfflineModuleEventEmitter } from "../../../javascript/modules/offline/offlineManager";
import MapLibreGL from "../../../src";
import { OfflineModuleEventEmitter } from "../../../src/modules/offline/offlineManager";

describe("offlineManager", () => {
const packOptions = {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/modules/snapshot/SnapshotOptions.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { featureCollection, point } from "@turf/helpers";
import { NativeModules } from "react-native";

import SnapshotOptions from "../../../javascript/modules/snapshot/SnapshotOptions";
import SnapshotOptions from "../../../src/modules/snapshot/SnapshotOptions";

describe("SnapshotOptions", () => {
it("should throw error if no centerCoordinate or bounds are provided", () => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/modules/snapshot/snapshotManager.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import MapLibreGL from "../../../javascript";
import MapLibreGL from "../../../src";

describe("snapshotManager", () => {
it("should resolve uri", async () => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/utils/BridgeValue.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import BridgeValue from "../../javascript/utils/BridgeValue";
import BridgeValue from "../../src/utils/BridgeValue";

describe("BridgeValue", () => {
it("should convert to array of numbers", () => {
Expand Down
6 changes: 3 additions & 3 deletions __tests__/utils/animated/AnimatedCoordinatesArray.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import React from "react";
import { Animated, Easing } from "react-native";
import TestRenderer from "react-test-renderer";

import ShapeSource from "../../../javascript/components/ShapeSource";
import AnimatedCoordinatesArray from "../../../javascript/utils/animated/AnimatedCoordinatesArray";
import AnimatedShape from "../../../javascript/utils/animated/AnimatedShape";
import ShapeSource from "../../../src/components/ShapeSource";
import AnimatedCoordinatesArray from "../../../src/utils/animated/AnimatedCoordinatesArray";
import AnimatedShape from "../../../src/utils/animated/AnimatedShape";

let clock = null;
let oldNodeEnv = null;
Expand Down
4 changes: 2 additions & 2 deletions __tests__/utils/filterUtils.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import BridgeValue from "../../javascript/utils/BridgeValue";
import { getFilter } from "../../javascript/utils/filterUtils";
import BridgeValue from "../../src/utils/BridgeValue";
import { getFilter } from "../../src/utils/filterUtils";

const FilterItem = BridgeValue;

Expand Down
11 changes: 2 additions & 9 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
module.exports = {
presets: ["module:@react-native/babel-preset"],
plugins: [
["@babel/plugin-proposal-class-properties", { loose: true }],
["@babel/plugin-transform-private-methods", { loose: true }],
presets: [
["module:react-native-builder-bob/babel-preset", { modules: "commonjs" }],
],
env: {
production: {
plugins: ["transform-remove-console"],
},
},
};
2 changes: 1 addition & 1 deletion docs/Annotation.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- DO NOT MODIFY -->
<!-- This file is auto-generated from javascript/components/Annotation.tsx -->
<!-- This file is auto-generated from src/components/Annotation.tsx -->
# `<MapLibreGL.Annotation />`


Expand Down
2 changes: 1 addition & 1 deletion docs/BackgroundLayer.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- DO NOT MODIFY -->
<!-- This file is auto-generated from javascript/components/BackgroundLayer.tsx -->
<!-- This file is auto-generated from src/components/BackgroundLayer.tsx -->
# `<MapLibreGL.BackgroundLayer />`


Expand Down
2 changes: 1 addition & 1 deletion docs/Callout.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- DO NOT MODIFY -->
<!-- This file is auto-generated from javascript/components/Callout.tsx -->
<!-- This file is auto-generated from src/components/Callout.tsx -->
# `<MapLibreGL.Callout />`
Callout that displays information about a selected annotation near the annotation.

Expand Down
Loading

0 comments on commit a017d64

Please sign in to comment.