Skip to content

Commit

Permalink
refactor: rename RCTMLN to MLRN (#519)
Browse files Browse the repository at this point in the history
* refactor: rename package from com.maplibre to org.maplibre
* refactor: rename RCTMLN to MLRN
* refactor: align module prefix to MLRN
* fix: remove unused ios files
* refactor: cleanup java component names
* refactor: use org.maplibre.reactnative package name
* refactor: remove getIOSModuleName
* test: update expo sync fingerprint
* refactor: rename MLRNImageUtils
  • Loading branch information
KiwiKilian authored Nov 27, 2024
1 parent 2ed0176 commit d476d5c
Show file tree
Hide file tree
Showing 333 changed files with 3,150 additions and 3,899 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ package.tgz
ios/temp.zip
ios/.framework_version
ios/Pods/
ios/RCTMLN.xcodeproj/xcshareddata/
ios/MLRN.xcodeproj/xcshareddata/
android/build/
android/.gradle/
android/.idea/
Expand Down
2 changes: 1 addition & 1 deletion .sonarcloud.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Path to sources
sonar.sources=javascript,android/src,ios/RCTMLN
sonar.sources=javascript,android/src,ios/MLRN
#sonar.exclusions=
#sonar.inclusions=

Expand Down
4 changes: 2 additions & 2 deletions __tests__/components/BackgroundLayer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe("BackgroundLayer", () => {
<BackgroundLayer id="requiredBackgroundLayerID" />,
);

const backgroundLayer = queryByTestId("rctmlnBackgroundLayer");
const backgroundLayer = queryByTestId("mlrnBackgroundLayer");
const { props } = backgroundLayer;

expect(props.sourceID).toStrictEqual("DefaultSourceID");
Expand All @@ -30,7 +30,7 @@ describe("BackgroundLayer", () => {
};

const { queryByTestId } = render(<BackgroundLayer {...testProps} />);
const backgroundLayer = queryByTestId("rctmlnBackgroundLayer");
const backgroundLayer = queryByTestId("mlrnBackgroundLayer");
const { props } = backgroundLayer;

expect(props.id).toStrictEqual(testProps.id);
Expand Down
4 changes: 2 additions & 2 deletions __tests__/components/CircleLayer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe("CircleLayer", () => {
const { queryByTestId } = render(
<CircleLayer id="requiredCircleLayerID" />,
);
const circleLayer = queryByTestId("rctmlnCircleLayer");
const circleLayer = queryByTestId("mlrnCircleLayer");
const { props } = circleLayer;

expect(props.sourceID).toStrictEqual("DefaultSourceID");
Expand All @@ -29,7 +29,7 @@ describe("CircleLayer", () => {
};

const { queryByTestId } = render(<CircleLayer {...customProps} />);
const circleLayer = queryByTestId("rctmlnCircleLayer");
const circleLayer = queryByTestId("mlrnCircleLayer");
const { props } = circleLayer;

expect(props.id).toStrictEqual(customProps.id);
Expand Down
4 changes: 2 additions & 2 deletions __tests__/components/HeatmapLayer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe("HeatmapLayer", () => {
const { UNSAFE_getByType } = render(
<HeatmapLayer id="requiredHeatmapLayerID" />,
);
const heatmapLayer = UNSAFE_getByType("RCTMLNHeatmapLayer");
const heatmapLayer = UNSAFE_getByType("MLRNHeatmapLayer");
const { props } = heatmapLayer;
expect(props.sourceID).toStrictEqual("DefaultSourceID");
});
Expand All @@ -27,7 +27,7 @@ describe("HeatmapLayer", () => {
style: { visibility: "none" },
};
const { UNSAFE_getByType } = render(<HeatmapLayer {...testProps} />);
const { props } = UNSAFE_getByType("RCTMLNHeatmapLayer");
const { props } = UNSAFE_getByType("MLRNHeatmapLayer");

expect(props.id).toStrictEqual(testProps.id);
expect(props.sourceID).toStrictEqual(testProps.sourceID);
Expand Down
4 changes: 2 additions & 2 deletions __tests__/components/Light.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Light from "../../src/components/Light";
describe("Light", () => {
test("renders correctly", () => {
const { queryByTestId } = render(<Light />);
const light = queryByTestId("rctmlnLight");
const light = queryByTestId("mlrnLight");
expect(light).toBeDefined();
});

Expand All @@ -21,7 +21,7 @@ describe("Light", () => {

const { queryByTestId } = render(<Light style={testStyles} />);

const customStyles = queryByTestId("rctmlnLight").props.reactStyle;
const customStyles = queryByTestId("mlrnLight").props.reactStyle;
const { anchor } = customStyles;
const { color } = customStyles;
const { position } = customStyles;
Expand Down
60 changes: 28 additions & 32 deletions __tests__/modules/location/locationManager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import LocationManager, {
LocationModuleEventEmitter,
} from "../../../src/modules/location/locationManager";

const MapLibreGL = NativeModules.MLNModule;
const MapLibreGLLocationManager = NativeModules.MLNLocationModule;
const MapLibreRN = NativeModules.MLRNModule;
const MLRNLocationModule = NativeModules.MLRNLocationModule;

const location = {
coords: {
Expand Down Expand Up @@ -37,16 +37,16 @@ describe("LocationManager", () => {
describe("#getLastKnownLocation", () => {
test("gets last known location from native locationManager if non available", async () => {
jest
.spyOn(MapLibreGLLocationManager, "getLastKnownLocation")
.spyOn(MLRNLocationModule, "getLastKnownLocation")
.mockImplementation(() => location);

const lastKnownLocation = await locationManager.getLastKnownLocation();

expect(lastKnownLocation).toStrictEqual(location);
expect(locationManager._lastKnownLocation).toStrictEqual(location);
expect(
MapLibreGLLocationManager.getLastKnownLocation,
).toHaveBeenCalledTimes(1);
expect(MLRNLocationModule.getLastKnownLocation).toHaveBeenCalledTimes(
1,
);

locationManager._lastKnownLocation = null;
});
Expand All @@ -58,9 +58,7 @@ describe("LocationManager", () => {

expect(locationManager._lastKnownLocation).toStrictEqual(location);

expect(
MapLibreGLLocationManager.getLastKnownLocation,
).not.toHaveBeenCalled();
expect(MLRNLocationModule.getLastKnownLocation).not.toHaveBeenCalled();

// reset
locationManager._lastKnownLocation = null;
Expand All @@ -69,7 +67,7 @@ describe("LocationManager", () => {

describe("#addListener", () => {
const myListener = jest.fn();
MapLibreGL.LocationCallbackName = { Update: "MapboxUserLocationUpdate" };
MapLibreRN.LocationCallbackName = { Update: "MapboxUserLocationUpdate" };

afterEach(() => {
locationManager._listeners = [];
Expand Down Expand Up @@ -100,7 +98,7 @@ describe("LocationManager", () => {
});

describe("#removeListener", () => {
MapLibreGLLocationManager.stop = jest.fn();
MLRNLocationModule.stop = jest.fn();

test("removes selected listener", () => {
// just two different functions
Expand All @@ -109,22 +107,22 @@ describe("LocationManager", () => {

locationManager.addListener(listenerA);
expect(locationManager._listeners).toStrictEqual([listenerA]);
expect(MapLibreGLLocationManager.stop).not.toHaveBeenCalled();
expect(MLRNLocationModule.stop).not.toHaveBeenCalled();

locationManager.addListener(listenerB);
expect(locationManager._listeners).toStrictEqual([
listenerA,
listenerB,
]);
expect(MapLibreGLLocationManager.stop).not.toHaveBeenCalled();
expect(MLRNLocationModule.stop).not.toHaveBeenCalled();

locationManager.removeListener(listenerB);
expect(locationManager._listeners).toStrictEqual([listenerA]);
expect(MapLibreGLLocationManager.stop).not.toHaveBeenCalled();
expect(MLRNLocationModule.stop).not.toHaveBeenCalled();

locationManager.removeListener(listenerA);
expect(locationManager._listeners).toStrictEqual([]);
expect(MapLibreGLLocationManager.stop).toHaveBeenCalledTimes(1);
expect(MLRNLocationModule.stop).toHaveBeenCalledTimes(1);
});
});

Expand All @@ -148,25 +146,25 @@ describe("LocationManager", () => {
});

describe("#start", () => {
jest.spyOn(MapLibreGLLocationManager, "start");
jest.spyOn(MLRNLocationModule, "start");
jest.spyOn(LocationModuleEventEmitter, "addListener");

afterEach(() => {
locationManager._isListening = false;
});

test("starts native location manager and adds event emitter listener", () => {
MapLibreGL.LocationCallbackName = {
MapLibreRN.LocationCallbackName = {
Update: "MapboxUserLocationUpdate",
};

expect(locationManager._isListening).toStrictEqual(false);

locationManager.start();

expect(MapLibreGLLocationManager.start).toHaveBeenCalledTimes(1);
expect(MLRNLocationModule.start).toHaveBeenCalledTimes(1);
expect(LocationModuleEventEmitter.addListener).toHaveBeenCalledWith(
MapLibreGL.LocationCallbackName.Update,
MapLibreRN.LocationCallbackName.Update,
locationManager.onUpdate,
);

Expand All @@ -176,8 +174,8 @@ describe("LocationManager", () => {
test('passes "displacement"', () => {
locationManager.start(5); // displacement 5meters

expect(MapLibreGLLocationManager.start).toHaveBeenCalledTimes(1);
expect(MapLibreGLLocationManager.start).toHaveBeenCalledWith(5);
expect(MLRNLocationModule.start).toHaveBeenCalledTimes(1);
expect(MLRNLocationModule.start).toHaveBeenCalledWith(5);
});

test("does not start when already listening", () => {
Expand All @@ -188,7 +186,7 @@ describe("LocationManager", () => {

locationManager.start();

expect(MapLibreGLLocationManager.start).not.toHaveBeenCalled();
expect(MLRNLocationModule.start).not.toHaveBeenCalled();
expect(LocationModuleEventEmitter.addListener).not.toHaveBeenCalled();
});
});
Expand All @@ -199,16 +197,16 @@ describe("LocationManager", () => {
locationManager._isListening = true;

// native location manager has no #stop exposed in tests?
MapLibreGLLocationManager.stop = jest.fn();
MapLibreGL.LocationCallbackName = {
MLRNLocationModule.stop = jest.fn();
MapLibreRN.LocationCallbackName = {
Update: "MapboxUserLocationUpdate",
};

expect(locationManager._isListening).toStrictEqual(true);

locationManager.stop();

expect(MapLibreGLLocationManager.stop).toHaveBeenCalledTimes(1);
expect(MLRNLocationModule.stop).toHaveBeenCalledTimes(1);
expect(locationManager.subscription.remove).toHaveBeenCalled();

expect(locationManager._isListening).toStrictEqual(false);
Expand All @@ -219,27 +217,25 @@ describe("LocationManager", () => {
locationManager._isListening = false;

// native location manager has no #stop exposed in tests?
MapLibreGLLocationManager.stop = jest.fn();
MapLibreGL.LocationCallbackName = {
MLRNLocationModule.stop = jest.fn();
MapLibreRN.LocationCallbackName = {
Update: "MapboxUserLocationUpdate",
};

expect(locationManager._isListening).toStrictEqual(false);

locationManager.stop();

expect(MapLibreGLLocationManager.stop).toHaveBeenCalledTimes(1);
expect(MLRNLocationModule.stop).toHaveBeenCalledTimes(1);
expect(locationManager.subscription.remove).not.toHaveBeenCalled();
});
});

describe("#setMinDisplacement", () => {
test('calls native "setMinDisplacement"', () => {
MapLibreGLLocationManager.setMinDisplacement = jest.fn();
MLRNLocationModule.setMinDisplacement = jest.fn();
locationManager.setMinDisplacement(5);
expect(
MapLibreGLLocationManager.setMinDisplacement,
).toHaveBeenCalledWith(5);
expect(MLRNLocationModule.setMinDisplacement).toHaveBeenCalledWith(5);
});
});

Expand Down
9 changes: 6 additions & 3 deletions __tests__/modules/offline/OfflinePack.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe("OfflinePack", () => {

it("should resume pack download", () => {
const spy = jest.spyOn(
NativeModules.MLNOfflineModule,
NativeModules.MLRNOfflineModule,
"resumePackDownload",
);
const offlinePack = new OfflinePack(fakeNativePack);
Expand All @@ -30,15 +30,18 @@ describe("OfflinePack", () => {
});

it("should pause pack download", () => {
const spy = jest.spyOn(NativeModules.MLNOfflineModule, "pausePackDownload");
const spy = jest.spyOn(
NativeModules.MLRNOfflineModule,
"pausePackDownload",
);
const offlinePack = new OfflinePack(fakeNativePack);
offlinePack.pause();
expect(spy).toHaveBeenCalled();
spy.mockRestore();
});

it("should get pack status", () => {
const spy = jest.spyOn(NativeModules.MLNOfflineModule, "getPackStatus");
const spy = jest.spyOn(NativeModules.MLRNOfflineModule, "getPackStatus");
const offlinePack = new OfflinePack(fakeNativePack);
offlinePack.status();
expect(spy).toHaveBeenCalled();
Expand Down
22 changes: 17 additions & 5 deletions __tests__/modules/offline/offlineManager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ describe("offlineManager", () => {

it("should set max tile count limit", () => {
const expectedLimit = 2000;
const spy = jest.spyOn(NativeModules.MLNOfflineModule, "setTileCountLimit");
const spy = jest.spyOn(
NativeModules.MLRNOfflineModule,
"setTileCountLimit",
);
MapLibreGL.offlineManager.setTileCountLimit(expectedLimit);
expect(spy).toHaveBeenCalledWith(expectedLimit);
spy.mockRestore();
Expand All @@ -80,7 +83,7 @@ describe("offlineManager", () => {
it("should set progress event throttle value", () => {
const expectedThrottleValue = 500;
const spy = jest.spyOn(
NativeModules.MLNOfflineModule,
NativeModules.MLRNOfflineModule,
"setProgressEventThrottle",
);
MapLibreGL.offlineManager.setProgressEventThrottle(expectedThrottleValue);
Expand Down Expand Up @@ -194,7 +197,10 @@ describe("offlineManager", () => {
beforeEach(() => (Platform.OS = "android"));

it("should set pack observer manually", async () => {
const spy = jest.spyOn(NativeModules.MLNOfflineModule, "setPackObserver");
const spy = jest.spyOn(
NativeModules.MLRNOfflineModule,
"setPackObserver",
);

const name = `test-${Date.now()}`;
const noop = () => {};
Expand All @@ -207,7 +213,10 @@ describe("offlineManager", () => {
});

it("should not set pack observer manually during create flow", async () => {
const spy = jest.spyOn(NativeModules.MLNOfflineModule, "setPackObserver");
const spy = jest.spyOn(
NativeModules.MLRNOfflineModule,
"setPackObserver",
);

const name = `test-${Date.now()}`;
const noop = () => {};
Expand All @@ -223,7 +232,10 @@ describe("offlineManager", () => {
beforeEach(() => (Platform.OS = "ios"));

it("should not set pack observer manually", async () => {
const spy = jest.spyOn(NativeModules.MLNOfflineModule, "setPackObserver");
const spy = jest.spyOn(
NativeModules.MLRNOfflineModule,
"setPackObserver",
);

const name = `test-${Date.now()}`;
const noop = () => {};
Expand Down
6 changes: 3 additions & 3 deletions __tests__/modules/snapshot/SnapshotOptions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe("SnapshotOptions", () => {
const options = new SnapshotOptions({ centerCoordinate });

expect(options.toJSON()).toEqual({
styleURL: NativeModules.MLNModule.StyleURL.Default,
styleURL: NativeModules.MLRNModule.StyleURL.Default,
heading: 0.0,
pitch: 0.0,
zoomLevel: 16.0,
Expand All @@ -36,7 +36,7 @@ describe("SnapshotOptions", () => {
height: 600,
writeToDisk: true,
withLogo: true,
styleURL: NativeModules.MLNModule.StyleURL.Default,
styleURL: NativeModules.MLRNModule.StyleURL.Default,
};

const options = new SnapshotOptions(expectedOptions);
Expand All @@ -54,7 +54,7 @@ describe("SnapshotOptions", () => {
],
width: 400,
height: 600,
styleURL: NativeModules.MLNModule.StyleURL.Default,
styleURL: NativeModules.MLRNModule.StyleURL.Default,
writeToDisk: false,
withLogo: true,
};
Expand Down
1 change: 0 additions & 1 deletion android/settings.gradle

This file was deleted.

Loading

0 comments on commit d476d5c

Please sign in to comment.