Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove duplicate of OfflinePackStatus type #542

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions packages/examples/src/examples/Map/CreateOfflineRegion.tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -70,7 +70,7 @@ function getRegionDownloadState(downloadState: OfflinePackDownloadState) {

export default function CreateOfflineRegion() {
const [offlineRegionStatus, setOfflineRegionStatus] =
useState<OfflineProgressStatus | null>(null);
useState<OfflinePackStatus | null>(null);
const [offlinePack, setOfflinePack] = useState<OfflinePack | null>(null);
const [isLoading, setIsLoading] = useState(true);

Expand All @@ -80,10 +80,7 @@ export default function CreateOfflineRegion() {
};
}, []);

function onDownloadProgress(
pack: OfflinePack,
status: OfflineProgressStatus,
) {
function onDownloadProgress(pack: OfflinePack, status: OfflinePackStatus) {
setOfflinePack(pack);
setOfflineRegionStatus(status);
}
Expand Down
5 changes: 1 addition & 4 deletions src/MapLibreRN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/modules/offline/OfflinePack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export type OfflinePackStatus = {
percentage: number;
completedResourceCount: number;
completedResourceSize: number;
completedTileSize: number;
completedTileCount: number;
completedTileSize: number;
requiredResourceCount: number;
};

Expand Down
20 changes: 3 additions & 17 deletions src/modules/offline/offlineManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;

/**
Expand Down
Loading