Expose Offline Region ID property on MLNOfflinePack for Darwin/iOS (#4161)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
nitrag
2026-03-10 17:53:36 -04:00
committed by GitHub
parent 36bbbccf5f
commit e27ea3a5f5
4 changed files with 29 additions and 0 deletions

View File

@@ -121,6 +121,18 @@ typedef struct __attribute__((objc_boxable)) MLNOfflinePackProgress {
MLN_EXPORT
@interface MLNOfflinePack : NSObject
/**
The unique identifier of the offline region associated with this pack.
This identifier is an auto-incrementing value assigned by the offline database
when the region is created. It is stable across application launches and can be
used to distinguish between different offline packs.
The value is `nil` for packs that have not yet been saved to the database. In
Swift, this property is typed as `NSNumber?`.
*/
@property (nonatomic, readonly, nullable) NSNumber *regionId;
/**
The region for which the pack manages resources.
*/

View File

@@ -92,6 +92,14 @@ private:
@"MLNOfflinePack was not invalided prior to deallocation.");
}
- (nullable NSNumber *)regionId {
if (_state == MLNOfflinePackStateInvalid || !_mbglOfflineRegion) {
return nil;
}
return @(_mbglOfflineRegion->getID());
}
- (id<MLNOfflineRegion>)region {
MLNAssertOfflinePackIsValid();

View File

@@ -16,6 +16,7 @@
invalidPack.state, MLNOfflinePackStateInvalid,
@"Offline pack should be invalid when initialized independently of MLNOfflineStorage.");
XCTAssertNil(invalidPack.regionId, @"Invalid offline pack should return nil regionID.");
XCTAssertThrowsSpecificNamed(
invalidPack.region, NSException, MLNInvalidOfflinePackException,
@"Invalid offline pack should raise an exception when accessing its region.");

View File

@@ -752,6 +752,14 @@
XCTAssertEqual([MLNOfflineStorage sharedOfflineStorage].packs.count,
countOfPacks + 1,
@"Adding contents of sideload_sat.db should add one pack.");
MLNOfflinePack *lastPack =
[MLNOfflineStorage sharedOfflineStorage].packs.lastObject;
XCTAssertNotNil(lastPack, @"Pack should exist after adding contents.");
XCTAssertNotNil(lastPack.regionId,
@"Region ID should not be nil after a pack is added.");
XCTAssertGreaterThan(
lastPack.regionId.longLongValue, 0,
@"Region ID should be greater than 0 after a pack is added.");
}];
// Invalid database type