From f1f1fec1ee007aa3cb91369b6367375f7f2e6647 Mon Sep 17 00:00:00 2001 From: Kilian Finger Date: Sun, 8 Dec 2024 11:52:24 +0100 Subject: [PATCH 1/2] feat: remove duplicate OfflinePackStatus type BREAKING CHANGE: Replace OfflineProgressStatus with OfflinePackStatus --- src/MapLibreRN.ts | 5 +---- src/modules/offline/OfflinePack.ts | 2 +- src/modules/offline/offlineManager.ts | 20 +++----------------- 3 files changed, 5 insertions(+), 22 deletions(-) diff --git a/src/MapLibreRN.ts b/src/MapLibreRN.ts index 0614abd60..d0c14e260 100644 --- a/src/MapLibreRN.ts +++ b/src/MapLibreRN.ts @@ -40,10 +40,7 @@ export { type Location, } from "./modules/location/locationManager"; export { default as offlineManager } from "./modules/offline/offlineManager"; -export type { - OfflineProgressStatus, - OfflinePackError, -} from "./modules/offline/offlineManager"; +export type { OfflinePackError } from "./modules/offline/offlineManager"; export type { OfflinePackStatus } from "./modules/offline/OfflinePack"; export { default as OfflinePack } from "./modules/offline/OfflinePack"; export { default as OfflineCreatePackOptions } from "./modules/offline/OfflineCreatePackOptions"; diff --git a/src/modules/offline/OfflinePack.ts b/src/modules/offline/OfflinePack.ts index b680240f0..6503e883f 100644 --- a/src/modules/offline/OfflinePack.ts +++ b/src/modules/offline/OfflinePack.ts @@ -10,8 +10,8 @@ export type OfflinePackStatus = { percentage: number; completedResourceCount: number; completedResourceSize: number; - completedTileSize: number; completedTileCount: number; + completedTileSize: number; requiredResourceCount: number; }; diff --git a/src/modules/offline/offlineManager.ts b/src/modules/offline/offlineManager.ts index 0daf5ac7e..ad3723a92 100644 --- a/src/modules/offline/offlineManager.ts +++ b/src/modules/offline/offlineManager.ts @@ -7,7 +7,7 @@ import { import OfflineCreatePackOptions, { type OfflineCreatePackInputOptions, } from "./OfflineCreatePackOptions"; -import OfflinePack from "./OfflinePack"; +import OfflinePack, { type OfflinePackStatus } from "./OfflinePack"; import { isUndefined, isFunction, isAndroid } from "../../utils"; const MapLibreRN = NativeModules.MLRNModule; @@ -16,17 +16,6 @@ export const OfflineModuleEventEmitter = new NativeEventEmitter( MLRNOfflineModule, ); -export type OfflineProgressStatus = { - name: string; - state: number; - percentage: number; - completedResourceSize: number; - completedTileCount: number; - completedResourceCount: number; - requiredResourceCount: number; - completedTileSize: number; -}; - export type OfflinePackError = { name: string; message: string; @@ -37,13 +26,10 @@ type ErrorEvent = { }; type ProgressEvent = { - payload: OfflineProgressStatus; + payload: OfflinePackStatus; }; -type ProgressListener = ( - pack: OfflinePack, - status: OfflineProgressStatus, -) => void; +type ProgressListener = (pack: OfflinePack, status: OfflinePackStatus) => void; type ErrorListener = (pack: OfflinePack, err: OfflinePackError) => void; /** From 0eab3f870a3d86179e912242791e4adf3222f45f Mon Sep 17 00:00:00 2001 From: Kilian Finger Date: Sun, 8 Dec 2024 13:03:56 +0100 Subject: [PATCH 2/2] chore: replace type in example --- .../examples/src/examples/Map/CreateOfflineRegion.tsx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/examples/src/examples/Map/CreateOfflineRegion.tsx b/packages/examples/src/examples/Map/CreateOfflineRegion.tsx index 3b645854c..e2e912f21 100755 --- a/packages/examples/src/examples/Map/CreateOfflineRegion.tsx +++ b/packages/examples/src/examples/Map/CreateOfflineRegion.tsx @@ -1,8 +1,8 @@ import geoViewport from "@mapbox/geo-viewport"; import MapLibreGL, { OfflinePack, - type OfflineProgressStatus, type OfflinePackError, + type OfflinePackStatus, } from "@maplibre/maplibre-react-native"; import { useEffect, useState } from "react"; import { @@ -70,7 +70,7 @@ function getRegionDownloadState(downloadState: OfflinePackDownloadState) { export default function CreateOfflineRegion() { const [offlineRegionStatus, setOfflineRegionStatus] = - useState(null); + useState(null); const [offlinePack, setOfflinePack] = useState(null); const [isLoading, setIsLoading] = useState(true); @@ -80,10 +80,7 @@ export default function CreateOfflineRegion() { }; }, []); - function onDownloadProgress( - pack: OfflinePack, - status: OfflineProgressStatus, - ) { + function onDownloadProgress(pack: OfflinePack, status: OfflinePackStatus) { setOfflinePack(pack); setOfflineRegionStatus(status); }